Get taxonomy slug from url

I think you are looking for get_query_var $term_slug = get_query_var( ‘term’ ); $taxonomyName = get_query_var( ‘taxonomy’ ); $current_term = get_term_by( ‘slug’, $term_slug, $taxonomyName );

Rewrite rule page url with category

Just of the top of my head, something along this way might work: function wpse178647_rewrite() { add_rewrite_rule( ‘^([^/]+)/([^/]+)/?$’, ” ‘index.php?category_name=$matches[1]&pagename=$matches[2]’, ‘top’ ); } add_action( ‘init’, ‘wpse178647_rewrite’ ); Completely and utterly untested.

Using Custom Fields in Custom Post Type URL

I managed to fix this. Basically I changed the permastruct to this: $wp_rewrite->add_permastruct(‘showroom’, ‘location/%state%/%city%/%showroom%’, false); I then grabbed state & city as two separate variables, replacing it in the permalink structure using these lines: $permalink = str_replace(‘%state%’, $state, $permalink); $permalink = str_replace(‘%city%’, $city, $permalink); With $state & $city grabbed using get_post_meta from the post.

Display posts with author in the url with custom post types

You can use the %author% tag in the rewrite property in register_post_type(). However, although the rewrite rules are added (after they’re flushed) – WordPress doesn’t replace the tag with its appropriate value when generating the permalink of your post type. For instance you end up with the permalink www.example.com/%author%/gallery-name The following replaces %author% with the … Read more

How do I use the same post slug for different Categories?

Using Parent-Child Page (Recommended) If you don’t have to have categories & posts, then this can be easily achieved using parent-child pages (not posts). For example, say you have three pages like: www.example.com/category-one/ www.example.com/category-two/ www.example.com/category-three/ Now you can have child pages for the above pages with slug email, e.g. www.example.com/category-one/email www.example.com/category-two/email www.example.com/category-three/email This is possible … Read more

How to automatically generate a unique random slug

Use the function wp_unique_post_slug(). Do not reinvent the wheel, this one is quite tricky. Usage: $unique_slug = wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, $post_parent ); Then you can test if $slug === $unique_slug and generate a new one if the test fails. You can find the function in wp-includes/post.php. It ends with a filter ‘wp_unique_post_slug’, so … Read more

How to prevent apostrophes and quotes from appearing in permalinks?

In WordPress, “—” and ” — ” become em-dashes (— —) and “–” becomes an en-dash (— #8212;). The sanitize_title_with_dashes() function doesn’t catch these. That function uses the databased copy, but the title displayed to the user always goes through a texturize function. So if we replace en/em dashes on their way into the database, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)