shortcode

How to ignore shortcode on html text search

眉间皱痕 提交于 2020-01-05 04:06:50
问题 I'm looking for a solution to a specific problem: I am trying to use a w3schools dropdown menu with a search option with a combination of a shortcode for countries flags and I need that the search function will ignore the shortcode and just look for the countries name. can someone please offer a solution? Thanks from advance. I am attaching the link to the basic w3schools html code and some screenshots for a better explanation: My code 回答1: WordPress Shortcodes are parsed at at runtime, so

Wordpress remove shortcode from content

别等时光非礼了梦想. 提交于 2020-01-01 17:26:12
问题 Is it possible to remove the gallery shortcode from the content before when the_content() is executed? I searched codex and found remove_shortcode( $tag ) but they show no examples. I tried adding to functions function remove_gallery($content) { $content .= remove_shortcode('[gallery]'); return $content; } add_filter( 'the_content', 'remove_gallery', 6); It doesnt work.. Update: I was able to unregister the shortcode using the code below, but it also removes the content function remove

Wordpress using echo vs return in shortcode function

不打扰是莪最后的温柔 提交于 2020-01-01 08:45:07
问题 I just found out that both echo and return works fine for displaying content from a shortcode function. function foobar_shortcode($atts) { echo "Foo Bar"; //this works fine } function foobar_shortcode($atts) { return "Foo Bar"; //so does this } I just want to know, is there any difference between using either of these? If so what's the recommended one? I normally use echo in this case; is it okay? 回答1: Echo may work in your specific case but you definitely shouldn't use it. Shortcodes aren't

Change markup in WooCommerce shortcode output

瘦欲@ 提交于 2019-12-31 03:09:47
问题 Is it possible to use a WooCommerce shortcode e.g. [product_category category="appliances"] amending the markup to include a <div> tag around some elements? I know I can do this by duplicating what the shortcode does but that seems overkill just to add a wrapping <div> . I could do it with jQuery but don't want any delay in them loading. 回答1: @Updated Yes this is absolutely possible. You can achieve this with something like that: if( !function_exists('prod_cat') ) { function prod_cat( $atts )

Change markup in WooCommerce shortcode output

跟風遠走 提交于 2019-12-31 03:09:08
问题 Is it possible to use a WooCommerce shortcode e.g. [product_category category="appliances"] amending the markup to include a <div> tag around some elements? I know I can do this by duplicating what the shortcode does but that seems overkill just to add a wrapping <div> . I could do it with jQuery but don't want any delay in them loading. 回答1: @Updated Yes this is absolutely possible. You can achieve this with something like that: if( !function_exists('prod_cat') ) { function prod_cat( $atts )

How to create a Wordpress shortcode-style function in PHP

戏子无情 提交于 2019-12-30 06:36:22
问题 I am trying to create a Wordpress shortcode-style feature in PHP to replace shortcodes like "[[133]]" with images. Basically, I have a MySQL table of image URLs/titles/subtitles with IDs 1-150, and I want to be able to dynamically insert them into the text of my pages with shortcodes like this: Blabla bla bla bla bla. [[5]] Also, bla bla bla bla bla [[27]] Hey, and bla bla bla! [[129]] So, I just want to grab the ID as $id, and then feed it to a MySQL query like mysql_query("SELECT title

Regex extract variables from [shortcode]

空扰寡人 提交于 2019-12-29 07:13:20
问题 After migrating some content from WordPress to Drupal, I've got som shortcodes that I need to convert: String content: Irrelevant tekst... [sublimevideo class="sublime" poster="http://video.host.com/_previews/600x450/sbx-60025-00-da-ANA.png" src1="http://video.host.com/_video/H.264/LO/sbx-60025-00-da-ANA.m4v" src2="(hd)http://video.host.com/_video/H.264/HI/sbx-60025-00-da-ANA.m4v" width="560" height="315"] ..more irrelevant text. I need to find all variables within the shortcode [sublimevideo

Add needed inner shortcode if missing

若如初见. 提交于 2019-12-25 05:28:20
问题 I have the following code: <textarea class="content"> [row] [col-md-12] text [/col-md-12] [/row] [row] text [/row] </textarea> Now I want to add the [col-md-12] inside (directly after) the [row] and close it before the [/row] with jquery. This should be the result: <textarea class="content"> [row] [col-md-12] text [/col-md-12] [/row] [row] [col-md-12] text [/col-md-12] [/row] </textarea> (Note: The code above is not bootstrap! I just took bootstrap, because its more clear, that the "col-md-12

Wordpress PHP - need to retain nextpage paginating tag in custom query

风格不统一 提交于 2019-12-25 00:24:07
问题 Preface: i am not a good coder. I need to use $post->post_content to get the raw post so that i can use the EXPLODE php command. But when i do use $post->post_content , it filters out the tags that are in my post which need to be retained. here is my script. what am i doing wrong? thanks! <?php $content = apply_filters('the_content', $post->post_content); $contents = array_filter(explode("</p>", $content)); foreach ($contents as $content) { if (strpos($content, '<img') !== false ) { echo

Display on a page all products below a specific price in Woocommerce

旧时模样 提交于 2019-12-25 00:04:11
问题 I have a Woocommerce store with more than 1000 products. I would like that all products which have a price below 999 should be shown on a separate page, so I can tag that Page in my menu. Is it possible? 回答1: Update: (added 'type' => 'DECIMAL', to the meta_query array) This can be done using Woocommerce shortcode [products] to be used on a page, with the following additional code (that will add the possibility to define a price to be compared through an existing argument) : add_filter(