is_main_query() never called on WP 4.4
The action hook pre_get_posts is called well before the page template is rendered. Move add_action(‘pre_get_posts’, ‘my_pre_get_posts’); and your my_pre_get_posts() function to your theme’s functions.php file.
The action hook pre_get_posts is called well before the page template is rendered. Move add_action(‘pre_get_posts’, ‘my_pre_get_posts’); and your my_pre_get_posts() function to your theme’s functions.php file.
Taken literally your question is about post to post relationships. Bad news — WordPress core doesn’t do post to post relationships. However there are some solutions ranging from frameworks like Posts 2 Posts to plugins like Post Connector. Stepping a bit back though, structure you are describing strongly implies grouping of posts. The mechanism for … Read more
You can use the action pre_get_posts . Just make sure to check is_post_type_archive(‘question’) and is_admin() to prevent affect queries in the whole website.
After some digging I found the answer! Hopefully this helps some other people! EDIT Improved Answer! <?php $args = array( ‘post_parent’ => get_the_ID(), ‘post_type’ => ‘airports’, ‘posts_per_page’ => -1 ); $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post(); ?> <h2><?php the_title(); ?></h2> <a href=”https://wordpress.stackexchange.com/questions/222748/<?php the_permalink(); ?>”> <button><?php _e(‘View’, ‘text_domain’); ?></button> </a> … Read more
Whether a post is a draft or published is defined by the post status, not any of the meta fields, so you’ll have to hook into wp_insert_post_data and force the post_status to draft if anything in your form is invalid: add_filter( ‘wp_insert_post_data’, function( $data ) { if ( $data[‘post_type’] != ‘zip_code’ ) return $data; // … Read more
You need to set your paged arg in your $args array: $listing_args = array( ‘post_type’ => ‘business’, ‘posts_per_page’ => 10, ‘meta_key’ => ‘listing_num’, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘DESC’, ‘offset’ => ($paged -1) * 10, ‘paged’ => $paged, // <- tell the query what page we are on. ‘tax_query’ => ……etc ); And then use … Read more
I’ve checked another option and asigned my custom taxonomy to custom post type using its name but without capitals and space. ‘postname’ works with original ‘Post Name’ So for custom post type register_post_type( ‘Post Name’, $args ); I can use register_taxonomy( ‘custom taxonomy’, array( ‘postname’ ), $args ); And it works.
In general you can not override functions or methods in PHP. Code can be written to support such things, but it needs to be planned in advance, and your snippet is not big enough to be able to decide if it is possible or not in your case. The good thing, is that you do … Read more
It’s should be return rather than echo. return ‘<meta name=”site_title” content=”‘.’test test’.'”>’.”\n”;
Possible solutions: Check if there’s a prefix which you setup for the custom field (https://en.bainternet.info/tax-meta-class-faq/#comment-1107) Go to the Tax-meta-class/Tax-meta-class.php file and find the function you’re calling and debug the issue: // Tax-meta-class.php public function get_tax_meta($term_id,$key,$multi = false){ $t_id = (is_object($term_id))? $term_id->term_id: $term_id; var_dump ($t_id); // debug this $m = get_option( ‘tax_meta_’.$t_id); var_dump ($m); // debug … Read more