Beginner needs PHP help on arrays
-
I’m using a theme that creates a custom post type with the name “Events.”
Here’s the code that creates it from the theme’s functions.php:
add_action('init', 'create_event'); function create_event() { $event_args = array( 'label' => __('Events', 'jollytheme' ), 'singular_label' => __('Event Item', 'jollytheme' ), 'public' => true, 'show_ui' => true, 'capability_type' => 'post', 'hierarchical' => false, 'rewrite' => array('slug' => __('event', 'jollytheme' )) , 'supports' => array('title', 'editor', 'thumbnail','comments'), 'taxonomies' => array('post_tag') ); register_post_type('event',$event_args); }
This is the line I’m concerned with:
'rewrite' => array('slug' => __('event', 'jollytheme' )) ,
It turns out that naming the slug “event” here conflicts with a plugin on that site. I’m not actually using this post type and don’t plan to. Luckily, I found out that I can simply change the name of the slug on this line and everything will work fine. So, I’m OK with this kludgy solution.
Unless, of course, the theme updates. That’s why I always try to do my changes in child themes.
So, that leads to my question. Is there code I can put in my child theme’s functions.php that will make that change, so I can leave the theme’s actual functions.php untouched? I’ve already discovered that I can’t just take the above code and replicate it there because it causes a “cannot redeclare” error.
Grateful for all suggestions…
- The topic ‘Beginner needs PHP help on arrays’ is closed to new replies.