• Hello,

    I have a conflict with Custom Post Types connected to pages. When I create a Post type I usually make a archive- and single- custom post type and connect it to a page with template.

    It works perfectly as long as the CMS user is typing text in the special created (in functions.php) Custom Post Type. But when the user is typing in the Page WYSIWYG editor the Custom Post Type data is lost and also the data inserted in the Page will not show. What am I doing wrong here?

    My code is like this:

    Archive template (with opening template name):
    <?php
    $temp = $wp_query;
    $wp_query = null;
    $wp_query = new WP_Query();
    $wp_query->query(‘showposts=10&post_type=customposttype’.’&paged=’.$paged);

    while ($wp_query->have_posts()) : $wp_query->the_post();
    ?>
    <?php if ( has_post_thumbnail() ) { the_post_thumbnail(); } ?>
    <h2><?php the_title(); ?></h2>
    <?php the_content(); ?>
    <?php endwhile; ?>

    Functions part:
    add_action( ‘init’, ‘create_post_type’ );
    function create_post_type() {
    register_post_type( ‘customposttype’,
    array(
    ‘labels’ => array(
    ‘name’ => __( ‘customposttype’ ),
    ‘singular_name’ => __( ‘customposttype’ )
    ),
    ‘public’ => true,
    ‘has_archive’ => true,
    ‘menu_position’=>4,
    ‘supports’ => array( ‘title’, ‘editor’, ‘thumbnail’ )
    )
    );

    Even with a query reset and <?php the_content (); ?> and <?php the_title(); code on the archive for the page title and wysiwyg editor doesnt work. It breaks on the content since the title will properly show.

    Anyone can help me with this issue since I fear in the future people who are not common with the WordPress CMS will make the mistake to edit on a page instead of a custom post type and breaking the whole website.

  • The topic ‘Conflict with custom post types connected to pages’ is closed to new replies.