Tips and Tricks HQ Support Portal › Forums › WP eStore Forum › Calling shortcodes in custom text areas
- This topic has 1 reply, 2 voices, and was last updated 13 years ago by admin.
-
AuthorPosts
-
November 9, 2011 at 10:17 pm #4726boagworldMember
I have a little PHP teaser I was hoping you could help me with.
I use a plugin to pull back some HTML content contained in a DB field. Nothing very clever. I pull it back as follows…
<?php $new_value = get_terms_meta($term->term_id, 'details', true);
if (function_exists('get_terms_meta')): ?>
<section id="seasonDetails"><?php echo $new_value; ?></section>
<?php endif; ?>As you can see it is essentially pulling the content from ‘details’ in and then displaying it as an echo.
The problem I have is that within the details field I would like to include this piece of PHP…
<?php echo print_eStore_buy_now_button(4); ?>
Basically I want the displaying of the field to trigger this other command to be run and displayed.
Of course, running an echo within an echo doesn’t work. Can any of you guys think of a work around.
Alternatively is there a way to get Shortcodes converted in other fields other than the main content area of wordpress?
Okay here is a more detailed description.
Essentially I use a plugin called category_meta to add a field into my season pages that allow me to show more of a description.
In that field I want to have a buy button to sell a book associated with that season. To do this I use a plugin called eStore.
eStore allows me two ways to call in buy buttons.
Shortcodes – [wp_eStore_buy_now:product_id:4:end]
PHP – <?php echo print_eStore_buy_now_button(4); ?>
The problem is that neither are processed within the meta field. The shortcode appears as text and the PHP is just not displayed at all.
Any ideas?
November 10, 2011 at 3:10 am #38328adminKeymasterYou can’t just place a PHP function in the custom fields and expect it to get executed. You need to look at it from a different angle.. for example store the product ID in a custom field and then call a function with the value of that custom field. These posts has examples that should give you ideas:
Problems adding "Add to Cart" on index.php using Custom Fields
-
AuthorPosts
- You must be logged in to reply to this topic.