Support » Alpha/Beta » [Resolved] Missing Argument 2 for _post_formats_title()

[Resolved] Missing Argument 2 for _post_formats_title()

  • 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...
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] Missing Argument 2 for _post_formats_title()’ is closed to new replies.