How to debug a blank page?

Notice: wpdb::escape is deprecated since version 3.6! Use wpdb::prepare() or esc_sql() instead. in /nfs/c01/h04/mnt/38315/domains/joao.pt/html/wp-includes/functions.php on line 2905 WordPress often is not really accurate with giving your information. You can change that: Set error_reporting( -1 ); and define( ‘WP_DEBUG’, true );. More info in that Gist. This will avoid the white screen of death. If you … Read more

Assigning the same custom meta box to multiple post types

Yes, you need to edit your video_add_box() function in order to make an array with the post type you need to show that box. $postypes = array(‘type1’, ‘type2’, ‘type3’); foreach ( $postypes as $postype) { add_meta_box( ‘video_information’, ‘Video Information’, ‘video_information’, $postype ); } You can read more in codex: http://codex.wordpress.org/Function_Reference/add_meta_box

Custom taxonomy template for multiple custom post types

When you land in a taxonomy archive page, e.g. the one with url http://yoursite.com/city/london/ WordPress can’t know if you want to see London’s Hotels, Gym of Supermarkets: you have to inform it. How inform WordPress? By url. So, if your url appear like http://yoursite.com/city/london/show/gym now WordPress understand you want to see only gyms… How to … Read more

Issue with pre_get_posts on custom post type archive pages

If we look in source, we’ll see under what conditions is_archive is true: if ( $this->is_post_type_archive || $this->is_date || $this->is_author || $this->is_category || $this->is_tag || $this->is_tax ) $this->is_archive = true; The issue is that is_archive is triggering your filter on your post type archive. If you want to exclude those, either make sure it’s not … Read more

Querying Term Posts in Loop

To expand on the answer from @s_ha_dum – you need to modify a few things about your query. First, use his suggested tax query: $args = array( ‘post_type’ => ‘custcpt’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘custtax’, ‘field’ => ‘id’, ‘terms’ => $cat->term_id, ) ), ‘order’ => ‘ASC’ ); Then, modify your code as follows: … Read more

Custom fields in Permalinks?

Use add_rewrite_tag( $tag, $regex ); to register a rewrite tag for the custom field. Filter post_type_link to replace the rewrite tag. The second argument is the post object, so you have always access to the post ID. For a sample implementation see my plugin T5 Rewrite. It does exactly that in the class T5_Rewrite_Tag_Custom.