Created
January 20, 2017 09:18
-
-
Save vanbaodo/44a26f8b1725d534c1ecf767f40b0596 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 | |
/* | |
Chuyển hướng tới trang khác khi post có shortcode nào đó | |
*/ | |
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