Custom Taxonomy breaking pages permalinks

I’m stuck for some days with this problem and I don’t know what else to do. With %somethingHere% on slug rewrite, pages permalinks are broken (CPT AND CT OK). Without, I don’t have my desired Post structure but Pages permalinks are OK. CPT and CT Creation function custom_post_type() { register_taxonomy( ‘marca’, ”, array( ‘label’ => … Read more

taxonomy/category term in URL slug irrelevant for post?

so I’ve got a nice hierarchical system working involving custom post types and taxonomies. (see Custom post types, taxonomies, and permalinks for reference) So if I have a post with mysite.com/taxonomy/subtaxonomy/tastes-good , it works, and I can access taxonomy pages in mysite.com/taxonomy/subtaxonomy etc etc However, noticed a bug – I can put ANYTHING as part … Read more

custom slug always ends in “-2”

I have a custom post type called task. I want the slug of each task to be an id, rather than use the entered title. I’ve modified the code from this SO question “How to customize this automatic slug shortener with an overrwrite function” as such: add_filter(‘name_save_pre’, array(__CLASS__, ‘change_task_slug_to_id’)); static function change_task_slug_to_id($slug) { // should … Read more

Change author base slug to user role

My goal is simple, to change authot base role to user role. For example: admin: wwww.mysite.com/admin/username editor: www.mysite.com/editor/username default looks like this to any user: www.mysite.com/author/username I couldn’t find any examples online. How to achieve this? 1 Answer 1 I think the plugin: https://wordpress.org/plugins/edit-author-slug/ does exactly what you need.

Set taxonomy slug as taxonomy title

With post types I can easily set the slug to be always identical to the post type title. add_filter( ‘wp_insert_post_data’, ‘prefix_wp_insert_post_data’ ); function prefix_wp_insert_post_data( $data ) { $data[‘post_name’] = sanitize_title( $data[‘post_title’] ); return $data; } But with taxonomies I’m rather stuck. I’ve been reading up on the editable_slug and wp_insert_post filters and this trac ticket … Read more

What user roles should have wp_unique_post_slug_is_bad_flat_slug filter applied?

I have a plugin where I need to reserve some slugs so I am using the filters wp_unique_post_slug_is_bad_flat_slug and wp_unique_post_slug_is_bad_hierarchical_slug. I apply them like this on my plugin code: if ( is_admin() ) { add_filter( ‘wp_unique_post_slug_is_bad_hierarchical_slug’, ‘is_bad_hierarchical_slug’, 10, 4 ); add_filter( ‘wp_unique_post_slug_is_bad_flat_slug’, ‘is_bad_flat_slug’, 10, 3 ); } Is using is_admin() correct? Or should I check … Read more

Add Slug Metabox to posts for contributors

I am trying to enable slug Metabox for contributors. Find a code to remove slug Metabox try to change it in way to work around my problem but nothing happens. function add_contributor_post_meta_box() { global $post; if ( current_user_can( ‘edit_post’, $post->ID )) { add_meta_box(‘slugdiv’, ‘post’, ‘normal’); } } add_action(‘admin_menu’, ‘add_contributor_post_meta_box’); Anyone can help to solve this … Read more

how to flush custom author rewrite rule

So, I’ve created custom AUTHOR url like domain.tld/user-nicename, and i have now links like domain.tld/john-doe. My functions.php is // AUTHOR add_filter(‘author_rewrite_rules’, ‘no_author_base_rewrite_rules’); function no_author_base_rewrite_rules( $author_rewrite ) { global $wpdb; $author_rewrite = array(); $authors = $wpdb->get_results(“SELECT user_nicename AS nicename from $wpdb->users”); foreach($authors as $author) { $author_rewrite[“({$author->nicename})/?$”] = ‘index.php? author_name=$matches[1]’; } return $author_rewrite; } if( !is_admin() ) … Read more

How I Can Use The Get Value as A Slug

in my single.php i took a data from one $_GET[] value and i’m using this like domain.com/example-slug/?holder=value The thing i want is domain.com/example-slug/value or domain.com/example-slug/holder/value so, how i can to this? 3 Answers 3 You don’t need to do anything with rewrite rules. Your example (“domain.com/example-slug/?holder=value”) is a perfect example of “Plain” Permalinks. So your … Read more