WordPress oEmbed not working for get_the_content() stored in variable

In a custom WordPress theme, I am using WP_Query to pull custom post type info on the home page. I am storing some data in variables, ending the custom query and loop, resetting the query, and then calling the variables later in the page.

oEmbed is working for the custom post types on the single post pages. On the home page, though, if I include a YouTube link for instance, oEmbed does not work when I get the custom post type content through the variable.

Read More

Does storing content in this way bypass oEmbed? I haven’t been able to find a specific conversation on this.

You can see the home page template here:

<?php
/*
Template Name: Home
*/
get_header(); 
?>

<!-- Row for main content area -->
        <section id="top">
            <div class="row">
                <article id="npo-info" class="small-12 small-centered large-6 large-uncentered columns">
                    <?php // loop for latest weekly NPO to store info for later use
                        $args = array( 'post_type' => 'weeklyNPO', 'posts_per_page' => 1 );
                        $loop = new WP_Query( $args );
                        while ( $loop->have_posts() ) : $loop->the_post();
                                $NPOtitle = get_the_title();
                                $NPOcontent = get_the_content();
                                $NPOexcerpt = get_the_excerpt();
                                $NPOthumbnail = get_the_post_thumbnail();
                                $NPOid = get_the_ID();
                        endwhile;
                    ?>
                    <header>
                        <h4>Karmasapien presents</h4>
                        <h1><?php echo $NPOtitle; ?></h1>
                    </header>
                    <section>
                        <p><?php echo $NPOexcerpt; ?></p>
                        <hr/>
                        <label><p>Because Giving Feels Good</p></label>
                        <?php dynamic_sidebar( 'Donation Progress Bar' ); ?>
                        <?php the_meta(); ?>
                        <?php wp_reset_query(); ?>
                    </section>
                    <footer>
                        <em id="ks-clock" src=""></em>
                        <?php echo do_shortcode( '[fergcorp_cdt max=1]' ); ?>
                    </footer>
                </article>
            </div>
        </section> <!-- end top -->

…other magical things happen, and then…

        <section id="weekly-npo">
            <div class="image-bg"></div>
            <div class="row">
                <article <?php post_class('small-12 small-centered large-10 columns') ?>>
                    <header>
                        <h2>More About <?php echo $NPOtitle; ?></h2>
                    </header>
                    <section>
                        <?php echo $NPOcontent; ?>
                    </section>
                    <hr/>
                    <footer class="row">
                        <div class="small-5 small-centered large-3 columns">
                            <?php echo $NPOthumbnail; ?>
                        </div>                    
                    </footer>
                </article>
            </div>
        </section>

<?php get_footer(); ?>

Cheers,

Related posts

Leave a Reply

1 comment