我正在开发一个插件,可以创建和显示自定义帖子类型。我将ACF用于其他字段。
当我需要将实际内容添加到过滤器中时,问题就出现了。普通wysiwyg编辑器中有一个幻灯片,需要在那里显示。请参见屏幕抓图。
是否有办法在使用\\u内容的筛选器中显示\\u内容?还是有其他的编码方式?
这是我的代码:
add_filter(\'the_content\', \'fds_the_content\');
function fds_the_content( $content ) {
if (is_singular( \'services\' ) && in_the_loop()) {
ob_start(); ?>
<div class="fds-top">
<div id="top-content" class="contain-columns">
<div id="portfolio" class="m-all t-2of3 d-3of4 gl">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="slideshow">
<section class="entry-content cf">
<?php the_content(); ?>
</section> <!-- end article section -->
</div>
<?php endwhile; ?>
<?php else : ?>
<?php endif; ?>
</div> <!-- end #portfolio -->
<div class="2-percent"></div> <!-- What a hack! -->
<div id="service-sidebar" class="m-all t-1of3 d-1of4 gl">
<h2>Recent
<?php
$category = get_the_category();
echo $category[0]->cat_name;
?>
</h2>
<?php
global $post;
$categories = get_the_category();
foreach ($categories as $category) :
?>
<?php
// The Query
$the_query = new WP_Query(
array(
\'posts_per_page\' => 2,
\'category__and\' => array( $category->term_id ) ) );
?>
<?php if ( $the_query->have_posts() ) : ?>
<!-- the loop -->
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<a class="recent-post" href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>" >
<div class="recent-thumb"><?php the_post_thumbnail(\'medium\'); ?></div>
<h3 class="recent-blog-title-desktop"><?php the_title(); ?></h3>
</a>
<?php endwhile;
wp_reset_query(); ?>
<!-- end of the loop -->
<!-- pagination here -->
<?php wp_reset_postdata(); ?>
<?php else: ?>
<p><?php _e( \'Sorry, no posts matched your criteria.\' ); ?></p>
<?php endif; ?>
<?php endforeach; ?>
</div>
</div>
<div class="clear"></div>
<div id="midriff" class="contain-columns">
<div id="service-info" class="m-all t-all d-all gl">
<header class="article-header">
<h1 class="single-title custom-post-type-title"><?php the_title(); ?></h1>
</header>
<section class="entry-content cf">
<div class="segment">
<div class="segment-photo-left">
<?php
$image = get_field(\'general_photo\');
$size = \'medium\'; // (thumbnail, medium, large, full or custom size)
if( $image ) {
echo wp_get_attachment_image( $image, $size );
}
?>
</div>
<div class="segment-text"><?php the_field(\'general_info\'); ?></div>
</div>
<div class="segment">
<h2>Rates</h2>
<div class="segment-photo-right">
<?php
$image = get_field(\'rates_photo\');
$size = \'medium\'; // (thumbnail, medium, large, full or custom size)
if( $image ) {
echo wp_get_attachment_image( $image, $size );
}
?>
</div>
<div class="segment-text"><?php the_field(\'rates\'); ?></div>
</div>
<div class="segment">
<h2>Areas Served</h2>
<div class="segment-photo-left">
<?php
$image = get_field(\'areas_served_photo\');
$size = \'medium\'; // (thumbnail, medium, large, full or custom size)
if( $image ) {
echo wp_get_attachment_image( $image, $size );
}
?>
</div>
<div class="segment-text"><?php the_field(\'areas_served\'); ?></div>
</div>
<div class="segment">
<h2>Kind Words</h2>
<?php
// args
$args = array(
\'posts_per_page\' => 1,
\'post_type\' => \'reviews\',
\'meta_key\' => \'review\',
\'orderby\' => \'rand\'
);
// get results
$the_query = new WP_Query( $args );
// The Loop
?>
<?php if( $the_query->have_posts() ): ?>
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<blockquote>
<?php the_field(\'review\'); ?>
</blockquote>
<h3 class="client-sig">~<?php the_field(\'review_client_name\'); ?></h3>
<?php endwhile; ?>
<?php endif; ?>
<?php wp_reset_query(); // Restore global post data stomped by the_post(). ?>
</div>
<div class="segment">
<h2>Contact</h2>
<div class="segment-photo-right">
<?php
$image = get_field(\'contact_photo\');
$size = \'medium\'; // (thumbnail, medium, large, full or custom size)
if( $image ) {
echo wp_get_attachment_image( $image, $size );
}
?>
</div>
<div class="segment-text"><?php the_field(\'contact\'); ?></div>
</div>
</section>
</div> <!-- End #service-info -->
</div>
</div>
</div>
<?php
echo ob_get_clean();
}
return $content;
}