WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. wpmhweb
    Member
    Posted 1 year ago #

    Hello,

    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?

    Thanks,

  2. manishkrag
    Member
    Posted 1 year 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 :)

    Thanks

  3. wpmhweb
    Member
    Posted 1 year 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.

    Thanks,

Topic Closed

This topic has been closed to new replies.

About this Topic