Skip to content

Instantly share code, notes, and snippets.

@kheniparth
Last active October 14, 2015 05:27
Show Gist options
  • Save kheniparth/aace4c42698261b8ae8f to your computer and use it in GitHub Desktop.
Save kheniparth/aace4c42698261b8ae8f to your computer and use it in GitHub Desktop.
Redirect From WordPress Widget to URL in excerpt of the post.
<?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