I'm displaying a gallery on my wordpress site using the following code:
<?php echo do_shortcode('[satellite gallery=2 auto=off caption=off thumbs=on]'); ?>
Now I've added a custom post value/field called 'guitLink' where I can add the gallery number which I want to then use in the above shortcode, so something like this:
<?php echo do_shortcode('[satellite gallery=' .get_post_custom_values('guitLink'). 'auto=off caption=off thumbs=on]'); ?>
Any ideas how to achieve this?
Use:
<?php $guitLink = get_post_custom_values('guitLink');
echo do_shortcode('[satellite gallery=' .$guitLink[0]. ' auto=off caption=off thumbs=on]'); ?>
Instead of
<?php echo do_shortcode('[satellite gallery=' .get_post_custom_values('guitLink'). ' auto=off caption=off thumbs=on]'); ?>
Related
I have a shortcode in a theme that displays only when a user is logged out. Usually, I would use the following shortcode to achieve this
[logged_out]Content[/logged_out]
How would I achieve this in PHP?
<?php echo do_shortcode("[logged_out]"); ?>
Can you just try the code like below,
<?php
$string = 'Hello world';
echo do_shortcode('[logged_out]'.$string.'[/logged_out]');
?>
you can assign any value to the variable $string ;
Or you can directly use like this,
<?php
echo do_shortcode('[logged_out]Hello world[/logged_out]');
?>
For more information please refer,
https://developer.wordpress.org/reference/functions/do_shortcode/
you can use following way in your php file.
echo do_shortcode('[logged_out] your content [/logged_out]');
I'm using Coupon Creator and I like that it comes with the categories and shortcodes. I am using a category shortcode like this example [coupon couponid="loop" category="Brumby's Bakery" couponorderby="date" coupon_align="cctor_alignnone" name="Coupon Loop"].
I wanted to use different category shortcode for each page. Therefore, I kinda created a custom meta box for that (Wordpress Meta Boxes) and called it in the php template page with <?php echo get_post_meta($post->ID, 'couponshortcode', true); ?>. However, the shortcode won't work in php template page unless I use <?php echo do_shortcode('[coupon...]'); ?>
In the end this code which was supposed to be like that wouldn't work because of php in php.
<?php echo do_shortcode(<?php echo get_post_meta($post->ID, 'couponshortcode', true); ?>); ?>
How do I rework this php code? The only thing I could think of is to use something like var but I don't know how to make it work in php template page.
var $store = <?php echo get_post_meta($post->ID, 'couponshortcode', true); ?>
<?php echo do_shortcode($store); ?>
No need to echo get_post_meta(). This should work:
<?php echo do_shortcode(get_post_meta($post->ID, 'couponshortcode', true)); ?>
Currently in the PHP file it has:
<?php if($myfooter_text){?>
<?php echo of_get_option('footer_text'); ?>
<?php } else { ?>
something else here
<?php } ?>
What I would like is for it to insert the footer text it finds using $myfooter_text but also add a link to the end of whatever has been pre filled in the footer text. I tried to use concatenation with the following:
<?php echo of_get_option('footer_text') . 'mylink; ?>
However this still just shows the predefined footer text and not the additional content. Is there a way to do this? I'm aware it could be added in the footer area of the dashboard but this isnt what i want to do.
Try it like this:
<?php echo of_get_option('footer_text'); ?> mylink
You can concatenate them as well like this or do it your way and be sure you close all the quotes:
<?php echo of_get_option('footer_text') . 'mylink'; ?>
this is the piece of code I'm not sure how to deal with:
<?php echo get_post_meta($post->ID, 'smartslider2', true); ?>
<?php echo do_shortcode('[smartslider2 slider="InsertHere"]'); ?>
I simply want to insert the first echo instead of InsertHere. The first echo should output the content of a custom field. The second should recall the slider with the specific number inserted in the custom field. When trying different possibilities I only get errors.
Can anybody help?
Thank you :)
Don't echo the first value, use it directly inside your second echo.
<?php
echo do_shortcode('[smartslider2 slider="'.get_post_meta($post->ID, 'smartslider2', true).'"]');
?>
Or you can easily put that first value in a variable and use that variable in the second line
<?php $slider = get_post_meta($post->ID, 'smartslider2', true); ?>
<?php echo do_shortcode('[smartslider2 slider="'.$slider.'"]'); ?>
this is the code where it load my dynamic menu
<?php echo $this->dynamic_menu->build_menu('1'); ?>
this is the code for my language type
<?php echo lanchor($uri, lang('menuenglish')); ?>
here i wanto to add like this
<?php echo $this->"<?php echo lanchor($uri, lang('menuenglish')); ?>"->build_menu('1'); ?>
i know the uper code is wrong but for makeing it clear..
instead of the dynamic_menu i wanto to echo from my language varaiables
one of my language variable inside the dymanic menu
regards
Just do this :
<?php
$menu = lanchor($uri, lang('menuenglish'));
echo $this->{(string) $menu}->build_menu('1');
?>
But if you search for this in Google, you will be able to find the answer.