PHP 用 $out 回显自定义字段
PHP echo custom fields with $out
我正在使用 Wordpress 中的收藏夹插件来保存帖子。我正在尝试调整信息的显示方式。所有样式等都在下面工作,我的 div 也被包括在内,但是我正在努力通过拉动信息来填充 div。例如,我试图将摘录拉入 p.details 但它只是抛出一个空结果,没有错误。同样,我试图将 'bath' 的 acf 自定义字段拉入 p.bath,但它也是空的。有什么建议么?提前致谢。
if ( is_multisite() ) switch_to_blog($this->site_id);
$out = '<ul class="property-list" data-userid="' . $this->user_id . '" data-links="true" data-siteid="' . $this->site_id . '" ';
$out .= ( $include_button ) ? 'data-includebuttons="true"' : 'data-includebuttons="false"';
$out .= ( $this->links ) ? ' data-includelinks="true"' : ' data-includelinks="false"';
$out .= ' data-nofavoritestext="' . $no_favorites . '"';
$out .= ' data-posttype="' . $post_types . '"';
$out .= '>';
foreach ( $favorites as $key => $favorite ){
$out .= '<li data-postid="' . $favorite . '">';
$out .= '<div class="third-1">';
$out .= '<a class="property-thumb" href="' . get_permalink($favorite) . '">';
$out .= '</a>';
$out .= '</div>';
$out .= '<div class="third-2">';
if ( $this->links ) $out .= '<h3 class="name"><a href="' . get_permalink($favorite) . '">';
$out .= get_the_title($favorite);
if ( $this->links ) $out .= '</a></h3>';
if ( $this->links ) $out .= '<h4 class="price">';
$out .= '£' . '300';
if ( $this->links ) $out .= '</h4>';
if ( $this->links ) $out .= '<p class="details">';
$out .= the_excerpt();
if ( $this->links ) $out .= '</p>';
if ( $this->links ) $out .= '<p class="bed">';
$out .= '1';
if ( $this->links ) $out .= '</p>';
if ( $this->links ) $out .= '<p class="bath">';
$out .= '1';
if ( $this->links ) $out .= '</p>';
if ( $this->links ) $out .= '<a class="full-details" href="' . get_permalink($favorite) . '">';
$out .= 'Full details';
if ( $this->links ) $out .= '</a>';
if ( $this->links ) $out .= '<a class="book-viewing" href="' . get_permalink($favorite) . '">';
$out .= 'Book Viewing';
if ( $this->links ) $out .= '</a>';
$out .= '</div>';
$out .= '</li>';
}
将 the_excerpt();
更改为 get_the_excerpt();
,它 应该 有效。
我正在使用 Wordpress 中的收藏夹插件来保存帖子。我正在尝试调整信息的显示方式。所有样式等都在下面工作,我的 div 也被包括在内,但是我正在努力通过拉动信息来填充 div。例如,我试图将摘录拉入 p.details 但它只是抛出一个空结果,没有错误。同样,我试图将 'bath' 的 acf 自定义字段拉入 p.bath,但它也是空的。有什么建议么?提前致谢。
if ( is_multisite() ) switch_to_blog($this->site_id);
$out = '<ul class="property-list" data-userid="' . $this->user_id . '" data-links="true" data-siteid="' . $this->site_id . '" ';
$out .= ( $include_button ) ? 'data-includebuttons="true"' : 'data-includebuttons="false"';
$out .= ( $this->links ) ? ' data-includelinks="true"' : ' data-includelinks="false"';
$out .= ' data-nofavoritestext="' . $no_favorites . '"';
$out .= ' data-posttype="' . $post_types . '"';
$out .= '>';
foreach ( $favorites as $key => $favorite ){
$out .= '<li data-postid="' . $favorite . '">';
$out .= '<div class="third-1">';
$out .= '<a class="property-thumb" href="' . get_permalink($favorite) . '">';
$out .= '</a>';
$out .= '</div>';
$out .= '<div class="third-2">';
if ( $this->links ) $out .= '<h3 class="name"><a href="' . get_permalink($favorite) . '">';
$out .= get_the_title($favorite);
if ( $this->links ) $out .= '</a></h3>';
if ( $this->links ) $out .= '<h4 class="price">';
$out .= '£' . '300';
if ( $this->links ) $out .= '</h4>';
if ( $this->links ) $out .= '<p class="details">';
$out .= the_excerpt();
if ( $this->links ) $out .= '</p>';
if ( $this->links ) $out .= '<p class="bed">';
$out .= '1';
if ( $this->links ) $out .= '</p>';
if ( $this->links ) $out .= '<p class="bath">';
$out .= '1';
if ( $this->links ) $out .= '</p>';
if ( $this->links ) $out .= '<a class="full-details" href="' . get_permalink($favorite) . '">';
$out .= 'Full details';
if ( $this->links ) $out .= '</a>';
if ( $this->links ) $out .= '<a class="book-viewing" href="' . get_permalink($favorite) . '">';
$out .= 'Book Viewing';
if ( $this->links ) $out .= '</a>';
$out .= '</div>';
$out .= '</li>';
}
将 the_excerpt();
更改为 get_the_excerpt();
,它 应该 有效。