Home Forums General Issues dynamic page


dynamic page

  • 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 :

    		$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

    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]'

    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 ?

  • Hi @virtualexpo

    You’ve not posted enough code to understand what’s going on here..
    There’s no reference to $postId other than where you use it in your shortcode.

    You could post the entirety of your code on a service like so it can be better viewed 🙂

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘dynamic page’ is closed to new replies.