Page Title Tags

Home Forums Calendar Products Events Calendar PRO Page Title Tags

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #1063421
    Sean
    Participant

    Hi,

    I’m using some of your snippets to clean up the default <title> tags for my Event Calendar. Yoast SEO has begun to remove references to wp_title function since WordPress core has begun to remove it. Thus, I need to update the snippets so that they will continue to display the correct page titles.

    1. How can I get the page titles for month view (e.g. Events for January 2016) to display in that view? I am guessing it is something similar to what I have for Day View, but I’m not sure what should be changed:

    $title = sprintf(
    'Events for %1$s',
    date_i18n( tribe_get_date_format( true ), strtotime( $wp_query->get( 'start_date' ) ) )
    );

    2. Likewise, for the Single Event pages, what can be used to display the current event’s title in the <title> tag?

    3. I’ve noticed that while the source code for the <title> tags stays correct, when anything is appended to the URLs (the user changes pages via Next Events or Previous Events, or any search criteria is submitted via the Tribe Bar or Filter Bar), that the title display in the browser reverts back to the default page title, while the source code continues to display the correct page title. Do search engines only use the <title> tag from the page’s source code to display the page titles on their pages? If so, this is not a big deal, as it would only effect a user who is bookmarking the page or when they look at the top of their browser window. However, if search engines grab the title that is displayed in the top of the browser window, then this would be a big deal since they’d be displaying incorrect page title (I think due to the Javascript that changes the page titles when new events are displayed).

    Thank you,
    Karly

    #1063509
    Brook
    Participant

    Howdy Karly,

    1. How can I get the page titles for month view (e.g. Events for January 2016) to display in that view? I am guessing it is something similar to what I have for Day View, but I’m not sure what should be changed:

    I believe that code you shared should actually work for Month view as well. If you wish to change the date format you can. Just replace ‘tribe_get_date_format( true )’ with your format. I think you want this:

    'F j, Y'

    2. Likewise, for the Single Event pages, what can be used to display the current event’s title in the <title> tag?

    You can use any of the available functions for getting the title. WordPress has quite a few depending on your need. For this I would probably use:

    get_the_title()

    3. I’ve noticed that while the source code for the <title> tags stays correct, when anything is appended to the URLs (the user changes pages via Next Events or Previous Events, or any search criteria is submitted via the Tribe Bar or Filter Bar), that the title display in the browser reverts back to the default page title, while the source code continues to display the correct page title. Do search engines only use the <title> tag from the page’s source code to display the page titles on their pages? If so, this is not a big deal, as it would only effect a user who is bookmarking the page or when they look at the top of their browser window. However, if search engines grab the title that is displayed in the top of the browser window, then this would be a big deal since they’d be displaying incorrect page title (I think due to the Javascript that changes the page titles when new events are displayed).

    The title shown in search results should match the one in the View Source view.

    Does that all make sense?

    • Brook
    #1063570
    Sean
    Participant

    Perfect, thank you Brook! All set now.

    As I mentioned, if the source code is used to display the page title’s elsewhere, the browser showing the incorrect (TEC default) page title tag in the browser is only an issue for those bookmarking the pages or those looking at the title displayed in the browser’s tab. Still, if it wasn’t already on the list of “reasons to disable ajax page loading”, perhaps it could be added when the team is considering that functionality further down the road?

    Thanks again,
    Karly

    #1063847
    Sean
    Participant

    Brook, I did notice that when navigating the Month View view pagination, the <title> tag shown in the source code does not change. It stays the same (for the current month). Is this a bug? The title tag for Day View does change when the user navigates to past/future days via ajax.

            elseif ( tribe_is_month() && !is_tax() ) {  // Month View Page
                    $title = sprintf(
    'Events for %1$s | My Site',
    date_i18n( 'F Y', strtotime( $wp_query->get( 'start_date' ) ) )
    );
            }
    #1064179
    Brook
    Participant

    Howdy Karly,

    For sure!

    That is not a bug. The source code is for the intial page that loaded. Any subsequent ajax requests will not be reflected in the view source, because they were loaded after the page loaded. However, you can hit the refresh button to reload the page with the new content, and you will see the <title> change.

    Let me know if you have anymore questions.

    • Brook
    #1064219
    Sean
    Participant

    Good morning Brook,

    Hmm, I’m not seeing that happen. When navigating to other months, refreshing the page, or even going directly to other months via a url, the <title> tag stays as “January 2016 | My Site Name”

    For day view the <title> tag does change in the source code (and the browser bar) both when ajax changes the page content and when the page is completely reloaded. There must be an issue with the Month View (possibly my snippet)since the Day View’s title tag does change via ajax or full page reloads? I tested this on my staging server too (where no cache exists) so I know its not a matter of the content being cached.

    Karly

    #1064627
    Brook
    Participant

    Oh okay, then that would be the result of the snippet not our default behavior. In that case we might be hitting that error I mentioned a topic back, where it will show an erroneous date instead of the proper one. However, I have an idea that might workaround this. Try replacing:

    $wp_query->get( 'start_date' )

    with

    $wp_query->get( 'eventDate' )

    Don’t forget that our forums have a tendency to convert regular single quotes into the angly kind, since that is just what WordPress does with text. So It might be best to not copy/paste the quotes, and instead just replace “start_date” with “eventDate”. Did that work?

    • Brook
    #1064669
    Sean
    Participant

    Excellent, that did the trick Brook! As always, thanks for helping me get to the finish line on this!

    Have a great weekend,
    Karly

    #1065948
    Brook
    Participant

    Wunderbar! It was my pleasure.

    • Brook
Viewing 9 posts - 1 through 9 (of 9 total)
  • The topic ‘Page Title Tags’ is closed to new replies.