di477
di477

Reputation: 57

How to get the link of the_ID();

I got 4 posts in Wordpress. In those posts they can add a link from custom field.

I got this code:

$args = array( 'post_type' => 'post');

$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
the_ID();
endwhile;

$other_page = 1330; // variable
the_field('bloglink', $other_page);  // show link

The output is: 104013301196827, #link (I made an example for $other_page)

My question is: How can I use those id's to make a link?

Any help is appreciated

Upvotes: 1

Views: 94

Answers (1)

Zoli Szabó
Zoli Szabó

Reputation: 4534

get_the_ID() - Retrieve the ID of the current item in the WordPress Loop.

<?php

    $args = array( 'post_type' => 'post');

    $loop = new WP_Query( $args );
    while ( $loop->have_posts() ) : $loop->the_post();
        the_ID();
        the_field('bloglink', get_the_ID());  // show link
    endwhile;

?>

Upvotes: 1

Related Questions