Add category image before post title on homepage

This is easily done using a filter on the title, which you can add to your functions.php. Like this: add_filter (‘the_title’, ‘wpse305812_add_flag’, 10, 2); function wpse305812_add_flag ($title, $id) { if (in_category (‘england’, $id)) $flag = “http://www.example.com/…/england.jpg” elseif (in_category (‘brasil’, $id)) $flag = “http://www.example.com/…/brasil.jpg” …; return ‘<img src=”‘ . $flag . ‘”> ‘ . $title; } … Read more

Remove category number fill

In order to override the default of per page, you can set the number to ” to instruct the query to return all categories. Add the following code to your functions.php file. add_filter( ‘get_terms_args’, ‘show_all_categories_admin_nav_menu’, 10, 2); function show_all_categories_admin_nav_menu( $args, $taxonomies ) { if( reset($taxonomies) === ‘category’ ) { $args[‘number’] = ”; } return $args; … Read more

Print the associated categories of the current post starting with parent (with option to remove href)

Here is code snippet from WordPress that display the categories (or terms from other taxonomies) assigned to a post ordered by parent-child category relationship.This example must be used inside the loop. $taxonomy = ‘category’; // Get the term IDs assigned to post. $post_terms = wp_get_object_terms( $post->ID, $taxonomy, array( ‘fields’ => ‘ids’ ) ); // Separator … Read more

Show thumbnails 1-12 of category x on any given page

Have a look at the WP_Query codex, they have a range of parameters you can use, and example functions. First setup your arguments, I have included 2 ways of doing this, the first being the easiest using the built in category parameters. $args = array( ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => 12, ‘category_name’ … Read more

Display post of current parent category, and in right hand side show child category post

To display posts only from current category, without posts from sub-categories, use pre_get_posts action hook to set ‘include_children’ => FALSE in tax_query parameter. add_action( ‘pre_get_posts’, ‘se342950_no_child_term_posts’ ); function se342950_no_child_term_posts( $query ) { if ( is_admin() || ! $query->is_main_query() || ! $query->is_category() ) return; $tax_obj = $query->get_queried_object(); $q_tax = [ ‘taxonomy’ => $tax_obj->taxonomy, ‘terms’ => $tax_obj->term_id, … Read more

In category.php I need to get the next 10/previous 10 posts

if the only difference in the category archives is the images, you can work without a custom query. in this case you could use (as suggested here https://developer.wordpress.org/themes/functionality/pagination/#simple-pagination ): <div class=”nav-previous alignleft”><?php next_posts_link( ‘Older posts’ ); ?></div> <div class=”nav-next alignright”><?php previous_posts_link( ‘Newer posts’ ); ?></div> or any other suggestion from https://developer.wordpress.org/themes/functionality/pagination/ for the image, you … Read more

How to add location as category?

Ok, based on what you wrote in your comments you’ll want to go to your wp-content/plugins/ directory and create a new directory in there. Let’s call it: zains-locations. In that directory, make a new file called: zains-locations.php In that file, add the following: <?php /* Plugin Name: Zain’s Location Taxonomy Description: Add’s location taxonomy. Version: … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)