WordPress.org

Support

Support » Plugins and Hacks » Hacks » links to tagged posts dependant on page name

links to tagged posts dependant on page name

  • Hi
    I have the following code working in a PHP text widget in universal sidebar, but when it works my other sidebar (contains main navigation) drops down below it, could anyone tell me if this is related to my code or if i’m missing something in the template bit. New to WP, i’ve a clumsy grasp of PHP, advice much appreciated, the first link to all tagged posts doesn’t make this happen it doesn’t happen when there are no matching posts either.

    <?php
    $slug = basename(get_permalink());
    
    ?>
    <h5>
    <a>/">see all <?php echo $slug; ?> posts.</a></h5>
    
    <?php
    
    $args = "tag=$slug";
    
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
    while ($my_query->have_posts()) : $my_query->the_post(); ?>
    
    <li><a>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
    <?php
    endwhile;
    }
    wp_reset_query();
    
    ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi Again
    I’ve fixed the menu issue by moving the

      tags but i’m only getting 10 of the 15 posts displayed

    http://www.i-needs.org/0-5/

    I’ve got a custom menu above this bit showing all the tagged posts so I know the’re there.

    Thanks
    Claire

    Yey.. sorted … sorry for spouting my little learning experience all ove the forums

    <?php
    $slug = basename(get_permalink());
    
    ?>
    
    <?php
    
    $args = "tag=$slug&posts_per_page=-1";
    
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
    while ($my_query->have_posts()) : $my_query->the_post(); ?>
    <ul><li><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></li></ul>
    
    <?php
    endwhile;
    }
    wp_reset_query();
    
    ?>
    <h5>
    <a href="http://www.i-needs.org/tag/<?php echo $slug; ?>/">see all <?php echo $slug; ?> posts.</a></h5><br>

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘links to tagged posts dependant on page name’ is closed to new replies.
Skip to toolbar