I was wondering if there is a way to add hidden shortcode to every Woocommerce's product post? And how would I do that?
Shortcode is: [customer_list]
Thanks
This should do it for you:
<div style="display:none;">
<?php echo do_shortcode('[customer_list]'); ?>
</div>
You can use <?php echo do_shortcode('[customer_list]'); ?> within the div wrapper if you are editing the content-product.php template or any other that is used directly on the product page.
Related
I created a new template for a page.
<?php
/**
* Template Name: Sponsors For Homepage
*/
?>
<html>
<body>
<?php get_header('sponsor'); ?>
<div class='divone'>
<?php the_content(); ?>
</div>
<div class='divtwo'>
<?php sponser_advertisement(); ?>
</div>
</section>
</body>
</html>
And I added a new custom field for the template. Using the Advanced Custom Fields plugin 4.4.8
I made sure that the field would show on the correct template:
The fields showed up on my template page
For some reason the field value "This is the new field" does not not show up when I preview the page in my browser.
Thanks in advance.
Suggestions?
This is the wrong way to display the custom field value.
If you want to display custom field values in your template, using Advanced custom fields plugin you have to use functions like these:
<?php the_field('field_name'); ?>
or
<?php echo get_field('field_name'); ?>
you can find full documentation on working with ACF values in here:
ACF Documentation
I have a div on my home page that I want to contain the top 8 best selling products from my website. Seeing as I'm using Woocommerce I've looked around and found the short code, but I don't know how to add that to the div. Can anybody help solve this please? Thanks in advance!
Woocommerce shortcode:
add_shortcode('best_selling_products', 'woocommerce_best_selling_products');
HTML:
<div id="trending">
add_shortcode('best_selling_products', 'woocommerce_best_selling_products');
</div>
do_shortcode function is used to fire up shortcodes
<div id="trending">
<?php echo do_shortcode('[best_selling_products]'); ?>
</div>
More: do_shortcode()
I want to change the product category menu style on the Woocommerce widgets but I can't find where to make the change. So far I've only found this. Where are the appropriate HTML tags?
<aside class="span4">
<div class="aside-wrap">
<?php dynamic_sidebar('Woocommerce Sidebar'); ?>
</div>
</aside>
Check your functions.php or simillar files, there will widgets_init hook using register_sidebar to register Woocommerce Sidebar.
In my shopping cart page i need to be able to check if any added products have a particular custom option set on them - in this case a custom option called 'age_guide'.
If so i need to add a small disclaimer text line. How would i go about doing so?
If your custom option set on a product is age_guide, then in your
template/checkout/cart/item/default.phtml
around line 46
<?php echo $this->htmlEscape($_option['label']) ?>
Use below code:
<?php if($_option['label'] =='age_guide'): // or whatever your custom option label ?>
<div>
<span><?php echo $this->__('Your Disclaimer Text Goes Here');?></span>
</div>
<?php endif; ?>
I have a custom wordpress post.php, all posts within a specific category will use this template. In nearly every post there will be scrolling testimonials, to handle this I am using a layer slider.
Within the page I have a custom field of testimonial that is filled with something like [layreslider id="2"]
In my php file I have:
<div class="trips-testimonials">
<?php do_shortcode(get_post_meta($post->ID, 'testimonial', true)); ?>
</div>
This seems to do nothing. If I add echo to the PHP:
<?php echo do_shortcode(get_post_meta($post-ID, 'testimonial', true)); ?>
I get the output of [layreslider id="2"]
Here is a sample page, the blue box under the photo is where the slider should show up.
http://www.ct-social.com/ctsdev/aff/capri/
Thank you very much for your help.
looks like you miss the > from post Id so it should read
<?php do_shortcode(get_post_meta($post->ID, 'testimonial', true)); ?>
Also you may need to call global $post; if outside the loop.