I'm trying to optimize MySQL queries, so I have replaced query:

```
echo wp_list_pages("title_li=&depth=3");

```

with:

```
$sidebar_menu = get_transient( 'sidebar_menu' );
if( $sidebar_menu === false ) {
    $sidebar_menu = wp_list_pages("title_li=&depth=3&echo=0");
    set_transient( 'sidebar_menu', $sidebar_menu, 60*60*24 );
}
echo $sidebar_menu;

```

But something weird is happening, after I return after 20 sec again in website and click on one of the links in sidebar, redirects me to the: [financedaily.co/work-at-home-mom-true-success-story/](http://financedaily.co/work-at-home-mom-true-success-story/)

Do you have any idea what is going on and how can I optimize the wp\_list\_pages query ? I am using shared hosting from [icnhost.net](http://icnhost.net)

Also when I activete W3TotalCache plugin, redirects all the pages on external URL.