WordPress.org

Ready to get started?Download WordPress

Forums

links to tagged posts dependant on page name (3 posts)

  1. claire pickle
    Member
    Posted 1 year ago #

    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();
    
    ?>
  2. claire pickle
    Member
    Posted 1 year ago #

    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

  3. claire pickle
    Member
    Posted 1 year ago #

    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>

Topic Closed

This topic has been closed to new replies.

About this Topic