Support » Theme: Twenty Twenty-Two » Redefine seperator for post terms / taxonomy

  • Resolved kultur.work

    (@lindages)


    Hi there,
    would anyone by any chance have a suggestion on how to redefine the separator (wp-block-post-terms__separator) for the post terms; it’s currently a comma, I’d like to change that into a vertical bar (like this: category 1 | category 2).

    Cheers.

Viewing 4 replies - 1 through 4 (of 4 total)
  • One of the attributes of the post terms block is ‘separator’ although at this time this cannot be edited in the visual editor as there is currently no control for it in the block sidebar panel.

    To add this attribute you will need to switch the view from ‘Visual editor’ to ‘Code editor’ in the template that you are editing (Gutenberg plugin required as Code editor is currently not available in core WP).

    In the code view the post terms block will look something like this for tags:

    
    <!-- wp:post-terms {"term":"post_tag"} /-->
    

    or this for categories:

    
    <!-- wp:post-terms {"term":"category"} /-->
    

    Taking the tags example, you can add the ‘separator’ attribute to change the default comma to some other character, for example a vertical bar with a space either side:

    
    <!-- wp:post-terms {"term":"post_tag","separator":" | "} /-->
    
    Thread Starter kultur.work

    (@lindages)

    Thanks a lot @uxl. This is promising!

    I just tried to edit it in the html template file (before going to a plugin I thought). Is there a reason why it wouldn’t work from there? (Other than old cache?).

    Best wishes,
    Linda

    It could be that you had previously edited the template in the Site Editor.

    When you make changes to a template or template part, it is saved in the database of your WordPress installation, and then this saved template takes priority over the html template from the theme.

    I wouldn’t advise editing the html template directly because your changes will be undone when there is a theme update. It is recommended to make changes to templates using the site editor so that your changes are saved and not undone when the theme is updated.

    The Gutenberg plugin is the official block features plugin and contains functionality that will eventually make its way into WordPress, so this is why the Code editor view is only available with Gutenberg at the moment.

    You could install and activate Gutenberg, use the code editor view to make the changes in your templates, and then deactivate the plugin if you don’t want to keep the plugin active.

    Thread Starter kultur.work

    (@lindages)

    Thanks so much for the insights, @uxl — worked a treat. (Such key learning!)

    All best,
    Linda

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Redefine seperator for post terms / taxonomy’ is closed to new replies.