• Resolved SimonJ

    (@simonj)


    Ok… I don’t know if I can do what I wanna do! πŸ™‚

    When I’m on my single.php, meaning I’m reading a particular post, I would like to get the post-slug of the post i’m reading and use it as a variable in query_posts later in the page.

    I wanna use the post-slug of a particular posts as a tag in other posts, wich are relative to this post…

    Example :

    I’m reading the post XYZ, with the post-slug XYZ. So I have a first loop to display it:

    <?php while (have_posts()) : the_post(); ?>
    Display the post's stuff
    <?php endwhile; ?>

    Then,on this same page, after this first loop, I want to put other loops to display all posts using the post-slug of the first post as a tag…

    <?php
    query_posts(array(
    'tag_slug__and'=>array('the-slug-of-the-post-looped-above '),
    ) );
    ?>

    Or

    <?php query_posts('tag=the-slug-of-the-post-looped-above'); ?>

    Don’t know if I’m clear enough… πŸ™‚ It is possible ?

    Thanks.

    S.

Viewing 1 replies (of 1 total)
  • Thread Starter SimonJ

    (@simonj)

    Ok! Well… πŸ™‚

    I think I was able to find the answer by myself…

    I found this thread :

    http://wordpress.org/support/topic/128046?replies=6

    There, I found a fucntion to get the post slug…

    Then, in my loops, I tried that :

    <?php
    query_posts(array(
    'cat'=>'12',
    'tag_slug__and'=>array((the_slug() )),
    ) );
    ?>

    And it works… πŸ™‚

    If any WP guru could confirm me that it’s an orthodox way to do so, I would be glad… πŸ™‚

    S.

Viewing 1 replies (of 1 total)
  • The topic ‘Get post sulg and use it for a variable in multiple loops… ?’ is closed to new replies.