• Resolved supertrooper2

    (@supertrooper2)


    Hi Justin

    Mostly the post title precedes the blog title. Sometimes, however, the blog title is followed by the post title. e.g.

    Focusing on Wildlife » Wild Tigers of India – in Battle! [465 Views]
    Government Road At Alligator Alley – Focusing on Wildlife [82 Views]

    This is not a problem because the blog title can be removed. Using the “titleremove” filter the blog title disappears but the separators can still be seen. e.g.

    » Wild Tigers of India – in Battle! [465 Views]
    Government Road At Alligator Alley [82 Views]

    This is a major problem because of the disruption to the layout.

    Which code can be used to remove the separators from the stats?

    Thanks in advance for your advice.

    https://wordpress.org/plugins/google-analytics-top-posts-widget/

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Justin Sternberg

    (@jtsternberg)

    I would use a snippet like this: https://gist.github.com/jtsternberg/58dc0a1abe7df36bbc0ad5a1ff9f4faa. If you want to get more fancy, you can use regex/preg_replace: http://php.net/manual/en/function.preg-replace.php.

    Just keep in mind, this is a filter on the entire output of the list, so you could mess up the html which could break the layout of your page.

    Thread Starter supertrooper2

    (@supertrooper2)

    Hi Justin

    I added the snippet you suggested to the functions.php file. The separator was indeed stripped out but replaced by another symbol with a space in front of it. e.g.

    �Wild Tigers of India – in Battle! [428 Views]

    Is there a way to remove the space and the new symbol?

    Please advise.

    Plugin Author Justin Sternberg

    (@jtsternberg)

    I’m not sure, it looks like you possibly have some odd encoding going on. I suggest playing with the replace values until it works right. For more info: http://php.net/manual/en/function.str-replace.php

    Thread Starter supertrooper2

    (@supertrooper2)

    Perhaps the alternative filter preg_replace would work better than str_replace.

    What would be the snippet to use with preg_replace?

    Please advise.

    Plugin Author Justin Sternberg

    (@jtsternberg)

    I’m sorry, but that’s outside the scope of this plugin’s support. The snippet I gave you, works for me, when I copy/paste the output from your site: http://codepad.org/TOWrGmom

    So something is different about the encoding on your actual site that is causing the replace to add a strange character.

    Thread Starter supertrooper2

    (@supertrooper2)

    I have read that the Plugin uses WordPress transients to cache the Google results so you’re not running the update from Google every time. cache updates every 24 hours. Does this mean that:

    a) the cache is supplemented with the additional stats from the previous 24 hours?

    or:

    b) the entire cache is deleted and the complete history re-cached from Google Analytics?

    If a) is the case, this could explain why formatting errors are preserved in the stats despite changes in the coding. e.g. » Wild Tigers of India – in Battle! [465 Views]

    In this case it could be worthwhile to delete the cached stats and allow Google Analytics to recreate the cache without formatting errors.

    Should I try deleting the cached stats via phpMyAdmin?

    Please advise.

    Plugin Author Justin Sternberg

    (@jtsternberg)

    Good point, but there is a filter on the cached output as well. I’ve updated the snippet to filter both: https://gist.github.com/jtsternberg/58dc0a1abe7df36bbc0ad5a1ff9f4faa

    Thread Starter supertrooper2

    (@supertrooper2)

    I tested the updated snippet but still get the same result:

    �Wild Tigers of India – in Battle! [428 Views]

    Which brings me back to my earlier questions:

    Is the cache stored in phpMyAdmin?
    Is it possible for me to drop the cache?
    If I drop the cache will the history be permanently lost?
    Alternatively will the history be regenerated from Google Analytics?

    Please advise.

    Plugin Author Justin Sternberg

    (@jtsternberg)

    Sure, you can drop the cache. The simplest way is to add ?delete-trans to the URL of the page where you want to flush the results. (e.g. http://focusingonwildlife.com/news/wild-tigers-of-india-in-battle/?delete-trans)

    And yes, the history will be re-populated from Google Analytics.

    But, the cache is likely not the culprit, and with the new snippet, it’s filtering the results of the cached AND non-cached versions, which tells me it’s still an encoding issue w/ your server. If you want to provide WP login credentials to your site via my contact form, I can try to look a little more in-depth. http://dsgnwrks.pro/connect/

    Thread Starter supertrooper2

    (@supertrooper2)

    I am pleased to report that with your help and suggestions I finally figured out the cause of this problem:

    It seems that our theme recently removed the SEO options because they are considered “plugin territory” by WordPress Themes Review Team. This was not widely publicized and had the unfortunate effect of reversing the order of post titles and blog title!

    The result was that the separator ( » ) was left at the beginning of the title (instead of the end of the title) after stripping out the blog name. e.g.

    » Wild Tigers of India – in Battle! [465 Views]

    The solution was to install the plugin All In One SEO Pack. Using the default settings this reverses the the order of post titles and blog title as it was before the theme removed the SEO functionality.

    So far it seems to be working perfectly.

    Thanks for your great help and suggestions, which contributed to the identification and solution of this problem.

    Plugin Author Justin Sternberg

    (@jtsternberg)

    Glad to hear it!

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘How can separators be removed?’ is closed to new replies.