$post variable isn’t exist in WP_Query Loop in Unyson framework.

I need to retrive most_meta from my Custom Query, I need function argument (postID), but in my Loop global variable $post doesn’t have anything.

I used Unyson framework(Page Builder Extension) to create shortcode View.
In my opinion it could be situation when this variable uses to create pages from shortcodes, wich were made with this extension.

Read More

I used this Loop outside the Unyson framework and it worked. I spent one day trying for realise the problem before write here, I dont have ideas and I don’t want to make site again with another framework.

            $args = array(
                'post_type' => 'elements',

            );
            $query = new WP_Query( $args );


            if($query->have_posts()):
                while( $query->have_posts()):
                    $query->the_post(); ?>

            <!--GRAPHIC DESIGN PART-->
            <div class="services__element--wrapper animate ">

                <div class="col-md-3 col-sm-6">
                    <i class="services__what-can-i-do--icon">
                        <?php echo $post->ID; ?> // nothing has shown

                    </i>
                    <h5 class="services__what-can-i-do--under-header"><?php the_title(); // work correcty?></h5>
                    <p class="services__what-can-i-do-text"><?php echo the_excerpt(); //work correcty?></p>
                </div>
            </div>
            <!--GRAPHIC DESIGN PART-->

Related posts

Leave a Reply

1 comment

  1. Just use get_the_ID while in the loop like: $post_id = get_the_ID();

    $args = array(
        'post_type' => 'elements',
    
    );
    $query = new WP_Query( $args );
    
    
    if($query->have_posts()):
        while( $query->have_posts()):
            $query->the_post(); ?>
    
            $post_id = get_the_ID();
    
    <!--GRAPHIC DESIGN PART-->
    <div class="services__element--wrapper animate ">
    
        <div class="col-md-3 col-sm-6">
            <i class="services__what-can-i-do--icon">
                <?php echo $post->ID; ?> // nothing has shown
    
            </i>
            <h5 class="services__what-can-i-do--under-header"><?php the_title(); // work correcty?></h5>
            <p class="services__what-can-i-do-text"><?php echo the_excerpt(); //work correcty?></p>
        </div>
    </div>
    <!--GRAPHIC DESIGN PART-->