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.'"]'); ?>
Related
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)); ?>
I am new in Yii.
I have a view file with following code
<?php echo CHtml::beginForm(); ?>
<?php echo CHtml::activeTextArea($model,'adremarks');?>
<?php echo CHtml::submitButton('Swap',array('id'=>'swap'));?>
<?php echo CHtml::endForm(); ?>
I want to access the value of text area to my script, here my jQuery script
var adremarks= $("textarea#adremarks").val();
alert(adremarks);
But I cant get the value there, Is this the right way else how can I get a text area value to script
Thanks in advance
The problem is your activeTextArea does not have html ID. You need to add id in this way:
<?php echo CHtml::activeTextArea($model,'adremarks', array("id" => "adremarks"));?>
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]'); ?>
In WordPress i'm currently using this function from a plugin <?php the_field('event_boat'); ?> to output the post ID for the selected field, which happens to be 5755 in this example.
As the plugin only allows me to output the post ID is it possible to incorporate the value from that function inside <?php echo get_permalink(); ?> to get the permalink based on the post ID?
You can pass the ID as a parameter in the get_permalink function, either by storing the ID value in a new variable, or just passing in the ACF-function directly as a parameter.
$post_id = get_field('event_boat');
echo get_permalink($post_id) // echoes out link for ID 5755
I'm using get_field() instead of the_field() because the_field() will echo out the value, We just want to pass it along.
We might aswell just do:
echo get_permalink(get_field('event_boat'));
This should work fine. :)
<?php $a = get_permalink(get_field('event_boat')); echo $a; ?>
<?php $a =get_permalink(get_field('event_boat')); echo $a; ?>
This should work fine. :)
<?php echo get_permalink(get_field('event_boat')); ?>
The following code is for a Wordpress plugin, it displays points and tank of a user:
<?php
if(function_exists('cp_displayPoints') && $authordata->ID){
echo '<span class="cubepoints_buddypress">'; cp_displayPoints($authordata->ID); echo '</span>';
if(function_exists('cp_module_ranks_getRank')) echo ' <span class="cupepoints_buddypress_rank">'.cp_module_ranks_getRank($authordata->ID).'</span>';
}
?>
I am trying to extract these two echo functions from the If statement but only succeeded with one of them. I can echo the points like this:
<?php cp_displayPoints($authordata->ID); ?>
Works fine. Now I tried doing the same with the second echo:
<?php cp_module_ranks_getRank($authordata->ID); ?>
But it did not work. Obviously, there is some basic thing that I am missing here. Do you know what it is?
The first one likely prints directly to output, while the second returns its value. So, you need to echo() the second one, just as they're doing in your sample code:
<?php echo cp_module_ranks_getRank($authordata->ID); ?>