shortcode

Wordpress get_option from shortcode

可紊 提交于 2019-12-09 03:38:29
I want to be able to get some wordpress options with the shortcode from the post, something like this: [get_option posts_per_page] Is there an easy way to do that? I think it is pretty easy first, create a function that will handle the short code function handle_shortcode($para){ //get_options } secord, register the shortcode add_shortcode('getOption', 'handle_shortcode'); then, use it in a post: [getOption para="key"] more details look at here: http://codex.wordpress.org/Shortcode_API 来源: https://stackoverflow.com/questions/8885007/wordpress-get-option-from-shortcode

Get orders from a SQL query displayed on as a list in Woocommerce

久未见 提交于 2019-12-08 13:39:31
In woocommerce, I'm trying to create a shortcode to put in my function.php document, that displays a custom database query on a page. There's something wrong with it though and i'm not sure what. function sqlquery_shortcode($atts) { global $wpdb; $results = $wpdb->get_results(" SELECT a.order_id, a.order_item_id, a.order_item_name, b.meta_key, b.meta_value FROM 7pW9iX3L_woocommerce_order_items a JOIN 7pW9iX3L_woocommerce_order_itemmeta b ON a.order_item_id = b.order_item_id JOIN 7pW9iX3L_posts c ON a.order_id = c.ID JOIN 7pW9iX3L_postmeta d ON c.ID = d.post_id WHERE order_item_type = 'line

Identifying wordpress shortcodes using a regular expression

流过昼夜 提交于 2019-12-08 11:00:00
问题 I have a wordpress shortcode which contains some other shortcodes inside it. When the first shortcode is executed i want to filter out other shortcodes using a regex. [main_code] [sub_code id='testid']test content[/sub_code] [sub_code id='testid' name='testname']test content[/sub_code] [/main_code] When i execute the main_code i want to filter the sub_code into an array and access its attributes without executing sub_code as a shortcode. Anyone who has knowledge to give me a solution is

Wordpress shortcode for tag list

蓝咒 提交于 2019-12-08 07:06:38
问题 I need to insert tags (of the post) inside post in the exact place. (default: they go after) As I understand the only way is to use shortcode and write its description in functions. I think its an easy one including "print $tags_list", but I haven't managed to write the whole piece of code needed. Can you help me? Or advise another way to solve my problem? PS: Maybe another way is to insert tag code inside post, but wordpress editor doesn't understand 回答1: You don't really need a shortcode

Display WooCommerce products with a shortcode using a custom meta_query

爱⌒轻易说出口 提交于 2019-12-08 04:23:34
问题 I'm creating a flash sale website and I already display products according to date range on my home and shop pages. But I also want to display products according to a date range elsewhere and therefore using a shortcode. Here is my code: function testt($meta_query) { $today = current_time('Ymd'); $args = apply_filters('woocommerce_shortcode_products_query', array ( 'post_type' => 'product', 'numberposts' => -1, 'meta_query' => array( 'relation' => 'AND', 'start_clause' => array( 'key'=>'flash

Regex pattern for shortcodes in PHP

丶灬走出姿态 提交于 2019-12-07 16:36:33
问题 I have a problem with a regex I wrote to match shortcodes in PHP. This is the pattern, where $shortcode is the name of the shortcode: \[$shortcode(.+?)?\](?:(.+?)?\[\/$shortcode\])? Now, this regex behaves pretty much fine with these formats: [shortcode] [shortcode=value] [shortcode key=value] [shortcode=value]Text[/shortcode] [shortcode key1=value1 key2=value2]Text[shortcode] But it seems to have problems with the most common format, [shortcode]Text[/shortcode] which returns as matches the

Visual Composer custom shortcode template - custom_markup display user input

旧街凉风 提交于 2019-12-07 09:39:37
问题 I have created some shortcode elements. Now I want to customize the look of the elements in the backend editor. From the description of the wiki of VC-Pagebuilder, I get out that I can use the "custom_markup" param for this. For simple html it works fine. But I can not display the user input in the shortcode backend element. <?php add_shortcode('simpletext', 'simpletext_shortcode'); add_action('vc_before_init', 'simpletext_vc'); // Frontend output function simpletext_shortcode($atts, $content

Create Custom Dropdown Box in Tinymce in Wordpress for Shortcodes

允我心安 提交于 2019-12-07 06:30:25
问题 Does anyone know how to create a custom dropdown box in tinymce for Wordpress? I need it to work with at least wordpress 3.0. I have searched the internet for a tutorial on this and I cannot find one. A link to a website tutorial would be great. Thanks in advance. 回答1: I know this question was already asked some time ago, but as I stumbled across the same problem, I tought I'd answer this question anyways. Maybe it helps someone else. The comments in the source of the DropDown-Control in

How to get shortcode of wp gallery on creating gallery in meta field

落爺英雄遲暮 提交于 2019-12-07 01:44:28
I create a gallery media up loader on a meta field. Its working perfectly. When I click on Browse , a gallery media up loader is open, I select images and then click on Insert Gallery but I didn't get a shortcode of a gallery in input meta field. Here is my code that I get from internet: var meta_image_frame_gallery; $( '#additional_image_1' ).click(function( event ) { event.preventDefault(); //var images = $( '#itv_additional_image_1' ).val(); //var gallery_state = images ? 'gallery-edit' : 'gallery-library'; if ( meta_image_frame_gallery ) { meta_image_frame_gallery.open(); return; } //

render Visual Composer shortcodes onto page

有些话、适合烂在心里 提交于 2019-12-06 18:06:43
问题 I am trying to echo visual composer shortcodes onto a page. I've tried both methods below, but they don't work: functions.php: Method 1 /* * add shortcode file */ function include_file($atts) { $a = shortcode_atts( array( 'slug' => 'NULL', ), $atts ); if($slug != 'NULL'){ ob_start(); get_template_part($a['slug']); return ob_get_clean(); } } add_shortcode('include', 'include_file'); Method 2 function someshortocode_callback( $atts = array(), $content = null ) { $output = "[vc_section full