Support Forum
Support › MB Frontend Submission › front end submission for post type does not auto refresh permalinks
Hi
I setup a custom table with a custom post type and front end submission form. There are no issues with the form. But I noticed when there is 0 posts and you create the first ever post using the front end form, the posts single page returns a 404 message, even though the post is in the database. If I manually force the refresh of permalinks in wordpress it fixes the issue. Is this normal behaviour?
thanks
Hello Nick,
It could be a caching issue on your site. I don't see that on my demo site. After creating the first post in the frontend, it is accessed properly.
Hi
I dont have any caching enabled on my localhost machine, I have submitted the post using the ajax form and it links to a custom table. Not that it should affect this. I have re-tested quite a few times and it only does it when there is no existing posts in the database (so the first post using the front end form).
I will keep looking to see if i can find out any more information.
here is the metabox code I'm using to create the posts for a custom post type of 'product'. Is it an issue with custom post types and tables?
$meta_boxes[] = [
'title' => 'Products',
'post_types' => 'Product',
'storage_type' => 'custom_table',
'table' => $wpdb->prefix . 'dc_products',
'id' => 'dc-product',
'context' => 'normal',
'fields' => [
[
'type' => 'text',
'name' => 'Title',
'id' => 'post_title',
'class' => 'dc-post-title',
'limit' => 50, //default character length
'required' => true,
],
[
'type' => 'textarea',
'name' => 'Description',
'id' => 'description',
'required' => true,
],
[
'type' => 'number',
'name' => 'Price',
'id' => 'price',
'step' => '.01', //two decimal places e.g. 0.00
'placeholder' => '0.00',
'required' => true,
],
[
'type' => 'number',
'name' => 'Sale Price',
'id' => 'sale_price',
'step' => '.01', //two decimal places e.g. 0.00
'placeholder' => '0.00',
'required' => false,
],
[
'type' => 'select',
'name' => 'Condition',
'id' => 'condition_id',
'options' => (new DripCreateProductCondition())->conditionTypes,
'multiple' => false,
'placeholder' => "",
'select_all_none' => false,
'required' => true,
],
[
'type' => 'text',
'name' => 'SKU',
'id' => 'sku',
'limit' => 10,
'required' => false,
],
],
];
hi
any update on this? thanks
Hello Nick,
I make a test on my local site with your fields but don't see that issue, here is the screen record https://drive.google.com/file/d/1qXIh26Qf6S60XcZcUbVLUocVtPllBai7/view?usp=sharing
I also notice the setting 'post_types' => 'Product',
the post slug should be in lowercase product
. Please correct the slug and try this again on a clean installation then see how it goes.
Hi
Yes i have tried a new installation with the lowercase 'product' post type as the same issue persists. When i manually clear the permalink cache it works, if i dont i see a 404 page if i try to visit the custom post type single page. I found a old post https://support.metabox.io/topic/permalink-issue-with-custom-post-type/ which said that using /%postname%/
permalink structure had issues (which is what im using) but is not clear on what the solution was at the time. If I use the 'plain' permalink wordpress structure there is no problem when replicating the above.
any ideas? As the problem seems very intermittent and i have tried over 10 times and only one of those times of replicating that the /%postname%/
permalink structure worked without manually refreshing permalinks.
thanks
Can you please share your site credentials by submitting this contact form https://metabox.io/contact/ ?
I will take a look.
Hi Peter,
I cannot as im working on a local development project and is not available online.
Its a difficult one to alway replicate, must be something to do with WordPress. I have no cache enabled. I will try and get a video of the issue but the post appears in the database ok, just the 404 when viewing the permalink for the page
Nick