WordPress.org

Ready to get started?Download WordPress

Forums

Contextual Related Posts
[Hack]Optimized usage of contextual related plugin (2 posts)

  1. vijayrajesh
    Member
    Posted 2 years ago #

    Hi,

    I use Contextual Related Plugin in my every blog. Just because, it helps me get very good traffic and nice user experience by providing best "relates posts".

    After getting lots of traffic in one of my blog, my host suddenly suspended my site due to high RAM usage and lots of queries in each and every page. Yes, in homepage, single post, tag page, category page, everywhere number of queries multiplied with 30 queries into number of posts.

    So, if the homepage displays 10 pots, The number of queries where almost 300.

    While checking the plugins manually one by one, i found that CRP is causing the increase in queries for each page.

    But technically, We know that only single post page needs "related posts display" and other pages do not need that plugin.

    Although i am not a coder, i could tweak plugins. I tried tweaking the plugin and set the plugin to execute the SQL query only in single post page.

    I edited contextual-related-posts.php through admin and replaced


    if (is_int($post->ID))&&($stuff != '')) {

    With

    if ((is_single()&&is_int($post->ID))&&($stuff != '')) {

    This will be approximately in 67th line.

    Once you save this code, the plugin will execute the query only in single post page.

    This hack has helped me a lot and reduced my "number of queries" loaded to 30 queries again.

    And after using W3 Total Cache, astonishingly it became 2 queries in homepage.

    Currently i use them at my blogs http://blog.pixelthemes.com/ and http://graphicblog.net/

    Happy tweaking :)

  2. Ajay
    Member
    Plugin Author

    Posted 2 years ago #

    Thanks for this hack. This is something I debated a lot. I think I'll try to throw in a feature with this for users who only care about using it on a single page

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic