• Cowboy WordPress Builder

    (@cowboy-wordpress-builder)


    I’m creating a site for a charity, which will display a profile for the individuals under the charities care. The individuals can be in one or many of four centres. I’ve created a Custom Post Type called child, and created a custom taxonomy called centres.

    I was wondering if anyone could help me on my way to creating the appropriate template files in order to create a permalink structure like this-

    children/specific-centre-name/individual-child-profile

    children will be a page listing the various centre taxonomies.

    specific-center-name will show a grid of the individual children in that taxonomy

    individual-child-profile will simply be the custom post

    Sorry if i haven’t explained this very well, my head is too frazzled to think properly.

Viewing 3 replies - 1 through 3 (of 3 total)
  • This can certainly be done, and I’ll try to make a clear explanation, but forgive me if this takes a few iterations.

    First I would create a page called “Children” and create a custom template for it. That template can be enforced by naming it page-children.php in the theme root, or by putting a template tag down and selecting it through wordpress.

    On this template you are going to use wp_list_categories (http://codex.wordpress.org/Template_Tags/wp_list_categories) to list out the centers.

    You will want to feed it a few $args. Particularly ‘taxonomy’ => ‘centres’, to get the right tax and ‘depth’ => 1 to keep it from showing the next list.

    From there you will need to create a custom taxonomy template for centres by creating a file called taxonomy-centres.php. You will probably want to model it on the normal page loop, but you will need to add a ‘tax_query’ array to the WP_Query $args to filter your results http://codex.wordpress.org/Class_Reference/WP_Query

    Your custom child page template will be a modification of the standard single post page which you will name single-child.

    That should be the broad strokes of a resolution. Feel free to reply for finer details.

    Thread Starter Cowboy WordPress Builder

    (@cowboy-wordpress-builder)

    Hey there, thanks for the quick response.

    First of all thanks for such a clear and concise answer, it was very easy read and follow. Plus you went that extra step and included links to the codex!

    I had already more or less tried this approach, which is quite frustrating as i cant understand what’s going wrong.

    But i’ve created new templates using your instructions and it’s all working fine, except for when i’m on the single-child page. The content is showing as i want, but the url is showing-

    localhost/site-folder/child/individual-child-profile

    This was the original problem. Any ideas what could be causing this? I’ve tried adding a rewrite in when registering the taxonomy in my functions file, but to be honest i’m not really sure what i’m doing and was using trial and error.

    Would you mind explaining how i should be registering my taxonomy in order to achieve the url structure i was hoping for?

    Strangely enough I believe this is set with the custom post type. There is an array of acceptable slugs.

    In the register_post_type function (http://codex.wordpress.org/Function_Reference/register_post_type) you will want to add this argument:
    'rewrite' => array( 'slug' => 'centre' ),

    Here is the most important caveat: this is an alteration to the permalink structure. Make this change and your listings will all 404 initially. This is normal. Go into the site’s Settings->Permalinks section, revert it back to the default permalink structure, save it, refresh a page or two, and then go back and restore your current permalink settings. Permalink rewrites are a programmatic function that gets cached and this is the preferred way to trigger the site to update all permalinks.

    I hope this helps.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom Taxonomy Templates’ is closed to new replies.