Home › Forums › General Issues › Why is control by metabox, when i need control by ACF ?
Hi , all
I have issue on my page, I am on posts and every post control metabox, but i need ACF inside blocks for control, whats a problem pls ?
Problem is i cannot change photo or text….from ACF…everything control metaboxes ?
This is loop:
<?php
/**
* Sekce novinky 2 blog
*
**/
$id = 'novinky2-' . $block['id'];
if( !empty($block['anchor']) ) {
$id = $block['anchor'];
}
// Create class attribute allowing for custom "className" and "align" values.
$className = 'novinky2';
if( !empty($block['className']) ) {
$className .= ' ' . $block['className'];
}
if( !empty($block['align']) ) {
$className .= ' align' . $block['align'];
}
$nadpisdark = get_field('nadpis_novinek') ?: '';
?>
<section id="<?php echo esc_attr($id); ?>" class="novinky-detail <?php echo esc_attr($className); ?>">
<div class="container">
<div class="row">
<div class="col-12">
<h2 class="h2dark"><?php echo $nadpisdark; ?></h2>
</div>
</div>
</div>
<div class="container">
<div class="row">
<?php
$pocetprispevku = get_field('pocet_prispevku_novinek') ?: '2';
$args = array(
'posts_per_page' => $pocetprispevku,
'post_type' => 'post',
'orderby' => 'publish_date',
'order' => 'DESC'
);
// query
$the_query = new WP_Query( $args );
?>
<?php if( $the_query->have_posts() ): ?>
<?php while( $the_query->have_posts() ) : $the_query->the_post(); ?>
<?php
global $post;
?>
<div class="col-12 col-sm-12 col-md-6 col-lg-12 col-xl-6">
<a class="product-card-clanky" href="<?php the_permalink(); ?>">
<div class="hero-left">
<div class="product-card__image">
<div class="img-container">
<?php
$obrazek = get_field('obrazek_pro_vypis', get_the_ID());
?>
<img src="<?php echo $obrazek['url']; ?>" alt="<?php echo the_title(); ?>" title="<?php echo $obrazek['title']; ?>" />
</div>
</div>
</div>
<div class="hero-content">
<div class="product-card__head">
<h2 class="h2dark-xs"><?php the_title(); ?></h2>
</div>
<div class="product-card__body mb-3">
<?php $excerpt = wp_trim_words( get_field('novinky_text', get_the_ID()) , $num_words = 14, $more = '...' ); ?>
<p class="popisek-sekce"><?php echo $excerpt; ?></p>
</div>
<div class="product-card-info mt-2 mb-2">
<span class="read-more" href="<?php the_permalink(); ?>"> Číst více </span>
</div>
</div>
</a>
</div>
<?php endwhile; ?>
<?php endif; ?>
<?php wp_reset_query(); // Restore global post data stomped by the_post(). ?>
</div>
</div>
When i do not use block, and target acf fields to posts….then its working normally….
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
🤔 Curious about the ACF user experience? So are we! Help guide the evolution of ACF by taking part in our first ever Annual Survey and guarantee you’re represented in the results. https://t.co/0cgr9ZFOJ5
— Advanced Custom Fields (@wp_acf) May 8, 2023
© 2023 Advanced Custom Fields.
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.