Custom post type templating problem

Archive pages A & B already exist as your brand and type term archives, you can style those differently by creating taxonomy-brand.php and taxonomy-type.php templates. The remaining piece is two different single product views. The simplest way to achieve that would be to append a GET var onto the permalinks: http://domain.com/product/someproduct/?origin=brand http://domain.com/product/someproduct/?origin=type WordPress has the … Read more

Copy post from category to custum post type

Create your custom post type and then try this. (BACKUP FIRST AS THIS IS UNTESTED). <?php // Get all posts in category “5” $news_posts = get_posts( array( ‘category’ => 5 ) ); // Loop through them foreach($news_posts as $p): // Update the post type wp_update_post( array( ‘ID’ => $p->ID, ‘post_type’ => ‘news’ ); ); // … Read more

Adding HTML tags or css classes to admin columns

Here’s what I ending up using thanks to Milo, the Codex and this post from http://simple2kx.com/. add_action( ‘manage_issues_pm_posts_custom_column’, ‘my_manage_issues_pm_columns’, 10, 2 ); function my_manage_issues_pm_columns( $column, $post_id ) { global $post; switch( $column ) { /* If displaying the ‘issues_type’ column. */ case ‘issues_type’ : if ( $terms = get_terms( ‘issues_type’ ) ) { echo ‘<span>’; … Read more

Custom Post Type with Templates using Meta Boxes?

I’d recommend using the template_include filter as opposed to template_redirect, as using this hook means that you don’t redirect the user but rather just present them with the template that is requierd. add_filter(‘template_include’, ‘my_custom_template_redirect’, 99); function my_custom_template_redirect($template){ global $post; if(is_single() && ‘campaign’ == get_post_type($post)){ $page_template = get_page_template(); $new_template = locate_template( array( ‘subfolder/’ . $page_template . … Read more

Tag Archive for Custom-Post-Type Posts yielding 404 when permalinks set to postname

Try give a name for your rewrite, like so: ‘rewrite’ => array( ‘slug’ => ‘news-updates-archive’, ‘with_front’ => true, ‘feeds’ => false, ‘pages’ => true, ) So you will avoid any problem. Also, the last functions you’re using are unnecessary. You can setup it on register_post_type: ‘taxonomies’ => array(‘post_tag’, ‘category’), PS: Try empty your trash also … Read more

Rewrite slug for CPT

Try this if you want to link your CPT archive in a menu: ‘has_archive’ => true, ‘rewrite’ => array( ‘slug’ => ‘generic’, ‘with_front’ => false ), After you re-save your permalinks, you can then add the link to your menu like this example: www.example.com/generic

Customize Query for post

The hierarchical argument when registering a custom post type should be set to false which is also the default setting hierarchical(boolean) (optional) Whether the post type is hierarchical (e.g. page). Allows Parent to be specified. The ‘supports’ parameter should contain ‘page-attributes’ to show the parent select box on the editor page.Default: false Note: this parameter was … Read more