Here is my code:
global $post; $args = array( 'posts_per_page' => -1, 'post_type' => 'post', ); $the_query = new WP_Query( $args ); $array = get_object_vars($the_query); //convert the object into an array (manual workaround) if ( $the_query->have_posts() ) : $count = 0; //start an iteration count while ( $the_query->have_posts() ) : ?> <? $the_query->the_post(); ?> <?php $postarray = get_object_vars($array['posts'][$count]); //convert the post object into an array ?> <div class="row"> <div class="col-md-6"> <div class="card"> <h4><?php echo get_the_title(); ?></h4> <p><?php echo get_the_excerpt(); ?></p> <?php the_permalink() ?> <!-- the guid is now accessable --> <a href="<?php echo $postarray['guid']; ?>">Read More</a> </div> </div> </div> <? endwhile; else : echo wpautop( 'Sorry, no posts were found' ); endif;
I have referenced other questions about this, however my
global $post; IS outside the loop (as referenced from Post Loop not Returning Permalink) and I have also already tried using the range of functions for grabbing/showing the permalink and guid value (as referenced from
also its worth noting that
get_the_ID() returned the currently viewed page id NOT the iterated post id
also this is all contained within a shortcode function.
any help is greatly appreciated :)