B2B Articles - Sep 9, 2009 4:37:22 PM
We have been asked a few times by bloggers how to limit or exclude categories from your Wordpress installation frontpage. By default Wordpress will display a stream of blog posts from all categories. Some bloggers may wish to not display certain categories in that stream of posts on their homepage. A few web designers asked us how to control or exclude specific categories that should not be displayed.
Our answer was to write the code for the theme, and not edit the core functionality since that would complicate WP updates.
In the index.php file of your theme, there is a Loop statement. Wordpress processes this Loop statement for each of the posts in your blog. The statement begins with this code snippet:
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
The loop ends with this piece of code:
<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
Here is one way to solve this problem. This will allow you to limit specific categories from your frontpage and publish the remaining categories automatically. We will try to expand upon this post soon and explain other options and this option in more detail. The numbers "1", "3", "5", and "7" are the categories to be excluded from the frontpage blog.
<?php while (have_posts()) : the_post(); ?>
<?php if (!in_category('1') && !in_category('3') && !in_category('5') && !in_category('7')) { ?>
POST CODE GOES HERE
<? } ?>
<?php endwhile; ?>
Tel 212-993-7809
Ironpaper ®
10 East 33rd Street
6th Floor
New York, NY 10016
Map
First-party data marketing
SEO for B2B
Customer journey strategy
ABM Agency
Marketing for IoT Companies
HubSpot Implementation
B2B Product Marketing
Measurable Marketing
IoT go-to-market strategy
IT Marketing
HubSpot for ABM
Go to market strategy
Technology Marketing
Marketing for IT Companies
ABM Campaigns
B2B lead generation
B2B Marketing and Growth Agency.
Grow your B2B business boldly. Ironpaper is a B2B marketing agency. We build growth engines for marketing and sales success. We power demand generation campaigns, ABM programs, create B2B content, strengthen sales enablement, generate qualified leads, and improve B2B marketing efforts.