Trying to exclude posts from a category on the home page

Technically, pre_get_posts is an action, not a filter, and you don’t need to return anything and $query is passed in by reference, but that code should nonetheless work. Cleaned up it would be: function excludeCat($query) { if ( $query->is_home ) { $catid = get_cat_ID(‘watch-isatv’); $query->set(‘cat’, ‘-‘.$catid); } } add_action(‘pre_get_posts’, ‘excludeCat’); There are several potential points … Read more

How to fix pagination for custom loops?

The Problem By default, in any given context, WordPress uses the main query to determine pagination. The main query object is stored in the $wp_query global, which is also used to output the main query loop: if ( have_posts() ) : while ( have_posts() ) : the_post(); When you use a custom query, you create … Read more

Removing a post from the results of a WP Query

Do you know the ID of the posts? Have you passed post__not_in as part of your query? $query = new WP_Query( array( ‘post_type’ => ‘post’, ‘post__not_in’ => array( 2, 5, 12, 14, 20 ) ) ); From: http://codex.wordpress.org/Class_Reference/WP_Query. The above will return all posts but exclude the IDs specified. Or do you have another way … Read more

Pulling values from a sepcific row in table

$leader_result = $wpdb->get_results(“SELECT user_first_name, user_last_name FROM “.$wpdb->prefix.”mro_attendees WHERE event_id = “.$project_id.” AND user_role=”team_leader” LIMIT 0,1″) foreach($leader_result as $row=>$value) { echo $value->column_name; }