Answer the question
In order to leave comments, you need to log in
The question is how to write a condition so that on the shop page it simply displays the word “products”, and on others the name of the category?
I had a problem that the title was displayed in the category: Archives: Category name, but I did not like that the word "Archives" was displayed and I was advised
<?php the_archive_title( '', '' );; ?>
to replace it with
<?php single_term_title() ?>
Now it is displayed in the categories as it should, but the text "products" is not displayed on the shop page.
The question is how to write a condition so that on the shop page it simply displays the word "products", and on others the name of the category. I don't know PHP.
Source:
<div class="banner-shop">
<?php if ( is_home() ) : ?>
<?php if( is_front_page()):?>
<h1 class="page-title blog-title"><?php esc_html_e('Latest Posts','organics');?></h1>
<?php else:?>
<h1 class="page-title blog-title"><?php single_post_title(); ?></h1>
<?php endif;?>
<?php elseif( is_single() ):?>
<?php elseif( is_page() ):?>
<h1 class="page-title"><?php the_title(); ?></h1>
<?php else:?>
<h1 class="page-title"><?php single_term_title() ?></h1>
<?php
?>
<?php endif;?>
</div>
Answer the question
In order to leave comments, you need to log in
<?php if (is_shop()) : ?>
<h1 class="page-title">Товары</h1>
<?php else : ?>
<h1 class="page-title"><?php single_term_title() ?></h1>
<?php endif; ?>
Here you did not write what "Shop page" means - is it a category, is it a page or a WooCommerce store?
If this is a rubric, then the easiest option is to do this:
<?php if ( is_category( 'shop' ) { ?>
<h1>Товары</h1>
<?php } else { ?>
<h1><?php single_cat_title(); ?></h1>
<?php }; ?>
<?php if ( is_page( 'shop' ) { ?>
<h1>Товары</h1>
<?php } else { ?>
<h1><?php single_cat_title(); ?></h1>
<?php }; ?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question