Cześć,
mama stronę na WP z CPT , zbudowana na Elementorze . CPT z ACF . Wyswietlam kilka postów na stroie główenj za pomoca shortcode i wyświetlanie działa ok , ale nie moge niestety edytowac strony w elementorze , podczas gdy shortcode jest aktywny .
Komunikat: "Przepraszamy , nie odnaleziono obszaru treści na twojej stronie . Aby móc używac elementora musisz wywołać funkcje the_content()" , którą to funkcje oczywiście wywołuję.
Kod shortcode poniżej. Jeśli ktos ma jakąś wiedze na ten temat to bardzo bym prosił o pomoc. Dziękuje z góry.
// Shortcode do wyswietlania prodktów
add_shortcode( 'lista-produktow', 'wyswietl_produkty_shortcode' );
function wyswietl_produkty_shortcode( $atts ) {
ob_start();
$query = new WP_Query( array(
'post_type' => 'produkty_mktest',
'posts_per_page' =>3,
'order' => 'ASC',
'orderby' => 'title',
) );
if ( $query->have_posts() ) { ?>
<?php /* Start the Loop */
while ( $query->have_posts() ) : $query->the_post(); ?>
<div class="row product-list-sn-row">
<div class="product-list-sn-wrap row">
<div class="col-sm-4">
<div class="product-thumb-sn">
<?php the_post_thumbnail(); ?>
</div>
</div>
<div class="col-sm-8">
<h3> <?php the_title(); ?></h3>
<h5 class="kategory-name-loop-sn">
<?php // Get terms for post
$terms = get_the_terms( $post->ID , 'kategoria_produktu' );
// Loop over each item since it's an array
if ( $terms != null ){
foreach( $terms as $term ) {
// Print the name method from $term which is an OBJECT
print 'Kategoria: '.$term->slug ;
// Get rid of the other data stored in the object, since it's not needed
unset($term);
} } ?>
</h5>
<p class="product-desc-sn">
<?php
$excerpt = wp_trim_words( get_field('opis_lista_single' ),
$num_words = 20, $more = '...' );
echo $excerpt;
?>
</p>
<a class="btn btn-primary" href="<?php the_permalink(); ?>">Szczegóły</a>
</div>
</div>
<div class="blue-33-back"></div>
</div>
<?php endwhile; ?>
<?php $lista_produktow = ob_get_clean();
return $lista_produktow;
}
}