最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

post meta - Using a comma instead of a pipe to separate metadata

matteradmin9PV0评论

The default way WordPress separates different types of meta data, such as in the post meta data, is using a pipe |. For example, Author Name | Date | Cat1, cat2, cat3

On a Wordpress site, with an existing theme, how would I go about using a comma (,) instead of the pipe (|) to separate the different classes of meta data?

End result, of above example, would be this: Author Name , Date , Cat1, cat2, cat3

Thanks very much.

The default way WordPress separates different types of meta data, such as in the post meta data, is using a pipe |. For example, Author Name | Date | Cat1, cat2, cat3

On a Wordpress site, with an existing theme, how would I go about using a comma (,) instead of the pipe (|) to separate the different classes of meta data?

End result, of above example, would be this: Author Name , Date , Cat1, cat2, cat3

Thanks very much.

Share Improve this question asked Feb 28, 2019 at 5:01 omega33omega33 3646 silver badges20 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

The default way WordPress separates different types of meta data, such as in the post meta data, is using a pipe |. For example, Author Name | Date | Cat1, cat2, cat3

This isn't correct. WordPress doesn't have a default way that it displays this information. It's entirely up to the theme developer.

if you'd like to replace this | character, you're going to need to modify the theme files. That is unless the theme provides its own custom way of changing this behaviour without modifying the theme. You would need to check with the theme author to know if your theme has a custom way of making this change.

If the theme was built according to best practices, you can do this modification safely by creating a Child Theme and copying the template file responsible for outputting this data into the same subdirectory in your child theme, and making the change to that file.

Without access to your specific theme, it's not possible to get more specific than that. But as an example, if you were using the latest default theme, Twenty Ninteen, then you would need to copy template-parts/header/entry-header.php from the twentynineteen directory, into a template-parts/header/ subdirectory in your child theme directory. Then you would add the commas between twentynineteen_posted_by() and twentynineteen_posted_on().

If you're not comfortable with coding, I recommend asking the theme author for advice in making this change.

Post a comment

comment list (0)

  1. No comments so far