How to add the custom code to the particular category in WordPress

I am trying to add the script to the particular product category, but the code is not adding it to the category.

This is my code for the page (This is working):

function wpb_hook_faq_javascript() {   if (is_single ('8') || is_page ('8')) {      ?>     <script type="application/ld+json">      </script>   <?php } } add_action('wp_footer', 'wpb_hook_faq_javascript'); 

And I am trying to add this similar code to the product category page:

function wpb_hook_faqtocategory_javascript() {   if ( in_category( 'category-name' )) {      ?>     <script type="application/ld+json">      </script>   <?php } } add_action('wp_footer', 'wpb_hook_faqtocategory_javascript'); 

But the above code is not working. This is my product category URL: wp-admin/term.phptaxonomy=product_cat&tag_ID=9&post_type=product.

Any help is much appreciated.

Exclude category from function – PHP

I have the following code in my functions.php to move product category description to the bottom of the category page.

remove_action( 'woocommerce_archive_description', 'woocommerce_taxonomy_archive_description', 10 ); add_action( 'woocommerce_after_shop_loop', 'woocommerce_taxonomy_archive_description', 100 ); 

However, I need to exclude a few product categories from this (and keep them at the top), how would I convert my code into a function that can achieve this?

In the php, how can I have a category of a custom post type display?

It’s for my search page on my site. I would link it but it’s not up and running yet so hopefully, I can explain.

I have custom post types that are then broken out into categories. I want, when searching the site, the results to list what category that type of content is (the content is classified as custom post type “library”).

How do I write this?

Can a monk using Open Hand Technique knock any size category of creature prone?

The D&D 5e Player’s Handbook states:

Open Hand Technique

Starting when you choose this tradition at 3rd level, you can manipulate your enemy’s ki when you harness your own. Whenever you hit a creature with one of the attacks granted by your Flurry of Blows, you can impose one of the following effects on that target:

• It must succeed on a Dexterity saving throw or be knocked prone.

• It must make a Strength saving throw. If it fails, you can push it up to 15 feet away from you.

• It can’t take reactions until the end of your next turn.

Let me understand this correctly: a monk need only spend 1 ki point to make two unarmed strikes as a bonus action AND impose a Dex save from his opponent (regardless of size) with each of those attacks?

Let’s say a halfling monk squares off against a large creature, an ettin for example. The monk spends 1 ki point to flurry, hits the ettin with the first of these two attacks and decides to impose a Dex save. The ettin saves and then the monk attacks with the second of the two attacks, hits the ettin again, and then can impose another Dex save lest the ettin fall prone? Is this right or is there something I’m missing?

If this is indeed correct then it could potentially lead to some terribly unbalanced encounters, all beginning as early as 3rd level (when a monk gains access to this method).

Can post name be same as category name?

I have an old website written in static HTML pages. Now I want to rebuild a new website via WordPress. And make sure all SEO I have done with the old site will be transferred to the new site.

So I want to migrate the URLs from left(old site) to the right one(new site) as below:

URL1(Product home page): https://www.example.com/product1/ ->(Unchanged) https://www.example.com/product1/

URL2(Product order page): https://www.example.com/product1/order.htm -> https://www.example.com/product1/order/

Then I want to use /%category%/%postname%/ as the permalink. Now the problem is, for URL1, the “product1” will be a post name. However, for URL2, the “product1” will be a category name. So can the post name same as the category name? Or is this a good practice to do the task?

List just subcategory and products of active category page in Woocommerce

Working on a category page – taxonomy-product_cat.php – I want to list all the subcategories of that category page, with all its products. I would think it is simple enough but I cant get it to work.

I can list all categories of the shop with all subcategories and all products – So for example bags would list all products of the whole shop.

Or I can list the subcategories of just the category page – but without the products listed.

How can I list just the subcategories of the category page with their products?

The code I am using that works great, but loops all the categories in the shop, and not just the active category is:

$  args = array('taxonomy' => 'product_cat' ); $  all_categories = get_categories( $  args );  foreach ($  all_categories as $  cat) {     $  category_id = $  cat->term_id;     $  args2 = array('taxonomy' => $  taxonomy,'parent' => $  category_id,'hierarchical' => $  hierarchical, 'orderby' => $  orderby, 'order' => $  order,'hide_empty' => $  empty); $  categories = get_categories( $  args2 );   $  sub_cats = get_categories( $  args2 );             if($  sub_cats) {                 foreach($  sub_cats as $  sub_category) {                     echo "<h2>".$  sub_category->cat_name."</h2>";                      $  args = array( 'post_type' => 'product','product_cat' => $  sub_category->slug, 'orderby' => $  orderby, 'order' => $  order);                             $  loop = new WP_Query( $  args );                                while ( $  loop->have_posts() ) : $  loop->the_post(); global $  product; ?>                               <!--HTML HERE-->                               <?php endwhile;  wp_reset_query();  }}} ?> 

Get x numbers of a woocommerce category products using Wp_Query

Is possible to show some woocommerce products inside a swiper slider? I want to create a slider that will show some “featured” products on the home page. For now I have a cpt that is achieving this, but I don’t know how to link them to the products that I will add to woocommerce. So I want to replace the cpt with a query to get an x number of products from woocommerce products and put them into the slider. Any help will be appreciated.

The code I’m using now is this

<div class="row featured-row" <?php $  featured = new WP_Query( ['post_type' => 'featured', 'order' => 'ASC', 'posts_per_page' => 3] ); ?> <?php $  i = 0; ?> <?php if( $  featured->have_posts() ): while( $  featured->have_posts() ): $  featured->the_post(); ?> <?php #$  class = get_post_meta( get_the_ID(), 'class', true); ?> <?php if( $  i === 1 ): ?>   <div class="col-md-6 col-lg-6 d-none d-sm-none d-md-block featured-desc">     <h2 class="featured-title-right text-right"><?php the_title(); ?></h2>     <p class="featured-excerpt-right text-right"><?php echo get_the_excerpt(); ?></p>   </div>   <div class="col-md-6 col-lg-6 text-center d-none d-sm-none d-md-block featured-img">     <img class="img-fluid" src="<?php the_post_thumbnail_url(); ?>">   </div> <?php else: ?>   <div class="col-md-6 col-lg-6 text-center d-none d-sm-none d-md-block featured-img">     <img class="img-fluid" src="<?php the_post_thumbnail_url(); ?>">   </div>   <div class="col-md-6 col-lg-6 d-none d-sm-none d-md-block featured-desc">     <h2 class="featured-title"><?php the_title(); ?></h2>     <p class="featured-excerpt"><?php echo get_the_excerpt(); ?></p>   </div> <?php endif;?> <?php $  i++; ?> <?php endwhile; ?> <?php endif; wp_reset_postdata(); ?> </div>  

Custom image dimensions for each category

Hi everyone and happy new year 2020,

I need to set up different image dimensions for each category of a website.

For example,

To set these dimensions for Category 1:

Catalog Images = 240 x 320px
Single Product Image = 470 x 627px
Product thumbnails = 75 x 100px

And these dimensions for category 2:

Catalog Images = 245 x 245px
Single Product Image = 470 x 470px
Product thumbnails = 75 x 75px

I use woocommerce.
How to do this? Is there any code or filter to affect to that a named…

Custom image dimensions for each category

How to remove Author and Category from a single portfolio page?

I have a little issue with removing the Category and Author from my single portfolio pages. I tried different suggestions from other posts here and nothing worked, I also tried to modify the code myself and am hitting a wall again. Apparently it seems the right code to be added is strictly individual depending on the page and I was hoping someone can give me a little nudge. I’am using the Edge theme and there’s the link to one of the pages that I’m trying to work on:

https://etc-fos4panel-prd.azurewebsites.net/?portfolio-item=wireless-control

Thank you all in advance!