Forums

Dropdown Posts List (16 posts)

  1. kwills7
    Member
    Posted 3 years ago #

    Hi All,

    I am in the middle of working on a project and seem to have hit a brick wall with something im not sure how to do.

    I need to create a dropdown list of posts to go on my website that shows all the posts i have created in every category. I have managed to find this: http://www.dagondesign.com/articles/drop-down-post-list-plugin-for-wordpress/which works well but only shows posts from one single category.

    Does anyone know any code i could use or manipulate to get the list to show all posts?

    I have managed to get a temporary fix for the problem by creating a category all putting all the posts under it, but i dont really want to go ahead with that because the search engines seem to index the wrong URL for it.

    Any help is appreciated, thanks.

  2. MadsK
    Member
    Posted 3 years ago #

    Try this :

    <select name=\"archive-dropdown\" onChange='document.location.href=this.options[this.selectedIndex].value;'>
    <option value=\"\"><?php echo attribute_escape(__('Select Post')); ?></option>
    <?php wp_get_archives('type=postbypost&format=option&show_post_count=0'); ?> </select>

    I hope this helps :)

  3. kwills7
    Member
    Posted 3 years ago #

    That works thanks! is there anyway i can change that to show the post title instead of the date?

    Thanks again

  4. MadsK
    Member
    Posted 3 years ago #

    I've edited the above code.

    When you use postbypost it shows the title instead of date :D

  5. kwills7
    Member
    Posted 3 years ago #

    it works!, Cheers for that, much appreciated!

  6. kwills7
    Member
    Posted 3 years ago #

    Just one more thing,

    I have another dropdown with the following code:

    <?php wp_dropdown_categories('show_option_none=Select a Category&show_count=1'); ?>

    <script type="text/javascript"><!--
    var dropdown = document.getElementById("cat");
    function onCatChange() {
    if ( dropdown.options[dropdown.selectedIndex].value > 0 ) {
    location.href = "<?php echo get_option('home');
    ?>/?cat="+dropdown.options[dropdown.selectedIndex].value;
    }
    }
    dropdown.onchange = onCatChange;
    --></script>

    it displays categories with posts within it, is there some way i can manipulate that to show all the categories even if they don't have a post within it?

    Thanks for this, you are saving me a lot of headache!

  7. MadsK
    Member
    Posted 3 years ago #

    Edit:

    You should use hide_empty=0

    <?php wp_dropdown_categories('show_option_none=Select a Category&show_count=1&hide_empty=0'); ?>

  8. kwills7
    Member
    Posted 3 years ago #

    brilliant, thanks for your help :o)

  9. MadsK
    Member
    Posted 3 years ago #

    No problem. Glad you could use it :)

  10. kwills7
    Member
    Posted 3 years ago #

    sorry, just ONE more last thing i promise!

    the dropdown code you have just listed is fine... i just need it now to show the "uncategorised" category...

    Is this possible?

    Thanks again

  11. MadsK
    Member
    Posted 3 years ago #

    Well the code i gave you above should list all categories you have. But given that the uncategorised category is there in default you might have to delete it and create your own uncategorised category.

  12. kwills7
    Member
    Posted 3 years ago #

    OK, thanks for your help, i'll leave you alone now.

  13. sene1983
    Member
    Posted 3 years ago #

    hi, i read the posts. but i could not understand. there are lots of php codes here. :(

    For example, there are 2 categories that named "A" and "B". when you login the A category, i want dropdown plugin to show the post of "A" category. when you click the category "B", i want to dropdown to show the post of category "B is that possible?

    plz help

  14. sene1983
    Member
    Posted 3 years ago #

    sorry?

    `<?php wp_dropdown_categories('show_option_none=Select a Category&show_count=1'); ?>

    <script type="text/javascript"><!--
    var dropdown = document.getElementById("cat");
    function onCatChange() {
    if ( dropdown.options[dropdown.selectedIndex].value > 0 ) {
    location.href = "<?php echo get_option('home');
    ?>/?cat="+dropdown.options[dropdown.selectedIndex].value;
    }
    }
    dropdown.onchange = onCatChange;
    --></script>`

    is that code is workin?

  15. issy-m
    Member
    Posted 3 years ago #

    What if I just wanted to display all posts under one specific category (i.e. hacks).

    Thank you

  16. sailpilot
    Member
    Posted 3 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic