custom-background in home page only
-
I’m trying to have a custom background using add_theme_support in functions file that is only shown on the home page.
add_theme_support( 'custom-background' )
works when used by itself, but I can’t get it to work in a condition. This is my code which includes echo statements for testing:function custom_bg() { if(is_front_page()){ echo "you are at front page"; add_theme_support( 'custom-background' ); }else{ echo "you are NOT at front page"; } } add_action( 'wp', 'custom_bg' );
The function seems to work, since the echo statements behave as expected. I’m hooking to ‘wp’ so that the function gets executed after wordpress knows that the page will be the front page. What am I missing or doing wrong?
In Reading Settings I have static page with the correct front page. I’m using a front-page.php template file. And I’m using underscores starter theme.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘custom-background in home page only’ is closed to new replies.