Wednesday, 26 December 2018

Check requested url for a text pattern then do something

I am using the code below to execute video shortcode on my WordPress website but some pages already contain manually added video which will cause duplicate when i use the code.

How can include a check if the page already contain a YouTube embedded iframe or video link and exclude pages which already have videos, here is what i have below:

if (is_single() && in_category(1) ) 
{
 echo '<h4 class="post-title entry-title">Video</h4>' ;
 echo do_shortcode( '[yotuwp type="keyword" id="'.get_post_field( 'post_title', $post_id, 'raw' ).'" player="mode=large" template="mix" column="1" per_page="1"]' );
}

I want to include youtube link check here:

 if (is_single() && in_category(1)

Here is what i am able to find Here but this scans the requested url instead of the content on it:

<?php
  if (stripos($_SERVER['REQUEST_URI'],'tout') == true && stripos($_SERVER['REQUEST_URI'],'dedans') == true) 
    {echo '<div class="clear"></div><a href="http://www.example.com/cakes/" class="btn"> >> View all Cakes</a>';}
?>



from Check requested url for a text pattern then do something

No comments:

Post a Comment