shortcode

Get and display the selected variation SKU in WooCommerce

不问归期 提交于 2020-07-15 21:51:17
问题 I have this code that works for simple product type but not for variable products in WooCommerce: add_shortcode( 'product_sku_div', 'wc_product_sku_div'); function wc_product_sku_div() { global $product; return sprintf( '<div class="widget" sp-sku="%s"></div>', $product->get_sku() ); } How can I make it work for both simple and variable products? 回答1: You need the Variation ID to get the SKU of Variable Product. If you pass the Variation ID in the below Function, then you can get its SKU.

Show products from above 99$ price in Woocommerce using shortcode or php code

假装没事ソ 提交于 2020-07-04 04:21:05
问题 I am searching for a conditional shortcode based on product price. I have 2k+ products on Woocommerce now and I want to show products above 99$ price from a specific category and from whole products. How can I apply this conditions in the shortcode? Is there any way to do this? Actually, I want to apply in a widget, so shortcode form will work. Below is simple shortcode to show products but I want to apply this needed condition: [products limit="10" columns="4" category="hoodies, tshirts"]

Strip shortcode, keep content in between

烂漫一生 提交于 2020-06-08 07:52:12
问题 The idea behind this question lies in getting excerpt of the posts created with avada but I can't strip the shortcodes from the post content to display the excerpt of the post. Here is example of my post (using avada): [fullwidth background_color="" background_image="" class="" id=""] [one_full last="yes" spacing="yes" class="" id=""][fusion_text] Content text ... [/fusion_text][/one_full][/fullwidth]` The default the_excerpt(); doesn't work because of shortcodes. get_content() returns the

Using WordPress shortcode in a title

青春壹個敷衍的年華 提交于 2020-04-10 04:25:35
问题 I have some shortcodes which work fine inside a WordPress post or page. Is there anything I can add to functions.php to enable a shortcode to work inside a WordPress post title? 回答1: You could try adding a filter to the title in the functions.php file such as: add_filter( 'the_title', 'do_shortcode' ); Seems to work for me, however it may play havoc with your permalink's and I wouldn't recommend it. In future WordPress related questions might be better directed at https://wordpress

Optimization, time complexity and flowchart (Scilab)

你离开我真会死。 提交于 2020-03-26 03:22:01
问题 I tried to optimize this code, but it’s impossible to optimize anymore. Please help with building a flowchart for this algorithm. A = [-1,0,1,2,3,5,6,8,10,13,19,23,45]; B = [0,1,3,6,7,8,9,12,45]; N1 = length(A); N2 = length(B); t = 1; m = 10; C = []; for i=1:N1 for j=1:N2 if A(i)==B(j) break else if j==N2 C(t)=A(i); t=t+1; end end end end disp(C); N3=length(C); R = []; y = 1; for l=1:N3 if C(l)>m R(y)=C(l); y=y+1; end end disp(R); How to find time complexity of an algorithm I think it should

Change wordpress gallery shortcode slug to filename

為{幸葍}努か 提交于 2020-01-17 03:27:05
问题 Is it possible to change the attachment page slug to the referring filename? In short... i use the Gallery Shortcode to build a simple page based gallery. I change the orignal filename (like DSC1223.jpg) during the upload process (to 3b1871561aab.jpg) but it does not appery as slug within the url. It uses only DSC1223. Is there anyway to change ist? Regards, Steve The best way would be to write something like this in my functions.php function twentyten_filter_wp_handle_upload () { $upload =

Shortcode plugins for own custom cms like wordpress shortcode plugins

两盒软妹~` 提交于 2020-01-15 04:01:08
问题 I have created a custom CMS for my own and a plugin system that is working as I expected. Now I want to create plugins based on shortcodes, eg: [gallery attr1=100 attr2="string"] and [mycode title='message' color='#F00']Hello World![/mycode] I want to handle the above mentioned shortcodes in my CMS. Functions will replace shortcodes with HTML and get & set attributes as parameters for mySQL queries or something else. may be regular expressions will help, I am not expert in regular expressions

WooCommerce: Merge 3 custom shortcodes in one

亡梦爱人 提交于 2020-01-14 04:22:10
问题 I have three separate woocommerce snippets where each one have one function. I'm trying to combine them together in one script but can't seems to return more than one value. function display_woocommerce_order_count2( $atts, $content = null ) { $args = shortcode_atts( array( 'status' => 'completed', ), $atts ); $statuses = array_map( 'trim', explode( ',', $args['status'] ) ); $order_count = 0; foreach ( $statuses as $status ) { // if we didn't get a wc- prefix, add one if ( 0 !== strpos(

How run shortcode before loading header.php in wordpress? [closed]

十年热恋 提交于 2020-01-07 07:44:13
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 3 years ago . guys. I have some situation when my shortcode don't work correctly, if I add shortcode in header, because first of all load header.php and only after that load my shortcode. How can I run shortcode before loading header.php ? I try to use hoocks, but not find solution. Best

Use Gallery Shortocode on another page but with specific photo category in wordpress

会有一股神秘感。 提交于 2020-01-07 02:43:10
问题 I have a galley page in a wordpress theme. Now I want to use that gallery shortcode on some other pages but want to display photos only from specfic photo category. Thanks in advance. Following is gallery short code: [gallery_list] Following is photo category ID which I Want to use in this short code : cat&tag_ID=50 回答1: If the gallery supports Id parameters, you'd do something like this: [gallery_list tag_ID="50" cat="XX"] Wordpress Shortcode API 来源: https://stackoverflow.com/questions