如何拉链接并放入href?

时间:2016-05-24 06:48:40

标签: php wordpress themes

我有一个网站,我正在尝试填充链接。现在,如果从计算机上查看网站,你会看到有一个带文字的浮动框,然后遍布地图上的点。如果将鼠标悬停在其中一个点上,则会显示该网站的名称以及相关的时间段。

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 个答案:

答案 0 :(得分:0)

尝试

<?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();
?>

我在标题中添加了链接,然后使用get_the_permalink()函数拉出固定链接。