I have a Custom Taxonomy called movie-genres
'rewrite' => array('slug' => 'movie-genres', 'with_front' => true) );
register_taxonomy( 'movie-genres', array( 'movies' ), $args );
And I have a WP template hierarchy for the Taxonomy and it's associated Terms like below
archive.php
archive-movie-genres.php
taxonomy.php
taxonomy-movie-genres.php
taxonomy-movie-genres-action.php
Now when navigating in the browser I am able to see the CPTs listed for term of action like this
domain.com/movie-genres/action
but when landing at movie-genres to get the all terms listed under this taxonomy like
domain.com/movie-genres/
I am getting the 404 page in return!
As you can see I have the archive-movie-genres.php and taxonomy-movie-genres.php created. Why am I getting ended at 404?
Related
I my WordPress v6.1, I have a custom taxonomy country and regular posts and pages.
With 'rewrite' => array('slug' => '/', 'with_front' => FALSE), I am getting my taxonomy terms URL as www.example.com/taxonomy-term-name. This is good.
But with the above, my regular posts and pages are returning error / 404. My desired posts and pages URLs are www.example.com/contact and www.example.com/my-blog-post.
I have tried register_taxonomy_args and term_link filters, but all fails the posts and pages URLs into 404 error.
You aren't defining anything with 'slug' => '/' essentially this is defaulting to your post type rewrite rule:
With that said: like i've answered you here:
There seems to be a quirk with wordpress when using this syntax for your rewrite so you will need to preface the term with a front.
'rewrite' => array( 'slug' => 'country/%country%', 'with_front' => false )
and then use return str_replace( 'country/%country%', $terms[0]->slug , $post_link ); in the post_type_link hook.
I have two Custom Post type,
register_post_type( 'classes',
array(
.
.
'rewrite' => array( 'slug' => 'classes', 'with_front' => false )
)
);
register_post_type( 'lessons',
array(
.
.
'rewrite' => array( 'slug' => 'chapters', 'with_front' => false )
)
);
I have created a custom admin UI to manage (create/update/delete) this two post type, the lesson post type is design to be a child post type for classes post type. So everytime someone create a lesson, it requires a parent post from the list of post type classes.
Now I have a problem with the url structure,
the URL of the classes will be site.dev/classes/class-post-name
and the URL of the lesson will be site.dev/chapters/lesson-post-name this is also the URL I can i see on wp_posts table under guid column
How can I acheive a URL structure like below that will also be stored as guid?
site.dev/classes/parent-post-post-name/chapters/lesson-post-name
Parent Post From Another Post Type and a new URL structure will help in achieving the results. The lessons post type should be hierarchical and classes should be non-hierarchical. One thing is notable in the metabox that you don't need to save the metabox manually. WordPress itself checks for field name parent_id and saves it.
I'm using tribe events in wordpress and been struggling with the following problem:
I have events (custom post type) filtered by category (default taxonomy for this plugin).
I'm using "pretty permalinks settings" so my url looks like that:
[website.com]/events/category/Amsterdam/ (when my category is Amsterdam).
And now to the question:
I sub filtered my posts by another custom taxonomy called “event_type” (concert, pub …)
when I'm trying to get all the posts from Amsterdam that are a "concert" type, my url is:
[website.com]/events/category/amsterdam/?event_type=concert
on default permalink settings the url is:
[website.com]/index.php?tribe_events_cat=amsterdam&event_type=concert
How do I get WordPress to transform and to recognize my url as:
[website.com]/events/category/amsterdam/event_type/concert/
I know it has something to do with the rewrite_rules_array but could not manage to do so.
Any help would be very appreciated!
Thanx in advance.
While You register custom post type:
function people_init() {
// create a new taxonomy
register_taxonomy(
'people',
'post',
array(
'label' => __( 'People' ),
'rewrite' => array( 'slug' => 'person' ),
'capabilities' => array(
'assign_terms' => 'edit_guides',
'edit_terms' => 'publish_guides'
)
)
);
}
add_action( 'init', 'people_init' );
checkout the "rewrite" parameter. More You can check here:
http://codex.wordpress.org/Function_Reference/register_taxonomy
Also sometimes You need to flush permalink structure by going to permalink settings and clicking save (dont ask me why) ;).
I have a custom post type named 'The Books', and a relative category named 'The Books' for these custom posts.
When I add the category The Posts to my nav menu, it doesn't work because it goes to the URL /category/the-books instead of just going to /the-books. If I posted this in the default post section it shows correctly, but when I post in the custom post section it does not return my post. I can, of course, add individual posts from my custom post section to the nav menu, but can't figure out how to add an archive page of the custom posts.
My permalinks are set to: URL/%postname%/ so I'm not sure why that is happening.
Here's the function for my custom posts:
add_action( 'init', 'create_post_type' );
function create_post_type() {
register_post_type( 'hpl_books',
array(
'labels' => array(
'name' => __( 'The Books' ),
'singular_name' => __( 'Book' )
),
'taxonomies' => array('category'),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'the-books'),
)
);
}
Any advice is greatly appreciated.
thanks!
You shouldn't need to add a category "the-books" in order to display the results.
Have you created a view in your page-templates directory called "archive-hpl_books.php?" That's the file WordPress will look for to display the archive of your custom post type. Basically, you would create a page called "the-books" or whatever, then set archive-hpl_books.php as the template.
See http://codex.wordpress.org/Template_Hierarchy
I'm only responding to this because I just went through a similar issue, so I'm down to help out. :)
I have the following code to build a custom taxonomy for my portfolio:
add_action( 'init', 'create_pc_db_taxonomies', 0 );
function create_pc_db_taxonomies() {
register_taxonomy( 'type', 'post', array( 'hierarchical' => true, 'label' => 'Type', 'query_var' => true, 'rewrite' => array( 'slug' => 'type' ) ) );
}
I have created a portfolio category on my site (I removed the /category/ base) and have created some items and set the custom taxonomies against them. So I get the following setup:
http://domain.com/portfolio/item1/ but what I want is for the taxonomy links to look like this: http://domain.com/portfolio/type/web and then this will show a list of portfolio items related to the that type. At the moment they are root like http://domain.com/type/web these create 404's, but I have also tried adding 'portfolio/type' as the taxonomy slug but it just creates a 404 as well, but i'm pretty sure this is the wrong way of doing it anyways. Any help?
Thanks
EDIT: The site is here: http://driz.co.uk/ all the work is in a category called Portfolio and under each pic is the title and custom taxonomy (if you click on them you will get the 404)
Make sure all plugins are disabled (at least ones that tweak with rewrites), and delete the option rewrite_rules in your wp_options table.
Now remove any hooks in your theme that meddle with custom taxes and post types, and run this on init;
register_taxonomy(
'type',
'post',
array(
'hierarchical' => true,
'label' => 'Type',
'rewrite' => array('slug' => 'portfolio/type')
)
);
In your permalink settings, choose one of the default options, and make sure both a category and tag base is set, then update.
Dump $wp_rewrite as you did before, and you should see a few lines like so;
[portfolio/type/([^/]+)/page/?([0-9]{1,})/?$] => index.php?type=$matches[1]&paged=$matches[2]
[portfolio/type/([^/]+)/?$] => index.php?type=$matches[1]
These should be near the very beginning of the array, before tags, categories and the like.
Let me know how you get on!
(When I run the code in my install of WP 3.0-beta-2 it works, so I assume something funky is happening at the moment).
I'm sure you can fake a slug like that, using portfolio/type - the key is, once you've updated your code, you'll need to flush the rewrite rules.
Do this by simply re-saving your permalink settings in the admin.