0

I've got a function working to achieve what I want on my dev server, but it will not work on the live site.

I have a random image implemented via shortcode and plugin, and it must appear everywhere EXCEPT the home page. This is what works on my dev server:

add_filter( 'option_woo_options', ‘my_woo_options_filter' );
function my_woo_options_filter( $options ) {

$url = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];

if ( $url !== 'http://www.mydomain.net/' ) {
    $options[ 'woo_logo' ] = do_shortcode( '[random-image attachmentids="380,381,383,384,385,386,387,388,389,390,400" is_header="1"]' );
}

return $options;

} 

However, it will not work on my new server. Everything appears to be the same. The random image replaces the header on all pages, including the home page.

Any suggestions? I need to do this without changing header.php in the theme. Thanks!

1 Answer 1

1

Try to replace if ( $url !== 'http://www.mydomain.net/' ) with if ( !is_home() ), which is WP's own function that checks if it's the blog's front page.

3
  • We couldn't do that because woothemes get's it's options on the 'init' hook which is run before the 'is_home' knows it's on the front page or not - or so the person who helped me set this up tells me...
    – RexTheRunt
    Oct 20, 2014 at 15:20
  • How about $url = home_url(); codex.wordpress.org/Function_Reference/home_url Oct 20, 2014 at 15:36
  • Unfortunately, the same problem applies to home_url. I'm going to resolve it by changing header.php for now.
    – RexTheRunt
    Oct 21, 2014 at 9:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.