1

I'm using the "Types" plugin for Wordpress to create two custom post types and it works fine. I built custom templates on the base of archive-slug.php where the "slug" is the post type slug. It applies everything fine, but in my navigation - I open a single custom post type, but it marks the page with the default post type as active.

Seems to be a conflict and WP can't figure out which menu item to mark as active so it uses the menu item that is a category page for the default post type instead of the custom one.

Any ideas?

  • Did you set has_archive to true and flushed your permalinks – Pieter Goosen Nov 18 '14 at 15:21
  • @PieterGoosen Yes. Basically, my file structure is: home.php for regular posts, archive-news.php for blog posts (custom post type). I have two menu items - one for the regular posts category page (BLOG) and another one for NEWS. When I open NEWS and an individual NEWS post - the nav bar marks the BLOG as the active menu item. Likewise, when I open NEWS (category page), both the NEWS and BLOG are marked as active. If it makes a difference, I'm using the ROOTS starter theme. – sixli Nov 18 '14 at 16:20
  • archive-news.php is for the news posts (not blog posts) - error in the above response, sorry – sixli Nov 18 '14 at 16:27
  • Sorry, but this is related to the theme and/or plugin you are using. Both of these are off topic unfortunately. Please contact the author of the theme and/or plugin – Pieter Goosen Nov 18 '14 at 16:59
  • I am the creator of the theme - that's why I'm struggling with this. I'm fairly sure it's the file structure that's causing the issue which is WP related so was hoping for some help... – sixli Nov 18 '14 at 20:38
0

Do you want to Multiple Custome Post of your Website ? you told that you have already created one custom post of your website. Don't worry about it. Now I will help you for your problem

First, make an another custom posts on your and paste function.php or custom-posts.php file. Now I will create custom post Movie Types . you can just change it Movie replaces it your custom post type name.

    function custom_post_type() {

// Set UI labels for Custom Post Type
    $labels = array(
        'name'                => _x( 'Movies', 'Post Type General Name' ),
        'singular_name'       => _x( 'Movie', 'Post Type Singular Name'),
        'menu_name'           => __( 'Movies'),
        'parent_item_colon'   => __( 'Parent Movie' ),
        'all_items'           => __( 'All Movies'),
        'view_item'           => __( 'View Movie'),
        'add_new_item'        => __( 'Add New Movie'),
        'add_new'             => __( 'Add New' ),
        'edit_item'           => __( 'Edit Movie' ),
        'update_item'         => __( 'Update Movie' ),
        'search_items'        => __( 'Search Movie'),
        'not_found'           => __( 'Not Found' ),
        'not_found_in_trash'  => __( 'Not found in Trash'),
    );

// Set other options for Custom Post Type

    $args = array(
        'label'               => __( 'movies' ),
        'description'         => __( 'Movie news and reviews' ),
        'labels'              => $labels,
        'supports'            => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'revisions', 'custom-fields', ),
        'hierarchical'        => false,
        'public'              => true,
        'show_ui'             => true,
        'show_in_menu'        => true,
        'show_in_nav_menus'   => true,
        'show_in_admin_bar'   => true,
        'menu_position'       => 5,
        'can_export'          => true,
        'has_archive'         => true,
        'exclude_from_search' => false,
        'publicly_queryable'  => true,
        'capability_type'     => 'page',

        // This is where we add taxonomies to our CPT
        'taxonomies'          => array( 'category' ),
    );

    // Registering your Custom Post Type
    register_post_type( 'movies', $args );

}



add_action( 'init', 'custom_post_type', 0 );

Displaying Multiple Post Types

<?php 
$args = array( 'post_type' => 'movies', 'posts_per_page' => 10 );
$the_query = new WP_Query( $args ); 
?>
<?php if ( $the_query->have_posts() ) : ?>
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<h2><?php the_title(); ?></h2>
<div class="entry-content">
<?php the_content(); ?> 
</div>
<?php wp_reset_postdata(); ?>
<?php else:  ?>
<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.