imath / wp-statuses

WordPress plugin to ease Custom Post Statuses integration
GNU General Public License v2.0
160 stars 27 forks source link

View Post returns a 404 error when post has a custom status #28

Closed dutchigor closed 5 years ago

dutchigor commented 5 years ago

I have created a status as follows:

    register_post_status( 'update', array(
        'label'                     => __( 'Update', 'flare-guide' ),
        'public'                    => false,
        'show_in_admin_all_list'    => true,
        'show_in_admin_status_list' => true,
        'label_count'               => _n_noop( 'Update <span class="count">(%s)</span>', 'Update <span class="count">(%s)</span>' ),
        'post_type'                   => array( 'participation' ), // Only for posts!
        'show_in_metabox_dropdown'    => true,
        'show_in_inline_dropdown'     => true,
        'show_in_press_this_dropdown' => true,
        'labels'                      => array(
            'metabox_dropdown' => __( 'Update', 'flare-guide' ),
            'inline_dropdown'  => __( 'Update', 'flare-guide' ),
        ),
        'dashicon'                    => 'dashicons-update',
    ) );

Then when I change the status of a participation CPT to Update, and click on View Participation, I get a 404 error. View participation works fine in either Draft or Published status. I noticed that when the post is in draft I get a url like .../?post_type=participation&p=6718&preview=true instead of the slug. As the Update status should basically be a synonym of draft, I would expect to see a similar url when the post is in this status but instead I get sent to the full permalink.

Any idea what could be the cause of this?

ibes commented 5 years ago

'public' => false,

This likely says, that the post with this status should not be seen by the outside world. Not sure how the "draft" status handles its preview link.

imath commented 5 years ago

yes try 'public'=> true The example I've shared in the README.md file was about an archive status and was about not showing the post on front.

dutchigor commented 5 years ago

Thanks, but that makes the post publicly available and this should not be the case until it is published. That did put me onthe right path though and after a bit of googling I came across an undocumented setting: protected. The following settings did the trick for anyone looking for something similar: ´'public' => false, 'internal' => false, 'protected' => true, 'private' => false,´