I have a custom post type 'products' and use polylang to localize content and rewrite urls. Since I changed the rewrite from 'products' to 'tools', acf shows me the wrong url for the tools archive in a page-link field.
Where before it showed
*/de/products/
it now shows
*/tools/
without the language identifier. I already flushed the wordpress permalink cache without success. All the links generated by wordpress work fine.
This is the custom post type rewrite
'rewrite' => array( 'slug' => 'tools', 'with_front' => false ),
'has_archive' => true,
I appreciate your help.
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'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 start maintaining a web site, that it is build from another person, and I like to modify the rewrite rules applied for a custom post type.
more specific, the custom post type is buidled with the following settings :
$args = array(
...
'rewrite' => array(
'slug' => 'myposttype',
'with_front' => false
),
....
)
register_post_type('myposttype', $args);
The permalink structure is the following:
Post name http://www.mysite.gr/sample-post/
but the url structure is the following:
http://www.mysite.gr/myposttype/my_post_slug/
how can I change it to
http://www.mysite.gr/my_post_slug/
Any idea please ?
Note: This is not a good idea as it may conflict with pages having the same slug.
Here is a tutorial on how to remove the post type name from the url.
I have a custom post type using WordPress 3.0 that has the following rewrite rule:
'rewrite' => array( 'slug' => 'events', 'with_front' => false )
which gives the following: domain.com/events/my-awesome-event/
How can I pass some additional info into the rule, such as the date, I'm wanting to have the following rewrite: domain.com/events/2010/my-awesome-event/
Thanks.
Props to Benj in Using Dates in Custom post_type Permalinks - check out this article on custom post type permalinks
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.