how to check post category and display latest post? (3 posts)

  1. wpmhweb
    Posted 4 years ago #


    How can I create a function that checks the post category and base on the that show the latest post on that category or if possible check multiple categories?


  2. manishkrag
    Posted 4 years ago #

    hi wppit,

    Sorry, I have tried to get but did not clear your requirement. :)

    Can you please explain more your problem.

    My guess: You want to show latest post of each category- right?

    If yes then,

    Answer: WP provides function to get all the categories in a array, then in foreach loop for categories you can get the post list by using function query_posts using parameters category id, order by post publish date and showpost parameter value to 1.

    Then print the data as you required :)


  3. wpmhweb
    Posted 4 years ago #

    Hello manishkrag,

    This is what I need: When a visitor loads a new post, I would like WordPress to check the category of the post the visitor just loaded. Then depending in which category that post is, I would like to show the latest post for that particular category.


Topic Closed

This topic has been closed to new replies.

About this Topic