WordPress.org

Ready to get started?Download WordPress

Forums

Relate Articles to Navigation selection (2 posts)

  1. netmotiv8
    Member
    Posted 4 years ago #

    Hi,

    I am bit confused about what I need to do. I have checked the support site but cannot find the answer I am looking for.

    I am managing this wordpress based site http://www.ambaraypublishing.co.uk/

    You will notice the navigation bar: Blog / Development / Teenagers etc some of which also have sub-navigation items as well.

    What I want to be able to achieve is, for example at the url http://www.ambaraypublishing.co.uk/category/development/being-bilingual/ instead of seeing 'Recent Posts' on the right hand side I want to be able to show only the articles (and ALL the articles, not just recent articles) relating to 'being-bilingual' and I want to be able to do this for each nav/sub-navigation item (Teenagers, Writing For Children > Fiction).

    I hope I have explained myself correctly and I hope someone could help me achieve what I need to do

    I look forward to your comments.

    Many thanks
    Neil

  2. MichaelH
    Member
    Posted 4 years ago #

    <?php
    //for a sidebar, list all posts in currently viewed category archive
    if (is_category( )) {
      $cat = get_query_var('cat');
      $category = get_term_by('id',$cat, 'category');
      if ($category) {
        $args=array(
          'category__in' => array($category->term_id),
          'post_type' => 'post',
          'post_status' => 'publish',
          'showposts' => -1,
          'caller_get_posts'=> 1
          );
        $my_query = null;
        $my_query = new WP_Query($args);
        if( $my_query->have_posts() ) {
          echo 'List of Posts for '.$category->name;
          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;
        }
      wp_reset_query();  // Restore global post data stomped by the_post().
      }
    }
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic