WordPress.org

Forums

WP Tiles
[resolved] Adding space after each comma in categories list (5 posts)

  1. metis-counsel
    Member
    Posted 1 year ago #

    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

    http://wordpress.org/plugins/wp-tiles/

  2. Mike Martel
    Member
    Plugin Author

    Posted 1 year ago #

    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

  3. metis-counsel
    Member
    Posted 1 year ago #

    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!

  4. Mike Martel
    Member
    Plugin Author

    Posted 1 year ago #

    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;
  5. metis-counsel
    Member
    Posted 1 year ago #

    Amazing. Thanks, Mike.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WP Tiles
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic