How to delete categories in WordPress

To delete a category from WP , first you need to open the category listing. It will come when you will mouse over the Posts. Once you click on Categories, it will display all the categories. Then mouse over to the category which you want to delete and it will show you an Delete link. … Read more

How do you get parent and grandparent categories [duplicate]

This query will help you global $wpdb; $cat_id = 65; // this query will get parent relationships from term_taxonomy table and get category names from terms table $category = $wpdb->get_row( “SELECT t4.term_id as parent_id, t4.name as parent_name, t5.term_id as grandparent_id, t5.name as grandparent_name FROM `{$wpdb->prefix}term_taxonomy` t1 left join `{$wpdb->prefix}term_taxonomy` t2 on t2.term_id = t1.parent left … Read more

How to define category ID in an array?

As Geert pointed out, your current conditional will always be true. An if() construct needs to be fed an expression. You’re feeding it a valid array, so that’s true. Always. So far this is basic PHP, regardless of whether in a WP environment or not. As can be read in Chris_O’s comment if ( is_category(‘some-cat’) … Read more

Fetch all categories from database

get_categories function will return an array of objects, each object a category. You can read more about it here: https://developer.wordpress.org/reference/functions/get_categories/ Edit And example, as Tim Malone mentioned in the comment there are examples on that page. But here is a simple one for you, that will display your categories in a list. $categories = get_categories(); … Read more

How to show posts of a specific category

Change $myposts = get_posts( ‘numberposts=6&offset=$debut’) to $myposts = get_posts( ‘numberposts=6&category_name=home-slider&offset=$debut’) OR $myposts = get_posts( ‘numberposts=6&category=1&offset=$debut’) replace 1 with your category ID Hope this helps

completely confused with archive.php, category.php

You don’t assign category templates to pages. They are templates that will be used automatically when you view a category. Read the Template Hierarchy documentation. You’re using WordPress completely wrong. You don’t create pages for archives, they exist automatically.

Moving Blog and Changing URL

Take a look at my plugin T5 All URIs. It prints all current URIs for posts and terms. From function print_term_uris(): $terms = get_terms( get_taxonomies(), array ( ‘hide_empty’ => FALSE, ‘get’ => ‘all’ ) ); foreach ( $terms as $term ) { print “\n” . get_term_link( $term ); } But if you keep the same … Read more

Add product category to post_class

Untested, but adapting from the Codex example for filtering the post class… basically changing get_the_categories() to get_the_terms and accounting for the name of the Product Category taxonomy. // add category nicenames to post class function product_category_class($classes) { global $post; foreach((get_the_terms($post->ID, ‘product_cat’)) as $term) $classes[] = $term->name; return $classes; } add_filter(‘post_class’, ‘product_category_class’);