Вопрос

I am using woocommerce and would like to move the title on my archive page to above the thumbnail. Right now it is below the thumbnail.

Is there a way to unhook the title in its current position and move it? Thanks!

Here is a link to my website.

Это было полезно?

Решение

First you need to locate the shop page. In your directory follow your directory to this location

wp-content/plugins/woocommerce/templates/content-product.php

And find this code:

<li <?php post_class( $classes ); ?>>   

<?php do_action( 'woocommerce_before_shop_loop_item' ); ?>

<a href="<?php the_permalink(); ?>">

    <?php
          do_action( 'woocommerce_before_shop_loop_item_title' );
    ?>

    <h3><?php the_title(); ?></h3>

    <?php
          do_action( 'woocommerce_after_shop_loop_item_title' );
    ?>

</a>

<?php do_action( 'woocommerce_after_shop_loop_item' ); ?>

 </li>

replace it with :

<li <?php post_class( $classes ); ?>>

    <h3><?php the_title(); ?></h3>

<?php do_action( 'woocommerce_before_shop_loop_item' ); ?>

<a href="<?php the_permalink(); ?>">

    <?php
          do_action( 'woocommerce_before_shop_loop_item_title' );
    ?>

    <?php
          do_action( 'woocommerce_after_shop_loop_item_title' );
    ?>

</a>

<?php do_action( 'woocommerce_after_shop_loop_item' ); ?>

 </li>

Lastly, work the css to line it up the way you want it. Like I said, not every template is created equal. This is a general fix for this issue. But it shouldn't be too far from the actual fix. You may consider checking the space you have above the image and again, allow css to modify this part

Другие советы

Actually I think the best way to do this is:

remove_action( 'woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_title' );
add_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_title', 5 );
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top