filter a loop base on specific category

There’s no valid query argument – category, it could be category_name or cat. So for your query, you can use – $custom_cat_args = array( ‘posts_per_page’ => 15, ‘order’ => ‘DESC’, ‘orderby’ => ‘post_date’, ‘cat’ => get_cat_ID( ‘سیاست’ ) ); Or $custom_cat_args = array( ‘posts_per_page’ => 15, ‘order’ => ‘DESC’, ‘orderby’ => ‘post_date’, ‘category_name’ => ‘سیاست’ … Read more

Get the ID of the current post’s child category

Display every grandchildren on wordpress support forum seems pretty close. Here is the solution that was proposed: <ul> <?php $all = get_pages(); //You could use $args to retrieve posts how you want. foreach($all as $all) { if($all->post_parent) { if( get_page($all->post_parent)->post_parent ) { $tp = get_page($all->post_parent); if( !get_page( $tp->post_parent )->post_parent) { $grandchild_ids[] = $all->ID; } //catching … Read more

Add description to categories menu in admin

I am assuming this is for the built-in Category taxonomy for Posts? This would be the way of doing it. add_action( ‘registered_taxonomy’, ‘my_custom_category_paragraph’, 10, 3 ); function my_custom_category_paragraph( $taxonomy, $object_type, $args ) { global $wp_taxonomies; if ( ‘category’ !== $taxonomy ) return; // Change the callback that renders the metabox with our own. $wp_taxonomies[$taxonomy]->meta_box_cb = … Read more

Break down output of wp_list_categories

A custom category walker should do what you need. class My_Cat_Walker extends Walker_Category { function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) { extract($args); $cat_name = esc_attr( $category->name ); $cat_name = apply_filters( ‘list_cats’, $cat_name, $category ); $output .= ‘<li>’.$cat_name.'</li>’; } } $args = array( ‘orderby’ => ‘name’, ‘show_count’ => … Read more

Exclude categories by ID

You could try modifying your query such that you have an array of categories to exclude and a conditional in the foreach, working similarly to the !empty(). An untested example: <!– category list with thumbs –> <?php $terms = apply_filters( ‘taxonomy-images-get-terms’, ”, array(‘taxonomy’ => ‘category’) ); $exclude = array(1,7); //add the category IDs to exlcude … Read more

Show post categories

If you select both categories for the post the_category() will display both and using multiple will make the child category display the parent relationship, so you will have the parent twice. If you want to display a link to the parent category and a link to child category select only the child category for the … Read more

Shows only one Category in home page

Use pre_get_posts to modify the query before it is executed: function include_category( $query ) { if ( $query->is_home() && $query->is_main_query() ) { $query->set( ‘cat’, ’17’ ); } } add_action( ‘pre_get_posts’, ‘include_category’ );

Category Page Template – Can’t get category ID

On a category archive, the “queried object” will have what you need. $cat = get_queried_object(); var_dump($cat->cat_ID); You can access it by means of get_query_var(): $cat = get_query_var(‘cat’); var_dump($cat); You can also pull is straight from the $wp_query global: var_dump($wp_query->query_vars[‘cat’]); All of these assume that you are actually on a proper category archive page and that … Read more