Community Forums › Forums › Archived Forums › Design Tips and Tricks › Background image ONLY Homepage
Tagged: agency pro
- This topic has 12 replies, 4 voices, and was last updated 11 years ago by Bader.
-
AuthorPosts
-
December 21, 2013 at 6:48 am #80590macrunnerParticipant
Hi,
I'm using Agency Pro.
I would like to display an image only on the Homepage. A color, for example #fcfcfc, for everything else, Pages, Posts, Comments, etc..
Thank you very much
December 21, 2013 at 7:08 am #80591Brad DaltonParticipantDecember 21, 2013 at 7:20 am #80592Brad DaltonParticipantYou could also change the PHP in the functions file so its includes a conditional tag for the front page like this:
if ( ! is_front_page() || ! get_background_image() ) return;
December 21, 2013 at 7:34 am #80596macrunnerParticipantHi Brad,
If I insert this code in the file front-page.php I get a blank page :
//* Enqueue Backstretch script and prepare images for loading add_action( 'wp_enqueue_scripts', 'agency_enqueue_backstretch_scripts' ); function agency_enqueue_backstretch_scripts() { //* Load scripts only if custom background is being used if ( ! get_background_image() ) return; wp_enqueue_script( 'agency-pro-backstretch', get_bloginfo( 'stylesheet_directory' ) . '/js/backstretch.js', array( 'jquery' ), '1.0.0' ); wp_enqueue_script( 'agency-pro-backstretch-set', get_bloginfo( 'stylesheet_directory' ).'/js/backstretch-set.js' , array( 'jquery', 'agency-pro-backstretch' ), '1.0.0' ); wp_localize_script( 'agency-pro-backstretch-set', 'BackStretchImg', array( 'src' => get_background_image() ) ); }
This site DEMO: http://egotheme.it/
December 21, 2013 at 7:58 am #80600macrunnerParticipantI tried the second method, I inserted this code in the front-page.php file but it has no effect:
if ( ! is_front_page() || ! get_background_image() ) return;
With this code, blank page:
//* Enqueue Backstretch script and prepare images for loading add_action( 'wp_enqueue_scripts', 'agency_enqueue_backstretch_scripts' ); function agency_enqueue_backstretch_scripts() { //* Load scripts only if custom background is being used if ( ! get_background_image() ) return; wp_enqueue_script( 'agency-pro-backstretch', get_bloginfo( 'stylesheet_directory' ) . '/js/backstretch.js', array( 'jquery' ), '1.0.0' ); wp_enqueue_script( 'agency-pro-backstretch-set', get_bloginfo( 'stylesheet_directory' ).'/js/backstretch-set.js' , array( 'jquery', 'agency-pro-backstretch' ), '1.0.0' ); wp_localize_script( 'agency-pro-backstretch-set', 'BackStretchImg', array( 'src' => get_background_image() ) ); }
Maybe I'm wrong something?
December 21, 2013 at 8:37 am #80609Brad DaltonParticipantHi
Please copy ALL the code from the view raw link and paste it at the end of your child themes functions.php file using a text editor like Notepad++
https://gist.github.com/braddalton/e503631f6937fce74f2c
December 21, 2013 at 8:55 am #80611macrunnerParticipantI used this code (github), no formatting, just as below:
//* Enqueue Backstretch script and prepare images for loading add_action( 'wp_enqueue_scripts', 'agency_enqueue_backstretch_scripts' ); function agency_enqueue_backstretch_scripts() { if ( ! is_front_page() || ! get_background_image() ) return; wp_enqueue_script( 'agency-pro-backstretch', get_bloginfo( 'stylesheet_directory' ) . '/js/backstretch.js', array( 'jquery' ), '1.0.0' ); wp_enqueue_script( 'agency-pro-backstretch-set', get_bloginfo( 'stylesheet_directory' ).'/js/backstretch-set.js' , array( 'jquery', 'agency-pro-backstretch' ), '1.0.0' ); wp_localize_script( 'agency-pro-backstretch-set', 'BackStretchImg', array( 'src' => get_background_image() ) ); }
This code I added to functions.php of the child theme Agency Pro, but still blank page.
I tried a new installation on the local server, same problem.December 21, 2013 at 9:08 am #80612macrunnerParticipantThis is the functions.php file that I edited (download ZIP file): http://egotheme.it/functions.zip
December 21, 2013 at 8:49 pm #80692Brad DaltonParticipantDecember 22, 2013 at 2:13 am #80733macrunnerParticipantHi Brad,
I'm sorry, I misunderstood.
Ok now it works, thank you very muchDecember 28, 2013 at 11:57 pm #81770omerkhanMemberThank you Brad!!
December 29, 2013 at 6:28 am #81793Brad DaltonParticipantJanuary 1, 2014 at 4:12 pm #82545BaderMemberThanks for the hint! 😉
“Whether you think you can, or you think you can’t–you’re right.”
?• Henry Ford -
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.