Tag Info

New answers tagged

1

Use the add_attachment hook to update the slug after the attachment has been inserted: function wpse_182454_attachment_id_as_slug( $post_id ) { if ( get_post_field( 'post_name', $post_id ) != $post_id ) { wp_update_post( array( 'ID' => $post_id, 'post_name' => ( string ) $post_id, ) ...


0

The easiest way to do it is to not use pages for that, but instead create a new post types for "hills" and/or "australia" this can be a PITA but you need to understand that the combination of post type and slug should be unique (the reason it is done this way is to let you change the permalink structure without having to update whole of the content). ...


1

No, no you cannot. Once a slug is used by a page, it cannot be used by other pages. It also can't be used by other posts, regardless of post types There is a Trac ticket on WP Core that's attempting to fix this so that a slug can be reused by post type, but that would still only allow you one use of your page slug. The chances that you could do what you're ...


0

You could try this in your functions.php <?php add_filter('rewrite_slugs', function($translated_slugs) { // the possible translations for your slug 'product' $translated_slugs = array( 'product' => array( 'pt' => array( 'has_archive' => true,'rewrite' => array('slug' => 'produto'), ), ...


0

It depends on what you're developing the theme for. Premium Themes - Themes for the masses. If you're going to sell or distribute the theme to many people use the template drop down which provides the most flexibility to the user. If they delete the page or rename the slug they can always reassign the template using that drop down. Custom One-Off Theme ...


0

I think custom templates is the best decision for your example. Besides custom page template is easy to develop.


0

Why you want to store this type of slug.If you store this type of slug and after some time when you edit any item from wordpress back-end,then it will update with its own slug.Better way is to store your slug as wordpress store itself..


0

I've been using this .. function get_id_by_slug($page_slug) { $page = get_page_by_path($page_slug); if ($page) { return $page->ID; } else { return null; } } Hope this will help someone.


4

This rewrite rule should work (assuming "brand" and "type" are the taxonomy registered names): function custom_rewrite_rules() { add_rewrite_rule('^brand/(.*)/type/(.*)?', 'index.php?brand=$matches[1]&type=$matches[2]', 'top'); } add_action('init', 'custom_rewrite_rules'); Remember to flush the rewirte rules after saving this code in your site. ...



Top 50 recent answers are included