Hello WillBontrager,
I did try your suggestion, here is what I did…
1. Deactivate all plugins except “Insert PHP (Your Plugin)” AND “Woocommerce (Because I was querying its products)”.
2. Apply wordpress default theme (Twenty Sixteen).
3. Did Execute this simple code
[insert_php]
$args = array(
'post_type' => 'product',
'posts_per_page' => -1,
'product_cat' => 'armour-suits-helmets'
);
$loop = new WP_Query( $args );
if ( $loop->have_posts() ) {
while ( $loop->have_posts() ) : $loop->the_post();
echo '<a href="'.the_permalink().'">'.the_title().'<br>';
endwhile;
}
wp_reset_postdata();
[/insert_php]
OUTPUT
https://localhost:85/media/product/product1/Product1
https://localhost:85/media/product/product2/Product2
https://localhost:85/media/product/product3/Product3
https://localhost:85/media/product/product4/Product4
Then I did one change in code. I did replace “the_permalink()” functions with static url (https://www.google.com) just for testing purpose. And I get this output
Poduct1
Poduct2
Poduct3
Poduct4
Conclusion:
When I did use “the_permalink()” function in anchor tag to get url dynamically then output got messy But when I did use static url instead of “the_permalink()” function then output was correct. But problem is I can’t use static url inside while loop!
Please do a test by yourself to understand what I mean (in case if my explanation is not understandable).
Any suggestions, what should I do?