• Hey everyone,

    I am working on a site for a client and he has a a page that is private for only users who are logged in to see, it is a list by genre of his movie collection, and when you click on the “Media Library” button he wants it to take you to a page that will only display the parent categories “English” (Subs: Action, Drama, Horror, Comedy, etc.) Parent: “Indian” (Subs: A, B, C, D, E, F, etc.) but he doesn’t want all of his other categories like News, Blog, Uncategorized to display on this page. He also wants it so you can click on the category name and it will take you to whatever is entered in under that category. Could anyone be so kind to help me out with this?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Michael Torbert

    (@hallsofmontezuma)

    WordPress Virtuoso

    http://codex.wordpress.org/Template_Tags/wp_list_pages

    This link will show you have you can have whichever pages shown you’d like… you may want to just try exclude=pageshedoesntwant.

    Thread Starter Danny Albeck

    (@dalbeck)

    Ok, i appreciate you pointing me int he right direction, quick question if anyone can help again. I will paste my code below, the problem is I know I put the exclude command in there wrong and the display categories even if there is nothing in them wrong. Could someone help me clean it up a little bit. Here is my code:

    <li id="categories">
    	<h2><?php _e('Posts by Category'); ?></h2>
    	<form action="<?php bloginfo('url'); ?>/" method="get">
    
    <?php
    	$select = wp_dropdown_categories('show_option_none=Select category&show_count=1&orderby=name&echo=0 exclude=9,23,16,15,3,1);
    	$select = preg_replace("#<select([^>]*)>#", "<select$1 onchange='return this.form.submit()'>", $select);
    	echo $select;
         echo $hide_empty=0;
    ?>
    	<noscript><input type="submit" value="View" /></noscript>
    	</form>
    </li>

    Here is the original code:

    <li id="categories">
    	<h2><?php _e('Posts by Category'); ?></h2>
    	<form action="<?php bloginfo('url'); ?>/" method="get">
    <?php
    	$select = wp_dropdown_categories('show_option_none=Select category&show_count=1&orderby=name&echo=0');
    	$select = preg_replace("#<select([^>]*)>#", "<select$1 onchange='return this.form.submit()'>", $select);
    	echo $select;
    ?>
    	<noscript><input type="submit" value="View" /></noscript>
    	</form>
    </li>

    Thanks guys!

    Michael Torbert

    (@hallsofmontezuma)

    WordPress Virtuoso

    &exclude=1,2,3

    Thread Starter Danny Albeck

    (@dalbeck)

    Halls,

    I really appreciate your help! I almost have it getting 2 problems. As soon as I added the exclude tag it made 2 drop down menus, but it is excluding the categories I don’t want which is good. Then I added the command to display categories that do not have posts in them. Final addition was the hierarchy command but that made the categories with no entry disappear. I will post my code so either you or anyone may see it.

    <li id="categories">
    	<h2><?php _e('Posts by Category'); ?></h2>
    	<form action="<?php bloginfo('url'); ?>/" method="get">
    <?php
    	$select = wp_dropdown_categories('show_option_none=Select category&show_count=1&orderby=name&echo=0 &exclude=9,23,16,15,3,1&hierarchical=1&hide_empty=0 ');
    	$select = preg_replace("#<select([^>]*)>#", "<select$1 onchange='return this.form.submit()'>", $select);
    	echo $select;
    ?>
    	<noscript><input type="submit" value="View" /></noscript>
    	</form>
    </li>

    Thanks again!

    Thread Starter Danny Albeck

    (@dalbeck)

    Update: I partially fixed the problem deleted an extra space I had in the code so now all of the categories are displaying, but I still have 2 drop down boxes.

    Thread Starter Danny Albeck

    (@dalbeck)

    Sorry for all the posts another update though. I got it working I had another space in the code. All is working well now! Thank you for all of your help halls!

    Michael Torbert

    (@hallsofmontezuma)

    WordPress Virtuoso

    You’re welcome, I’m glad I was able to help get it working. Please mark this post as resolved.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘List Certain Categories only plus their sub categories’ is closed to new replies.