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 );
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 );
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.
The code used to make this decision by WordPress is get_page_template(). The pagename version (page-{slug}.php) is pulled from get_query_var( ‘pagename’ ), you can use this in your page.php template to see what it outputs when visiting the child page. <?php echo get_query_var( ‘pagename’ ); ?> This mostly just means that the parent slug is ignored … Read more
WordPress does have a way of doing what you want. Make them all top level pages. Unless you have a good reason not to.
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.
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
WordPress uses the attachment filename to create the attachment post slug. If your file was named something else, there would not be any conflicts. If you have your post permalinks set to /%postname%/ , and you upload an image FIRST, and then create a post SECOND, then WordPress has to make a choice between the … Read more
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
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
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