douju8782 2015-10-09 11:23
浏览 134
已采纳

PHP使用$ out回显自定义字段

i am using the Favorites plugin in Wordpress to save posts. I'm trying to adjust the way the information is displayed though. All the styling etc works below and my divs are being included, however i am struggling to pull information through to fill the divs. Fore example, i am trying to pull the excerpt in to the p.details but it is just throwing out an empty result, with no errors. Similarly, i am trying to pull through an acf custom field of 'bath' into p.bath but that is also empty. Any suggestions? Thanks in advance.

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>';
    }
  • 写回答

1条回答 默认 最新

  • dongyue8640 2015-10-09 13:19
    关注

    Change the_excerpt(); to get_the_excerpt(); and it should work.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序