Hello !
I tried to make custom field working in a page which including multiple query loop of article.
I declare my $variable
($magazine = get_field(‘edition’, ‘option’);) just after the header.
She is working in my first loop post :
<?php
$args = array(
'post_type' => 'cover',
'posts_per_page' => 1,
'magazine' => $magazine
);
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
$src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), array( 5600,1000 ), false, '' );?>
/// content
endwhile;?>
But when i try to use
($postId = get_field(‘postId ‘, ‘option’);) ,
outside this loop, it doesn”t work
Here my code :
<article class="container">
<?php echo do_shortcode(
'[blog post_type="article-long" blog layout="articleexcerptsharing" limit="1" include="'.$postId.'" ///etc///][/blog]'
);?>
</article>
I have to dynamized the short code with acf to enable the possibility of compose a list of article by ID thought the back office.
I don’t understand why my $variable only work inside a loop of post, but not in the global page.
Can you give me some advice please ?