Search code examples
phpwordpresscategoriespage-title

Changing Page Title while "in_category"


So I'm not sure what happened but this was working until the update to Wordpress 4.7. Can someone please help me figure out why my page header is still showing default "News & Events" when on any single post?

  if( $subheader_show ){
                        echo '<div id="Subheader" style="'. $subheader_style .'">';
                            echo '<div class="container">';
                                echo '<div class="column one">';

                                    // Title
                                    $title_tag = mfn_opts_get( 'subheader-title-tag', 'h1' );
                                    if( in_category('news' || 'community' || 'events')) {
                                    echo '<'. $title_tag .' class="title">News & Events</'. $title_tag .'>';
                                    } elseif( in_category('attorneys')) {
                                    echo '<'. $title_tag .' class="title">Attorneys</'. $title_tag .'>';
                                    } elseif( in_category('publications')) {
                                    echo '<'. $title_tag .' class="title">Publications</'. $title_tag .'>';
                                    } else {
                                    echo '<'. $title_tag .' class="title">'. mfn_page_title() .'</'. $title_tag .'>';
                                    }

                                    // Breadcrumbs
                                    if( $breadcrumbs_show ) mfn_breadcrumbs( $breadcrumbs_link );

                                echo '</div>';
                            echo '</div>';
                        echo '</div>';
                    }

Solution

  • You're using in_category function incorrectly.
    It accepts int, string or array. In your case it should be in_category(array('news', 'community', 'events')). I have no clue how it was working before, because nothing changed with this function in 4.7 as far as I can see.