I am using an Html block in the category description field and there are only product categories in the block.
The first time I enter the category screen, it looks like (ss1), it gets better when I refresh the page. (ss2)
Hi, I’ve identified the plugin causing the problem as Rank Math, what should I do? The settings are as follows. (ss3)
(ss1) – https://ibb.co/Qvb7L37
(ss2) – https://ibb.co/YWNnLBd
(ss3) – https://ibb.co/Mf2LKTB
function change_existing_currency_symbol( $currency_symbol, $currency) {
$product_cats = wp_get_post_terms( get_the_ID(), 'product_cat' );
if ( $product_cats && ! is_wp_error ( $product_cats ) ){
$single_cat = array_shift( $product_cats );
$cat = $single_cat;
}
switch($single_cat->name) {
case 'Amazon US': $currency_symbol = '$ '; break;
case 'Amazon GB': $currency_symbol = '£ '; break;
case 'Amazon DE': $currency_symbol = '€ '; break;
case 'Amazon IT': $currency_symbol = '€ '; break;
case 'Amazon FR': $currency_symbol = '€ '; break;
case 'Amazon ES': $currency_symbol = '€ '; break;
case 'Amazon JP': $currency_symbol = '¥ '; break;
}
return $currency_symbol;
}
function woo_custom_format_position($format, $currency_pos)
{
/*'left':$format = '%1$s%2$s';
'right':$format = '%2$s%1$s';
'left_space':$format = '%1$s %2$s';
'right_space':$format = '%2$s %1$s';
*/
$product_cats = wp_get_post_terms( get_the_ID(), 'product_cat' );
if ( $product_cats && ! is_wp_error ( $product_cats ) ){
$single_cat = array_shift( $product_cats );
$cat = $single_cat;
}
switch($single_cat->name) {
case 'Amazon US': $format = '%1$s%2$s'; break;
case 'Amazon GB': $format = '%1$s%2$s'; break;
case 'Amazon DE': $format = '%2$s %1$s'; break;
case 'Amazon IT': $format = '%2$s %1$s'; break;
case 'Amazon FR': $format = '%2$s %1$s'; break;
case 'Amazon ES': $format = '%2$s %1$s'; break;
case 'Amazon JP': $format = '%1$s %2$s'; break;
}
return $format;
}
I use these function to format the prices in my woocommerce shop. And therefore it would be awesome to have these changes with a snippet like
add_filter('woocommerce_currency_symbol', 'change_existing_currency_symbol', 10, 2);
this at the search too. Also it would be very nice to know if there is a way to show the category of the search result under the result name in small. Any help would be great. Thank you!
]]>I have two CPTs, one called Ligas (leagues) and the other Clubes (clubs), both related to ACF (relacion_ligas_clubes). When I show a club, it should show which leagues it belongs to. I was able to do some of that with the following code in the single.php file, but what it outputs is the league id:
<?php if (in_category('clubes')) { ?>
<p><strong>Liga:</strong> <?php the_field('relacion_ligas_clubes'); ?></p>
<?php } ?>
I would need to show the name of the league and that in turn be a link that takes me to it.
I also tried this code, but it shows me the “clubes” category:
<li><strong>Liga:</strong>
<?php
$name = get_post( ($id) )->post_type;
echo $name;
?>
</li>
CPT Ligas:
https://contextodigital.com.ar/futbolinterior/ligas/
CPT Clubes:
https://contextodigital.com.ar/futbolinterior/clubes/
Club:
https://contextodigital.com.ar/futbolinterior/clubes/club-atletico-acassuso/
If someone could help me, I will appreciate it.
]]><div id="container">
<div id="content" role="main">
<div class="row">
<?php
$mod = get_theme_mod('product_cat');
$cat_id = explode(',', $mod);
// get all the categories from the database
$cats = get_terms ( 'product_cat', $args );
$args = array(
'post_type' => 'product',
'posts_per_page' => 6,
'tax_query' => array(
array(
'taxonomy' => 'product_cat',
'field' => 'term_id',
'terms' => $cat_id,
)
)
);
$q = new WP_Query( $args );
$leadingcount = 3;
// loop through the categries
foreach ($cats as $cat) {
// setup the cateogory ID
$cat_id= $cat->term_id;
// Make a header for the cateogry
echo "<h6>".$cat->name."</h6>"; ?>
<?php if (have_posts()) : while ( $q->have_posts() ) : $q->the_post(); ?>
<article class="item col-lg-<?php echo $leadingcount; ?>">
<div class="card rounded-0">
<div class="card-body">
<a>">
<h5><?php the_title(); ?></h5>
</a>
<?php the_excerpt(); ?>
<?php the_category(); ?>
</div>
</div>
</article>
<?php endwhile; endif; // done our wordpress loop. Will start again for each category ?>
<?php } // done the foreach statement ?>
</div><!--row-->
</div><!-- #content -->
</div><!-- #container -->
]]>What I am trying to achieve is to display a list of the latest reviews in the homepage of the website, and to show the category name at the bottom of each review.
Thank you.
]]><ul>
<li>Category 1</li>
<li>Category 2</li>
<li>Category 3</li>
<li>Category 4</li>
</ul>
]]>i wan’t to automatically add the name of the category-page for some products.
the products are automatically imported, that’s why changing it per hand is not an option.
i found the title.php, where i want to add the category name.
<h1 class="product_title entry-title">
<?php echo esc_html( get_the_title() ); ?>
</h1>
i just can’t figure out how to display the category name.
]]>* how remove category name under each product in product archive .. shop page ?
Best regards
Michael