Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Azureum

    (@azureum)

    Never mind, I actually managed to code it myself pulling from various sources.

    Only thing I’m stuck with now is I would like it to not show up if there is only 1 post of the same name.

    Here is the code I am using:

    <?php $counter = '1'; ?>
    
    <form action="../">
    <select onchange="window.open(this.options[this.selectedIndex].value,'_top')">
    
    <option value="">Choose a chapter...</option>
    <?php
    
    $chapters = $wpdb->get_results("SELECT * FROM $wpdb->posts
    	WHERE post_title = '" . $post->post_title . "' AND post_status = 'publish' ORDER BY post_date");
    if ($chapters) :
    	foreach ($chapters as $post) :
    		setup_postdata($post);
    ?>
    	<option value="<?php the_permalink(); ?>">Chapter <?php echo $counter++; ?></option>
    <?php
    	endforeach;
    else :
    ?>
        <h2> Not Found</h2>
    <?php endif; ?>
    
    </select>
    </form>

    I am stuck on what code I would put in this mini loop so that it would check if the results returned are more than 1 and display the above drop down, if its just the 1 post then don’t display drop down.

    If I’m thinking along the right lines, as I also wish to do this …

    <li id="nav-homelink" class="current_page_item"><a class="fadeThis" href="<?php bloginfo('siteurl'); ?>/index.php" title="<?php _e('You are Home','arclite'); ?>"><span><?php _e('Title of Link Here','arclite'); ?></span></a></li>

    Then just order your pages links correctly, i.e; 0 1 2 3 etc.

    But thats just my judgement based on my knowledge, haven’t actually tested this yet …

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