• Resolved Shaped Pixels

    (@shaped-pixels)


    Out of like 1800 people using my Seasonal theme (and the pro one), the method I used in my functions file to remove the archive title labels is this:

    add_filter( 'get_the_archive_title', function ($title) {
    
    	if ( is_category() ) {
    		$title = single_cat_title( '', false );
    	} elseif ( is_tag() ) {
    		$title = single_tag_title( '', false );
    	} elseif ( is_year() ) {
    		$title = get_the_date( '', false );
    	} elseif ( is_month() ) {
    		$title = get_the_date( '', false );
    	} elseif ( is_day() ) {
    		$title = get_the_date( '', false );
    	} elseif ( is_post_type_archive() ) {
    		$title = post_type_archive_title( '', false );
    	} elseif ( is_author() ) {
    		$title = '<span class="vcard">' . get_the_author() . '</span>' ;
    	}
    	return $title;
    });

    I’ve had 2 people, one using the free Seasonal theme and one using the pro version, both versions use the same filter. But what is odd is that only 2 people out of the 1800 are getting this kind of error:

    Parse error: syntax error, unexpected T_FUNCTION in /home/content/65/10216865/html/wp-content/themes/seasonal/inc/extras.php on line 209

    I got that from a support question on my free Seasonal theme.

    Line 209 for both people is the first line of add_filter(….etc.

    As far as I know, the code I have is the correct method. Long story short, I do not want the title labels to show for any of the archives, as they are labeled by default in the core.

    Any idea why only a couple people got that error?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Could it be that they’re using PHP < 5.3.0? I think that’s when lambdas became available.

    Thread Starter Shaped Pixels

    (@shaped-pixels)

    hmmmm…good question. IF they are, would that affect how the add_filters work in WordPress?

    One said they are on 5.2.17

    Thread Starter Shaped Pixels

    (@shaped-pixels)

    Found out from the few who had that error…turns out yes, it’s due to PHP. I think I can set this to resolved. Thanks Sam.

    Yeah, it just means you have to define a named function instead, e.g.:

    add_filter( 'get_the_archive_title', 'blahblah_get_the_archive_title');
    function blahblah_get_the_archive_title($title) {
    	if ( is_category() ) {
    		$title = single_cat_title( '', false );
    	} elseif ( is_tag() ) {
    		$title = single_tag_title( '', false );
    	} elseif ( is_year() ) {
    		$title = get_the_date( '', false );
    	} elseif ( is_month() ) {
    		$title = get_the_date( '', false );
    	} elseif ( is_day() ) {
    		$title = get_the_date( '', false );
    	} elseif ( is_post_type_archive() ) {
    		$title = post_type_archive_title( '', false );
    	} elseif ( is_author() ) {
    		$title = '<span class="vcard">' . get_the_author() . '</span>' ;
    	}
    	return $title;
    }
    
Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Remove Archive Title Labels error’ is closed to new replies.