WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Missing Argument 2 for _post_formats_title() (3 posts)

  1. Dominic
    Member
    Posted 1 year ago #

    I've noticed an issue with the new filter on 'the_title'. The function _post_formats_title expects 2 arguments (the title and the post ID). But there are, in my opinion, legitimate situations to use 'the_title' filter where we won't have a post ID.

    For example, I have a filter on 'the_title' that wraps ampersands in a <span> for special styling. However, if I want to use this on the title of an archive page or a taxonomy term, I won't have a readily available post id to pass to the filter.

    My suggestion is to simply alter the _post_formats_title function like so:

    function _post_formats_title( $title, $post_id = false ) {
    	if ( !$post_id || is_admin() || is_feed() || ! in_array( get_post_format( $post_id ), array( 'aside', 'status' ) ) )
    		return $title;
    
    	// Continue with function...
    }
  2. Sergey Biryukov
    WordPress Dev
    Posted 1 year ago #

    Thanks for reporting, should be fixed in the latest nightly builds:
    http://core.trac.wordpress.org/ticket/24233

  3. Dominic
    Member
    Posted 1 year ago #

    Thanks for the link. That's what I get for not checking Trac first. :)

Topic Closed

This topic has been closed to new replies.

About this Topic