Query shortcodes aren't working with custom fields

The press release section on my home page was created with a short code in the text element. The short code is from the “insert php code snippets plugin”. When we add in the text element with that short code, all sections from the bottom except the footer go missing. The reason we opted to use a third party plugin is because we couldn’t find out how to use a query shortcode form xthemes that allows customs filelds.
We reformatted the php an there are no errors in the console or php so I don’t understand why its having that behavior. The query is a custom query with a custom post type that is all in the insert php snippet shortcode. We had to remove the xthemes query shortcode because we cant add extra elements to loop items. So we had to use a third party shortcode with the entire query inside. And now again the only issue is the section after the query go missing. The sections show in the editor but do not show up on the live site. If this is not supported what can we do with the query shortcode from xthemes that allows custom fields? We are just trying to use a custom field within the loop. Here is the URL:http://specialnarcoticsp.sg-host.com. I also attached a secure note. Please advise. Thanks for your help.
Thank you.

Hello @Jennine,

Thanks for writing in! Instead of using the text element, kindly use the content area element, and then you can insert your shortcode. I am assuming that you are referring to this one:

[xyz-ips snippet="home-press"]

Kindly let us know how it goes.

Thanks for your response. Yes, that is the shortcode I am referring to. However, when using the content-area element I am still having the same issue where all the content below is gone. :frowning_face:

Hello @Jennine,

I have inspected your code and you have this:

<div class="x-row-inner flex-row">
    <?php
    $press_posts = new WP_Query();
    $press_posts->query('post_type=press&posts_per_page=3');
    while ($press_posts->have_posts()):
        $press_posts->the_post(); ?>

    <div class="e7-50 x-col press-col text-center" style="background-color:white">
        <span class="x-image pr-seal">
            <img
                alt="Image"
                width="124"
                height="124"
                data-src="http://specialnarcoticsp.sg-host.com/wp-content/uploads/2020/08/nav-logo.png"
                class="ls-is-cached lazyloaded"
                src="http://specialnarcoticsp.sg-host.com/wp-content/uploads/2020/08/nav-logo.png"
            />
            <noscript><img alt="Image" src="http://specialnarcoticsp.sg-host.com/wp-content/uploads/2020/08/nav-logo.png" width="124" height="124" /></noscript>
        </span>
        <div class="pr-content-wrapper">
            <div class="x-text pr-date">
                 <?php echo get_the_date(); ?>
            </div>

            <h1 class=" x-text" style="color: #0c0480;text-transform:uppercase;font-weight:600;font-size:16px;margin-top:10px;line-height:25px;">
               <?php the_title(); ?>
            </h1>

            <div class="e7-54 x-text excerpt-text">
              <?php the_excerpt(); ?>
            </div>
         </div>
  <div class="pr-links-wrapper">
                                    <a class="e7-55 x-anchor x-anchor-button pr-btn" tabindex="0" href="<?php the_permalink(); ?>" rel="noopener" target="_blank" aria-label="Read More (opens in a new tab)" style="outline: none;">
                                        <div class="x-anchor-content">
                                            <div class="x-anchor-text"><span class="x-anchor-text-primary">Read More</span></div>
                                        </div>
                                    </a>
                                    <?php
                                    $eps = get_post_meta(get_the_ID(), 'spanish-version', true);
                                    if (!empty($eps)): ?> 
                                    <div class="text-center spanish-link">
                                        <a href="<?php echo $eps; ?>" target="_blank">Version En Espa&#241;ol</a>
                                    </div>
                                <?php endif;
                                    ?>
                                </div>
           
        </div>
  
    <?php
    endwhile;
    ?>
</div>

As it turns out, you are using the WP_Query() incorrectly. You may need to reset the post data so that this new loop will not cause any conflict or issue to the rest of your page. We highly recommend that you go over to this codex instead:

And maybe check out this tutorial in creating a new loop.

Note: Be advised that custom coding is beyond the scope of our support. You may need to contact someone who can fix your loop in your shortcode. We are unable to provide support for customizations under our Support Policy.

Best Regards.

thank you that worked

You are most welcome @Jennine!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.