Community Forums › Forums › Archived Forums › Design Tips and Tricks › Adding Code to Custom Functions Kills Site
- This topic has 8 replies, 5 voices, and was last updated 9 years, 4 months ago by Brad Dalton.
-
AuthorPosts
-
July 27, 2015 at 6:17 pm #160637seanerin72Member
Hi, when I add code to the "custom functions" box under custom code, it shuts down my website. Meaning, when I try to go to my site, I get only a white screen. Here is my site: http://www.blackboarddreams.com
Any help would be greatly appreciated. Thank you.
July 27, 2015 at 7:26 pm #160651Victor FontModeratorIt would be helpful if you posted the code that's breaking the site.
Regards,
Victor
https://victorfont.com/
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet?July 27, 2015 at 8:50 pm #160671seanerin72MemberHere is just one bit of code that I used:
<?php if (is_category( 'sophs' )) {
echo do_shortcode("[metaslider id=5769]");
} ?>
Thank you so much.
July 27, 2015 at 9:31 pm #160677coralseaitMemberYou are probably already in php mode so need for the extra tags. So change it to:
if (is_category( ‘sophs’ )) { echo do_shortcode(“[metaslider id=5769]”); }
July 28, 2015 at 7:01 am #160727Victor FontModeratorAlso, use straight quotes, not curly quotes. Curly quotes will break php.
if (is_category( 'sophs' )) { echo do_shortcode("[metaslider id=5769]"); }
Regards,
Victor
https://victorfont.com/
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet?July 28, 2015 at 7:04 am #160728coralseaitMemberYeah, I've posted about tick versus back tick / etc on here before. For some reason a lot of discussion software mangles that and people just need to be aware cutting and pasting from the internet can be dangerous depending on character set, etc.
July 28, 2015 at 12:20 pm #160775seanerin72MemberThank you so much for getting back to me. I have changed the code to:
if (is_category( 'sophs' )) {
echo do_shortcode("[metaslider id=5769]");
}
Putting that code in the "custom functions" box does nothing. So, now using the simple hooks plugin, I input that code in the "genesis header hook" section clicking all three boxes (unhook genesis_do_header, execute shortcodes, execute php). If you click the link to my sophomore page you will see that the slider is there but so is the wording of the code. Also, the slider has been included on ALL of my pages when I only wanted it on the sophomore page.
http://www.blackboarddreams.com/category/sophs/Help please... 🙂 The school year is fast approaching...
July 28, 2015 at 12:54 pm #160777emasaiParticipantLook at your quotation marks in Simple Hooks, Coral Sea and Victor both mentioned this. There is a big difference between
” and " or ’ and '
. It's very slight I know, but that will kill your php. Anything you add into the header will appear on all pages, so you will have to use a conditional statement to select only the page you want your slider to appear. See here
Need Website Customization or a Responsive CSS fix? Contact Me
Lynne emasai.comJuly 29, 2015 at 3:17 am #160839Brad DaltonParticipantTry this in your functions file and change the hook position
function output_metaslider() { if (is_category( ‘sophs’ )) { echo do_shortcode("[metaslider id=5769]"); } } add_action( 'genesis_after_header', 'output_metaslider' );
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.