add-page functionality
-
I’m relatively new to WordPress and to PHP, so please forgive any idiocy.
I’m running a plugin (WP-Carousel) on a template for a page I’m designing/developing. That template will be used for several pages in the site. The content of each carousel, however, must be different.
This is all well and good when I am setting things up and configuring each individual carousel in the back-end via php. I am actually currently using conditional php to let each individual carousel gallery be pulled in, depending on the page’s name.
However, I need a way for my client to be able to add a new page using that same template, while being able to pull in a carousel that has a unique ID and unique content, all while never touching code.
Is this possible?
Essentially, the WP-Carousel plugin requires that I enter
<?php wp_carousel(CAROUSEL'S ID); ?>into the template, wherever I want the carousel to appear. The ID# is automatically assigned to a carousel based on the order in which you create them — you have no choice in naming it. So my first Carousel has an ID# of 0, the second has an ID# of 1, etc.
So, is there any way for me to add php to a template that would allow the client to add meta-data to a page — that would then allow that page to recognize and display a certain gallery with a certain ID number? Could I somehow use slugs or custom fields with some kind of <?php get_meta…?> code which I then use to populate the wp_carousel() call?
Any help would be much appreciated.
-
Your best bet would be to create a page template using php that the user can select. You can read about that at http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates.
Once you create that page template you should think about creating your own shortcode that your client can add directly into the content where they want the carousel to appear. You would probably want the carousel ID to be the attribute they enter. It would like something like:
[carousel id=”4″]
You can read about creating your own shortcodes and find examples at http://codex.wordpress.org/Function_Reference/add_short code.
You can add the code for the shortcode to either the functions.php file or to your own plugin.
Hope that’s helpful. Good luck.
The topic ‘add-page functionality’ is closed to new replies.