简体   繁体   中英

How to pull link and put into an 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();
?>

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM