Issue with Custom Post Types
-
Background
I have enabled multiple post types on my site and I am using the same tags across all post types. The first issue that I had was the custom posts where not appearing in the tag archive. I found a solution to the issue on this page which suggested adding the following code into my functions.php file which resolved the issue.
add_filter('pre_get_posts', 'query_post_type'); function query_post_type($query) { if(is_tag()) { $post_type = get_query_var('post_type'); if($post_type) $post_type = $post_type; else $post_type = array('post','video'); // replace cpt to your custom post type $query->set('post_type',$post_type); return $query; } }
New Problem
Since adding the code, when I save a post (standard post or custom page), I get a PHP error despite the post saving successfully.
Warning: Cannot modify header information – headers already sent by (output started at /home/tbassett/webapps/thetennisbulletin/wp-content/themes/StudioBlue/functions.php:61) in /home/tbassett/webapps/thetennisbulletin/wp-includes/pluggable.php on line 881
- The topic ‘Issue with Custom Post Types’ is closed to new replies.