Changing wp_link_pages() to “Next Page” and “Previous Page” buttons?
Use the ‘next_or_number’ parameter: wp_link_pages( array ( ‘next_or_number’ => ‘next’ ) ); See the Codex for details.
Use the ‘next_or_number’ parameter: wp_link_pages( array ( ‘next_or_number’ => ‘next’ ) ); See the Codex for details.
You can modify all main queries before they happen via the pre_get_posts action and a check if is_main_query: function wpa75492_post_type_query( $query ) { if ( $query->is_main_query() ) { $query->set( ‘post_type’, array( ‘book’ ) ); } } add_action( ‘pre_get_posts’, ‘wpa75492_post_type_query’ );
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
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
There is a difference because you are not using the_post function in the first example. What this function does is it calls setup_postdata function, which sets up all the globals needed for other functions to work. You can call it manually, just at the beginning of your foreach loop, like this: setup_postdata( $post ). In … Read more
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
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);
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
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
You have to pass some arguments to new WP_Query or no database request will be sent. Your check … if ($my_query->have_posts()) … will never evaluate to TRUE, because there are no data.