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 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
  • ¥60 pb数据库修改与连接
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab