adamramadhan
Member
Posted 3 years ago #
<?php
//for use in the loop, list 5 post titles related to first tag on current post
$tags = wp_get_post_tags($post->ID);
if ($tags) {
echo 'Related Posts';
$first_tag = $tags[0]->term_id;
$args=array(
'tag__in' => array($first_tag),
'post__not_in' => array($post->ID),
'showposts'=>5,
'caller_get_posts'=>1
);
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
<?php
endwhile;
}
}
?>
there is 10 post on my blog
and it shows 5 of the last post that the code search
how can we make it shows 5 of the first post that the code search ?
and it shows 5 of the last post that the code search
how can we make it shows 5 of the first post that the code search ?
I am confused by your question. Please rephrase.
adamramadhan
Member
Posted 3 years ago #
as u see at
http://www.eattuts.com/html-xhtml-part-1/
result :
Html - Xhtml Part 7
Html - Xhtml Part 6
Html - Xhtml Part 5
Html - Xhtml Part 4
Html - Xhtml Part 3
how can i make it
Html - Xhtml Part 2
Html - Xhtml Part 3
Html - Xhtml Part 4
Html - Xhtml Part 5
Html - Xhtml Part 6
To those query_posts() arguments, add 'orderby' => 'title' and 'order' => 'ASC'
adamramadhan
Member
Posted 3 years ago #
yes thanks michealh u save my life . may god bless u somehow haha.
adamramadhan
Member
Posted 3 years ago #
wait
when i go to http://www.eattuts.com/html-xhtml-part-2/
it does't show like
Html - Xhtml Part 3
Html - Xhtml Part 4
Html - Xhtml Part 5
Html - Xhtml Part 6
Html - Xhtml Part 7
but it shows like
Html - Xhtml Part 1
Html - Xhtml Part 3
Html - Xhtml Part 4
Html - Xhtml Part 5
Html - Xhtml Part 6
can u help me once more ? sry .
adamramadhan
Member
Posted 3 years ago #
maybe another hack can solve this any idea ?
If you want different order for different 'pages' then you will need to review Conditional Tags and Template Hierarchy