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
add_filter( 'register_post_type_args', 'rename_registered_post_types', 999, 2 ); | |
function rename_registered_post_types( $args, $post_type ){ | |
if( 'post' == $post_type ){//your post type to rename | |
$args['rewrite']['slug'] = 'your_custom_slug'; | |
} | |
return $args; | |
} |
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
add_filter( 'post_link', 'add_custom_base_to_post_links', 10, 3 ); | |
function add_custom_base_to_post_links( $post_link, $post, $leavename ) { | |
if ( 'post' != $post->post_type || 'publish' != $post->post_status ) { | |
return $post_link; | |
} | |
$post_link = str_replace( '/' . $post->post_name . '/', '/your_custom_base/' . $post->post_name . '/', $post_link ); | |
return $post_link; | |
} |
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
remove_filter('get_the_excerpt', 'wp_trim_excerpt'); |
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
add_filter('get_the_excerpt', 'allow_html_in_excerpt'); | |
function allow_html_in_excerpt($text) { // Fakes an excerpt if needed | |
global $post; | |
if ( '' == $text ) { | |
$text = get_the_content(''); | |
$text = apply_filters('the_content', $text); | |
$text = str_replace('\]\]\>', ']]>', $text); | |
/*just add all the tags you want to appear in the excerpt -- | |
be sure there are no white spaces in the string of allowed tags */ |
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
add_filter( 'init', 'custom_registered_taxonomy_admin_labels' ); | |
function custom_registered_taxonomy_admin_labels() { | |
global $wp_taxonomies; | |
$labels = &$wp_taxonomies['your_taxonomy']->labels;//change to your taxonomy slug | |
$labels->name = 'NAME'; | |
$labels->singular_name = 'SING_NAME'; | |
$labels->add_new = 'Add NAME'; | |
$labels->add_new_item = 'Add NAME'; | |
$labels->edit_item = 'Edit NAME'; |
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
add_action( 'wp_enqueue_scripts', 'conditionally_enqueue_styles'); | |
function conditionally_enqueue_styles() { | |
if ( is_front_page() || !is_archive() ) { | |
wp_enqueue_style('bootstrap', 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css'); | |
wp_enqueue_style('style', get_stylesheet_uri()); | |
wp_enqueue_script( 'bootstrap-js', 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js', array('jquery'), '3.3.4', true ); | |
} | |
} |
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
add_action( 'pre_get_posts', 'remove_post_type_from_front_end_search_results'); | |
function remove_post_type_from_front_end_search_results($query){ | |
if(is_admin() || !$query->is_main_query()) return; | |
if($query->is_search()){ | |
$post_type_to_remove = 'your_post_type'; | |
$searchable_post_types = get_post_types(array('exclude_from_search' => false)); |
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
add_action( 'template_redirect', 'change_wp_search_url' ); | |
function change_wp_search_url() { | |
if ( !empty( $_GET['s'] ) ) { | |
wp_redirect( home_url( "/your_page/?your_param=" ) . urlencode( get_query_var( 's' ) ) ); | |
exit(); | |
} | |
} |
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
add_action('init','safe_remove_backend_admin_access_for_role'); | |
function safe_remove_backend_admin_access_for_role(){ | |
if( current_user_can('editor') || current_user_can('administrator') )//Your roles | |
return; | |
if( is_admin() && !defined('DOING_AJAX') ){//IMPORTANT! Front end AJAX events are excluded... | |
if(isset( $_GET[ 'action'] ) && 'trash' == $_GET[ 'action'])//Perhaps you have a call to some WP Admin Operation that needs whitelisting... | |
return; | |
wp_redirect( home_url() ); | |
exit; |
OlderNewer