• Resolved Madd1974

    (@madd1974)


    On a page of my website I use the “the_title” wordpress-filter to change the Title of that page.

    This works, but also the koko list of popular posts in the sidebar widget changes. All 10 popular posts there have now the name of that page.

    Can I somehow disable the prevent of the titles in the koko popular sidebar widget.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Lap

    (@lapzor)

    Can you share your filter here? Maybe that will give me a better idea of what’s happening.

    Do you mean the display title in popular posts is changed only when viewing this specific page that you apply this filter to, or is it permanently altered to the new title?

    Thread Starter Madd1974

    (@madd1974)

    I want to changed the Headline und Title of the page, which works with the following filter. But this also results in changing the titles in the sidebar widget of Koko popular posts. All 10 entries in the Koko-Widget have the name of the site.

    The filter is:

    add_filter(‘the_title’, ‘filter_product_wpseo_title’);
    add_filter(‘wp_title’, ‘filter_product_wpseo_title’);

    function filter_product_wpseo_title($title) {
    if ( is_page ( 12712 ) ) {
    … (database-code)
    return $newtitle;
    }
    else {
    return $title;
    }
    }

    Plugin Support Lap

    (@lapzor)

    Hi Madd,

    This is the reply I got from Danny our chief and coder:

    That code is filtering on?the_title?but then checking a global property whether to apply the change.

    The fix is to use the 2nd argument passed to the callback which holds the post ID of the title that callback is being applied to

    Something like this:

    add_filter('the_title', 'filter_product_wpseo_title', 10, 2);
    
    function filter_product_wpseo_title($title, $post_id) { 
    	if ( $post_id == 12712  ) { 
    		// database code here
    		return $newtitle; 
    	} 
    
    	return $title;
    }

    Hope that helps. If you have any questions, please let me know!

    Thread Starter Madd1974

    (@madd1974)

    perhaps I have expressed myself wrongly.

    The problem is not the page. The title is only changed on this page. That works.

    But on this page, the changed title is also displayed in the sidebar in the Koko Analytics list of the most popular articles from place 1 to 10 (the URLs, on the other hand, remain correct in the Koko list).

    Attached is a screenshot of the Koko Popular Posts Widget on that page. On all other pages and posts there is no problem.

    Plugin Support Lap

    (@lapzor)

    Did you try the provided code that targets just the post by ID instead of all posts titles? Didn’t that fix the issue?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘The Title Problem’ is closed to new replies.