why is the delete option missing from just one category?
You’re unable to delete just one category because it’s your default category. You may change the default category via via wp-admin > Settings > Writing > “Default Post Category” .
You’re unable to delete just one category because it’s your default category. You may change the default category via via wp-admin > Settings > Writing > “Default Post Category” .
get_the_category() returns the array of WP_Term objects. So, // get all categories objects $categories = get_the_category(); // get the first category name if ( ! empty( $categories ) ) { $category = $categories[0]->name; } $output .= ‘<li><a href=”https://wordpress.stackexchange.com/questions/293636/” . get_the_permalink() . “https://wordpress.stackexchange.com/questions/293636/”>’; $output .= get_the_title() . ‘</a> ‘; $output .= $category .”https://wordpress.stackexchange.com/questions/293636/”; $output .= get_the_time(‘d … Read more
That’s easy. Just use the same shortcode and in the parent attribute, place the ID of the parent category. You’ll get out its sub-categories as a result: [product_categories number=”12″ parent=”57″]
get the child categories, using get_categories(); then loop through them with a foreach loop, using WP_Query() : <?php $cats = get_categories(‘child_of=”.get_query_var(“cat’)); foreach ($cats as $cat) : $args = array( ‘posts_per_page’ => 3, // max number of post per category ‘category__in’ => array($cat->term_id) ); $my_query = new WP_Query($args); if ($my_query->have_posts()) : echo ‘<h3>’.$cat->name.'</h3>’; while ($my_query->have_posts()) : … Read more
I’m going to guess here. I assume you are using the Taxonomy Images plugin? This: if($term->term_id == $categories_item->term_id) { Can be changed to: if($term->term_id == $categories_item->term_id && $term->parent == $categories_item->cat_ID) { Hereby, you check if the parent ID of the term is the same as the ID of the categories_item.
You can create a page template (for service page) and then set it to particular page, on which you want to display posts. After that open page template and paste below code where you wan to show posts. <?php query_posts(‘cat=1’); // cat=1 , id of category you want to show (e.g. cat id of food … Read more
add_action( ‘wp_ajax_nopriv_load-filter’, ‘prefix_load_cat_posts’ ); add_action( ‘wp_ajax_load-filter’, ‘prefix_load_cat_posts’ ); function prefix_load_cat_posts () { global $post; $cat_id = $_POST[ ‘cat’ ]; $args = array ( ‘cat’ => $cat_id, ‘posts_per_page’ => 3, ‘order’ => ‘ASC’ ); $cat_query = new WP_Query($args); if($cat_query->have_posts()) : while($cat_query->have_posts()) : $cat_query->the_post(); $response=”<div class=”the-post”>”; $response .= ‘<h1 class=”the-title”>’; $response .= ‘<a href=”#”>’. get_the_title() .'</a>’; $response … Read more
EDIT: On a post page, the categories are already seen in hierarchical manner but with checkboxes. So, I have assumed that you have to show list of all the categories/subcategories somewhere in the admin panel in following format. Category 1 Sub-Category 1.1 Sub-Category 1.2 Category 2 So, presentation is upto you, I have just given … Read more
Write this in your theme’s functions.php file function category_enqueue_script() { $cat_education_id = ‘xx’; // category id for “education” $cat_dog_id = ‘yy’; // category id for “dog” if ( is_category() && ( is_category( $cat_education_id ) || is_category( $cat_dog_id ) ) ) { wp_enqueue_script( ‘my-js’, ‘filename.js’, false ); } } add_action( ‘wp_enqueue_scripts’, ‘category_enqueue_script’ );
When you go to the second page of the “General Lab”, WordPress does a query for posts in that category and finds none. If WordPress finds no posts, it will display the 404 template. The only case is when you are on the first page of a taxonomy (like a category): then it still loads … Read more