Jump to content
Sign in to follow this  
cdhphoenix

Add Php function to Page Template

Recommended Posts

cdhphoenix    0
cdhphoenix

Hi Guys, I am trying to install a carousel gallery on this one page, which I have created in base theme for platform pro. This is the link to see what plugin it is if you require: [http://wordpress.org/extend/plugins/wp-carousel/installation/ It asks to place this code in my page template (which in this case, is the child functions.php? AM i correct in this assumption?:

	<?php wp_carousel(CAROUSEL'S ID); ?>
I m trying to understand hooks so I can add this on my own without having to ask everytime. I think i had it, but then i got an error, this is my interrpretation of it:
	add_action('pagelines_after_theloop','wp_carousel')
	function wp_carousel(){
	if (is_page('114')):
	wp_carousel('0');
	endif;
	}
	

But of course, that didn't work? Which line is incorrect so I can learn from my mistakes to do this own my own and add php functions on my own (I would like to add more than one gallery on this page)? My page is called page.114.php for your reference. Any suggestions of how I can add this to the page template would be greatly appreciated. thank you kindly. Carolyn

Share this post


Link to post
Share on other sites
bryan-hadaway    3
bryan-hadaway

Marking for developer review. Thanks, Bryan

Share this post


Link to post
Share on other sites
cmunns    16
cmunns

Did it return an error or is simply not working? The hook and code you used look fine unless of course it doesn't allow "0" as an ID.

Share this post


Link to post
Share on other sites
Simon    247
Simon

Try some debugging 101 ;) `add_action('pagelines_after_theloop','wp_carousel');` `function wp_carousel(){` `if (is_page('114')):` `echo 'this is page 114 and my carousel should be here!';` `endif;` `}` You did forget the ; at the end of your add_action line, but that should have thrown a php error.

Share this post


Link to post
Share on other sites
cdhphoenix    0
cdhphoenix

Hey Guys, Thanks for your input; so this is code i ended up tweaking, after fixing my typo:

	add_action('pagelines_after_theloop','wp_carousel');
	function wp_carousel(){
	if (is_page('114')):
	wp_carousel('1');
	endif;
	}
	
*note, line 110 is the very last "}" in the code. But then i get this error:
Fatal error: Cannot redeclare wp_carousel() (previously declared in /home/thewood2/public_html/www.criterioninedit.com/wp-content/plugins/wp-carousel/wp-carousel.php:451) in /home/thewood2/public_html/www.criterioninedit.com/wp-content/themes/platformbase/functions.php on line 110
AHhhhh. It never ends! Once again, this is the code the plugin asks to input in the page template:
<?php wp_carousel(CAROUSEL'S ID); ?>

If anyone knows how to litigate this error, i would greatly appreciate it.

Share this post


Link to post
Share on other sites
Simon    247
Simon

Your nearly there, your function must be unique: `add_action('pagelines_after_theloop','my_wp_carousel');` `function my_wp_carousel(){` `if (is_page('114')):` `wp_carousel('1');` `endif;` `}`

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

×