shortcode

Wordpress Featured Image Custom Shortcode

两盒软妹~` 提交于 2019-12-11 15:07:35
问题 I've ran into an issue that's doing my head in. I'm trying to create custom shortcodes within my themes functions.php file that will allow me to insert and place a posts featured image into a post and align it either left of right. Below is the code I tried last, I've been looking at different sources and trying different things to no avail. function featured_img_left() { if (has_post_thumbnail() ) { $image_id = get_post_thumbnail_id(); $image_url = wp_get_attachment_image_src($image_id,

Using a custom taxonomy for products shortcode in Woocommerce 3.3

邮差的信 提交于 2019-12-11 08:03:43
问题 I'm currently developing the homepage for a Woocommerce website and on this page the goal is to have 3 rows displaying products from different brands. Example; Row 1 will display Apple Products, Row 2 will display Samsung Products and Row three will display HTC products. I've used the plugin CPT UI to create the custom taxonomy 'Brand'. Now I wish to use the example above to display only products listed under a particular brand. Looking into the Woocommerce Shortcodes, I saw this: [products

Display custom stock quantity conditionally via shortcode on Woocommerce

安稳与你 提交于 2019-12-11 07:19:35
问题 I'm using WooCommerce: Display stock quantity for a given product ID on normal Pages or Posts amazing answer code that works to display the product quantity for a WooCommerce product in any page or post via a shortcode. I would like to only display the exact quantity up to 5 products in stock and have "More than 5" for any quantity of 6 or more. Can it be done by modifying this code? 回答1: The following should do the trick: if( !function_exists('show_specific_product_quantity') ) { function

Display Most Popular Product Tags in WooCommerce sidebar widgets area

邮差的信 提交于 2019-12-11 07:02:35
问题 I found this code (http://devotepress.com/faqs/display-popular-tags-wordpress) and I used the short code ([wpb_popular_tags]) but I do not see any result. How can I use this code for displaying most popular WooCommerce product tags? Here is their code: function wpb_tag_cloud() { $tags = get_tags(); $args = array( 'smallest' => 10, 'largest' => 22, 'unit' => 'px', 'number' => 10, 'format' => 'flat', 'separator' => " ", 'orderby' => 'count', 'order' => 'DESC', 'show_count' => 1, 'echo' => false

Convert a Woocommerce hooked function into a shortcode

吃可爱长大的小学妹 提交于 2019-12-11 04:46:31
问题 A previous question of mine was answered and included two separate functions, one using a WooCommerce add_action hook. How can I take this answer and convert it to a shortcode that I could add to a product page? I am using a page builder (Divi Builder) to create a custom layout/template of WooCommerce product pages. Having a shortcode will allow me to paste the shortcode into the builder, and have it output the result anywhere within that template structure. This is the code I need turned

Display Woocommerce notices on a page

半腔热情 提交于 2019-12-11 03:28:26
问题 I have created a function to display some products with a shortcode, but the problem I am having is that the errors messages are not shown on that page. For example if some fields are required then it's only displayed on the cart/checkout page. Here's some of my code: while ( $query->have_posts() ) : $query->the_post(); global $product; ?> <div style="border-bottom:thin dashed black;margin-bottom:15px;"> <h2><?php the_title(); ?> <span><?php echo $product->get_price_html();?></span></h2> <p><

Creating Wordpress like shortcode in laravel blade

不羁的心 提交于 2019-12-11 00:25:37
问题 I have a mail template (in laravel blade) that is need to be dynamic (so it should be saved in database i think). This is the registration_complete.blade.php: <html> <body> {{$dynamic_content_from_database}} </body> </html> And the $dynamic_content_from_database value came from the WYSIWYG i used.This is the management i worked for : I need to find a way that admin user can manage the content of the template with variable inside or shortcode. Just like in WordPress they used short code to put

Count the number of times a WordPress shortcode is used in a post

泄露秘密 提交于 2019-12-10 21:22:52
问题 I have the following WordPress shortcode function: function wp_shortcode() { static $i=1; $return = '['.$i.']'; $i++; return $return; } add_shortcode('shortcode', 'wp_shortcode'); This works fine. The $i variable gets incremented each time the function is called in the article. So for [shortcode][shortcode][shortcode][shortcode] the output is as expected [1][2][3][4] but if the article has more than one page, than the counter resets on the next article page. So for: [shortcode][shortcode]

Woocommerce Add to cart link Ajax enabled in other post or pages

若如初见. 提交于 2019-12-10 12:08:05
问题 In Woocommerce, I Would like co create add to cart link on a simple page of WordPress website (not product page) . So I have tried this code (Where 123 is the product ID) : <a href="http://example.com/cart/?add-to-cart=123">Buy</a> I have enabled AJAX add to cart on archives pages Woocommerce option setting. But It doesn't work and Ajax functionality is not enabled on my custom Add-to-cart link. How to enable ajax add-to-cart on a custom link (in other pages than woocommerce ones) ? 回答1: To

WordPress Orderby Last Word In Title

时光怂恿深爱的人放手 提交于 2019-12-09 17:12:20
问题 I have a custom post type of "staff". I need to get this to display the staff alphabetically by last name on the page. I know a work around would be to use custom meta boxes and break up first and last names into two fields but I'm trying to avoid that as that seems very hackish and not as clean as just using the title field. I have a shortcode working that will show the custom post type with the staff "type" taxonomy attribute requested. Here is an example: [staff type="local"] I can't just