Query post types with multiple keys

meta_query has a relation parameter just like tax_query so: $documents = array( ‘post_type’ => ‘documents’, ‘meta_query’ => array( ‘relation’ => ‘AND’, array( ‘key’ => ‘document-type’, ‘value’ => ‘manual’, ), array( ‘key’ => ‘document-status’, ‘value’ => ‘current’, ) ) ); query_posts( $documents ); get_template_part( ‘loop’, ‘documents’ ); wp_reset_query();

Which file displays the date archive?

archive.php is used to display author, search, category, tag and date archives. As clicking on a calendar day will take you to the date archive for that day, then the file you’re looking for is archive.php. More specifically, WordPress will check for these files in this order, stopping when it finds one of these files … Read more

Problem ordering posts with numbers for titles numerically E.g. 1, 10, 100

Here’s code that will order posts by the post_title field, numerically. This code will affect the main query for posts on both the back end and front end. // Apply numeric post ordering for posts in admin and front end. // Adapted from https://www.fldtrace.com/custom-post-types-numeric-title-order function wpse247871_post_order( $wp_query ) { if ( $wp_query->is_main_query() && $wp_query->query[‘post_type’] == … Read more

Specific loop in Shortcode

Ok mate – i got you… you should really break into 2 shortcodes. One as a wrapper (which is really short) and the other for the content… Example: add_shortcode(‘servicewrap’, ‘service_wrapsc’); function service_wrapsc($atts, $content = null) { return ‘<div class=”service”><div class=”container”><div class=”row”>’.do_shortcode($content).'</div></div></div>’; } add_shortcode(‘servicesingle’, ‘service_singlesc’); function service_singlesc($atts, $content = null) { extract(shortcode_atts(array( ‘icon’ => ‘fa-briefcase’ ), … Read more

How to create posts (not post template) to be displayed on projects page?

The best way is to register a custom post type then loop through that type within your projects page template. CPT from GenerateWP. if ( ! function_exists(‘projects’) ) { // Register Custom Post Type function projects() { $labels = array( ‘name’ => _x( ‘Projects’, ‘Post Type General Name’, ‘text_domain’ ), ‘singular_name’ => _x( ‘Project’, ‘Post … Read more

Exclude posts with specific meta_value while sorting by a separate meta_value

You code may be $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; $args = array( ‘posts_per_page’ => ’50’, ‘meta_key’ => ‘release_date’, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘ASC’, ‘meta_query’ => array( array( ‘key’ => ‘undetermined_date_toggle’, ‘value’ => ‘true’, ) ), ‘paged’ => $paged ); $the_query = new WP_Query( $args ); this code show only those posts which … Read more