Skip to content

Instantly share code, notes, and snippets.

@arioch1984
Last active August 29, 2015 14:11
Show Gist options
  • Save arioch1984/aa65c3ef6e04567dfdf9 to your computer and use it in GitHub Desktop.
Save arioch1984/aa65c3ef6e04567dfdf9 to your computer and use it in GitHub Desktop.
Wordpress: Change CPT values from child theme
<?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.
}
?>
<?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