• Resolved Jaja..

    (@jaja-1)


    Hello,

    I try to exclude two of my category’s on a custom Archive page.

    This is my code and it only exclude one category it doesn’t do multiple while the WP Codex says it has to by a comma,

    <h3 class="archive-heading">Categories:</h3>
    <ul>
    <?php $args=array( 'orderby' => 'name', 'order' => 'ASC', 'exclude' => 1,12 );
    	   $categories=get_categories($args);
    	   foreach($categories as $category) {
    	   echo '<li class="archive-cat-list"><span><a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a> ';
    	   echo '('. $category->count . ')</span></li>';  } ?>
    </ul>

    Very strange i think.
    It takes ID 1 but not ID 12.
    I have try to exclude other ID’s just to test it but it can only exclude one ID in this code.

    Little WP Glitch?

Viewing 4 replies - 1 through 4 (of 4 total)
  • I think exclude takes a string. Try wrapping it in quotes: '1,12'

    Thread Starter Jaja..

    (@jaja-1)

    Nope, ??

    WP Codex

    Default uses:

    <?php $args = array(
        'type'                     => 'post',
        'child_of'                 => 0,
        'parent'                   => ,
        'orderby'                  => 'name',
        'order'                    => 'ASC',
        'hide_empty'               => 1,
        'hierarchical'             => 1,
        'exclude'                  => ,
        'include'                  => ,
        'number'                   => ,
        'taxonomy'                 => 'category',
        'pad_counts'               => false );?>

    try:

    <?php $args=array( 'orderby' => 'name', 'order' => 'ASC', 'exclude' => array(1,12) );

    (untested)

    Thread Starter Jaja..

    (@jaja-1)

    WOW,,

    Thats it!

    Thank you so much,

    Strange..

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Exclude category doesn't work while the codex says it should.’ is closed to new replies.