Created
November 6, 2015 03:13
-
-
Save levantoan/f608c4dadee6886c460f to your computer and use it in GitHub Desktop.
Chuyển hướng tới trang khác khi post có shortcode nào đó
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 | |
function my_page_template_redirect(){ | |
global $post; | |
if( is_a( $post, 'WP_Post' ) && has_shortcode( $post->post_content, 'your_short_code') && ! is_user_logged_in() ) { | |
wp_redirect(URL_IN_HERE); | |
exit(); | |
} | |
} | |
add_action( 'template_redirect', 'my_page_template_redirect' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment