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!
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;
?>
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!
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");
}
tomweber
Member
Posted 1 year ago #
Yes..i tried it as well and it worked.
[signature moderated Please read the Forum Rules]
if your issue is solve, plz mark it as resolved