WordPress.org

Ready to get started?Download WordPress

Forums

Add Meta Tags
[resolved] Front page custom title not working (51 posts)

  1. elainebosse
    Member
    Posted 1 year ago #

    Hello, I have a problem on a client's WP site, the custom title I'm saving for the front page doesn't load in the theme, but the Description is working fine.

    My front page is a static page set through WP settings with simple content in it.

    I'm using a "blankslate" theme of shorts, but we don't have a function for the wp_title to overwrite anything.

    I'm trying to get rid of the "Home" title - currently the field contains: "Enduride – Performance Rollers & Idlers"

    Any help would be appreciate!

    http://enduridecanadausa.com/

    http://wordpress.org/extend/plugins/add-meta-tags/

  2. George Notaras
    Member
    Plugin Author

    Posted 1 year ago #

    This will be fixed in the upcoming version. Thanks for your feedback.

  3. George Notaras
    Member
    Plugin Author

    Posted 1 year ago #

    Originally the custom title feature was not meant to be used on a static page which is used as the front/posts page.

    I tried to make it work, but it seems there is a limitation of the usage of the default WordPress is_front() function when used inside a 'wp_title' filter. This function is essential for the check, so, I'll have to find a workaround using the page IDs instead.

    I'll postpone the resolution for another future release.

    However, the normal title of a static page that is used as the frontpage does not usually appear anywhere inside the content, so I guess the custom title for such a page is a bit of overkill.

  4. George Notaras
    Member
    Plugin Author

    Posted 1 year ago #

    It seems to work as expected for the front page that is a static page, after doing the filter priority change I wrote about in: http://wordpress.org/support/topic/custom-title-issue

  5. bodokade
    Member
    Posted 10 months ago #

    Hallo George,

    I've a smiliar problem: I'm using the latest version of your plugin. The website uses a theme template front-page.php and therefore does not have an active post in $post. This has the effect that your plugin refuses to handle that call allthough is_home() returns true.

    Your code in amt_get_metadata_head() is:

    $post_type = get_post_type( $post );
    if ( ! in_array( $post_type, amt_get_supported_post_types() ) ) {
    $do_add_metadata = false;
    }

    As $post ist empty, the $post_type results to false and your plugin does not generate the header-code.

    You might want to change that in future version. E.g. using

    if ( !is_home() && !in_array( $post_type, amt_get_supported_post_types() ) ) {
    $do_add_metadata = false;
    }

    seems to work fine.

  6. George Notaras
    Member
    Plugin Author

    Posted 10 months ago #

    Hi.

    is_home() returns true at the following cases:

    1) If the latest posts are displayed on the front page (default behavior of WP) and the user visits the front page

    2) If a static page is used as the "latest posts page" and the user visits this page (not front page).

    The case we are dealing with is #1, right? Because in #2 the $post object (retrieved using get_queried_object()) is never null. I'm asking this because front-page.php got me confused.

    Apart from this, there is a problem I noticed.

    As $post ist empty, the $post_type results to false and your plugin does not generate the header-code.

    I'm testing this in WP 3.7.1. Even if the $post object might be null (case #1), get_post_type($post) still returns post instead of false!

    I am not sure if this is a WordPress bug or a feature, but it's definitely the cause of the well hidden bug we are dealing with in this topic.

  7. George Notaras
    Member
    Plugin Author

    Posted 10 months ago #

    @bodokade: Your feedback let me better understand what the problem is. Thanks a lot.

  8. bodokade
    Member
    Posted 10 months ago #

    Hallo George!

    I've taken a closer look. I thought your $post is the global $post. I did a var_dump( $post ) in front-page.php and this showed a filled objekt.

    But your functions are using get_queried_object() which returns in my case empty.

    btw: i would like to configure which of your meta-fields should by visible when editing an entry. E.g. "Full meta tags:" is hardly of use to me for a simple article but needs a lot space on the screen.

    Kind regards

  9. George Notaras
    Member
    Plugin Author

    Posted 10 months ago #

    But your functions are using get_queried_object() which returns in my case empty.

    Thanks for confirming it. Much appreciated.

    btw: i would like to configure which of your meta-fields should by visible when editing an entry. E.g. "Full meta tags:" is hardly of use to me for a simple article but needs a lot space on the screen.

    I understand. I'll file it as a feature request. But it is very unlikely to be implemented by adding options in the admin panel. I try to keep the admin panel as simple as possible. I think it will be configurable through the use of a filter. A function that configures it could then be placed in the functions.php file of the theme.

  10. George Notaras
    Member
    Plugin Author

    Posted 10 months ago #

    I've taken a closer look. I thought your $post is the global $post. I did a var_dump( $post ) in front-page.php and this showed a filled objekt.

    This must be the last of the posts that were loaded by the loop.

    BTW, a release of the plugin with the fix will most probably be out during the weekend or next week, unless I find enough time to do it earlier. The release will have many other enhancements on which I've been working lately.

    Kind Regards,
    George

  11. bodokade
    Member
    Posted 10 months ago #

    is_home() returns true at the following cases:

    1) If the latest posts are displayed on the front page (default behavior of WP) and the user visits the front page

    2) If a static page is used as the "latest posts page" and the user visits this page (not front page).

    The case we are dealing with is #1, right? Because in #2 the $post object (retrieved using get_queried_object()) is never null. I'm asking this because front-page.php got me confused.

    I've never thought about this in details but I checked it now:

    version 1) uses front-page.php; is_home() returns true; get_queried_object() returns null

    version 2) uses front-page.php; is_home() returns false; get_queried_object() returns an object.

    In my opinion is_home() should return true in both cases. What you say about get_queried_object() looks correct.

    Thanks for the fixing. I'll give it a try next week.

  12. George Notaras
    Member
    Plugin Author

    Posted 10 months ago #

    Because of the way it works, its name does not make sense.

  13. George Notaras
    Member
    Plugin Author

    Posted 10 months ago #

    Hi bodokade,

    I'm looking at this right now and I need some more information about the initial problem so I can reproduce it.

    Basically I need the following:

    1. The problem appeared on a) the default front page (regular WP latest posts page), b) a static front page, c) a static posts page ?

    2. The problem was that metadata was a) not generated or b) it was generated but there was a PHP warning?

    I have the impression that, despite the hidden bug, the plugin should have worked correctly. When 1a is the case, the metadata generators do not use $post at all. In cases 1b and 1c, they use $post, but in these cases there is always a $post object to use.

    Please shed some light on this. Thank you in advance.

  14. bodokade
    Member
    Posted 10 months ago #

    Hello!

    I can see it in german only. The selected radio button's html ist:

    <input name="show_on_front" type="radio" value="posts" class="tog" checked="checked"/>

    I think thats 'latest posts page"

    There are no warnings or notices (I switched them ON) but just an empty-line-output. ALL functions of amt-template-tags.php have an empty-line-output.

    In my header.php there is:

    =============================
    <meta name="viewport" content="initial-scale=1.0,width=device-width,maximum-scale=1.0">
    <?php
    amt_content_description();
    amt_content_keywords();
    amt_metadata_head();
    amt_metadata_footer();
    ##amt_metadata_review(); // error: Call to undefined function amt_get_metadata_inspect()
    ?>
    <title>123</title>
    =============================

    the generated html-code is:

    =============================
    <meta name="viewport" content="initial-scale=1.0,width=device-width,maximum-scale=1.0">

    <title>123</title>
    =============================

    According to $post: The plugin does not use $post. It only uses get_queried_object(). There is no "global $post" and get_queried_object() also does not return the global $post.

  15. George Notaras
    Member
    Plugin Author

    Posted 10 months ago #

    Apart from the fact that get_post_type($post) returns post instead of false, if $post is null, which made me improve the checks, I do not see any problematic behavior either with the generated metadata or the custom title.

    I'll recheck the plugin more thoroughly after you provide some more feedback about the problem.

    Thank you

  16. George Notaras
    Member
    Plugin Author

    Posted 10 months ago #

    Oh, you use the template tags. OK. I'll get back with more info in a while.

    Thanks for your feedback.

  17. George Notaras
    Member
    Plugin Author

    Posted 10 months ago #

    You are right. The template tags do not work at all. They were completely untested.

    I'm scheduling to get them fixed for the next release.

    Thanks for your valuable feedback and sorry for any inconvenience.

    George

  18. George Notaras
    Member
    Plugin Author

    Posted 10 months ago #

    amt_content_description();
    amt_content_keywords();

    Please note that these two correctly return nothing where ever a $post object is not available (not the global $post but the one returned by get_queried_object()).

  19. George Notaras
    Member
    Plugin Author

    Posted 10 months ago #

    I performed the test with the template tags on a theme I did not use! Sorry, must be tired or something...

    The template tags, although untested, they appear to work correctly.

    Please note that the use of the template tags is for cases where the wp_head and wp_footer actions hooks are not used in the theme.

    You still need to enable the the metatag generation in the admin panel for the template tags to work.

  20. bodokade
    Member
    Posted 10 months ago #

    You are right. The template tags do not work at all. They were completely untested.

    Yes, I used the tags. But the problem looks the same if the plugin does the insertion with the wp_head-action.
    =============================================
    function amt_add_metadata_head() {
    print "1 ";
    echo PHP_EOL . implode(PHP_EOL, amt_get_metadata_head()) . PHP_EOL . PHP_EOL;
    print "2 ";
    }
    add_action('wp_head', 'amt_add_metadata_head', 0);
    ============================================

    results on my frontpage in:
    ============================================
    1

    2
    ============================================

    If I change your code by adding an is_home() (as said above) it works:

    ============================================
    1
    <!-- BEGIN Metadata added by Add-Meta-Tags WordPress plugin -->
    <meta name="description" content="FRONMT APGE DESCIRTPTION" />
    <meta name="keywords" content="fronten dpage keyworfdss" />
    <!-- END Metadata added by Add-Meta-Tags WordPress plugin -->

    2
    ============================================

    So what is the recommended way to use it?

  21. George Notaras
    Member
    Plugin Author

    Posted 10 months ago #

    I'll investigate this again tomorrow. Sorry, no free time at the moment.

    We are always talking about the default front page that displays the latest posts, right?

    The problem is I am not able to reproduce this. The metatags are generated on the 'latest posts' page without the is_home workaround.

    Please make sure the settings are enabled in the admin panel.

    The recommended way to use is using the theme's wp_head action hook.

    George

  22. George Notaras
    Member
    Plugin Author

    Posted 10 months ago #

    Also could you reproduce the problem on a clean WordPress installation?

  23. bodokade
    Member
    Posted 10 months ago #

    Which settings to i need to enable? I'm running with the default settings of the plugin.

  24. George Notaras
    Member
    Plugin Author

    Posted 10 months ago #

    Settings->Metadata: Enable the automatic generation of the metadata (keywords, description, opengraph, etc.

    Also, try with a theme that ships with wordpress.

    If you changed the code of the plugin, please reinstall.

  25. George Notaras
    Member
    Plugin Author

    Posted 10 months ago #

    Please provide detailed information about what you did so I can try to reproduce it.

  26. bodokade
    Member
    Posted 10 months ago #

    I've changed to twenty-eleven and added

    var_dump( get_queried_object() );

    at the beginning of my header.php. The output ist

    null

    so your $post would be null and the thing cannot work.

    I'll try another wordpress on another server now! ;-)

  27. George Notaras
    Member
    Plugin Author

    Posted 10 months ago #

    That's the expected behavior

  28. George Notaras
    Member
    Plugin Author

    Posted 10 months ago #

    The fact that get_queried_object() returns null should not be a problem. The plugin should be able to handle it.

  29. George Notaras
    Member
    Plugin Author

    Posted 10 months ago #

    Does it work with the twentyeleven without touching the code? Don't bother with get_queried_object().

  30. bodokade
    Member
    Posted 10 months ago #

    I've used a clean wordpress now: Latest version 3.7.1 and latest version of Twenty Thirteen. If I add

    var_dump( get_queried_object() );

    to the beginning of header.php and turn the starting-page to "last posts", the output ist null. This is the problem as your plugin does not have post-objekt.

    If I set the starting-Page to a certain fix page, the data of the post is printed.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic