How to use this $tax_selection variable in this custom loop?

I suppose you need to make it global. It might look like: add_action( ‘pre_get_posts’, ‘do_user_post_selection’ ); function do_user_post_selection( $query ) { if( !is_home() || !is_user_logged_in() ) return; if( isset( $query->query_vars[‘post_type’] ) && ( ‘nav_menu_item’ == $query->query_vars[‘post_type’] ) ) return; if( 1 < did_action(‘wp’) ) return; global $current_user, $tax_selection; $tax_selection = get_user_option( ‘taxonomy_selection’, $current_user->ID ); if( … Read more

Pagination for normal (standard) posts on a page with a custom loop?

get_pagination_links is looking at $wp_query, whereas you want pagination for your query object named $loop. So instead, use paginate_links Something similar to this code, which is based on get_pagination_links, alebit with wp-query swapped out for your loop query object: $endsize = $midsize = 1; $type=”plain”; $loop->query_vars[‘paged’] > 1 ? $current = $loop->query_vars[‘paged’] : $current = … Read more

Loop for custom-post-type comparing taxonomy terms for “related” posts?

Change your $args array a little bit: $args = array( ‘post_type’ => array( ‘my_projects’ ), // it need to get the posts from this post_type ‘order’ => ‘DESC’, ‘posts_per_page’ => 5, ‘project_tags’ => $term // search taxonomy ); Other ways to search for taxonomy terms can be found here in the WordPress Codex pages. Answer … Read more

Creating ‘posts page’ loop based on the page itself

You can get the selected page for posts by the following code: $page_for_posts = get_option( ‘page_for_posts’ ); Then, get the requested post by: $post = get_post( $page_for_posts ); And, get the data you need: echo apply_filters( ‘the_title’, $post->post_title ); echo apply_filters( ‘the_content’, $post->post_content ); echo get_post_meta( $post->ID, $key, $single);

Performance concerns: index.php vs taxonomy-$taxonomy.php

TL;DR Template: Performance not so much, semantics however, use hierarchy! TL;DR Query String: Use provided hooks, never edit directly. The Template File Apart from performance, first look at semantics. If you direct your browser to a taxonomy archive, WordPress will look for the following files (straight from the Codex): taxonomy-{taxonomy}-{term}.php – If the taxonomy were … Read more

Does search.php autofilter The Loop?

The loop doesn not display the latest posts, it just shows the posts the main query has found. On your search page the main query returns search results, and you can change its order (we have plenty of examples for that on our site). WordPress looks for the parameter s or /search/ in the request … Read more