Modification to wp_list_categories

Move what you are calling the “standard link ending” to the end of the function, instead of the beginning. class CategoryThumbnail_Walker extends Walker_Category { // A new element has been stumbled upon and has ended function end_el( $output, $category, $depth, $args ) { // Get one post $posts = get_posts( array( // …from this category … Read more

get only sub category ID

As you only want a select form field that has a categories children, then simply go with wp_list_categories() wp_list_categories( array( ‘child_of’ => ‘your parent cat ID’, ) ); Depending on your use case, you could as well use get_the_category() and its get_the_categories filter apply_filters( ‘get_the_categories’, $categories ); get_the_terms() and its filter (the function is called … Read more

How do I change the sql query for wp_get_archive()

Looking at the source code for wp_get_archives(), there is a filter called getarchives_join which you can use to restrict wp_get_archives() to a specific category You also need to get the current category ID, which is easy, simply use get_queried_object_id() You can try something like this to display archives for the currently viewed category add_filter( ‘getarchives_join’, … Read more

Attachment page per category

Attachments does not have categories, so a simple in_category() or has_category() check will not work. What we will need to do to solve is this issue is the following Get the current attachment object. We will make use of get_queried_object() which will hold the current post object of the attachment being viewed Determine the post … Read more