在自定义WordPress主题中,我正在使用WP_Query在主页上提取自定义帖子类型信息。我将一些数据存储在变量中,结束自定义查询和循环,重置查询,然后稍后在页面中调用变量。
o嵌入适用于单个帖子页面上的自定义帖子类型。但是,在主页上,例如,如果我包含YouTube链接,则当我通过变量获取自定义帖子类型内容时,oEmbed不起作用。
以这种方式存储内容是否会绕过 oEmbed?我无法找到关于此的具体对话。
您可以在此处查看主页模板:
<?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 -->
。其他神奇的事情发生了,然后...
<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(); ?>
干杯
听起来你在the_content
中filter/shortcode
,尝试其中之一,我相信问题会得到解决,apply_filters
$NPOcontent = apply_filters('the_content', get_the_content());
或使用do_shortcode
$NPOcontent = do_shortcode(get_the_content());