Count how many posts have a specified tag AND category

I know how to count how many posts has a certain tag, or category

For example:

$  term_slug = 'some-post-tag'; $  term = get_term_by('slug', $  term_slug, $  post_tag); echo $  term->count; 

BUT! Is there anyway to count how many posts that have a tag AND a specified category?

I want to count how many posts that have the tag(slug) “cats” and the category slug “allow-list”

Is this even possible?

Does the re-use of HTML email newsletter content for blog posts have SEO (or other) repercusions?

I am (in parallel) building both a newsletter subscriber list (using Mailchimp) and also a blog website (using WordPress). I want to be as efficient as possible with the use of my content / copy. I would like to send out newsletters to subscribers first and then re-use the content for time delayed blog postings. Using a WordPress plugin such as ‘postie’ I can easily send an email directly to my website that is then entered into my blog post stream automatically. If I prepare the styling of my email appropriately in Mailchimp, the posting should look like native content on my website.

However, my current understanding is that robust HTML emails tend to use A LOT of tables to force the email client to render the email correctly. Also, they tend to use A LOT of inline CSS and the like. If I simply insert this into my blog stream the website HTML is going to get ‘ugly’ and likely slow to load.

But, does this actually matter? Will webcrawlers & search engines have a tantrum?

If I need to avoid this scenario, should I search for a solution (hopefully not manual re-coding) that creates two versions of the HTML: one for newsletter use; one for blog stream insertion?

I really want to avoid the manual effort of having to create two versions of the HTML content from scratch each time.

Many thanks in advance for any thoughts, advice and suggestions you can offer.

[ If it is of any interest / relevance, you can visit my fledgling blog site at https://charlesgull.mobi ]

Not able to understand this problem ( home page – latest posts) not showing properly

Hi i am working on my friend’s site it is using gwangi theme (https://community.gwangi-theme.com/) and my website is https://www.tamilpeoples.ml/

it is working fine in localhost (xampp) but after i upload it to my hosting server only home page shows extra contents below footer. ( if i de activate 4 plugins) it is working fine but without these plugins functions are not working. somebody help plz

can I extend the WP_Query class to deal with ‘duplicate’ posts created by joining to wp_posts?

Based on the premise that one big database requests is better than many smaller ones, I’ve modified WP_Query for my custom post type ‘word’ and joined three tables to it. The resulting query looks more or less like this and works well.

SELECT wp_posts.*, verbs.*, nouns.*, definitions.* FROM wp_posts   LEFT JOIN verbs ON ( wp_posts.ID = verbs.word_id )   LEFT JOIN nouns ON ( wp_posts.ID = nouns.word_id )   LEFT JOIN definitions ON ( wp_posts.ID = definitions.word_id )   WHERE 1=1   AND wp_posts.post_type = 'word'  AND (wp_posts.post_status = 'publish' OR [...] )   ORDER BY wp_posts.post_title ASC  

I of course now have duplicate posts for each of the words’ respective definitions and I am rolling them back up into one post per word with an array of definitions instead.

But because these results are used in different ways all around the website, I’m having to write similar logic time and time again. Here, for example, I am using the data in an AJAX response.

    $  query = new WP_Query( $  args );      $  posts = $  query->get_posts();      if ( $  query->post_count ) > 0 )     {         $  prev_word = null;         foreach ( $  posts as $  key => &$  row )          {             if ( !property_exists( $  row, 'definitions' ) ) $  row->{'definitions'} = array();              $  definition = array(                 'definition_id' => $  row->definition_id,                 'definition' => $  row->definition,                 'note' => $  row->note,             );              if ( is_object( $  prev_word ) )             {                 if ( $  prev_word->post_id == $  row->post_id )                 {                     // update the previously inserted row                     $  prev_word->definitions[] = $  definition;                      // remove the current row                     unset( $  row );                      continue;                 }             }              $  row->definitions[] = $  definition;             $  prev_word = $  row;         }     }      echo json_encode( array_values( $  posts ) );     die();  

What I would like to do now is extend the WP_Query class to have this done automatically on construction.

class Words_Query extends WP_Query {     function __construct( $  args = array() )     {         $  args = array_merge( $  args, array(             'post_type' => 'word'         ) );          parent::__construct( $  args );          [insert magic here?]     }      public $  definitions = array(); } 

I don’t have any experience with OOP though so I am asking for some help/guidance. Is something like this possible?

Will I have to update a bunch of other properties to reflect the changes…? Like $ post_count

What other things might I need to be aware of?

Thanks

Display list of posts from taxonomy term, but display the latest post featured image

I’m trying to do a page where all posts from a custom post type list, divided by their taxonomy terms and having a big photo on top of the list (latest featured image from said term). Right now I have the following code, but it displays the wrong images (each term should show latest post’s featured image, and I’m not even sure why the images are just random, even in the wrong term):

<section id="" class="">  <?php      }     wp_reset_query();   $  tax = 'technology-category';      $  terms = get_terms( $  tax ,array(          'orderby'    => 'ID',         'order'      => 'ASC',         'hide_empty' => 0,     ));      //Loop throug each taxonomy terms,      foreach ( $  terms as $  term ) {          //Query argument for post     $  args = array(              'post_type' => 'technology', // Or Custom Post Type,              'order' => 'DESC',              'orderby' => 'date',             'taxonomy' => $  tax,             'term' => $  term->slug, // Query posts for each term based on term slug         );         $  query = new WP_Query( $  args );          $  posts = $  query->get_posts();          ?>  <div class="container-fluid tech-cat-item py-5">     <div class="container">     <div class="row align-items-center pb-3">     <div class="col-1">     <img class="img-fluid" src="<?php echo z_taxonomy_image_url($  term->term_id); ?>"> </div> <div class="col-11">     <h3><?php echo $  term->name;?></h3> </div> </div> <?php //Do query to get image?        $  ga_item = array(             'post_type' => 'technology',               'order' => 'DESC',              'orderby' => 'date',             'taxonomy' => $  tax,             'term' => $  term->slug,              'posts_per_page' => '1', //just one because only need the latest post's featured image );        $  ga_query = new WP_Query( $  ga_item );         $  ga_posts = $  query->get_posts();     if ( $  ga_query->have_posts() ) {     while ( $  ga_query->have_posts() ) { $  ga_query->the_post(); ?>     <div class="row ga-panel py-5">     <div class="col-12">         <?php          $  ga_url = get_the_post_thumbnail_url($  post->ID,'full'); ?>         <img class="img-fluid ga-img" src="<?php echo esc_url($  ga_url);?>">     </div>     </div> <?php } } wp_reset_query(); ?>     <div class="row">         <?php          if ( $  posts ) {          foreach ( $  posts as $  post ) { ?>              <div class="col-4 ga-links">                 <a href="<?php the_permalink( $  post->ID ); ?>" data-swap="<?php echo esc_url($  ga_url);?>" > <?php echo $  post->post_title; ?></a>             </div>          <?php                     }         }        ?> </div> </div> </div>   <?php  }  wp_reset_query(); ?>                      </section> 

WP Query for Posts (Products) in Specific Category that has 2 Specific Tags (*AND* both tags not *OR*)

This is really confusing me.

I’ve tried numerous things but cannot get appropriate results.

Here’s what I currently have for my query:

$  args = array(     'post_type' => 'product',     'tax_query' => array(         'relation' => 'AND',         array(             'taxonomy' => 'product_cat',             'field'    => 'slug',             'terms'    => array( 'ring' ),         ),         array(             'taxonomy' => 'product_tag',             'field'    => 'slug',             'terms'    => array( 'black', 'men' ),         ),     ), ); $  query = new WP_Query( $  args ); 

As you can see I am trying to return products in the product category ring that contain both the tags black AND men

It appears though the product_tag terms array which includes black and men, is returning posts that include the tag black OR the tag men in the ring category.

How do I get it so that only products that include BOTH the tags in the query are returned?

Thanks so much

WordPress posts in the loop not stacking side by side

I was following a wp theme developement tutorial but somehow the posts from main loop and projects are not showing side by side ..although all other css works fine here is my code

front-page.php

<?php get_header();?>      <div id="banner">         <h1>&lt;GTCoding/&gt;</h1>         <h3>Learn coding from scratch</h3>     </div>      <main>         <a href="<?php echo site_url('/blog');?>">             <h2 class="section-heading">All Blogs</h2>         </a>        <?php         $  args =  array(          'post_type' => 'post',          'posts_per_page' => 2         );         $  blogposts = new WP_Query($  args);          while($  blogposts->have_posts()){             $  blogposts->the_post();        ?>         <section>             <div class="card">                 <div class="card-image">                     <a href="<?php echo the_permalink(); ?>">                         <img src="<?php echo get_the_post_thumbnail_url(get_the_ID()); ?>" alt="Card Image">                     </a>                 </div>                  <div class="card-description">                     <a href="<?php echo the_permalink(); ?>">                         <h3><?php the_title(); ?></h3>                     </a>                     <p>                        <?php echo wp_trim_words(get_the_excerpt(),30); ?>                     </p>                     <a href="<?php echo the_permalink(); ?>" class="btn-readmore">Read more</a>                 </div>             </div>           <?php }              wp_reset_query();            ?>          </section>          <a href="<?php echo site_url('/projects');?>">             <h2 class="section-heading">All Projects</h2>         </a>          <?php         $  args =  array(          'post_type' => 'project',          'posts_per_page' => 2         );         $  projects = new WP_Query($  args);          while($  projects->have_posts()){             $  projects->the_post();        ?>         <section>             <div class="card">                 <div class="card-image">                     <a href="<?php echo the_permalink(); ?>">                         <img src="<?php echo get_the_post_thumbnail_url(get_the_ID()); ?>" alt="Card Image">                     </a>                 </div>                  <div class="card-description">                     <a href="<?php echo the_permalink(); ?>">                         <h3><?php the_title(); ?></h3>                     </a>                     <p>                        <?php echo wp_trim_words(get_the_excerpt(),30); ?>                     </p>                     <a href="<?php echo the_permalink(); ?>" class="btn-readmore">Read more</a>                 </div>             </div>           <?php }              wp_reset_query();            ?>          </section>          <h2 class="section-heading">Source Code</h2>          <section id="section-source">             <p>                 Lorem ipsum dolor sit amet consectetur adipisicing elit. Rerum neque qui delectus ad dolor blanditiis perferendis praesentium                 consectetur aut sed provident obcaecati aspernatur perspiciatis, dolores nobis pariatur ipsum vel corrupti!             </p>             <a href="#" class="btn-readmore">GitHub Profile</a>         </section>        <?php get_footer();?> 

header.php

<!DOCTYPE html> <html lang="en">  <head>     <meta charset="UTF-8">     <meta name="viewport" content="width=device-width, initial-scale=1.0">     <meta http-equiv="X-UA-Compatible" content="ie=edge">     <title>GTCoding</title>     <?php wp_head(); ?> </head>  <body>     <div id="slideout-menu">         <ul>             <li>                 <a href="<?php echo site_url('');?>">Home</a>             </li>             <li>                 <a href="<?php echo site_url('/blog');?>">Blog</a>             </li>             <li>                 <a href="<?php echo site_url('/projects');?>">Projects</a>             </li>             <li>                 <a href="<?php echo site_url('/about');?>">About</a>             </li>             <li>                 <input type="text" placeholder="Search Here">             </li>         </ul>     </div>      <nav>         <div id="logo-img">             <a href="#">                 <img src="<?php echo get_template_directory_uri();?>/img/logo.png" alt="GTCoding Logo">             </a>         </div>         <div id="menu-icon">             <i class="fas fa-bars"></i>         </div>         <ul>             <li>                 <a class="active" href="<?php echo site_url('');?>">Home</a>             </li>             <li>                 <a href="<?php echo site_url('/blog');?>">Blog</a>             </li>             <li>                 <a href="<?php echo site_url('/projects');?>">Projects</a>             </li>             <li>                 <a href="<?php echo site_url('/about');?>">About</a>             </li>             <li>                 <div id="search-icon">                     <i class="fas fa-search"></i>                 </div>             </li>         </ul>     </nav>      <div id="searchbox">         <input type="text" placeholder="Search Here">     </div> 

footer.php

  <footer>             <div id="left-footer">                 <h3>Quick Links</h3>                 <p>                     <ul>                         <li>                             <a href="index.html">Home</a>                         </li>                         <li>                             <a href="about.html">About</a>                         </li>                         <li>                             <a href="#">Privacy Policy</a>                         </li>                         <li>                             <a href="blogslist.html">Blogs</a>                         </li>                         <li>                             <a href="blogslist.html">Projects</a>                         </li>                         <li>                             <a href="#">Contact</a>                         </li>                     </ul>                 </p>             </div>              <div id="right-footer">                 <h3>Follow us on</h3>                 <div id="social-media-footer">                     <ul>                         <li>                             <a href="#">                                 <i class="fab fa-facebook"></i>                             </a>                         </li>                         <li>                             <a href="#">                                 <i class="fab fa-youtube"></i>                             </a>                         </li>                         <li>                             <a href="#">                                 <i class="fab fa-github"></i>                             </a>                         </li>                     </ul>                 </div>                 <p>This website is developed by GTCoding</p>             </div>         </footer>      </main>   <?php wp_footer();?> </body>  </html> 

enter image description here

it should show like this

enter image description here

here is my index.html code

<!DOCTYPE html> <html lang="en">  <head>     <meta charset="UTF-8">     <meta name="viewport" content="width=device-width, initial-scale=1.0">     <meta http-equiv="X-UA-Compatible" content="ie=edge">     <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.1.0/css/all.css" integrity="sha384-lKuwvrZot6UHsBSfcMvOkWwlCMgc0TaWr+30HWe3a4ltaBwTZhyTEggF5tJv8tbt"         crossorigin="anonymous">     <link href="https://fonts.googleapis.com/css?family=Roboto|Roboto+Condensed|Roboto+Slab" rel="stylesheet">     <link rel="stylesheet" href="style.css">     <title>GTCoding</title> </head>  <body>     <div id="slideout-menu">         <ul>             <li>                 <a href="index.html">Home</a>             </li>             <li>                 <a href="blogslist.html">Blog</a>             </li>             <li>                 <a href="blogslist.html">Projects</a>             </li>             <li>                 <a href="about.html">About</a>             </li>             <li>                 <input type="text" placeholder="Search Here">             </li>         </ul>     </div>      <nav>         <div id="logo-img">             <a href="#">                 <img src="img/logo.png" alt="GTCoding Logo">             </a>         </div>         <div id="menu-icon">             <i class="fas fa-bars"></i>         </div>         <ul>             <li>                 <a class="active" href="index.html">Home</a>             </li>             <li>                 <a href="blogslist.html">Blog</a>             </li>             <li>                 <a href="blogslist.html">Projects</a>             </li>             <li>                 <a href="about.html">About</a>             </li>             <li>                 <div id="search-icon">                     <i class="fas fa-search"></i>                 </div>             </li>         </ul>     </nav>      <div id="searchbox">         <input type="text" placeholder="Search Here">     </div>      <div id="banner">         <h1>&lt;GTCoding/&gt;</h1>         <h3>Learn coding from scratch</h3>     </div>      <main>         <a href="blogslist.html">             <h2 class="section-heading">All Blogs</h2>         </a>          <section>             <div class="card">                 <div class="card-image">                     <a href="blogpost.html">                         <img src="img/1.jpg" alt="Card Image">                     </a>                 </div>                  <div class="card-description">                     <a href="blogpost.html">                         <h3>The Blog Title Here</h3>                     </a>                     <p>                         Lorem ipsum dolor sit, amet consectetur adipisicing elit. Blanditiis, ullam facilis consequuntur eligendi sit accusamus tempora                         cum distinctio pariatur ipsa quod, odit dolorum non vero recusandae? Corporis voluptatem optio nulla.                     </p>                     <a href="blogpost.html" class="btn-readmore">Read more</a>                 </div>             </div>              <div class="card">                 <div class="card-image">                     <a href="blogpost.html">                         <img src="img/2.jpg" alt="Card Image">                     </a>                 </div>                  <div class="card-description">                     <a href="blogpost.html">                         <h3>The Blog Title Here</h3>                     </a>                     <p>                         Lorem ipsum dolor sit, amet consectetur adipisicing elit. Blanditiis, ullam facilis consequuntur eligendi sit accusamus tempora                         cum distinctio pariatur ipsa quod, odit dolorum non vero recusandae? Corporis voluptatem optio nulla.                     </p>                     <a href="blogpost.html" class="btn-readmore">Read more</a>                 </div>             </div>         </section>          <a href="blogslist.html">             <h2 class="section-heading">All Projects</h2>         </a>          <section>             <div class="card">                 <div class="card-image">                     <a href="blogpost.html">                         <img src="img/3.jpg" alt="Card Image">                     </a>                 </div>                  <div class="card-description">                     <a href="blogpost.html">                         <h3>The Project Title Here</h3>                     </a>                     <p>                         Lorem ipsum dolor sit, amet consectetur adipisicing elit. Blanditiis, ullam facilis consequuntur eligendi sit accusamus tempora                         cum distinctio pariatur ipsa quod, odit dolorum non vero recusandae? Corporis voluptatem optio nulla.                     </p>                     <a href="blogpost.html" class="btn-readmore">Read more</a>                 </div>             </div>              <div class="card">                 <div class="card-image">                     <a href="blogpost.html">                         <img src="img/4.jpg" alt="Card Image">                     </a>                 </div>                  <div class="card-description">                     <a href="blogpost.html">                         <h3>The Project Title Here</h3>                     </a>                     <p>                         Lorem ipsum dolor sit, amet consectetur adipisicing elit. Blanditiis, ullam facilis consequuntur eligendi sit accusamus tempora                         cum distinctio pariatur ipsa quod, odit dolorum non vero recusandae? Corporis voluptatem optio nulla.                     </p>                     <a href="blogpost.html" class="btn-readmore">Read more</a>                 </div>             </div>         </section>          <h2 class="section-heading">Source Code</h2>          <section id="section-source">             <p>                 Lorem ipsum dolor sit amet consectetur adipisicing elit. Rerum neque qui delectus ad dolor blanditiis perferendis praesentium                 consectetur aut sed provident obcaecati aspernatur perspiciatis, dolores nobis pariatur ipsum vel corrupti!             </p>             <a href="#" class="btn-readmore">GitHub Profile</a>         </section>          <footer>             <div id="left-footer">                 <h3>Quick Links</h3>                 <p>                     <ul>                         <li>                             <a href="index.html">Home</a>                         </li>                         <li>                             <a href="about.html">About</a>                         </li>                         <li>                             <a href="#">Privacy Policy</a>                         </li>                         <li>                             <a href="blogslist.html">Blogs</a>                         </li>                         <li>                             <a href="blogslist.html">Projects</a>                         </li>                         <li>                             <a href="#">Contact</a>                         </li>                     </ul>                 </p>             </div>              <div id="right-footer">                 <h3>Follow us on</h3>                 <div id="social-media-footer">                     <ul>                         <li>                             <a href="#">                                 <i class="fab fa-facebook"></i>                             </a>                         </li>                         <li>                             <a href="#">                                 <i class="fab fa-youtube"></i>                             </a>                         </li>                         <li>                             <a href="#">                                 <i class="fab fa-github"></i>                             </a>                         </li>                     </ul>                 </div>                 <p>This website is developed by GTCoding</p>             </div>         </footer>      </main>      <script src="main.js"></script> </body>  </html> 

Recover posts and pages from expired domain (no xml x-port pre expiration)

Hey guys! Quick question, what is the easiest way to recover posts and pages from an old wordpress site? I have the database files, the wordpress site files captured pre-expiration, but the client did not export the XML to import into the new site pre-expiration. Do I just pull the specific tables in database and transmute to new? These files are from an old php version as well.

How can I display the most like posts from ultimate member?

With Ultimate Member Social Activity plugin the users are able to write posts and like each-others posts. I would like to display the most liked posts on a different page. How could I do that?

I was thinking on shortcodes but there are none for this purpose or write some code but i have no idea how to start it :/ I have seen a plugin with this functionality is possible to copy that peace of code and replace the hook from UM like counter? (If its make no sense i am sorry)

Thank You!