[wp-hackers] changing the built in categories label on the add post screen

Paul Menard paul at codehooligans.com
Sat Nov 19 00:08:02 UTC 2011


On Nov 18, 2011, at 6:59 PM, IC IC wrote:

> Paul,
> 
> I got the point...
> 
> I've been wondering those init hooks..
> When we run the add_action('init', 'whatever' ... , is that going to run
> everytime a page is served for some visitor for the rest of the time?

Correct. Add that code snippet to you theme functions.php. Yes, this will and need to run on every page load. The core WordPress register_taxonomy functions also run on every page load. The code I provided is just changing the label AFTER the core register_taxonomy functions are run. 


> 
> Normally, you would run this code once and then comment it out right? So,
> such actions are there to run once right?
> there is no point of running it millions of time if that taxonomy exists do
> nothing part…

See above comment. This is the way the WordPress taxonomy system is setup. Runs on every page load. 

> 
> however in this particular instance, I guess I have to remember of running
> it once after every core update?

No. You are not updating any WordPress core file. This code I provided goes into your theme functions.php file. 

> 
> shouldn't there be a more elegant way to handle this UI matter?

I can't really speak to this. 


> 
> 
> 
> 
> 
> On Fri, Nov 18, 2011 at 3:44 PM, Paul Menard <paul at codehooligans.com> wrote:
> 
>> Really guys. I know it's Friday evening but hacking the code and changing
>> the database. Really. Easiest solution is to just add your own init action
>> hook. Grab the global $wp_taxonomies object then replace the label. No need
>> to unregister or register some other taxonomy.
>> 
>> Is the following advisable? Probably not but then again WordPress does not
>> provide any hooks to override these.
>> 
>> Something like the following:
>> 
>> 
>> add_action('init', 'change_category_taxonomy_label', 999);
>> function change_category_taxonomy_label() {
>> 
>>       global $wp_taxonomies;
>> 
>>       // Add your own code to verify this object and exists. You have
>> been warned
>>       $wp_taxonomies['category']->labels->menu_name = "Topics";
>> }
>> 
>> P-
>> 
>> 
>> 
>> On Nov 18, 2011, at 6:36 PM, William P. Davis wrote:
>> 
>>> This is getting complicated. Maybe just create a translation file?
>>> Sent from my BlackBerry® wireless device
>>> 
>>> -----Original Message-----
>>> From: Charles Frees-Melvin <charles.freesmelvin at me.com>
>>> Sender: wp-hackers-bounces at lists.automattic.com
>>> Date: Fri, 18 Nov 2011 19:31:10
>>> To: wp-hackers at lists.automattic.com<wp-hackers at lists.automattic.com>
>>> Reply-To: wp-hackers at lists.automattic.com
>>> Subject: Re: [wp-hackers] changing the built in categories label on the
>> add
>>> post screen
>>> 
>>> Add a new taxonomy "topics" and then change in the _terms table all
>> Categories to topics. That will convert what was category's to the topic
>> taxonomy. Then just unregister the category tax or de-link it from the
>> "post" post type.
>>> 
>>> --
>>> Charles E. Frees-Melvin
>>> 
>>> Sent from my Rogers iPhone 4S
>>> 
>>> On 2011-11-18, at 19:18, IC IC <icwordpress at gmail.com> wrote:
>>> 
>>>> When you unregister, what happens to the existing categories that have
>> been
>>>> created?
>>>> 
>>>> Shall I just run this at the twentyten functions.php?
>>>> 
>>>> add_action( 'init', 'unregister_taxonomy');
>>>> function unregister_taxonomy(){
>>>>  global $wp_taxonomies;
>>>>  $taxonomy = 'category';
>>>>  if ( taxonomy_exists( $taxonomy))
>>>>      unset( $wp_taxonomies[$taxonomy]);
>>>> }
>>>> 
>>>> and after that, go find the post.php and change the label from
>> categories
>>>> to topics? is that a safe thing to do ?
>>>> wouldn't this go away when we update the wordpress core though?
>>>> 
>>>> I want the label topics to stay permanently regardless of the updates..
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> On Fri, Nov 18, 2011 at 3:08 PM, Charles Frees-Melvin <
>>>> charles.freesmelvin at me.com> wrote:
>>>> 
>>>>> You can't it is hard coded into wp-includes/post.php
>>>>> 
>>>>> The best option is to unregister categories and replace with a new tax.
>>>>> 
>>>>> --
>>>>> Charles E. Frees-Melvin
>>>>> 
>>>>> Sent from my Rogers iPhone 4S
>>>>> 
>>>>> On 2011-11-18, at 18:59, IC IC <icwordpress at gmail.com> wrote:
>>>>> 
>>>>>> Which table stores the "categories" label?
>>>>>> 
>>>>>> I already changed the categories folder name from "category" to
>> "topics"
>>>>>> but the add post screen still display "Categories" as the label?
>>>>>> I want to change that too to Topics.
>>>>>> 
>>>>>> When you create a custom taxonomies, this issue is not a problem
>> cause it
>>>>>> has the label argument.
>>>>>> but since the categories already come pre-created, I need to make that
>>>>>> change straight into the table!
>>>>>> where do I do that?
>>>>>> _______________________________________________
>>>>>> wp-hackers mailing list
>>>>>> wp-hackers at lists.automattic.com
>>>>>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>>>> _______________________________________________
>>>>> wp-hackers mailing list
>>>>> wp-hackers at lists.automattic.com
>>>>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>>>> 
>>>> _______________________________________________
>>>> wp-hackers mailing list
>>>> wp-hackers at lists.automattic.com
>>>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>> _______________________________________________
>>> wp-hackers mailing list
>>> wp-hackers at lists.automattic.com
>>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>> _______________________________________________
>>> wp-hackers mailing list
>>> wp-hackers at lists.automattic.com
>>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>> 
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>> 
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers



More information about the wp-hackers mailing list