Support » Plugin: Book Review Library » Small custom change?

  • Hi I really love your plugin so far.. I would just like to do one one small thing and that is change the Taxonomy “Genre” to Display “Format” As I use your plugin to review movies, music and so on… I have been using the Genre section for that so far, so i only would like to display “format” on the front… (or I am open to any other suggestions) Many thanks for your work! 5 stars!

Viewing 1 replies (of 1 total)
  • Plugin Author Chris Reynolds


    So there are a couple ways of doing this. One is using code. I’m going to link to specific blocks of code on the GitHub repository for the plugin because I can link to direct lines.

    Since you are already using the Genre taxonomy, you probably don’t want to change the taxonomy name. If you did, you’d lose all the data that was associated to that taxonomy and would need to re-tag everything. This is the function that creates the Genre taxonomy:

    All you really care about there is changing the labels, so you could hack the plugin and update all those labels. That would be lost if there was an update to the plugin, so you’d probably want to fork and rename the plugin (which would still mean that you wouldn’t receive any future updates).

    You can also use a filter that was added in WordPress 4.4 to filter the taxonomy arguments as they are registered. I have some (untested) sample code in this gist:

    (Note: I haven’t used the register_taxonomy_args filter that this snippet uses but I have used register_post_type_args which works the same way for post types.)
    The benefit of this is that you don’t need to hack the plugin for this, you can add this code into your theme or child theme and it will just magically work.

    The last option is to use translation functions to “retranslate” “Genre” as “Format”. In my opinion, this is a little hacky, but it will also get the job done, regardless. And, again, there are two different ways of doing this. One is through code, which looks like this:

    // hook the translation filters
    add_filter(  'gettext',  'change_genre_to_format'  );
    add_filter(  'ngettext',  'change_genre_to_format'  );
    function change_genre_to_format( $translated ) {
         $translated = str_ireplace(  'Genre',  'Format',  $translated );
         return $translated;

    This isn’t my preferred method, but it works. There’s a StackExchange suggestion here with a link to an article for more information:
    Basically what this is doing is it’s running all instances of the word Genre through the internal translation functions and using those functions to translate Genre as Format. This is why I feel like this is hacky and don’t like this solution, because we’re hijacking the translation system for a quick fix. That said, what I hear you describing is a need for a quick fix, so this could be the thing for you. This code can also be thrown into a theme or child theme and avoid hacking the plugin itself.

    Along the same lines is literally editing the language files in a program like Poedit and translating Genre as Format. This is actually pretty simple when you have Poedit to create the files for you, but, again, it’s using a system (the internal translation system) to do something that isn’t really what it’s intended to do. If you want to go down that route I can add a bit more detail into how this would work in practice but if you were going to use the translation system at all, I’d probably go with the function above than actually editing the translations files.

Viewing 1 replies (of 1 total)
  • The topic ‘Small custom change?’ is closed to new replies.