wordpress

How include mask in the Woocommerce fields? E.g. Phone: (99) 9999-9999

你说的曾经没有我的故事 提交于 2021-02-19 08:57:14
问题 According to the WC docs, if I want to add a new field in the checkout area I should write the following code in functions.php: /* Add the field to the checkout*/ add_action('woocommerce_after_order_notes', 'my_custom_checkout_field'); function my_custom_checkout_field( $checkout ) { echo '<div id="my_custom_checkout_field" class="my_new_field"><h2>' . __('My Field') . '</h2>'; woocommerce_form_field( 'my_field_name', array( 'type' => 'text', 'class' => array('my-field-class form-row-wide'),

Display description before the title in WooCommerce product category archives

你离开我真会死。 提交于 2021-02-19 08:50:53
问题 In WooCommerce, I am trying to display the description before the title in Product category archive pages. But I fail trying to find out what hooks could I use to do it. The idea was to have a "Flavour Menu" be displayed first, and then the title afterwards, like in this screenshot: Any track is appreciated. 回答1: You will need to override the template templates/archive-product.php located in the Woocommerce plugin, copying it to your active theme folder to a woocommerce subfolder (but not in

How to set nofollow rel attribute to all outbound links in WordPress? Any Plugin?

戏子无情 提交于 2021-02-19 08:38:18
问题 I want to know how to automatically set all links to nofollow in Wordpress. Is there a WP Plugin that will make all my outbound links nofollow ? Help is greatly appreciated! 回答1: If you are make this change for SEO optimization, you can't make the change only with JS because the google bots don't read the content generated by Javascript. But, you can add a filter in your function.php like this: function rel_nofollow( $content ) { return preg_replace_callback( '/<a[^>]+/', 'rel_nofollow

Wordpress dbDelta not functioning

情到浓时终转凉″ 提交于 2021-02-19 08:27:11
问题 I'm currently writing a plugin for a customer, and while it's usually working good, I found that dbDelta does not allow me to create the table I need on plugin activation. I'm running the below code to bind the activation function: register_activation_hook(__FILE__, 'adminInstallation'); And this is the function itself: function adminInstallation(){ global $wpdb; $objectEquipment = 'wp_object_equipment'; $equipmentSQL = "CREATE TABLE ".$objectEquipment." ( id mediumint(9) NOT NULL AUTO

Getting all product ids of woocommerce categories

痴心易碎 提交于 2021-02-19 08:16:13
问题 I am trying to get all product ids using product_cat here is my code function get_products_from_category_by_ID( $category ) { $products_IDs = new WP_Query( array( 'post_type' => 'product', 'post_status' => 'publish', 'fields' => 'ids', 'tax_query' => array( 'relation' => 'AND', array( 'taxonomy' => 'product_cat', 'field' => 'term_id', 'terms' => $category, ) ), ) ); return $products_IDs; } var_dump( get_products_from_category_by_ID( 196 ) ); But getting WP_Query objects instead of ids of

Hiding products without thumbnail in WooCommerce shop page

不问归期 提交于 2021-02-19 08:13:07
问题 I use importer which imports thousands of products to the shop. Although I must insert picture and description for the product before I want to sell the item. I would like to hide product from the store at all IF there is no thumbnail image assigned. This way new products appear to the shop only after I have set the thumbnail image. I tried this in header.php, but did not work: <?php if($_product->getImage() && $_product->getImage() != 'no_selection'){ ?> <style> /* Css to hide Featured image

An unexpected error occurred. Something may be wrong with WordPress.org

房东的猫 提交于 2021-02-19 07:45:34
问题 I was not able to install plugins in my WordPress site. I am getting the following error when i try to install a new plugin.But its allowing me to upload a plugin and then to install it. "An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the support forums." 回答1: After spending more time is this I have resolved this by looking at wp-config.php Make sure this flag is false, if it's true update

Paginating GatsbyJS pages when filtering Wordpress posts by category

旧巷老猫 提交于 2021-02-19 07:36:07
问题 Can anyone shed some insight on how I would go about paginating pages in Gatsby when filtering Wordpress posts by category? For context, my gatsby-node file: const path = require('path') module.exports.createPages = async ({ graphql, actions }) => { // import { paginate } from 'gatsby-awesome-pagination'; const { createPage } = actions const blogPostTemplate = path.resolve('./src/templates/blog-post.js') const blogCategoryFilter = path.resolve('./src/templates/blog-filter-category.js') const

display product attribute and taxonomy in woocommerce product page

隐身守侯 提交于 2021-02-19 07:33:13
问题 I want to display the Brand attribute from the Additional Info on the product page. Is there a way to create a shortcode because i have a specific location to display it or even in php. This is for woocommerce 3.6.5 Thank you in advance 回答1: You can add the follows code snippet in your active theme's functions.php to do the above - // to display product additional info in product page add_action( 'woocommerce_single_product_summary', 'show_additional_info_product_summary', 45 ); // To diplay

Adding more product from contact form 7 to woocommerce checkout

吃可爱长大的小学妹 提交于 2021-02-19 07:32:45
问题 I am creating an order form that sells sim and i have a dropdown menu that list option to top up i want once a customer select an option it add to cart and then link a button to the checkout page 回答1: on_sent_ok is deprecated in latest version of contact form 7, but alternate way is: document.addEventListener( 'wpcf7mailsent', function( event ) { location = 'http://www.yoursite.com/checkout/?add-to-cart=ID';}, false ); 来源: https://stackoverflow.com/questions/53063904/adding-more-product-from