Last active
October 14, 2015 05:27
-
-
Save kheniparth/aace4c42698261b8ae8f to your computer and use it in GitHub Desktop.
Redirect From WordPress Widget to URL in excerpt of the post.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$excerpt = get_the_excerpt(); | |
$categories = get_the_category(); | |
$cat = ""; | |
$flag1=false; | |
$flag2=false; | |
if ( ! empty( $categories ) ) { | |
$cat=esc_html( $categories[0]->name ); | |
echo "Category=".$cat."</br>"; | |
if($cat == "News"){ | |
$flag1=true; | |
} | |
} | |
if (filter_var($excerpt, FILTER_VALIDATE_URL)) { | |
echo "Excerpt is Url = ".$excerpt; | |
$flag2=true; | |
} | |
else{ | |
echo "excerpt is not url"; | |
} | |
if($flag1 == true && $flag2 == true) | |
{ | |
echo "</br>Hurrrayyyy</br>"; | |
if(is_single()){ | |
echo '<script type="text/javascript">'; | |
echo 'window.location="'.$excerpt.'";'; | |
echo '</script>'; | |
} | |
} | |
else{ | |
echo "</br>:(</br>"; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment