Most efficient way of showing children posts?
Most efficient way of showing children posts?
Most efficient way of showing children posts?
You should use a custom select query: $querystr = ” SELECT * FROM $wpdb->posts LEFT JOIN $wpdb->term_relationships ON($wpdb->posts.ID = $wpdb->term_relationships.object_id) LEFT JOIN $wpdb->term_taxonomy ON($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id) LEFT JOIN $wpdb->terms ON($wpdb->term_taxonomy.term_id = $wpdb->terms.term_id) WHERE ($wpdb->terms.name=”sounds-flavors” OR $wpdb->posts.ID IN(12345,12678)) AND $wpdb->term_taxonomy.taxonomy = ‘category’ AND $wpdb->posts.post_status=”publish” AND $wpdb->posts.post_type=”post” LIMIT 3 “; Take a look here: https://codex.wordpress.org/Displaying_Posts_Using_a_Custom_Select_Query Regards
You can pass array with multiple queries to meta_query. Something like: ‘meta_query’ => array( array( ‘key’ => ‘eg-enddate’, ‘value’ => date(“d/m/Y”), ‘compare’ => ‘>’, ‘type’ => ‘numeric’ ), ‘relation’ => ‘AND’, array( ‘key’ => ‘eg-startdate’, ‘value’ => date(“d/m/Y”), ‘compare’ => ‘<‘, ‘type’ => ‘numeric’ ) ) For more please go through documentation: https://codex.wordpress.org/Class_Reference/WP_Meta_Query Note: Code … Read more
I don’t have a full detailed response for you, but here’s a few things I’d suggest: 1) Use template parts for each of those segments. That will help clean up the template so it’s easier to work with in the future. ( see here: https://konstantin.blog/2013/get_template_part/ ) 2) You could then create a helper function for … Read more
You must add meta_key to your array. How else the query will know what meta value to use? Try adding ‘meta_key’ => ‘your_key’
I’m typically against using a bunch of plugins, but an option for you is to use the Relevanssi plugin. I use it along side ACF and allows you to search within those fields. If you decide to use it, after installation/activation, go to the setting page for the plugin and scroll down to the “Indexing … Read more
If your footer file name is abc.php inside Codeigniter pages and you want to run that file in the WordPress directory. In the footer.php file in WordPress include your abc.php file. Otherwise, you can make your own functions to call or manage the content. <?php include ‘abc.php’; ?>
You can first get posts from your featured category and check if it has any posts or not. If yes, you will show them. If not, you will make another query that will get 3 posts from random categories (as you described) and show them. $events_args = array( // include the code in your question … Read more
There’s a couple problems I foresee here. I’m assuming the featured portion is a meta value of some sort. We can run a conditional that will run for all queries on the Front Page but it would override the meta_queries instead of append to them. The hook would look something like this: /** * Modify … Read more
WP default loop will automatically show the posts with in current tag on tag.php page. you dont need to set custom WP_Query for that but make sure that you are not modifying the loop from any other method. if( have_posts() ) : while( have_posts() ) : the_post(); the_title(); //Rest of code. endwhile; endif;