WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. metis-counsel
    Member
    Posted 11 months 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
    Member
    Plugin Author

    Posted 11 months 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 11 months 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
    Member
    Plugin Author

    Posted 11 months 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 11 months ago #

    Amazing. Thanks, Mike.

Reply

You must log in to post.

About this Plugin

About this Topic