duannao3819 2016-05-24 06:48
浏览 13
已采纳

如何拉链接并放入href?

I have a website that I'm trying to populate with links. Right now, if you look at the website from the computer, you'll see that there's a floating box with text, then dots all over the map. If you hover over one of the dots, it will have the name of the site, along with the time period associated.

http://jeremynative.com/onthissite/

<?php
$i = 0;
while ( have_posts() ) : the_post();
    $et_location_lat = get_post_meta( get_the_ID(), '_et_listing_lat', true );
    $et_location_lng = get_post_meta( get_the_ID(), '_et_listing_lng', true );

    $et_location_rating = '<div class="location-rating"></div>';
    if ( ( $et_rating = et_get_rating() ) && 0 != $et_rating )
        $et_location_rating = '<div class="location-rating"><span class="et-rating"><span style="' . sprintf( 'width: %dpx;', esc_attr( $et_rating * 17 ) ) . '"></span></span></div>';

    if ( '' != $et_location_lat && '' != $et_location_lng ) {
?>




            et_add_marker( <?php printf( '%1$d, %2$s, %3$s, \'<div id="et_marker_%1$d" class="et_marker_info"><div class="location-description"> <div class="location-title"> <h2>%4$s </h2> <div class="listing-info"><p>%5$s</p></div> </div> ' . $et_location_rating . ' </div> <!-- .location-description --> </div> <!-- .et_marker_info -->\'',
                $i,
                esc_html( $et_location_lat ),
                esc_html( $et_location_lng ),
                get_the_title(),
                wp_strip_all_tags( addslashes( get_the_term_list( get_the_ID(), 'listing_type', '', ', ' ) ) )
            ); ?> );
<?php
    }

    $i++;
endwhile;

rewind_posts();
?>
  • 写回答

1条回答 默认 最新

  • dovgqc2648 2016-05-24 07:24
    关注

    Try with

    <?php
    $i = 0;
    while ( have_posts() ) : the_post();
        $et_location_lat = get_post_meta( get_the_ID(), '_et_listing_lat', true );
        $et_location_lng = get_post_meta( get_the_ID(), '_et_listing_lng', true );
    
        $et_location_rating = '<div class="location-rating"></div>';
        if ( ( $et_rating = et_get_rating() ) && 0 != $et_rating )
            $et_location_rating = '<div class="location-rating"><span class="et-rating"><span style="' . sprintf( 'width: %dpx;', esc_attr( $et_rating * 17 ) ) . '"></span></span></div>';
    
        if ( '' != $et_location_lat && '' != $et_location_lng ) {
    ?>
            et_add_marker( <?php printf( '%1$d, %2$s, %3$s, \'<div id="et_marker_%1$d" class="et_marker_info"><div class="location-description"> <div class="location-title"><h2><a href="%6$s">%4$s</a></h2><div class="listing-info"><p>%5$s</p></div> </div> ' . $et_location_rating . ' </div> <!-- .location-description --> </div> <!-- .et_marker_info -->\'',
                    $i,
                    esc_html( $et_location_lat ),
                    esc_html( $et_location_lng ),
                    get_the_title(),
                    wp_strip_all_tags( addslashes( get_the_term_list( get_the_ID(), 'listing_type', '', ', ' ) ) ),
                    get_the_permalink()
                ); ?> );
    <?php
        }
    
        $i++;
    endwhile;
    
    rewind_posts();
    ?>
    

    I added the link inside the title and then used get_the_permalink() function to pull the permalink in.

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

报告相同问题?

悬赏问题

  • ¥15 想用@vueuse 把项目动态改成深色主题,localStorge里面的vueuse-color-scheme一开始就给我改成了dark,不知道什么原因(相关搜索:背景颜色)
  • ¥20 OPENVPN连接问题
  • ¥15 flask实现搜索框访问数据库
  • ¥15 mrk3399刷完安卓11后投屏调试只能显示一个设备
  • ¥20 白日门传奇少一个启动区服和启动服务器的快捷键,东西都是全的 , 他们说套一个出来就行了 但我就是弄不好,谁看看,
  • ¥100 如何用js写一个游戏云存档
  • ¥15 ansys fluent计算闪退
  • ¥15 有关wireshark抓包的问题
  • ¥15 需要写计算过程,不要写代码,求解答,数据都在图上
  • ¥15 向数据表用newid方式插入GUID问题