admin管理员组文章数量:1122846
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!
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!
Share Improve this question asked Oct 11, 2014 at 19:27 user1547761user1547761 11 silver badge3 bronze badges 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? – Seamus Leahy Commented Oct 11, 2014 at 20:45
- Following up on that, would you link to the CPUI plugin? – Seamus Leahy 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 – user1547761 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. – Seamus Leahy Commented Oct 12, 2014 at 21:59
4 Answers
Reset to default 1One 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 );
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
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.
If you need CPT working with post_format, you can add a filter to remove the parameter from the preview url like this.
add_filter('preview_post_link', 'remove_postformat_from_preview_link', 10, 2);
function remove_postformat_from_preview_link($preview_link, $post) {
if (str_contains($preview_link, 'post_format')) {
return preg_replace('~(\?|&)post_format=[^&]*~', '$1', $preview_link);
}
return $preview_link;
}
本文标签: pluginsPreview with Custom Post Type Not Working
版权声明:本文标题:plugins - Preview with Custom Post Type Not Working 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736299130a1930383.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论