Forums

[resolved] View the top post of one category. (6 posts)

  1. darwinsantos24
    Member
    Posted 1 year ago #

    Need Help!
    How will I do if I want the top post to be view its content and title of a category to be the first in my FrontPage, and then below of it is the other post?

    for example.
    category1
    hello world! content example
    other title
    other title1
    other title2

    Any help is appreciated!

  2. MAS
    Member
    Posted 1 year ago #

    How to get first post?

    <?php
    $my_query = new WP_Query("order=DESC&category_name=category1&showposts=1");
    while($my_query->have_posts()): $my_query->the_posts();
    <!-------------- Write your code here --------------->
    endwhile;
    ?>
  3. darwinsantos24
    Member
    Posted 1 year ago #

    i just add count for a simple loop to open all the first post in each category, thank you!

    but i will try if my code is working..

    thank you!

  4. MAS
    Member
    Posted 1 year ago #

    if u want to all first in every category, then the code would be little bit change

    $categories = get_categories();
    foreach($categories as $cat){
    $my_query = new WP_Query("order=DESC&cat=".cat->term_id."&showposts=1");
    }
  5. tomweber
    Member
    Posted 1 year ago #

    Yes..i tried it as well and it worked.

    [signature moderated Please read the Forum Rules]

  6. MAS
    Member
    Posted 1 year ago #

    if your issue is solve, plz mark it as resolved

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.