• Resolved forrestuv

    (@forrestuv)


    I have an add_filter on “the_title” that accept two parameters(it’s the correct config as stated in WP docs)
    When I try to index my site, your plugin doesn’t seem to like it. On every post I get:

    Warning: Missing argument 2 for newTitle() in /web/htdocs/www.quizeconcorsi.com/home/wp/wp-content/themes/headline-news-child/functions.php on line 21

    can you fix the issue?

    thx

    https://ww.wp.xz.cn/plugins/relevanssi/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Mikko Saari

    (@msaari)

    Relevanssi runs the filters on the_title using apply_filters(). If your function throws an error when that happens, I’d say there’s something to fix on your function. So, what’s the filter trying to do?

    Thread Starter forrestuv

    (@forrestuv)

    It just adds a small image near the title..

    add_filter('the_title', 'newTitle', 10, 2);
    function newTitle($title, $id) {
    	$catImgs="";
        if(get_post_type($id)=='post' && are_we_in("the_title"))
    	{
    		if ( !is_admin() && in_the_loop() )
    		{
    			$catImgs=getTitleImages($id);
    		}
    	}
    	else
    		if(get_post_type($id)=='page')
    		{
    		}
    	return $catImgs.$title;
    }
    Plugin Author Mikko Saari

    (@msaari)

    Hmm… looks like the_title should indeed supply two values, it’s just that most of the time the second isn’t necessary.

    If you want a quick fix, adjust your function so that $id has a default value of null and if it is set to null, it gets the global $post id. That should probably fix the issue. Or, you can find this line in lib/indexing.php in Relevanssi:

    $titles = relevanssi_tokenize(apply_filters('the_title', $filtered_title));

    and change it to:

    $titles = relevanssi_tokenize(apply_filters('the_title', $filtered_title, $post->ID));

    I’ll fix this in the next version.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘The_Title() issue’ is closed to new replies.