1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Is there a way to cahe searches in wp?

Discussion in 'General Programming Chat' started by undeterminederror, Sep 18, 2009.

  1. undeterminederror

    undeterminederror BANNED BANNED

    Joined:
    Mar 31, 2008
    Messages:
    630
    Likes Received:
    457
    i need search results pages to be cached in database of wordpress, is there a way ?
     
  2. cyklotrial

    cyklotrial Regular Member

    Joined:
    Oct 13, 2008
    Messages:
    248
    Likes Received:
    82
    Location:
    Wonderland
    do you mean saving eg. Google serch resoults in WP?
     
  3. undeterminederror

    undeterminederror BANNED BANNED

    Joined:
    Mar 31, 2008
    Messages:
    630
    Likes Received:
    457
    nope, when somebody search something in my blog, the result page to be cached as a html and not dynamic as php.
     
  4. cyklotrial

    cyklotrial Regular Member

    Joined:
    Oct 13, 2008
    Messages:
    248
    Likes Received:
    82
    Location:
    Wonderland
    hmmm i think that it can be done...
    in search.php file (in your template folder) you can add variable for saving whole page with search resoults (eg.$s_content)

    PHP:
    $s_content='<div id="content">';

    <?php if (have_posts()) : ?>
        $s_content.='next tags for template blablabla';
        <?php while (have_posts()) : the_post(); ?>

    //here another tags for conent (for titles dates etc)

    $s_content.=get_the_content();

    //here another tags for conent
        <?php endwhile; ?>
    <?php 
    endif; ?>
    you need to use wp functions with "get_" at the begining in the name or with "echo=0" as arguments to not show resoults but save it in variable.
    than just save this variable in *.html file using
    fopen():
    fwrite();
    fclose();


    and show it using redirection/including/iframe etc etc
    After that you can delete this file or save it for search engines



    I hope you will understand the idea how it can be done.

    regards
    Cyklotrial
     
  5. undeterminederror

    undeterminederror BANNED BANNED

    Joined:
    Mar 31, 2008
    Messages:
    630
    Likes Received:
    457
    nope, sorry, i didn't :( i mean like in wp cache, like the other pages...
    there are some cache plugins but they cache just posts...
     
    Last edited: Sep 19, 2009