I’m using WordPress as a customised CMS for my fishkeeping website.
Currently I’m developing a Custom Post Type called species which produces an information sheet about a specific species of fish.
With no intention of patronising anybody, just in case people aren’t familiar with the classification of fishes, in the example below, I’ll be referring to “Apistogramma panduro”. “Apistogramma” is the “Genus” and “panduro” is the “Species”. Both of these are fields in this Custom Post Type.
For example, my Custom Post Type may produce a factsheet about Apistogramma panduro, containing details of how to keep it and breed it, etc.
I’m wondering about the Title of the post because right now all of my posts are being given the Title “Auto Draft X” (X being a number) and as such the URL of “?species=auto-draft-9”.
I may be asking a three-pronged question here (the Title of the post, the URL of the post and any potential htaccess rewrites), but basically what I want to do is this:
I’d like all of my species profiles to have the Genus and Species in the URL
I’m not too bothered how it’s laid out, but this would be ideal: /species/apistogramma/panduro
Apologies if the post isn’t best formed, it’s 0100 and I’ve just spent hours with my “head in the code”..! Please don’t hesitate to ask for clarity and I’ll do my best when I wake up tomorrow.
I’m unable to comment on this SX but I would have thought the best way to do what you wanted would have been to use a custom post type, but combine it with a custom taxonomy. In the same way that a post belongs to a category, a fish species could belong to a genus (the genus being the part defined by the custom taxonomy). The genus could then be arranged just like categories if desired – e.g. example.com/fish/apistogramma/panduro.
I’m not experienced in this area of WP development (In fact, I’m just embarking on my first project involving them at the moment) but I think they would have been a better option than modifying the slug to /genus-species.
See http://codex.wordpress.org/Taxonomies for more info.
OK, I’ve made a few subtle changes which have helped me to solve the problem.
Firstly, a function to change the Title of the post.
add_action( 'save_post', array( &$SpeciesProfile, 'custom_post_type_title' ) );
Secondly, I can manually amend the
slug
to reflect genus-species.Thirdly, I set the “permalink” structure to “%postname%”.