Exclude category from recent posts

If you are looking for a way to exclude category from recent post (post that show up on your homepage).  Here is a quick and simple way to do it.  First find the category id by editing the category you want to exclude.  From your dashboard click Categories and edit the category you want to exclude.  Once you select edit, in the URL you’ll see the category ID.  Make a note of this number.

I use frameworks (genesis), so I would open my child theme functions.php file. And add the following code:

//Exclude category from recent posts
add_filter(‘pre_get_posts’, ‘exclude_category_from_home’);
function exclude_category_from_home($query) {
if ( $query->is_home ) {
$query->set(‘cat’, ‘-id‘);
}
return $query;
}

Now just replace the “id” with your category number save the file and there you have it.

New AgentPress 2.0 Child Theme

AgentPress 2.0 is now available from StudioPress.  This is a great solution for real estate agents to edit and update property listings, integrate with IDX, and display featured listings.  I’ll be speaking at a REBarCamp in October, so I’m looking forward to speaking about this new child theme.

AgentPress - The Leading WordPress Theme for Real Estate Professionals

What is a Hook?

Hooks, Actions and Filters

Hooks are provided by WordPress to allow your plugin to ‘hook into’ the rest of WordPress; that is, to call functions in your plugin at specific times, and thereby set your plugin in motion. There are two kinds of hooks:

  1. Actions: Actions are the hooks that the WordPress core launches at specific points during execution, or when specific events occur. Your plugin can specify that one or more of its PHP functions are executed at these points, using the Action API.
  2. Filters: Filters are the hooks that WordPress launches to modify text of various types before adding it to the database or sending it to the browser screen. Your plugin can specify that one or more of its PHP functions is executed to modify specific types of text at these times, using the Filter API.

You can sometimes accomplish the same goal with either an action or a filter. For example, if you want your plugin to change the text of a post, you might add an action function to publish_post (so the post is modified as it is saved to the database), or a filter function to the_content (so the post is modified as it is displayed in the browser screen).