• Hi,

    Hope all is well!
    If anyone can help me with this html below I would be so thankfull.
    I want to exclude a category from my blog that shows on my frontoage, I know there is something with cat=- ?

    <!-- Blog -->
    
    <div class="app">
    <?php
    
    $blog_number = get_option('gpp_blog_number');
    $blog_category = get_option('gpp_blog_cat');
    if($blog_category=="") {$blog_category = "Blog";}
    $blog_category_ID = get_cat_ID($blog_category);
    ?>
    
    <div id="blog-section">
    <div class="span-<?php if (get_option('gpp_sidebar') == 'true' || !get_option('gpp_sidebar')) { echo "15 colborder home"; } else { echo "24 last"; } ?>">
    <h3 class="sub"><?php echo "$blog_category"; ?></h3>
    <?php $blog_query = new WP_Query("cat=;'$blog_category_ID'&showposts=$blog_number"); ?>
    
    	<?php $i = 0; ?>
    	<?php while ($blog_query->have_posts() ) : $blog_query->the_post();
    		$do_not_duplicate = $post->ID;  ?>
    			<div <?php if(function_exists('post_class')) : ?><?php post_class(); ?><?php else : ?>class="post post-<?php the_ID(); ?>"<?php 
    
    endif; ?>>
    				<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
    				<div class="entry">
    					<?php include (TEMPLATEPATH . '/apps/multimedia.php'); ?>
    					<?php include (TEMPLATEPATH . '/apps/video.php'); ?>
    					<?php the_content(); ?>
    					<?php if ($i == 1) { ?>
    					<?php include (TEMPLATEPATH . '/apps/ad-main.php'); ?>
    					<?php  } ?>
    				</div>
    				<div class="clear"></div>
    				<p class="postmetadata"><?php the_time('M d, Y') ?> | Categories: <?php if (the_category(', '))  the_category(); ?> <?php if (get_the_tags()) the_tags('| Tags: '); ?> | <?php comments_popup_link('Leave A Comment »', '1 Comment »', '% Comments »'); ?> <?php edit_post_link('Edit', '| ', ''); ?> </p>
    			</div>
    		<div class="clear"></div>
    		<?php endwhile; ?>
    	<?php $i == 0; ?>
    </div>
    </div>
    </div>
    <?php if (get_option('gpp_sidebar') =='true' || !get_option('gpp_sidebar')) { get_sidebar(); } ?>
    <hr />
Viewing 3 replies - 1 through 3 (of 3 total)
  • Well this line

    <?php $blog_query = new WP_Query("cat=;'$blog_category_ID'&showposts=$blog_number"); ?>

    seems meant to include only one category but it doesn’t seem properly constructed…maybe this will work:

    <?php $blog_query = new WP_Query('cat=' . $blog_category_ID . '&posts_per_page='.$blog_number); ?>

    Somewhere in your theme options you may specify what is your “blog category”

    Otherwise you are correct about excluding a category, but since it seems you can specify a blog category, you will have to decide if you want to change it to something like:
    <?php $blog_query = new WP_Query('cat=-3&posts_per_page='.$blog_number); ?>

    Thread Starter michaelsjoberg

    (@michaelsjoberg)

    Dear Michael,

    Thanks for your response!
    Frustrated cuz I cant get this to work, have tried with a plugin that is supposed to exclude categories from the blog but it didnt work.

    I post a link below, I want to exclude the category “Videoblog” so it only appears in the thumbslider but not in the “latest blog” on the frontpage.

    https://1-icon.se/JO/

    Thanks again and have a nice weekend!

    You might want to provide a link to download the theme you are using and maybe someone can spot the problem.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Exclude a category from show’ is closed to new replies.