I've been battling with this for a while. I have a CPT created with PostTypes (I have used this library many many times in other projects w/o problems):

$volunteer = new PostType( 'volunteer' );
            'supports'     => array( 'title' ),
            'capability_type'    => 'post',
            'publicly_queryable' => true,
            'show_in_rest' => false,
            'has_archive'  => true,
            'public'       => true,
            'show_ui'      => true,
            'rewrite'      => array(
                'slug'     => 'volunteers',
    $volunteer->icon( 'dashicons-groups' );

I have opened Options->Permalinks and saved settings so that permalinks will display as Post name.

I have created a couple of volunteer posts.

In one page I am using a custom query to bring the results. I create a link to the post by using the permalink which renders this URL:


Which is odd because (AFAIK) should be:


When I click the link, I get a 404. When I type in the second permalink, I immediately get sent to the home page, it does not show an error. I have tried to debug this in index.php but by the time the breakpoint hits, it's referring to info on the page.

I have added archive-volunteer.php and single-volunteer.php and they never get invoked no matter what I do.

This has really left me baffled, I don't think I'm making a careless mistake anywhere.

Has anyone experience anything like this before or can recommend any tools that might lead me in the right direction? I already have installed Show Current Template.

Thanks in advance!

  • 1
    If you register the post type with register_post_type(), rather than this library, does it work? – Jacob Peattie Dec 9 '19 at 6:33
  • 1
    I can't see anything in the documentation for ACF Builder about new PostType( 'volunteer' ). There's no PostType class in WordPress either. Where is this coming from? – Jacob Peattie Dec 9 '19 at 6:35
  • I tried and by doing so I copied a sample from codex.wordpress.org/Function_Reference/register_post_type. With that code I do NOT get the problematic redirection when I created a post type "books", which is progress. I'll try and troubleshoot to see what is causing this, but thanks for your suggestion! :-) – csaborio Dec 9 '19 at 6:44
  • You are right, @Jacob, my apologies. The class package is PostTypes, not ACF Builder-> posttypes.jjgrainger.co.uk I'll fix the question. – csaborio Dec 9 '19 at 6:47

After hours of debugging I noticed that the problem was only reproduced when I used the library. Even if I used register_post_type, if I used any other functionality from the library before the register_post_type function call, it would cause some erratic behaviour.

I opted on removing PostTypes from my project and simply sticking to register_post_type and everything works as expected. Third-party libraries are nice and can be a godsend, but unless you are ready to get down and dirty debugging someone else's code when things got astray, I can only recommend to steer clear of them.

Thanks to everyone who took the time to read and pitch in, much appreciated.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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