• Resolved jeffersonpowers

    (@jeffersonpowers)


    Apologies if some of this is vague. A client of a client is complaining about Google Analytics errors on his web page, specifically that he’s getting “missing: author” and “missing: updated” errors, which he thinks is disrupting his search placement.

    The client went to a programmer, who made the following changes to the WordPress core files (bad idea, I know):

    #1. In wp-settings.php, swapped places of following line:

    require( ABSPATH . WPINC . '/plugin.php' );
    require( ABSPATH . WPINC . '/functions.php' );

    Earlier functions.php was above plugin.php

    #2. In functions.php, added following code:

    add_filter( 'post_class', 'remove_hentry_function', 20 );
    function remove_hentry_function( $classes ) {
        if( ( $key = array_search( 'hentry', $classes ) ) !== false )
            unset( $classes[$key] );
        return $classes;
    }

    I’m not a PHP programmer so I don’t really know what this is even supposed to do. I need to know if there is a way to implement his solution without editing the core files, or a better way to get rid of the Google Analytics errors, via a plugin or theme function.

    I would appreciate any help or advice. Thank you.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Yes, editing core files is a terrible thing. I hate it when clients try to fix things they don’t understand. My sympathies.

    The fixes needed can be solved with a child theme. Make sure both the WordPress core and current theme are both up to date, then read this articles:

    https://www.acceleratormarketing.com/trench-report/google-analytics-errors-and-structured-data/

    You would need to create a post template in the child theme to override the one in the parent theme.

    Alternately, you could try this in the child theme’s functions.php file:

    https://www.ads-software.com/support/topic/missing-author-and-updated-in-google-webmaster-tools?replies=14#post-5349900

    But a lot of it depends on the theme you are using.

    Thread Starter jeffersonpowers

    (@jeffersonpowers)

    Sorry, I should have mentioned: the site is using a child theme of Twenty Twelve.

    I think I’ve kind of figured out what the second bit of code is for: it drops the “hentry” class so Google doesn’t look for author or date information there (please correct me if I’m wrong about that).

    I find the first bit completely baffling – does anyone know what the point of that would be?

    Moderator bcworkz

    (@bcworkz)

    The hentry class attribute is best removed by filtering ‘post_class’ and finding that entry in the passed array and removing it. Possibly a better approach is to add the missing attributes Google is looking for by filtering ‘the_title’, ‘the_date’, and ‘the_author’. Filters are added to functions.php of the child theme, or by creating a simple plugin. You can instead edit the template as kjodle and the linked article suggests.

    Since there already is a child theme, this can only be done by directly editing the template in the child theme, if it is there already. If not, copy it from the parent theme and edit the copy. If there is any problem editing the child theme, filters via a plugin will work.

    I also see no point in switching the requires. There may have been no intention, just absent minded cutting/pasting. AFAIK there are no dependencies where changing the order would effect WP operation.

    Thread Starter jeffersonpowers

    (@jeffersonpowers)

    I think adding the missing attributes is the direction I am headed with this. This programmer’s solution seems like it is just sweeping the problem under the rug in order to get the Google Analytics alerts to stop appearing, rather than doing anything to actually improve the SEO.

    Thanks for your help with this, I appreciate it.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Changes to core files to improve SEO?’ is closed to new replies.