recently i install wordpress Themeforest VideoTube Theme. But when i use codecanyon Social Locker plugin, then facing this issue. My wordpress theme only support do_shortcode
My short code is...
[sociallocker id="2378"] [/sociallocker]
and i want to put this code in the middle position of my short code.
<div class="player player-small <?php print apply_filters( 'aspect_ratio' , 'embed-responsive embed-responsive-16by9');?>">
Kindly help me... how can i to do this? What query i set to in my wordpress theme functions.php file?
You can use do_shortcode like this way,
$text_to_be_wrapped_in_shortcode = '<div class="player player-small <?php print apply_filters( 'aspect_ratio' , 'embed-responsive embed-responsive-16by9');?>">';
echo do_shortcode( '[sociallocker id="2378"]' . $text_to_be_wrapped_in_shortcode . '[/sociallocker]' );
This should work,
$text_to_be_wrapped = "<div class='player player-small ".apply_filters( 'aspect_ratio' , 'embed-responsive embed-responsive-16by9')."'";
echo do_shortcode( '[sociallocker id="2378"]' . $text_to_be_wrapped . '[/sociallocker]' );
Related
In standard Woocommerce on the products page of the shop has a nice "add-to-cart"-button. I wanted to add a "more-information"-button to it in the same style.
Using the code from this page I managed to add a button by placing this code in my functions.php:
add_action('woocommerce_after_shop_loop_item_title','more_information');
function more_information() {
global $product;
$link = $product->get_permalink();
echo do_shortcode('<br>[button class="meer-informatie" link="' . esc_attr($link) . '"]meer informatie[/button]');
}
It's crucial I add a class to the button I want to add so I can style it. Point is I added the button (see image) but the link isn't working. It needs to link to the productdetail-page. So, where does it go wrong? I can't seem to figure it out (but then again: I only speak PHP a little).
Thanks in advance for any help!
Still don't really know what is wrong with the code I posted in my question but I found something that actually works. Someone might someday be looking for this or encounter the same issue so I'm going to post this as an answer to my own question. After seeking help in all kinds of directions I came up with the following code:
function more_information() {
global $product;
if ($product){
$url = esc_url($product->get_permalink() );
echo '<a rel="nofollow" href="' .$url .'" class="meer-informatie">meer informatie</a>';
}
}
add_action('woocommerce_after_shop_loop_item_title','more_information');
It works like a charm!
If you need to localize the string following Wordpress guide:
function more_information() {
global $product;
if ($product){
$url = esc_url($product->get_permalink() );
echo '<div class="bottone-cat"><a rel="nofollow" href="' .$url .'" class="tt_button tt_primary_button">';
echo __('More Information','woocommerce');
echo '</a></div>';
}
}
I tested it with WPML and it works fine.
I am new to PHP and was writing a condition while making WordPress website. I have writing the correct tag syntax but when I am converting it into PHP echo then it is showing error.
Both the tags are present in the jsfiddle link below.
Jsfiddle link
Please let me know how to convert correct HTML code of the jsfiddle link to correct and working PHP code.
In wordpress we can write php code in header.php , footer.php etc. files which are under the directory wordpress/wp-content or wordpress/wp-admin etc.
But if we want to use php code after login in wordpress I mean in page, post , widget etc. wordpress can't recognize those php code ().
So, please explain in which file are you writing both code.
I'm damn sure that the code which is not working is inside the admin panel.
(Note : if you want to use condition through () inside admin panel (inside page,post etc.) ) you have to add a plugin like Exec-PHP (https://wordpress.org/plugins/exec-php/) or any other plugin which executes PHP code in posts, pages and text widgets.
May be this will help
You added something in last like
";}?>
These are no needed
<?php if (is_user_logged_in() ) {
echo "<a"; <?php if ( get_post_meta( get_the_id(), 'dysaniaselect', true ) == 'dysania-link' && get_option('dysania_gridgallery_targetblank') == "true") {
echo 'target="_blank"'; } ?> class="<?php echo( get_post_meta( get_the_id(), 'dysaniaselect', true ) ); ?> <?php echo 'clbx' . $id; ?>" data-title="<?php the_title(); ?>" data-rel="<?php echo ( get_post_meta( get_the_id(), 'dysaniaselect', true ) ) . 'clbx' . $id; ?>" href="<?php if (!empty($video)) { echo $video; } else { echo $imageurl; } ?>">
I have a Wordpress website with Virtue theme. And I want the page titles on every page (except the homepage) give a typing effect. I installed this plugin and it wrotes I just need to insert this code:
<?php echo do_shortcode( '[typed string0="Projects" typeSpeed="40" startDelay="0" backSpeed="40" backDelay="500"]' ) ?>
into the .php file in the theme where I need it. I just need to change the "Projects" to the actual page's title.
Where should I insert it?
You should concatenate that string with get_the_title():
<?php echo do_shortcode( '[typed string0="' . get_the_title() . '" typeSpeed="40" startDelay="0" backSpeed="40" backDelay="500"]' ) ?>
I could find the solution! I had to insert it in page-header.php like:
<?php echo do_shortcode( '[typed string0="'. apply_filters('kadence_page_title', kadence_title() ) .'" typeSpeed="40" startDelay="0" backSpeed="40" backDelay="500"]' ); ?>
I've done a ton of searching and I'm pulling out what's left of my hair. The PHP code on its own is:
<?php echo wp_get_attachment_url($file->ID) ?>
...the shortcode is: [embed][/embed]
I've tried all sorts of variations of 'do shortcode' but can't get things working. Can you suggest the correct code?
WordPress (3.6 or higher) has an audio shortcode, the following should work:
$mp3 = wp_get_attachment_url( $file->ID );
echo do_shortcode( '[audio src="' . $mp3 . '"]' );
More info: https://codex.wordpress.org/Audio_Shortcode
I am building a wordpress ecommerce template with Cart66 plugin. Using a Cart66 shortcode inside a php template page, I would like to generate the Post ID inside the shortcode. Can someone please help and tell me if this is possible. Here is the code that I am using.
<?php echo do_shortcode("[add_to_cart item=\". the_ID() .\" quantity=\"user:1\"]"); ?>
This code will lay inside loop-single.php and above
Thank you!
#silent almost had it, but it should be get_the_ID() and not the_ID() since the later one echos it out, so try:
<?php echo do_shortcode("[add_to_cart item=\"". get_the_ID() ."\" quantity=\"user:1\"]"); ?>
The right line should be:
<?php echo do_shortcode("[add_to_cart item=\"". the_ID() ."\" quantity=\"user:1\"]"); ?>
simpler correct answer:
<?php echo do_shortcode('[add_to_cart item="'. get_the_ID() .'" quantity="user:1"]');?>