Excluded category from loop

Can’t really help with custom Genesis code, but the WordPress way to modify the main loop is to filter pre_get_posts. To exclude Category ID 7 from contexts other than single post pages: function wpse72961_filter_pre_get_posts( $query ) { if ( is_main_query() && ! is_singular() ) { $query->set( ‘category__not_in’, 7 ); } return; } add_action( ‘pre_get_posts’, ‘wpse72961_filter_pre_get_posts’ … Read more

Help with if statement inside while loop

You’re setting $id = $post->ID; outside of the loop for agent_type posts, it’ll never match. Anyway, if you’re not doing anything with the agent_type posts that don’t match, just query for the one post you want by its ID: $list_agent = get_post_meta( $post->ID,’ec_agents’,true ); $args = array( ‘post_type’ => ‘agent_type’, ‘p’ => $list_agent ); $agent_query … Read more

How to query for a page, get data, then query for child pages of that page

I don’t understand the distinction you are making between ‘sublevel’ query and ‘toplevel’ query, but this is how I pull children for a page. $children = get_children( array( ‘post_parent’ => $servid, ‘post_type’ => ‘page’, ‘post_status’ => ‘publish’, ‘orderby’ => ‘menu_order’, ‘order’ => ‘ASC’ )); ?> Or… $page_children = get_pages( array( ‘child_of’ => $post->ID, ‘post_type’ => … Read more

How can I use AJAX with check-box categories?

You’ll need to hook into the “onchange” event of javascript. When using jquery, it’s as simple as $(‘<the selector string>’).change(function(){}); When ever the values are changed, you’ll do an AJAX request to the server with the new parameters & populate the output screen with the new result. For the server-side, you’ll check the parameters, do … Read more

How to sort queried pages by an array of page ids?

There is no need to use such custom code when wordpress provides a better way of ordering the pages using menu_order. You can see this option under Page Attributes box on the right side of page edit screen. You can assign the ordering as per your criteria, then use the following code <?php global $wp_query; … Read more

Sidebar limiting to 10 posts?

Your problem is that you’re using query_posts(), when you need to be using WP_Query(). To display all posts (by ignoring pagination, use the posts_per_page parameter: $cat_query_args = array( // Include posts from category with ID $cat_id ‘cat’ => $cat_id, // Include all posts ‘posts_per_page’ => -1 ); $cat_query = new WP_Query( $cat_query_args ); if ( … Read more

WordPress Queries Not Working?

For the sidebar bit, you should be using a new Wp_Query: if ( $query->is_category(‘movies’) ): $movies = new Wp_Query(‘tag=movie-reviews’); while ( $movies->have_posts() ) : $movies->the_post(); get_template_part( ‘sidebar-reviews’, get_post_format() ); endwhile; else: get_template_part( ‘no-results’, ‘index’ ); endif; You don’t need query filters for anything except the main loop on a page.