I am currently creating a site for literature review. Currently, I need one function in the home page, that is to show a list of latest posts.

This would be trivial, until the requirement is the category of latest posts is determined by user, by clicking into corresponding category (for example, in the picture, if user click on criticism category, the latest posts list will show post related to Criticism).

I am using Flatsome theme for my site. I have tried JavaScript but it does not work. Is there any built-in Wordpress function or plugin that help me to do that?

enter image description here

  • What do you mean by 'have tried javascript but it doesn't work'? You should have included the code you tried rather than a picture because with the picture, there's basically no information that someone could use to help you. What you want is to dynamically change the posts being loaded based on the category the user selects and the best way to do that is with AJAX so the page doesn't have to reload every time. Nov 4, 2021 at 5:29
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
    – Community Bot
    Nov 4, 2021 at 5:29
  • Hi all, thanks for the feedback. It seems that I cannot edit the question, so here am I. I want to show a list of latest posts, but divide by category. So if user click on Criticism, the square on the right will show all posts on Criticism category, same for Interview and Creative work. That is my requirement. For the JavaScript code, I have tried DOM and List category post plugin. Here is the code:
    – Long Doan
    Nov 4, 2021 at 9:51
  • function change_category(category) { var category = category function changer() { console.log(category); document.getElementById("category_name").innerHTML = '[rpwe limit="10"]' } return changer } document.getElementById("btn_criticism").addEventListener('click', change_category('criticism')); document.getElementById("btn_interview").addEventListener('click', change_category('interview')); document.getElementById("btn_creative_work").addEventListener('click', change_category('creative work'));
    – Long Doan
    Nov 4, 2021 at 9:54

1 Answer 1


I believe what you need is the wp_list_categories() function. You would need to do something like this;

    wp_list_categories( array(
        'orderby'    => 'name',
        'show_count' => true,
        'exclude'    => array( 10 )
    ) );

This will list all the available post categories ordered by title. You can have a look at the docs for this to find a list of all the parameters you can use.

  • Could you elaborate further? Like how to link that with the "button" (the one for user to click on)? I am a bit new to WordPress though
    – Long Doan
    Nov 3, 2021 at 12:41
  • Apologies @LongDoan I seem to have misunderstood your question. I thought what you wanted to do was display a list of clickable post categories which would redirect you to an archive page. Please disregard my answer as it won't won't help you achieve the result you want.
    – eugene
    Nov 4, 2021 at 15:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.