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

276
Visualizações
Elementor displays the same shortcode twice (only on editor)

Elementor displays the same shortcode twice. One in the place where the shortcode is placed, the other right behind the header. The problem only occurs in the editor. On the page, it displays normally. Please help. How can i fix it?

    function display_grid_func ( $atts ){
echo '<div class="post-grid">';
    $args = array(
        'post_type' => 'realizacje',
        'post_status' => 'publish',
        'posts_per_page' => 9,
        'cat' => 5
    );

    $loop = new WP_Query($args);

    while ($loop->have_posts()) : $loop->the_post(); ?>

        <div class="post-tile home">
            <a href="<?php the_permalink(); ?>">
                <img src="<?php the_post_thumbnail_url('tile-foto'); ?>" />
            </a>
                <a class="button-zobacz home" href="<?php the_permalink(); ?>">Zobacz &#8594;</a>
            
        </div>

    <?php endwhile;
    wp_reset_postdata();?><?php
    echo '</div>';
}

add_shortcode('post_grid', 'display_grid_func');

What I have tried so far: -I change the theme -I turned off all plugins -I was looking on google

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

0

I solved the problem :) I used ob_start(); and return ob_get_clean();

function display_grid_func($atts)
{
    ob_start();
    echo '<div class="post-grid">';
    $args = array(
        'post_type' => 'realizacje',
        'post_status' => 'publish',
        'posts_per_page' => 9,
        'cat' => 5
    );

    $loop = new WP_Query($args);

    while ($loop->have_posts()) : $loop->the_post(); ?>

        <div class="post-tile home">
            <a href="<?php the_permalink(); ?>">
                <img src="<?php the_post_thumbnail_url('tile-foto'); ?>" />
            </a>
            <a class="button-zobacz home" href="<?php the_permalink(); ?>">Zobacz &#8594;</a>

        </div>

    <?php endwhile;
    wp_reset_postdata(); ?>
<?php echo '</div>';
    return ob_get_clean();
}

add_shortcode('post_grid', 'display_grid_func');
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