0

I know there are countless questions on here about this, but all of them suggest the same thing I'm already trying to do, but I appear to be missing/misunderstanding something here.

I'm creating an FAQs section for a site, and have the following:

  • faq custom post type
  • faqs custom taxonomy for categorisation of FAQ pages

Both are updated to their most recent versions as of time of writing.

My goal is to have a page that lists all of those FAQ categories, which I can then click, to reveal all of the FAQ pages associated with the FAQ category.

I have created the file archive-faq.php to try and list the FAQ pages themselves, but the file is not being used.

I have also created the file taxonomy-faqs.php, to list the different categories in the taxonomy, but the file is not being used.

I'm using the Custom Post Type UI plugin to manage the creation of custom post types and taxonomies, since I have a few of them now.

And I have indeed tried refreshing permalinks, several times.

Just in case this is relevant, I'm using the Advanced Custom Fields PRO plugin to manage the creation of various fields (since this site is comprised entirely of bespoke pages, no blog).

And also, in case this is relevant, I do have a piece of code allowing me to remove the name of the custom post type from the URL to the page:

function remove_slug($post_link, $post) {
    if(!in_array($post->post_type, ['availability_page']) || 'publish' != $post->post_status) {
        return $post_link;
    }

    $post_link = str_replace('/' . $post->post_type . '/', '/', $post_link);

    return $post_link;
}

add_filter('post_type_link', 'remove_slug', 10, 3);

function parse_request($query) {
    if(!$query->is_main_query() || 2 != count($query->query) || !isset($query->query['page'])) {
        return;
    }

    if(!empty( $query->query['name'])) {
        $query->set('post_type', array('post', 'availability_page', 'page'));
    }
}

add_action('pre_get_posts', 'parse_request');

I'm not hugely adept with WordPress, but the client was insistent we use WordPress for their site. And since I'm so used to ProcessWire (which I believe is a far more practical solution for entirely bespoke websites), I'm finding it a bit difficult to adjust to the very fixed nature of WordPress.

So, any pointers as to why the template files I created are not being used would be greatly appreciated.

1

I've identified the error of my ways, it was down to a misconfiguration and a misunderstanding.

Firstly, the archive-{post-type}.php file was not being loaded because the 'Has Archive' option for the custom post type was set to false. It worked the second I flipped that.

Secondly, I was under the impression that the taxonomy-{taxonomy-name}.php file was used to list the terms under the taxonomy, that is not correct. That is specifically for using a custom template for a post under that taxonomy.

It usually always is something simple. If only I'd just waited a bit longer before asking the question. Though sometimes, trying to work it out while you already have a question on SE seems to spur me further to work it out before someone else does!

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.