Community Forums › Forums › Archived Forums › Design Tips and Tricks › Seeking help with hook with conditional statement
Tagged: conditional statement, hook, syntax error
- This topic has 7 replies, 2 voices, and was last updated 12 years, 7 months ago by
Brad Dalton.
-
AuthorPosts
-
October 24, 2013 at 10:47 am #68650
Jumpringer
MemberGoal: display a different image that displays beneath the header on specified pages.
The original "Beautiful Pro" template code is this:
//* Hook site header banner after header
add_action( 'genesis_after_header', 'beautiful_site_header_banner' );
function beautiful_site_header_banner() {echo '<div class="site-header-banner"></div>';
}
My revised code (which has a syntax error I can't resolve) is this:
//* Hook site header banner after header
if (is_home())
add_action( 'genesis_after_header', 'beautiful_site_header_banner' );
function beautiful_site_header_banner() {
echo '<div class="site-header-banner"></div>';
} elseif (is_page('?page_id=12'))
add_action( 'genesis_after_header', 'beautiful_site_header_banner' );
function beautiful_site_header_banner_custom() {
echo '<div class="site-header-banner-add"></div>';
}
These two lines display as php errors when viewed in Dreamweaver:
add_action( 'genesis_after_header', 'beautiful_site_header_banner' );
function beautiful_site_header_banner_custom() {
If you can point me in the right direction, it will be appreciated!
October 24, 2013 at 12:05 pm #68663Brad Dalton
ParticipantHow many pages and how many images do you want to display after the header?
Please paste code in a Github Gist or Pastebin.
What is the error message?
October 24, 2013 at 4:19 pm #68720Jumpringer
Member8 additional pages each with a different image that displays beneath the header.
Parse error: syntax error, unexpected T_CLASS, expecting ',' or ';' in /usr/www/users/me/stage/dev/my_site/wp-content/themes/beautiful-pro/functions.php on line 110
<script src="http://pastebin.com/embed_js.php?i=Qh0SRziH"></script>
pastebin title:Hook with conditional statements
Thanks.
October 24, 2013 at 4:47 pm #68726Brad Dalton
ParticipantThe code i looked at is not written properly.
You might be better off using a custom field to add different images after the header http://wpsites.net/web-design/add-unique-header-images-using-custom-fields/
October 25, 2013 at 11:41 am #68869Brad Dalton
ParticipantOctober 25, 2013 at 12:21 pm #68879Jumpringer
MemberJust what I was looking for! I did begin the custom field approach described in your previous post, but this technique with the conditional statement is more streamlined. I'll keep this post open until I finish my coding. Thanks again.
October 25, 2013 at 3:00 pm #68925Jumpringer
MemberBrad, I successfully used your code here: http://wpsites.net/web-design/display-different-after-header-images-in-beautiful-pro-theme/
and added one more condition, which worked fine. You rock.
October 25, 2013 at 5:50 pm #68959Brad Dalton
Participant -
AuthorPosts
- The topic ‘Seeking help with hook with conditional statement’ is closed to new replies.