“Item not updated” when try to change category properties
You are attempting to update your category’s name to one that already exists. Duplicates are not allowed – either of other categories or of tags.
You are attempting to update your category’s name to one that already exists. Duplicates are not allowed – either of other categories or of tags.
I did not test this, but this should do what you want. Put the following in your functions.php: add_filter(‘rewrite_rules_array’, ‘new_category_name_rewrite_rule’); function new_category_name_rewrite_rule($rules) { $new_rules = array(); $categories = get_categories(); foreach ($categories as $category) { $cat_name = preg_replace(‘#\s+#’, ‘-‘, $category->name); $new_rules[“https://wordpress.stackexchange.com/”.$category->slug.”https://wordpress.stackexchange.com/”] = “https://wordpress.stackexchange.com/”.urlencode($cat_name).”https://wordpress.stackexchange.com/”; } return $new_rules + $rules; }
You’re doing query_posts and then immediately get_posts. This looks wrong. Remove the query_posts call. Also, where does your $cat come from? It doesn’t appear to be set anywhere in your code snippet. Try to start with setting it first: $cat = get_query_var(‘cat’);
You are overwriting the query that loads with the page (which you saved to $temp) – why not just use the one that loads with the page: while(have_posts()) : the_post(); // put the post here endwhile;
Try the restrict categories plugin. It lets you configure which categories are visible in the WordPress admin, based on the user role or the individual user.
This happens because you chose category and subcategory from the right options tick boxes when editing the entry. Choose only the subcategory box in every entry and it will show the nested URL. This is I found online. And I just tried that. It’s true. Hope this will help you.
I’m solved, by using: $category[0]->parent Thanks anyway.
I played with your code a little bit on my local WordPress. I think this should solve your problems. Arguments for your first get_categories call, should look like this: $args=array( ‘hide_empty’=>false, ‘orderby’ => ‘slug’, ‘order’ => ‘ASC’, //’include’ => ‘5, 6, 7, 8′, – you don’t need to include anything //’exclude’ => ‘3, 8, 9, … Read more
get_query_var will get the category from the main query, and it is only going to be set for some pages, such as category archives. It is not set for “single” pages or tag archives or a many other kids of “pages”. The value that get_query_var returns is something like a ‘search’ variable. It will be … Read more
Just use the break statement to abort after the first cat that is found and that is a child category. foreach ( get_the_category() as $cat ) { if ( cat_is_ancestor_of( 10, $cat ) ) { printf( ‘<a href=”https://wordpress.stackexchange.com/questions/103533/%s”>%s</a>’, get_category_link( $cat->cat_ID), echo $cat->cat_name ); break; } }