WordPress gets and outputs the first link of the article

» WordPress » WordPress gets and outputs the first link of the article

Many people can get the first picture of the article from WordPress, but it seems that they haven't seen the first link of the article from WordPress. Today Cloudfall shares the results of today's struggle

 WordPress gets and outputs the first link of the article - Geek Park

preface

function code

Put the following code into the topic functions.php In file

 function get_link_url() { $content = get_the_content(); $has_url = get_url_in_content( $content ); return ( $has_url ) ? $ has_url : apply_filters( 'the_permalink', get_permalink() ); }

When using <? php echo get_link_url();?> Output.

--End--

Post reply

Your email address will not be disclosed. Required items have been used * tagging