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');
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 vmware exsi重置后的密码
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?
  • ¥15 电磁场的matlab仿真
  • ¥15 mars2d在vue3中的引入问题
  • ¥50 h5唤醒支付宝并跳转至向小荷包转账界面