[wp-trac] [WordPress Trac] #38545: Add span element to get_the_archive_title()

WordPress Trac noreply at wordpress.org
Fri Mar 22 09:17:08 UTC 2019


#38545: Add span element to get_the_archive_title()
-----------------------------------+------------------------
 Reporter:  Kaira                  |       Owner:  desrosj
     Type:  enhancement            |      Status:  reviewing
 Priority:  normal                 |   Milestone:  5.3
Component:  Taxonomy               |     Version:  4.6.1
 Severity:  normal                 |  Resolution:
 Keywords:  has-patch 2nd-opinion  |     Focuses:
-----------------------------------+------------------------

Comment (by Confridin):

 I tried another solution.

 It does not add a span tag by itself, but it adds another filter. People
 will be able to easily add a span, for example:
 {{{#!php
 <?php
 add_filter( 'get_the_archive_title_prefix', 'sx_archive_prefix' );
 function sx_archive_prefix( $prefix ){
     return '<span class=”helloworld”>' . $prefix . '</span>';
 }
 }}}



 They will also be able to remove or alter the begining of the function
 (ex. "Category: %s"). Here are some examples:

 - An easy way to remove it:
 {{{#!php
 <?php
 add_filter( 'get_the_archive_title_prefix', __return_empty_string() );
 }}}


 - An easy way to change it:
 {{{#!php
 <?php
 add_filter( 'get_the_archive_title_prefix', 'sx_archive_prefix' );
 function sx_archive_prefix( $prefix ){
     $prefix = str_replace( "Category", "Awesome Category", $prefix );
     return $prefix;
 }
 }}}

 - An easy way to add other HTML tag:
 {{{#!php
 <?php
 add_filter( 'get_the_archive_title_prefix', 'sx_archive_prefix' );
 function sx_archive_prefix( $prefix ){
     return '<strong>' . $prefix . '</strong>';
 }
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/38545#comment:71>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list