Get current post slug and display inside query_posts
-
Hey guys
Been searching the forums for hours but still no luck with the problem I am having.
Basically I use a query to show all the posts on my site that use the same tag as the current post title in my single.php page.
I started out using this particular example where I manually type in the post slug and it works:
<?php query_posts('tag=jambaroo-action-park');?> <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
But it does not help me use the current post title so I added the_slug hack to my functions.php and tried this with no luck:
<?php query_posts('tag=' . echo the_slug() . '');?> <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
I kept up my search and found this but once again no luck:
<?php $post_slug = $post->post_name; query_posts( 'tag=' . $post_slug . ''); if (have_posts()) : while (have_posts()) : the_post(); ?>
I anyone has any idea how to do this I would be most appreciative
Thanks in advance
Andy
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Get current post slug and display inside query_posts’ is closed to new replies.