Skip to content
This repository has been archived by the owner. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Posts with the external_url custom field set will use that for the ur…
…l. Trying to access a post with the external_url set will automatically redirect you to the set url.
  • Loading branch information
Zurawel committed Dec 4, 2018
1 parent 2ecfced commit 6986f8c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -16,3 +16,4 @@ sass/_notes/dwsync.xml
css/_notes/dwsync.xml

js/_notes/dwsync.xml
/nbproject/private/
17 changes: 17 additions & 0 deletions functions.php
Expand Up @@ -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']);
//}
Expand Down

0 comments on commit 6986f8c

Please sign in to comment.