How to get the_category(‘, ‘) with link “title” attribute

There are no filters in get_the_category_list function, that will allow you to add title attribute to those links, so you’ll have to write your own code for that… <?php $categories = get_the_category(); foreach ( $categories as $i => $cat ) : if ( $i ) echo ‘, ‘; ?> <a href=”https://wordpress.stackexchange.com/questions/320140/<?php echo esc_url( get_category_link( $category->term_id … Read more

Style post archive blog preview based on category

This sounds like something that should go to the The Loop – you want this class per post, not for the whole <body>, right? Roughly archive.php (or index.php, or category-*.php) should look like this: while (have_posts()) { the_post(); $add_class = array(); if (in_category(‘new’)) { // inside the loop, don’t need $post->ID $add_class[] = ‘new’; if … Read more

how to get only grandchild category from a child category

One way you could do it is to make another get_categories inside the foreach ( $categories as $category ) Example code //preparing an array to hold later info $grandchildren_ids = []; //getting the child categories of parent 72 $args = array( ‘orderby’ => ‘name’, ‘parent’ => 72, ‘taxonomy’ => ‘category’, ‘hide_empty’ => 0 ); $categories … Read more