diff --git a/.gitignore b/.gitignore index 2b321c9..724019b 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ sass/_notes/dwsync.xml css/_notes/dwsync.xml js/_notes/dwsync.xml +/nbproject/private/ \ No newline at end of file diff --git a/functions.php b/functions.php index e4c7e07..f6c88e5 100644 --- a/functions.php +++ b/functions.php @@ -315,6 +315,23 @@ else{ } } +function external_link_for_posts( $url, $post, $leavename=false ) { + if (get_field('external_url') && $post->post_type == 'post') { + $url = get_field('external_url'); + } + return $url; +} +add_filter( 'post_link', 'external_link_for_posts', 10, 3 ); + +function redirect_if_external_url(){ + $post_types = array('post'); + if (get_field('external_url') && is_singular($post_types)) { + wp_redirect(get_field('external_url')); + exit; + } +} +add_action('template_redirect', 'redirect_if_external_url'); + //function report_blank_alt() { // mail('joshua.roy@uconn.edu', 'Empty Alt Tag', 'Image with empty alt tag found at '.$_POST['location'].' on image '.$_POST['image']); //}