How to remove comment count column in Posts inside the admin dashboard?

I know how to remove from pages:

function remove_pages_count_columns($  defaults) {   unset($  defaults['comments']);   return $  defaults; } add_filter('manage_pages_columns', 'remove_pages_count_columns'); 

But can’t find the answer how to remove for posts.

I have tried:

add_filter('manage_posts_columns', 'remove_posts_count_columns'); 


add_filter('manage_post_columns', 'remove_post_count_columns'); 

But none of the above worked.

Any help would be appreciated.

Make all posts of a category to only appear on the sidebar of that particular page

I have created a top navigation menu based on categories and assigned all posts to different categories. What I want is for each "page" to only show posts from that category. For example I have 5 posts in "Home" and 10 posts in "Articles". I want the Home page to show 5 posts on the sidebar and show 10 posts in the Articles page.

I have tried different widgets such as wp-posts-widget but these only list either all posts from all categories or show categorised posts on ALL pages.

Please help

Output a specific link in WordPress post if the single post’s category’s name contain certain word

I want to output a specific link in every post, depending on the post’s category. For example, If a post is in "travel" category, then the link to will be displayed in this post. If a post is in "hotel" category, then the link to will be displayed in this post.

I tried this code

    <?php    $  category = get_the_category();   $  firstCategory = '$  category[0]->cat_name';   if (strpos($  firstCategory, 'travel') !== false) { echo '<a href="">Visit travelbooking</a>'; }        if (strpos($  firstCategory, 'hotel') !== false)  {     echo '<a href="">Visit hotelbooking</a>';    }          else {      echo '<a href="">Visit homepage</a>'; }       ?>  

But it doesn’t work, any suggestion?

How to Not Show posts on Category page?

i simply dont want to show posts on category page and show the description only, i tried this code but it wont work if i use the zero value, 1+ value would work but not 0

add_filter('pre_get_posts', 'posts_in_category'); function posts_in_category($  query){     if ($  query->is_category) {         if (is_category('')) {             $  query->set('posts_per_archive_page', 0);         }           } } 

Combine relationship posts with existing wp_query

So I am building a query, and I wanted to see if someone can assist me on a special attempt to infuse two queries.

So here is what I’m attempting to do:

  1. Check if we have any relationship posts, which I can return either an array of IDs or an array of WP_Post objects.

  2. I want to showcase the relationship posts first if they are and then showcase the remaining wp_query posts.

Here is what I’m working with:


$  args = [     'post_type' => ['work', Report_Type::CPT_NAME],     'posts_per_page' => 4,     'post_status' => ['publish'], ]; $  query = new WP_Query($  args); 

Then I’m looping through using a template as shown below:

if ($  query->have_posts()) {     ob_start();     get_template_part('template-parts/blocks/work-expertise-filter/work-items-template', null, ['query' => $  query]);     $  content = ob_get_contents();     ob_end_clean();     wp_reset_postdata(); } 

So let’s say, that I have get_field('featured_posts') which returns back an ARRAY of IDs (I can check it to ARRAY of WP_Post objects if needed).
This is our return: array(2) { [0]=> int(14244) [1]=> int(14566) } array(4) {

So I attemped to do something like this:

    $  args = [         'post_type' => ['work', Report_Type::CPT_NAME],         'posts_per_page' => 4,         'post_status' => ['publish'],     ];     $  query = new WP_Query($  args);      $  all_ids = [];     if ($  query->have_posts()) {         while ($  query->have_posts()) {             $  query->the_post();             $  all_ids[] = array_merge($  query->post->ID, get_field('featured_posts'));         }         wp_reset_postdata();     }     $  all_ids = array_unique($  all_ids);     $  args = [         'post__in' => $  all_ids     ];     $  the_query = new WP_Query($  args); 

But I’m getting no response back, it’s basically: object(WP_Query)#1853 (50) { [“query”]=> array(1) { [“post__in”]=> array(1) { [0]=> NULL } } [“query_vars”]=> array(63) { [“post__in”]=> array(1) { [0]=> NULL }

If someone could help me with a query, it would be much appreciated!

List archived posts by subcategory

I would like to override the default post archives, via category.

In some cases (not all), I have 2 level-categories, such as:

Parent Category: "Video"

  • Subcategory "Comedy"
  • Subcategory "Action"

But some other categories, are just single-level.

Currently, no matter which category you choose, you get a list of posts, no matter whether its a main- or sub- category.

What I would like to do, is when entering the category listing, there is a test of sub-categories exist, and if so, the posts should be lists as such:

Heading: Video


  • post 1
  • post 2
  • post 3


  • post 4
  • post 5
  • post 6

If however, there are no subcategories, than the default listing is displayed:

Heading: Books

  • post 7
  • post 8
  • post 9

How can this be done?

I have very basic PHP knowledge, and have a PHPCode script installed, but I’m not sure how to access the archive/category page.

If its relevant, I am using Avada (child) theme.

How to search WordPress Posts by Category

I’m on WordPress 5.7.2 and testing the following through the twenty-twenty-one theme.

I apologize in advanced if this question has been asked to death, but I’m having a hard time trying to find a solution for the issue. All I want from the wp-admin side is a way to search for Posts by "category name". Even if I have to add a custom hook / filter into my child theme to make this happen, I’ll do it. But is this possible today?

Right now, when I attempt to search a published post by its assigned category name in /wp-admin/edit.php?…, I get nothing back.

Thanks for any tips!

How do I display/pull posts from subdomains to the landing page (domain) in WordPress Multi-site?

I have 8 sites in my multi-site network:

  1. Group Landing site (domain)
  2. Group 1 site (subdomain 1)
  3. Group 2 site (subdomain 2)
  4. Group 3 site (subdomain 3)
  5. Group 4 site (subdomain 4)
  6. Group 5 site (subdomain 5)
  7. Group 6 site (subdomain 6)
  8. Group 7 site (subdomain 7)

Essentially, Groups 1 to 7 will have separate contents. However, the Group Landing site will have content from both. I would rather not have the user enter the content twice. The post must also link/point to the Group/subdomain where it was originally published.

Is there a way for me to pull content from Group 1 and Group 2, and display it in Group Landing?

(Clarification: I want to pull content. That means, that I want to be able to run a query and get information from other posts and pages and display on the front end. I am not looking to duplicate content on the back-end, or to share content on the back-end. So, if the source is deleted than nothing will show on the front-end.)

What I did: I’m not sure if I did it correctly (I don’t even know how to code), but I appended the code snippet below in the functions.php of my theme:

foreach( $  blog_ids as $  blog_id ){     switch_to_blog( $  blog_id );     $  post = get_post( $  post_id );     restore_current_blog(); } 

Reason for asking: I want to replicate this feature from the front/homepage of this website: Also, the web hosting support team cannot provide snippets for this feature because they only have Python/Go developers rather than WordPress developers.