N
N
nextnull2018-07-18 00:52:06
JavaScript
nextnull, 2018-07-18 00:52:06

How to display content using show()?

Hello, please tell me how to implement.
There is a WordPress page, it has its own template.
In this page, you need to display 4 posts of a certain category.
This is understandable. Did

Here I want to do, when you click on the link of the post, below showed the content of this post. without going to the page

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Proskurin, 2018-07-18
@nextnull

Well, in general, for good, you need to make an API, and access each post via ajax, and display it.
And so, let each post have a block
in css you do and the links should be of the form
and if we use jQuery, then we write

$(function() {
   $('[data-to-post]').click(function(e) {
      e.preventDefault();
      var postId = $(this).data('to-post');
      $('.post_block').not('[data-post-id="' + postId + '"]').fadeOut(); // прячем все блоки, кроме текущего, чтобы не было бага анимации
      $('.post_block[data-post-id="' + postId + '"]').fadeIn(); // показываем нужный
   });
});

Something like this. Posted on my phone, so feel free to check.

S
Stalker_RED, 2018-07-18
@Stalker_RED

You hang up the output agent on click on title.
The handler makes an ajax request.
Receives data.
Brings out something down there.
With which of the points of difficulty?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question