• Resolved kaspar wimberley

    (@kaspar-wimberley)


    I guess for many of you this is fairly simple, but I’ve tried and read everything now without luck. Any help greatly appreciated.

    I want to remove a post category from my blog and magazine templates (template-blog.php & template-magazine.php).

    I guess I change this bit in some way:

    <?php
    $paged = ( !empty($paged) ) ? $paged : $page;
    query_posts(array(
    'posts_per_page' => get_option('posts_per_page'),
    'paged' => $paged
    ));
    ?>

    But maybe I’m off the mark. Let me know if you need any code.

    I’m using wpshower’s unspoken theme (http://www.treacletheatre.co.uk/portfolio).

    These are the files I could edit:

    Templates

    404 Template
    (404.php)
    Archives
    (archive.php)
    AutoEmbed.php
    (AutoEmbed.php)
    Blog Page Template
    (template-blog.php)
    Comments
    (comments.php)
    Contact Form Page Template
    (template-contactform.php)
    FixImageMargins.php
    (FixImageMargins.php)
    Footer
    (footer.php)
    Header
    (header.php)
    Image Gallery Page Template
    (template-gallery.php)
    Magazine Page Template
    (template-magazine.php)
    Main Index Template
    (index.php)
    Page Template
    (page.php)
    Search Results
    (search.php)
    Sidebar
    (sidebar.php)
    Single Post
    (single.php)
    Sitemap Page Template
    (template-sitemap.php)
    Tags Page Template
    (template-tags.php)
    Theme Functions
    (functions.php)
    Wide Page Template
    (template-wide.php)
    advanced_post_options.php
    (advanced_post_options.php)
    commentform.php
    (commentform.php)
    home.php
    (home.php)
    loop-page.php
    (loop-page.php)
    loop-single.php
    (loop-single.php)
    loop.php
    (loop.php)
    pagination.php
    (pagination.php)
    shortcodes.php
    (shortcodes.php)
    theme_options.php
    (theme_options.php)
    twitter.class.php
    (twitter.class.php)
    widgets.php
    (widgets.php)
    yarpp-template-recommended.php
    (yarpp-template-recommended.php)
    yarpp-template-similar.php
    (yarpp-template-similar.php)

    Styles

    Stylesheet
    (style.css)
    ie.css
    (ie.css)

Viewing 14 replies - 1 through 14 (of 14 total)
  • Hi,

    basically all the categories on the menu can be found at the header.php file in your theme folder.

    Find this:

    <?php wp_list_categories(‘title_li=’) ?>

    Replace with:
    <?php wp_list_categories(‘exclude=6,43&title_li=’) ?>

    This will exclude category 6 and 4 from the list. But you can change the category ID according to your requirement.

    Thanks,

    Thread Starter kaspar wimberley

    (@kaspar-wimberley)

    Thanks Criador! I’ll give it a go.
    And that will not remove these categories from the site? They will still appear in category listings, etc?
    K

    Thread Starter kaspar wimberley

    (@kaspar-wimberley)

    No

    php wp_list_categories

    to be found! Only stuff relating to the menus etc appearing above the main content.
    Any other ideas?
    K

    Thread Starter kaspar wimberley

    (@kaspar-wimberley)

    Maybe I wasn’t clear earlier. I want to stop the category appearing in the loop/content of my blog template and/or magazine template (currently set as home page). I don’t want to remove it from the menus.
    k

    Thread Starter kaspar wimberley

    (@kaspar-wimberley)

    Here’s my loop if that helps:

    [code moderated – please use the pastebin]

    Thread Starter kaspar wimberley

    (@kaspar-wimberley)

    And here’s the full magazine template code:

    [code moderated – please use the pastebin]

    Thread Starter kaspar wimberley

    (@kaspar-wimberley)

    I believe it should be in the loop (see above). But where and how?

    You need to modify the query_posts() argument string, using the appropriate category query arguments.

    Let’s say the ID for the category you want to exclude is “5” (you’ll need to figure out the actual category ID).

    See this?

    <?php
    $paged = ( !empty($paged) ) ? $paged : $page;
    query_posts(array(
    'posts_per_page' => get_option('posts_per_page'),
    'paged' => $paged
    ));
    ?>

    Add the cat parameter. e.g.:

    <?php
    $paged = ( !empty($paged) ) ? $paged : $page;
    query_posts(array(
    'posts_per_page' => get_option('posts_per_page'),
    'paged' => $paged,
    'cat' => '-5'
    ));
    ?>

    Thread Starter kaspar wimberley

    (@kaspar-wimberley)

    Thanks Chip, I’ll try it!
    K

    Thread Starter kaspar wimberley

    (@kaspar-wimberley)

    Works! Thanks Chip,
    k

    mingookoh

    (@mingookoh)

    Wimberley,
    Now, I also use unspoken theme and I’m in same situation.
    I don’t know how to edit this source.

    <?php
    		$paged = ( !empty($paged) ) ? $paged : $page;
    		query_posts(array(
                    'posts_per_page' => get_option('posts_per_page'),
                    'paged' => $paged
    				'cat' => '-5'
                ));
            ?>

    This part I understood. but “You need to modify the query_posts() argument string, using the appropriate category query arguments.” It’s difficult.

    <?php
    
    	// The Query
    	$the_query = new WP_Query( $args );
    	$query = new WP_Query( 'cat=-5' );
    
    	// The Loop
    	while ( $the_query->have_posts() ) : $the_query->the_post();
    		echo '<li>';
    		the_title();
    		echo '</li>';
    	endwhile;
    
    	// Reset Post Data
    	wp_reset_postdata();
    
    	?>
    
            <?php
    		$paged = ( !empty($paged) ) ? $paged : $page;
    		query_posts(array(
                    'posts_per_page' => get_option('posts_per_page'),
                    'paged' => $paged
    				'cat' => '-5'
                ));
            ?>

    This is right? Please, tell me how to use! T_T
    Thanks!

    Thread Starter kaspar wimberley

    (@kaspar-wimberley)

    Hi mingookoh,
    I think you might be over complicating things.
    My code in the magazine template is now like this:

    `<div class=”title”><?php _e(‘Latest entries’, ‘unspoken’); ?><a href=”javascript: void(0);” id=”mode” class=”<?php if ($_COOKIE[‘mode’] == ‘grid’) echo ‘flip’; ?>”></a></div>

    <?php
    $paged = ( !empty($paged) ) ? $paged : $page;
    query_posts(array(
    ‘posts_per_page’ => get_option(‘posts_per_page’),
    ‘paged’ => $paged,
    ‘cat’ => ‘-491’
    ));
    ?>

    <?php get_template_part(‘loop’); ?>`

    Change the ID to whatever categories you want to exclude.
    That’s all I needed to do.
    K (http://treacletheatre.co.uk/portfolio)

    mingookoh

    (@mingookoh)

    Works! Thanks Wimberley, 🙂

    can anyone help me..
    i want to display latest entries section at homepage of my unspoken website.
    as per demo theme by wpshower they displayed a latest entries section below video section at homepage..
    But in my case i am not able to add that section below video section…
    look at my sample blog: http://shiva1819.byethost7.com/

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

The topic ‘Excluding categories in a template’ is closed to new replies.