Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

263
Visualizações
Move title & ratings above image gallery on mobile devices in Woocommerce

I am trying to move my title and ratings above the image gallery in woocommerce but only on mobile. Desktop version should remain the same.

I found a php code that i pasted in my theme's functions.php and it does the job but it moves them above on desktop as well.

Any way to run this php code only on mobile?

function product_change_title_position() {
    remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
    add_action( 'woocommerce_before_single_product', 'woocommerce_template_single_title', 5 );
}

add_action( 'init', 'product_change_title_position' );

function product_change_rating_position() {
    remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_rating', 10 );
    add_action( 'woocommerce_before_single_product', 'woocommerce_template_single_rating', 5 );
}

add_action( 'init', 'product_change_rating_position' );

Thanks
Vaibhav

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Wordpress provides a function called wp_is_mobileDocs, which allows you to do what you're looking for:

add_action('init', 'product_change_title_position');

function product_change_title_position()
{
    if (wp_is_mobile()) 
    {
        remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_title', 5);
        add_action('woocommerce_before_single_product', 'woocommerce_template_single_title', 5);
    }
}

add_action('init', 'product_change_rating_position');

function product_change_rating_position()
{
    if (wp_is_mobile()) 
    {
        remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_rating', 10);
        add_action('woocommerce_before_single_product', 'woocommerce_template_single_rating', 5);
    }
}

Note:

  • "It works through the detection of the browser user agent string ($_SERVER[‘HTTP_USER_AGENT’])."
  • "This function will return true for a tablet, as it too is considered a mobile device. It is not a substitute for CSS media queries or styling per platform."
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda