[resolved] is_feed() before template_redirect()????? (2 posts)

  1. ext103
    Posted 5 years ago #

    i have come across a bug in one of my plugins


    the problem i have is that when a user opts to use the title rewrite setting the rss feed title all become the blog title??

    the way the plugin rewrites the title is like this:

    if($options['title_rewrite'] == 'Enabled'){
       add_action('template_redirect', __NAMESPACE__.'\before_header', 0);
       add_action('wp_head', __NAMESPACE__.'\after_header', 1000);
    function before_header()
    function after_header()
    function change_title_tag($head) {
       //Replace the old title with the new and return
       return preg_replace('#<title>[^<]*</title>#', '<title>'.seo_title().'</title>', $head);}}

    so i access the head element from the page and format the title using another function seo_title()

    the new function has a !is_feed() check but id doesnt seem to be working??

    is this variable even available before the template_redirect() as i think this is the issue.

  2. ext103
    Posted 5 years ago #

    okay, should of waited a bit, ive found a fix.

    adding the is_feed() call INSIDE the seo_title() function got it to work.

    im still sure this is because i was calling the variable before wordpress loads, but now its fixed, hope this helps others.

Topic Closed

This topic has been closed to new replies.

About this Topic