duanduan8439 2017-09-14 02:05
浏览 23
已采纳

我的WP LOOP脚本中的Ghost post_title

The code below is displaying the title in black text before it displays blue title with hyperlink under it.

I only want the link to appear.

if ( $query2->have_posts() ) {
    // The 2nd Loop
    while ( $query2->have_posts() ) {
        $query2->the_post();
                 if ($post->ID == $do_not_duplicate)
                continue;
                $permalink = get_the_permalink($query2->post->ID);
                $ID = $post->ID;
                $titleAtribute = the_title_attribute();
                $title = get_the_title();
        echo '<h2 id="post-' .$ID.' ">
                <a href="'.$permalink.'" rel="bookmark" title="Permanent Link to '.$permalink.' ">
                   '.$title.'</a></h2>';
    }

    // Restore original Post Data
    wp_reset_postdata();
}

For example, on my website: http://skkelti.cz/, the following text appears in black above the link with the same text:

-Martin Davídek ml. : „Fanoušci jsou vždy to, co vás žene kupředu“-

Where is this coming from and what do I need to do to stop it from appearing?

  • 写回答

1条回答 默认 最新

  • dth54864 2017-09-14 03:02
    关注

    The problem is with the_title_attribute(). This is displaying the value directly instead of returning it.

    The function accepts echo in $args to specify whether to display or return the value. The default value is true (to display it), so pass false to return the value e.g.:

    $titleAtribute = the_title_attribute('echo=0');
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型