Why ids in urls don’t work but slugs do?

Because the tag query variable expects the value to the terms slug. It’ll be looking for the term with slug ’15’ (which presumably doesn’t exist). And, yes its quite frustrating that wp_dropdown_categories() uses the ID as the value, rather than the slug. This is because it was originally used only for categories (for which IDs … Read more

How can I get the page url slug when ‘post_name’ returns an id?

Try this : $menu = get_term( $locations[$theme_location], ‘nav_menu’ ); $menu_items = wp_get_nav_menu_items($menu->term_id); foreach( $menu_items as $menu_item ) { $link = $menu_item->url; $title = $menu_item->title; $slug = basename($menu_item->url); } Pass the whole permalink to the basename function, which will automatically process the URL and give us only the slug.

Hook on slug generator

I think you should be able to do this using the wp_unique_post_slug filter (which is applied in the function of the same name): add_filter(“wp_unique_post_slug”, function($slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug) { if($meta = get_post_meta($post_ID, “my-meta”, true)) { $slug = $meta . ‘-‘ . $slug; } return $slug; }, 10, 6); As this is applied at … Read more

Filter string like a slug

You can use sanitize_title() function: $string = “This is title string”; // return “this-is-title-string” $slug = sanitize_title( $string ); You can also filter the result of sanitize_title() function using sanitize_title filter: add_filter( ‘sanitize_title’ , ‘sanitize_filter_callback’, 10, 3 ); function sanitize_filter_callback( $title, $raw_title, $context ) { // do something }

Custom Taxonomy leads to 404 page

You can add flush_rewrite_rules() after registering your custom taxonomy. NOTE: Flush rules only on activation or deactivation, or when you know that the rewrite rules need to be changed. Don’t do it on any hook that will triggered on a routine basis. More detail information in the comments on WP Engineer’s post: Custom Post Type … Read more

Show all wp_get_post_terms slugs

This is more of a PHP question, but the solution is simple – you need to use a foreach-loop on $getslug, because you just echo the slug of the first taxonomy. The function wp_get_post_terms() does not return a single object, but an array of objects. You are right with the [0], this indicates that you … Read more

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