• Resolved metis-counsel

    (@metis-counsel)


    Hi Mike,

    I’ve been trying to add a space after each comma when categories are displayed. I’m fairly confident that this is the code snippet I must change to do this:

    case ‘cats’ :
    default :
    $byline = wp_get_post_categories( $post->ID, array( “fields” => “names” ) );
    break;

    Your guidance would be appreciated on this one. Thanks!
    Mike

    https://www.ads-software.com/plugins/wp-tiles/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Mike Martel

    (@mike_cowobo)

    Hi Mike,

    You could change the plugin code in that spot, but I wouldn’t recommend it – your changes would be overwritten with every update. You could filter over the tiles data however, by putting something like this in your functions file:

    add_filter( 'wp-tiles-data', 'example_wp_tiles_add_spaces' );
    function example_wp_tiles_add_spaces( $data ) {
        foreach( $data as &$tile ) {
            $tile['byline'] = implode( ', ', $tile['byline'] );
        }
    
        return $data;
    }

    (code is untested)

    Let me know how that works out.

    Cheers,
    Mike

    Thread Starter metis-counsel

    (@metis-counsel)

    Mike,

    It doesn’t seem like this works. I added the snippet to my functions.php child theme. Is there a quick fix that I can make to the location I mentioned in my first post in the meantime?

    Thanks again for your help!

    Plugin Author Mike Martel

    (@mike_cowobo)

    Hm, I just tested it, and it works for me, are you sure you put it in the functions.php of the active theme?

    If you really have to change the code of the plugin, do this:

    case 'cats' :
    default :
        $byline = wp_get_post_categories( $post->ID, array( "fields" => "names" ) );
        $byline = implode( ", ", $byline );
    break;
    Thread Starter metis-counsel

    (@metis-counsel)

    Amazing. Thanks, Mike.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Adding space after each comma in categories list’ is closed to new replies.