• I have a site and the categories are displayed in a sidebar box. This is fine for most of my category names but some are too long and simply run through other names.

    Is there a way for the displayed category name to be truncated in the display

Viewing 4 replies - 1 through 4 (of 4 total)
  • It takes some code.

    The description of wp_list_categories is here
    http://codex.wordpress.org/Template_Tags/wp_list_categories

    One of the parameters is “echo”. With this you can have the contents of the category list saved in a PHP variable rather than displayed on the screen. The reason for doing this is so you can further filter the output before displaying it, using PHP code. In your case you’d want to replace all titles that are longer than say 30 characters with only the first thirty characters.

    If you can do a little bit of coding you can google for
    filter wp_list_categories
    you may find some code you can adapt to your theme.

    Its also quite possible there is a plugin that will do something along this line, with the code already written. search the plugins for category and see what you find.

    Thread Starter ndev2k

    (@ndev2k)

    Thanks can’t find any plugins to do the job and the code i have found doesn’t seem to work.

    Oh well will have to keep looking.

    I guess I have to create a new function in the functions.php file but don’t know how to program so will have to struggle

    Thread Starter ndev2k

    (@ndev2k)

    Thanks for the help. I have already found that but cannot get it to work with my theme. My theme has the standard functions file as well as a theme specific one. I don’t know where to put the code to make it work. I have broken my theme 3 times trying to get it to work and have needed to reupload the original files.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Truncate Category Name in Display’ is closed to new replies.