• How do i list all posts within a category in a drop down box on any post?

    When i choose a post on the drop down box i want to be taken to the post as well.

    an example of the drop down box i had in mind. >> http://www.echoecho.com/htmlforms11.htm

    I’ve looked through a lot of the plugins and none seem to have what i want. I found one that lists posts in form format and i can’t not confident with my editing skills to know how to change it to a select option format.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Didn’t really test this but using example from http://wordpress.org/support/topic/dropdown-list-of-posts-in-a-category?replies=4

    <?php
    $cat_id = get_cat_ID('uncategorized');
    $args=array(
      'cat' => $cat_id,
      'post_type' => 'post',
      'post_status' => 'publish',
      'posts_per_page' => -1,
      'caller_get_posts'=> 1
    );
    $my_query = null;
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
    ?>
    <form name="jump">
    <select name="menu">
    <?php
      while ($my_query->have_posts()) : $my_query->the_post(); ?>
        <option value="<?php the_permalink() ?>"><?php the_title(); ?></option>
        <?php
    
      endwhile;
    }
    ?>
    </select>
    <input type="button" onClick="location=document.jump.menu.options[document.jump.menu.selectedIndex].value;" value="Go">
    </form>
    
    <?php
    wp_reset_query();  // Restore global post data stomped by the_post().
    ?>

    I changed the code slightly so I could use it as part of a drop down in a header menu.

    <ul id="nav">
    	<?php wp_list_pages('title_li=&depth=2'); ?>
    	<li class="page_item"><a href="http://organic-babyclothes.co.uk/category/suppliers/">Brands</a>
    	<ul><?php
    $cat_id = get_cat_ID('suppliers');
    $args=array(
      'cat' => $cat_id,
      'post_type' => 'post',
      'post_status' => 'publish',
      'posts_per_page' => -1,
      'caller_get_posts'=> 1
    );
    $my_query = null;
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
    ?>
    
    <?php
      while ($my_query->have_posts()) : $my_query->the_post(); ?>
        <li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
        <?php
    
      endwhile;
    }
    ?>
    
    <?php
    wp_reset_query();  // Restore global post data stomped by the_post().
    ?></ul>
    </li>
    	<li class="page_item last-page-item rss"><a href="<?php bloginfo('rss2_url'); ?>" title="News Feed">RSS</a></li>
    </ul>

    Hope that helps.

    Rich

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Listing posts within a category’ is closed to new replies.