0

At this point I have tried everything I know to fix the issue.

Issue: preview only works right after a custom posts is loaded or updated. If you make any changes or hit preview twice without updating the preview 404s. Pages and blog post do not 404 the previews.

We were using the ACF and CPUI plugins and roots theme. I have turned off all the plugins, switch to the 2014 theme, add the CPT manually, and Update WP core.

We have a lot of Custom post types in our site and rebuilding would be a huge pain.

Has anyone dealt with this issues? Anything helps.

Thanks!

4
  • Would you walk us through the situations where the preview works and where it doesn't work? What do you mean by "right after a custom posts is loaded or updated"? Are you having issues with Pages or Posts? Commented Oct 11, 2014 at 20:45
  • Following up on that, would you link to the CPUI plugin? Commented Oct 11, 2014 at 20:47
  • 1
    Preview works: Pages and Posts. Preview Doesn't work: Custom Post Types - When you click preview it 404s whenever you add anything to be previewed, but haven't saved or clicked update. wordpress.org/plugins/custom-post-type-ui Commented Oct 11, 2014 at 22:26
  • Sorry, but I wasn't able to reproduce the issue. Try disabling pretty URLs to see if something with the rewrite rules is messing with it. Commented Oct 12, 2014 at 21:59

3 Answers 3

1

One of the parameter that you can pass to the supports argument is post_formats, removing this argument will fix the problem with the preview redirecting to a wrong or non-existing url. Code sample:

    if ( ! function_exists('custom_post_type') ) {

    // Register Custom Post Type
    function custom_post_type() {

        // some code

        $args = array(
            // 'supports'            => array( 'title', 'editor', 'author', 'thumbnail', 'revisions', 'post-formats', 'comments', 'sticky'),
            'supports'            => array( 'title', 'editor', 'author', 'thumbnail', 'revisions', 'comments', 'sticky'),
            'taxonomies'          => array( 'category', 'post_tag', 'your_cpt_pictures', 'your_cpt_updates', 'your_cpt_outline' ),
            'capability_type'     => 'post'
        );
        register_post_type( 'your_cpt', $args );

    }

    // Hook into the 'init' action
    add_action( 'init', 'custom_post_type', 0 );
0

I had the same issue. I was using CPT UI and ACF. To resolve the issue i went into CPT UI > Edit Post Types and disabled support for Post Formats

0

Having the exact same issue, if anyone used CPT UI to create them, turn on REVISIONS to fix the problem, this managed to fix the issue for me. Latest WP 5.7 & CPT UI.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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