Last active
August 29, 2015 14:11
-
-
Save arioch1984/aa65c3ef6e04567dfdf9 to your computer and use it in GitHub Desktop.
Wordpress: Change CPT values from child theme
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 | |
add_action('registered_post_type', 'custom_registered_post_type_handler', 10, 2); | |
function custom_registered_post_type_handler($post_type, $args) { | |
do_action("custom_registered_{$post_type}_post_type", $post_type, $args); | |
} | |
add_action('custom_registered_foo_post_type', 'custom_registered_foo_post_type_handler', 10, 2); | |
function custom_registered_foo_post_type_handler($post_type, $args) { | |
remove_action(current_filter(), __FUNCTION__, 10, 2); // only run once | |
// change your args here | |
$args['show_ui'] = false; | |
// re-register | |
register_post_type($post_type, $args); // will call this hook again if it exists, so we removed it above. | |
} | |
?> |
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 | |
add_action( 'after_setup_theme', 'portfolio_new_labels', 20 ); | |
function portfolio_new_labels() | |
{ | |
global $wp_post_types; | |
foreach($wp_post_types['portfolio_page']->labels as $label_name => $label_value){ | |
$wp_post_types['portfolio_page']->labels->$label_name = str_replace('Portfolio','Prodotti',$label_value); | |
} | |
$wp_post_types['portfolio_page']->rewrite['slug'] = 'prodotti'; | |
//print_r($wp_post_types); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment