This file contains 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
//* Customize Comment Policy | |
function modify_text_before_comment_form($arg) { | |
$arg['comment_notes_before'] = '<p class="comment-notes">' . __( 'Lưu ý:</br>> Không sử dụng từ khóa trong mục "Tên". </br>> Hãy sử dụng tên thật và địa chỉ email chính xác.</br>> Vui lòng bình luận bằng tiếng Việt có dấu.</br> Mọi bình luận trái quy định sẽ bị gỡ bỏ link hoặc xóa bỏ hoàn toàn.' ) . '</p>'; | |
return $arg; | |
} | |
add_filter('comment_form_defaults', 'modify_text_before_comment_form'); |
This file contains 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
//* Re-order posts list | |
function orderby_modified_posts( $query ) { | |
if ($query->is_main_query()) { | |
$query->set( 'orderby', 'modified' ); | |
} | |
} | |
add_action( 'pre_get_posts', 'orderby_modified_posts' ); |
This file contains 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
add_filter( 'preprocess_comment', 'minimal_comment_length' ); | |
function minimal_comment_length( $commentdata ) { | |
$minimalCommentLength = 20; | |
if ( strlen( trim( $commentdata['comment_content'] ) ) < $minimalCommentLength ){ | |
wp_die( 'All comments must be at least ' . $minimalCommentLength . ' characters long.' ); | |
} | |
return $commentdata; | |
} |
This file contains 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
function remove_comment_fields($fields) { | |
unset($fields['url']); | |
return $fields; | |
} | |
add_filter('comment_form_default_fields','remove_comment_fields'); |
This file contains 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
function filter_search($query) { | |
if ($query->is_search) { | |
$query->set('post_type', 'post'); | |
} | |
return $query; | |
} | |
add_filter('pre_get_posts', 'filter_search'); |
This file contains 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
add_action('template_redirect', 'redirect_single_post'); | |
function redirect_single_post() { | |
if (is_search()) { | |
global $wp_query; | |
if ($wp_query->post_count == 1 && $wp_query->max_num_pages == 1) { | |
wp_redirect( get_permalink( $wp_query->posts['0']->ID ) ); | |
exit; | |
} | |
} | |
} |
This file contains 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
add_filter( 'author_link', 'my_author_link' ); | |
function my_author_link() { | |
return home_url( 'about' ); | |
} |
This file contains 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
define ('WP_CONTENT_FOLDERNAME', 'newfoldername'); |
This file contains 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
define ('WP_CONTENT_URL', 'http://www.yourwebsite.com/newlocation/wp-content'); |
This file contains 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
define( 'WP_CONTENT_DIR', dirname(__FILE__) . '/newlocation/wp-content' ); |