-1

I want to trim the Category Name from left to right. For example the Category Name is Men | Clothing, so I want to trim Men |, that just Clothing is displayed on the page. I just found a line for trimming at the End:

<?php echo rtrim(single_cat_title('', false), 'g'); ?>

Or a line for replacing Men |, but then the output is Category: Clothing :


<?php echo str_replace("Men | ", "", get_the_archive_title()); ?>

I'm happy about any help. Thank you.

  • Does this answer your question? [Split a comma-delimited string into an array?](https://stackoverflow.com/questions/1125730/split-a-comma-delimited-string-into-an-array) – Björn Jul 27 '21 at 15:28

1 Answers1

0

if your category name is like this : $str ="X | Y" and you want Y You can try this:

$exp = explode("|", $str)

$y = $exp[1]

jiali
  • 616
  • 9
  • 20