Menu
  • HOME
  • TAGS

wordpress shortcode attributes not being passed

php,wordpress,shortcode

function list_display($atts) { $atts = shortcode_atts( array( 'pagename' => 'No Page Received' ), $atts ); extract($atts); echo $pagename; } add_shortcode('list-display', 'list_display'); You'll probably want to use "return" instead of "echo" if you're using the shortcode within pages and posts.. Echo could cause it to send output to the screen a...

Shortcode default variables don't appear

php,wordpress,function,variables,shortcode

Don't add the attributes that don't have a value. Otherwise you're giving the value of an empty string. So it doesn't take the default value. e.g [blogcolumns limit="3" columns="3"] Or [blogcolumns limit="5"] ...

Wordpress shortcode inside shortcode not working

wordpress,shortcode

You need to return the html in your callback function, e.g.: function test() { $html = ''; $html .= '<h1>Datos de Usiario</h1>'; $html .= '<form id="" action="" method="">'; // etc. return $html; } ...

Create wordpress shortcode for jQuery UI Tabs

php,jquery,wordpress,jquery-ui,shortcode

OK this is what you have to do. if( is_array( $GLOBALS['tabs'] ) ){ foreach( $GLOBALS['tabs'] as $k=>$tab ){ $tabs[] = '<li><a href="#tab-'.$k.'">'.$tab['title'].'</a></li>'; $panes[] = '<div id="tab-'.$k.'"><p>'.$tab['content'].'</p></div>'; } $return = "\n".'<!-- the tabs --><div class="tabs"><ul>'.implode( "\n", $tabs ).'</ul>'."\n".'<!-- tab "panes" -->'.implode( "\n", $panes ).'</div>'."\n"; } ...

php remove selected square brackets and ignore the rest [closed]

php,regex,shortcode

This should do it. Just add the static value between the brackets. $str = 'The [adjective value="quick"] brown fox [verb value="jumps"] over the lazy dog.'; echo preg_replace("/\[adjective.*?\]/", '', $str); Output: The brown fox [verb value="jumps"] over the lazy dog. Demo: http://sandbox.onlinephpfunctions.com/code/3495d424001f71d360270cb78d767ba7d0ec034b This solution also presumes the first ] is closing...

How to pass parameter that ends up being part of a class name with wordpress shortcode

php,wordpress,parameter-passing,shortcode

please modify your shortcode : [/box] to [end-box] [box color="bluemed"] Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec nec nulla vitae lacus. [end-box] Try this : I replace [/box] to [end-box] and also in grey to 'grey' function colored_box_shortcode($atts) { extract(shortcode_atts(array( 'color' => 'grey', ), $atts)); return '<div class="shadow-wrapper...

Add shortcode inside another with echo

wordpress,wordpress-plugin,shortcode

There's not enough information in your code sample to say for sure. However, it looks like you are attempting to put PHP code into an actual WordPress page/post. Is that the case? If not, please provide more info on what you're trying to do exactly. If so, you can't put...

How to extract the variables out from “add_shortcode” function in Wordpress?

wordpress,function,variables,shortcode

From what I'm understanding you're not trying to generate output with the shortcode, but to save data instead. I would try using custom fields to handle this. If you need to output the "USER DETAILS" block within the post content (right where the shortcode is written), you should just merge...

preg_split shortcode attributes into array

php,regex,quotes,shortcode,preg-split

Using preg_split is not always handy or appropriate in particular when you have to deal with escaped quotes. So, a better approach consists to use preg_match_all, example: $pattern = <<<'EOD' ~ (\w+) \s*= (?| \s* "([^"\\]*(?:\\.[^"\\]*)*)" | \s* '([^'\\]*(?:\\.[^'\\]*)*)' # | uncomment if you want to handle unquoted attributes #...

Shortcodes Ultimate DIV color

html,css,wordpress,shortcode

In the css of your template there is already a general styling rule for the color of h3. You should rather specify your selector a bit more in order to overrride this: .su-service-content:hover h3, .su-service-title:hover { background-color: #2680BE; color: white; } ...

How can I replace shortcode in wordpress

php,html,wordpress,shortcode

function add_shortcode( $tag, $func ) is the core of what you need to know. So insert into your functions.php: function srpmgt_shortcode() { return ' Content to replace... '; } add_shortcode('SRPMGT_id=12345', 'srpmgt_shortcode'); ...

How do i call shortcode value from dashboard editor?

php,wordpress,shortcode

Are you doing this in the visual or the text editor? For Shortcodes to work must be on the text editor in the tinymce on the right tabs. Also you must include your myproduct_func in functions.php so it's available....

Set a new value for $key => $value using WordPress shortcode_atts

php,arrays,wordpress,shortcode

You didn't assigned the variable! See: $atts['size'] == false; //^^ See here, you don't assign anything You have to remove one = so it looks like this: $atts['size'] = false; Also i would use var_dump here, because if you assign false and you use print_r the output would be: Array...

WordPress/Codeigniter Integration - Pass WP shortcode attribute to CI script

php,wordpress,codeigniter,shortcode

I had to solve this using a completely different solution than any of the ones I mentioned above. The code below still needs to be tweaked, but you can get the idea. I had to add this function to my WP plugin: function save_shortcodes_to_db($content) { global $post; $postID = $post->ID;...

Store and Echo PHP with Wordpress

php,wordpress,plugins,echo,shortcode

You're not far off. You need to use get_field() rather than the_field(): the_field() actually echoes out the content, so that's why it's not working as currently using it. It's the equivalent of trying to echo it twice. Another thing to look out for is that you need to include the...

Why is my wordpress shortcode not following closing tag?

php,wordpress,wordpress-plugin,shortcode

Try this way: function testf($atts, $content = "") { // print_r($atts); die(); if (!isset($atts['username']) ) $atts['username'] = 'att'; if ( empty($content) ) $content = 'Follow me on Twitter'; // shortcode_atts ob_start(); ?> <div style="font-family: Arial, sans-serf"> <h2 style="color:orange">My Plugin here!</h2> <a style="color:blue" href="http://twitter.com/<?php echo $atts['username']; ?>"><?php echo $content; ?></a></div> </div>...

Custom Short Code to Loop Through Custom Content Types

jquery,html,wordpress,shortcode

This should point you in the right direction to add a custom shortcode in your theme functions.php file: add_shortcode( 'rlcf_sermons', function( $atts ){ // set default attributes extract( shortcode_atts( array( 'speaker' => '', 'count' => -1 ), $atts ) ); // query $sermons = new WP_Query(array( 'post_type' => 'th_sermons', 'tax_query'...

Wordpress issue with shortcodes

php,wordpress,shortcode

$wpdb isn't defined in your shortcode callback so you'll be triggering an error when you try to access the get_results method. Add global $wpdb; to the top of your function....

How to create shortcodes with options in Wordpress

php,wordpress,shortcode

1] Try using a switch on the $style variable to echo out the corresponding $return_string depending on it's value. 2] Pay special attention to the default: case, as it is what will be displayed if $style is not set to clear or white. I set it to have no attribute,...

Remove frameborder in avada theme in youtube shortcode?

wordpress,themes,shortcode

Shortcode comes in fusion core plugin. fusion-core/shortcodes.php findout add_shortcode('youtube', 'shortcode_youtube'); remove frameborder from div under above shortcode....

Wordpress do_shortcode work in one widget but not another

php,wordpress,widget,shortcode

this is a tentative answer, if needed can be updated with more information: use this: // Display text if($instance['text']!="") { echo "\n<p class=\"lead\">" . str_replace("\n", "</p><p class=\"lead\">", do_shortcode($instance['text'])) . "</p>\n"; } or even this to apply all widget_text filters: // Display text if($instance['text']!="") { echo "\n<p class=\"lead\">" . str_replace("\n", "</p><p...

Custom WordPress Shortcode, can't replace echo with return

php,wordpress,return,echo,shortcode

You're using HTML where PHP is expected. That's why you have a blank screen. Here's how I'd move this into a shortcode: function wpse_shortcode_userlevel() { global $current_user; get_currentuserinfo(); $output = '<span class="shortcode-user-level">'; $output .= $current_user->display_name . "\n"; $output .= "Level: {$current_user->level} \n <br>"; $output .= '</span>'; return $output; } add_shortcode(...

Modifying $post->post_content in WordPress

wordpress,filtering,shortcode

I think you could use the_post action hook, that allows to modify the post object immediately after being queried and setup: add_action('the_post', function($post, $query){ // do whatever you want to $post, for example: $post->post_content = str_replace('{YOUR_SHORTCODE}', 'WHATEVER', $post->post_content); }, 10, 2); ...

shortcode Conditional Form - PHP

php,forms,email,conditional-statements,shortcode

You need to set the $mailbox value before you try to use it. I recommend using jQuery. <script src="jquery.js"></script> <script type="text/javascript"> jQuery.noConflict(); (function ($) { function readyFn() { $("#emailSelect").change(function(){ $("#your_form").attr('action', 'MAILTO:' + $("#emailSelect").val() + '@email.com'); }); } $(document).ready(readyFn); })(jQuery); /*$(document).ready(function(){ $("#emailSelect").change(function(){ $("#your_form").attr('action', 'MAILTO:' + $("#emailSelect").val() +...

Wordpress shortcode blog feed

php,wordpress,feed,shortcode

Yes, of course this is possible. You are using a WordPress loop, so just use get_the_excerpt(). while (have_posts()) : the_post(); $return_string .= '<li><a href="'.get_permalink().'">'.get_the_title().'</a>'; $return_string .= '<div class="excerpt">' . get_the_excerpt() . '</div></li>'; endwhile; You can use the new_excerpt_more filter to control what displays at the end of the excerpt. Here...

in woocommerce, is there a shortcode/page to view all orders?

wordpress,plugins,woocommerce,shortcode

My Account shortcode: [woocommerce_my_account order_count="-1"] Shows the ‘my account’ section where the customer can view past orders and update their information. You can specify the number or order to show, it’s set by default to 15 (use -1 to display all orders.) Reference: Woocommerce Shortcodes Update If you need only...

How to use shortcode of any plugin to show it visually where i want?

wordpress,wordpress-plugin,shortcode

Try changing get_post_field('post_content', $post->ID) to echo do_shortcode(get_post_field('post_content', $post->ID)); It should work....

php get variables from inside a function when outside

php,jquery,wordpress,global,shortcode

You have to echo variables for them to output columnWidth: <?php echo $masonry_item_width ?>, gutter: <?php echo $masonry_item_padding ?>, As to how to get your values... Wordpress makes plugins such a mess with all these standalone callbacks. Normally I would abhor doing this but I can't think of any other...

Regex Nested Shortcode Does Not Work

php,regex,nested,shortcode

It's because of the negative lookahead assertion at the end. I suggest you to remove that lookahead and use a greedy regex pattern like below. \[dzspgb_container(.*?)](.*)\[\/dzspgb_container\] DEMO (?!\s*\[\/) asserts that the match won't be followed by (zero or more space characters and a [ symbol)...

WordPress Shortcode thrown outside WYSIWYG html DIV

html,wordpress,shortcode,static-html

This problem occurs whenever a plugin is printing out its contents instead of using return. See the Shortcode API docs for more information; http://codex.wordpress.org/Shortcode_API#Output...

Wordpress add get_template_part into shortcode php

php,wordpress,shortcode

You need to rename your template file to portfolio-shortcode.php (with a dash rather than an underscore). get_template_part is checking for the following file: {current_theme}/includes/shortcode_helpers/portfolio-shortcode.php You also need to change the first parameter of get_template_part to remove the leading slash: get_template_part('includes/shortcode_helpers/portfolio', 'shortcode'); See get_template_part on the WordPress Codex for the order...

Category Filter Shortcode Quotation Issue in Wordpress

php,wordpress,shortcode

I don't know much about wordpress, nor the reason why it looks like this, but nesting quotes three times can get very confusing and should be avoided if possible. The PHP in your example is invalid in several ways: Quotes are not properly escaped Some of the HTML within your...

Wordpress shortcodes not working

php,wordpress,shortcode

It seems like the shortcode sp_responsiveslider isn't actually defined. Are you sure the plugin is installed correctly? If the plugin is installed correctly you can test to see if shortcodes are working on your WordPress installation. Paste the following in your functions.php file (add <?php to the first line if...

Add needed inner shortcode if missing

jquery,wordpress,shortcode

LIVE: It was very hard to achieve: (Hope it helps) // auto_descritive function wrap_string( str, open_param, close_param ){ var text = $(".content").text(); // all indexes of str var re = new RegExp(str,'gi'), results = []; while (re.exec(text)){ results.push(re.lastIndex); } // check each parent param of each str for (var i=0;...

Hide Shortcodes From Wordpress RSS Feed

wordpress,rss,feed,shortcode

You will need to alter how the RSS is output. All the RSS styling files are located in the wp-includes folder and are titled as follows: feed-rss2.php feed-rss.php feed-rdf.php feed-atom.php feed-atom-comments.php feed-rss2-comments.php Then within these files, you need to find where it calls the function the_excerpt_rss(). This calls out the...

WordPress: Get ID of custom post type within nested shortcodes

php,wordpress,nested,shortcode

try this in your display_activity method if it works for you .. $theContent = str_replace('[textarea]','[textarea id="'.$activityId.'"]', $theContent); $html .= "<div class='sbusuws-activity-content'>"; $html .= do_shortcode($theContent); $html .= "</div>"; ...

How I can use php if statment in wordpress shortcode?

php,if-statement,shortcode

You can do it either like this (short way): $list .= '<div class="collapse-card"> <div class="title">'; if($accordion_icon) $list .= '<i class="fa '.$accordion_icon.' fa-2x fa-fw"></i>">'; else $list .= '<i class="fa fa-question-circle fa-2x fa-fw"></i>'; Or like this (long way): $list .= '<div class="collapse-card"> <div class="title">'; if($accordion_icon){ $list .= '<i class="fa '.$accordion_icon.' fa-2x fa-fw"></i>">';...

Wordpress shortcode for tag list

php,wordpress,plugins,tags,shortcode

You don't really need a shortcode unless the position changes per post. To render tags in your template (you could just move the code): <?php the_tags(); ?> If you wanted to make a shortcode: function sc_taglist(){ return get_the_tag_list(); } add_shortcode('tags', 'sc_taglist'); And use [tags]...

Shortcode API parameters rejected like logic in the Congressional Branch

php,wordpress,shortcode

According to the Codex for add_shortcode the attribute names for a shortcode are converted to lowercase. Shortcode attribute names are always converted to lowercase before they are passed into the handler function. Values are untouched. That would mean you need to access your array keys with the lowercase version for...

How to use wc_paying_customer function to create shortcodes and display content only to paying customers

php,wordpress,function,woocommerce,shortcode

You can check the current user's paying_customer user meta field with following function: function so27296867_is_paying_customer() { $user_id = get_current_user_id(); if( '' != get_user_meta( $user_id, 'paying_customer', true ) ) return true; return false; } and use the function in a conditional check: if( so27296867_is_paying_customer() ){ // current user is paying customer,...

Creating shortcodes in wordpress - how do I allow paragraphs

php,wordpress,shortcode

If you're adding markup to your posts, you should NOT be using the visual editor. Either find a way to add your markup via a custom filter, so you can avoid inserting into your posts, or STOP USING THE VISUAL EDITOR. The visual editor is for people who don't know...

Shortcode inside a WordPress shortcode

php,jquery,wordpress,shortcode

You could manually call do_shortcode on the string your shortcode callback returns. Something like the following should work: // Add Shortcode function person_shortcode( $atts , $content = null ) { // Attributes extract( shortcode_atts( array( 'name' => 'name', 'numb' => 'numb', ), $atts ) ); // Code return do_shortcode( '<p...

a regex for cleaning quotes between quotes

regex,shortcode

This regex matches the sample text you provided: /="(.*?)"(?=\s*(?:[a-z]+=|]))/ Explanation: =" '="' ( group and capture to \1: .*? any character except \n (0 or more times (matching the least amount possible)) ) end of \1 " '"' (?= look ahead to see if there is: \s* whitespace (\n, \r,...

Front End of Wordpress Plugin

wordpress,plugins,frontend,shortcode

I have got it working with the help of short code. Here is what i did. added this code in my main plugin file i.e: amt.php add_shortcode( 'clan', 'clan_fn' ); function clan_fn() { } Create a new page from word press admin and simply call the short code as below...

How to apply TAB on several lines in Android Studio

android,android-studio,shortcode,tabular

Sure. Press (and keep pressed) the alt-option command on your Mac, then click with the mouse/touchpad and move upwards/downwards. The effect is the following: (source)...

Wordpress shortcodes in the wrong place

php,wordpress,plugins,shortcode

An easy workaround is to use Output control functions: function shortcode_fn( $attributes ) { ob_start(); // start a buffer wanted(); // everything is echoed into a buffer $wanted = ob_get_clean(); // get the buffer contents and clean it return $wanted; } ...

Making a Variable using “if” and working with Empty Variables

php,wordpress,attributes,shortcode,is-empty

If you want it to display if something is "empty", you're using the wrong method with if(!empty($ptitle)){ you're telling it if it is NOT empty. The ! is a negation character which translates as not. You need to use if(empty) Plus, you also need to echo while inside PHP. Another...

How add condition in wordpress shortcode loop

php,wordpress,wordpress-loop,shortcode

Based on your comment, maybe this helps: function testimonial_thumb_shortcode($atts){ extract(shortcode_atts(array( 'category' => '' ), $atts)); $q = new WP_Query(array( 'posts_per_page' => -1, 'post_type' => 'testimonials', 'testimonial_cat' => $category )); $list = ' <ul><li>'; $i = 0; //init the counter while($q->have_posts()): $q->the_post(); $idd = get_the_ID(); $author_photo = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'thumbnail'); $list .=...

p tag formatting in shortcode's content wordpress

php,wordpress,shortcode

As I've mentioned in my question's Update this bit of code in the functions.php does the trick: remove_filter( 'the_content', 'wpautop' ); add_filter( 'the_content', 'wpautop' , 99); add_filter( 'the_content', 'shortcode_unautop',100 ); As seen in this question's answer: http://stackoverflow.com/a/21460343/1275525 and this post: http://www.paulund.co.uk/remove-line-breaks-in-shortcodes (scroll down to: Removing wpautop() To Content Only In...

Woocommerce add attribute info to product shortcode

attributes,woocommerce,product,shortcode

You could either unregister and re-register your own version of the shortcode OR the [product] shortcode displays content via <?php wc_get_template_part( 'content', 'product' ); ?> Therefore you can customize the the content-product.php template in your own theme via template overrides or via hooks/filters. (The content-product.php template is mostly just a...

Wrong URL in [audio] WordPress shortcode

wordpress,audio,html5-audio,shortcode

The problem is not the url, it works fine with the extra paramaters. I think the problem is that the visibility of the element is on hidden: style="width: 100%; visibility: hidden;" Another problem can be that it says audio/mpeg instead of audio/mp3....

Adding Custom Field To Shortcode Display In WooCommerce

php,wordpress,woocommerce,custom-fields,shortcode

Remember, shortcodes are just a convenient wrapper for using other existing functions. If you look inside of class-wc-shortcodes.php you'll find that the [product_category] shortcode includes the content-product.php template to output the products. You can override any template in WooCommerce by copying it to your theme folder: create a new folder...

wordpress - adding shortcode with tax_query value terms variable

php,wordpress,shortcode

So effectively you want to pass the supplied terms="SOMETHING" to the function defined in add_shortcode ? The example from this page ( http://codex.wordpress.org/Shortcode_API ) is // [bartag foo="foo-value"] function bartag_func( $atts ) { $a = shortcode_atts( array( 'foo' => 'something', 'bar' => 'something else', ), $atts ); return "foo =...

Proper Shortcode Usage in Template File

wordpress,shortcode

You need to have the whole shortcode block inside the do_shortcode function. So you could do something like this: $text = some_code_or_function_that_returns_text_your_shortcode_can_act_on(); $sc_string = sprintf("[myshortcode]\n%s\n[/myshortcode]", $text); echo do_shortcode($sc_string); ...

Regex expression similar to WordPress shortcodes

php,regex,shortcode

Just add a negative lookahead assertion like below, \[cigar].*?\[\/cigar\](?!\s*\[\/) DEMO (?!\s*\[\/) Negative lookahead asserts that the match would be followed by any but not of one or more spaces and further followed by [/ symbols....