Posts

Showing posts with the label wordpress

Programming Languages for making wordpress-like(blog) website

Image
Clash Royale CLAN TAG #URR8PPP Programming Languages for making wordpress-like(blog) website I was assigned to make a website which is like a blog, so that future or past posts can be edited easily by people managing it in the future. So it will be something like wordpress, and needs to have an admin/dashboard page for setting up the website easily. Also I need enter image description here to implement something like this when editing the posts. Note that I am required to make it from scratch. I have 2 language in my mind; python(django framework) and PHP. Is there any other I should consider? What are the cons and pros of using this language for this website? Thanks! By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Wordpress sage bootstrap not working

Image
Clash Royale CLAN TAG #URR8PPP Wordpress sage bootstrap not working I have setup a fresh wordpress installation with bedrock and I want to build a theme using the sage workflow. I've installed everything correctly and I've run a yarn build successfully. yarn build Now when I try something very simple in my body like this: <div class="container-fluid"> <row> <div class="col-md-4">col1</div> <div class="col-md-4">col2</div> <div class="col-md-4">col3</div> </row> </div> It doesn't actually seem to be working, I just get 3 divs below each other instead of in the bootstrap grid. When I inspect the element I see the correct css classes and stuff. During my setup of sage I've selected to load in Bootstrap so I am not sure why it's not working. Which framework would you like to load? [Bootstrap]: [0] None [1] Bootstrap [2] Bulma [3] F...

Serialize field in SQL condition and compare greater than

Image
Clash Royale CLAN TAG #URR8PPP Serialize field in SQL condition and compare greater than I have two dates in serialized field in my DB . That filed looks like a:2:{i:0;s:8:"20180801";i:1;s:8:"20180808";} a:2:{i:0;s:8:"20180801";i:1;s:8:"20180808";} My important variable looks like $data = $_GET['DATA']; $data = $_GET['DATA']; Now I want get all post where $data is between dates in serialize field. For example: If $data = 20180805 my query should find post with that field $data = 20180805 a:2:{i:0;s:8:"20180801";i:1;s:8:"20180808";} a:2:{i:0;s:8:"20180801";i:1;s:8:"20180808";} My query looks like: $test2 = $wpdb->get_results(" SELECT DISTINCT post_id FROM wp_postmeta WHERE meta_value >= '$data' AND meta_value <= '$data' ...

How to add multiple variable products to the cart via the add-to-cart query string

Image
Clash Royale CLAN TAG #URR8PPP How to add multiple variable products to the cart via the add-to-cart query string I want to add two variable product into my cart when i clicking a link on my site. i added below code in my function.php this code is only working with the simple product its not working with the variable product. function woocommerce_maybe_add_multiple_products_to_cart( $url = false ) { // Make sure WC is installed, and add-to-cart qauery arg exists, and contains at least one comma. if ( ! class_exists( 'WC_Form_Handler' ) || empty( $_REQUEST['add-to-cart'] ) || false === strpos( $_REQUEST['add-to-cart'], ',' ) ) { return; } // Remove WooCommerce's hook, as it's useless (doesn't handle multiple products). remove_action( 'wp_loaded', array( 'WC_Form_Handler', 'add_to_cart_action' ), 20 ); $product_ids = explode( ',', $_REQUEST['add-to-cart'] ); $count ...

Set Woocommerce product thumbnail with new thumbnail PHP

Image
Clash Royale CLAN TAG #URR8PPP Set Woocommerce product thumbnail with new thumbnail PHP I have created a custom plugin to import and export woocommerce products. I am facing an issue that when i try to import the CSV, the thumbnails of the products got changed and set to the old one which were added to the products earlier. I have full image URL in the CSV. Here is my import code: $product_img = $row[13]; //Product Image $res = $wpdb->get_results('select post_id from ' . $wpdb->prefix . 'postmeta where meta_value like "%' . basename($product_img). '%"'); if(count($res) == 0) { $res = $wpdb->get_results('select ID as post_id from ' . $wpdb->prefix . 'posts where guid="' . $product_img . '"'); } $thumbnail_id = $res[0]->post_id; set_post_thumbnail( $product_id, $thumbnail_id ); $attach_data = wp_generate_attachment_metadata( $thumbnail_id, $product_img ); wp_upda...

Converting MYSQL to WordPress $WPDB

Image
Clash Royale CLAN TAG #URR8PPP Converting MYSQL to WordPress $WPDB I’m upgrading an archaic Wordpress site from 3.7. It has some SQL query requests that don’t function after 3.9+ where you now have to connect to the DB via $WPDB. I've taken an initial stab at it but am hung up on the mysql_fetch_array part and also unclear if what I've already done is even correct. Seems like the mysql_fetch_array needs to use get_results. I'm fully aware that this is a less than ideal way to approach this and fully intend to modernize everything but in keeping a long story short it would be very helpful to be able to sort this out within this old jumbled paradigm if at all possible. Attached is the original code and then my attempt (also added a v2 attempt) . Thanks for taking a look. SQL: $sql = "SELECT wp_acf_values.value FROM wp_acf_values, wp_acf_fields WHERE wp_acf_fields.post_id = '620' AND wp_acf_fields.id = wp_acf_values.field_id ORDER BY wp_acf_fields.order_no"; ...

Filtering WooCommerce Products by $_GET

Image
Clash Royale CLAN TAG #URR8PPP Filtering WooCommerce Products by $_GET What I need to be able to do is apply a value for an attribute in the URL, so only the products match that attribute are displayed. I don't want to do any widgets or other visible filters on the page. For this I presume I would need to use one of the webhooks, and filtering out all products that are about to be displayed. Can anyone advise which hook will be best in this case and a simple explanation on how the triggered function will return the new array of products? Thanks in advance! By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

How to set a variable separator

Image
Clash Royale CLAN TAG #URR8PPP How to set a variable separator I have a variable $cameramodel which contains term meta of a wordpress taxonomy: $cameramodel <?php function cameramodel() { $terms = get_the_terms($post->ID, 'camera'); $result = ""; foreach ($terms as $term) { $term_id = $term->term_id; $result .= get_term_meta( $term_id, 'model', true ); } return $result; } $cameramodel = cameramodel(); ?> On the front end I would echo $cameramodel $cameramodel <?php echo $cameramodel; ?> There are instances where $cameramodel contains more than one value, but when I echo $cameramodel , They all appear on one line with no spaces. My question is, how do I make a separator between each value? I want each value to be on it's own line, and I would like to be able to separate them with the word "and". $cameramodel $cameramodel For example, if the variable contains "one two three" it currently prints "onetwothre...

Disable new attributes values for WP All import Woocommerce

Image
Clash Royale CLAN TAG #URR8PPP Disable new attributes values for WP All import Woocommerce Is it possible to create some function to disable WP All import to create new attribute values? I want to create a function that will update product attribute values only if there is already in Woocommerce. I want to do this because it is very hard to map all attribute values when it comes to 5k products and more. By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

How to add feed ads in frontier theme wordpress?

Image
Clash Royale CLAN TAG #URR8PPP How to add feed ads in frontier theme wordpress? I am using frontier wordpress theme and I want to add in feed ads (google adsense) on the home page. By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

pre_get_posts with WooCommerce Shortcode Query

Image
Clash Royale CLAN TAG #URR8PPP pre_get_posts with WooCommerce Shortcode Query I want to add some additional query vars and customise the query for woocommerce [products] shortcode. i'm trying to add some additional fields and conditions with pre_get_posts and posts_fields hooks but both of them is not working. is there any other way to filter (customise) the SQL query specific to woocomerce shortcodes? pre_get_posts posts_fields By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

wordpress wp-content/uploads folder 301 redirect to S3 bucket by cloudfrond CDN by .htaccess issues

Image
Clash Royale CLAN TAG #URR8PPP wordpress wp-content/uploads folder 301 redirect to S3 bucket by cloudfrond CDN by .htaccess issues See below, the .htacess file from wordpress. If I remove the part starting from #begin Wordpress. All the image file url will be change to d28rt1vkpsdxas.cloudfront.net/someimage.png successfully. However, all the internal link will be unable to access(only the home page can access). The error is Not Found The requested URL /shop/ was not found on this server. But if I keep the part start from #begin Wordpress. The cdn redirect will not work any more. All photos are missing. Thanks in advanced. Options +FollowSymlinks RewriteEngine on Rewriterule ^wp-content/uploads/(.*)$ http://exampled28t1vkps.cloudfront.net/$1 [r=301,nc] # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END Wo...

Multiple loops on category.php WP_Query or pre_get_posts?

Image
Clash Royale CLAN TAG #URR8PPP Multiple loops on category.php WP_Query or pre_get_posts? Bit of background i have an normal events category, specifically for that category there is a date meta box for the date of the event. In the list of posts on that page category-events.php i need the upcoming posts to appear first in the list and then the events that are in the past to appear after. So how can i combine two loops to spit out the list of posts that are upcoming first and events in the past after those. Can you combine a pre_get_posts to do this, or just use two WP_Query on the category-events.php file? pre_get_posts WP_Query pre_get_posts Query for upcoming events... pre_get_posts function events_query_order($query){ if( ! is_admin() && $query->is_main_query() ): $query->set( 'cat', '3' );//Specific Event Category $query->set( 'meta_key', 'event_date_picker' ); $query->set( ...

wordpress search result and permalink

Image
Clash Royale CLAN TAG #URR8PPP wordpress search result and permalink I have a page that search's posts from specific category. when the permalink is in post id format it works well, but when I change it to post name format it returns no result : when the permalink format is post id : search page url : localhost/wordpress/?pageid=12 localhost/wordpress/?pageid=12 result page url : localhost/wordpress/?s=123 localhost/wordpress/?s=123 it works well but When I use postname format : search page url: localhost/wordpress/verifycertificates/?s=123 result page url : localhost/wordpress/verifycertificates/?s=123 localhost/wordpress/verifycertificates/?s=123 it loads the "404 page" and the result not found. the problem is here : result page url :localhost/wordpress/?s=123 result page url: localhost/wordpress/verifycertificates/?s=123 By clicking "Post Your Answer", you acknowledge that you have read our u...

how to delete completed orders in woocommerce using a my sql query

Image
Clash Royale CLAN TAG #URR8PPP how to delete completed orders in woocommerce using a my sql query I want to delete completed all orders in woocommerce by using a single my sql query . Because, I'm having a problem with my WordPress Dashboard . I can't view the completed orders from the back-end. It's getting blank. I have 7,823 Completed Orders . I hope that's why I seen white page when I'm going to view the Completed Orders . WordPress Dashboard 7,823 Completed Orders Completed Orders Is there have a way to, That I can delete all Completed Orders using MySQL query. So, that I can run it in PHPMYADMIN . Completed Orders PHPMYADMIN Have any suggestions. have you checked to just see if there's PHP errors and that's why theres a white page? Usually the reason – Andy Holmes Jul 23 '14 at 7:36 ...

htaccess redirect url with special characters (+)

Image
Clash Royale CLAN TAG #URR8PPP htaccess redirect url with special characters (+) I have a URL like this. http://olddomain.com/product-category/x-tended+bottoms/ and I wanted to apply a 301 redirect via htaccess to http://newdomain.com/shop/extended-bottoms However, when i'm trying to apply a rule that goes like this, it doesn't take effect and instead lands me to page not found. RedirectMatch 301 ^/product-category/x-tended+bottoms/(.*)$ https://mothersenvogue.com.hk/shop/all-bottoms? RedirectMatch 301 ^/product-category/x-tended+bottoms/(.*)$ https://mothersenvogue.com.hk/shop/all-bottoms? What regex can I use to change the plus sign (+) on the url? 1 Answer 1 So I was able to find a reference answer to my question by adding the highlighted rule to check the plus sign (+) on URLs: RedirectMatch 301 ^/product-category/x-tended**[s+]**bottoms/$ https://newdomain.com/?$ htaccess redirect a plu...

How to correctly add your message to the “Thank you” page? Woocommerce 3

Image
Clash Royale CLAN TAG #URR8PPP How to correctly add your message to the “Thank you” page? Woocommerce 3 Need add custom message after "Thank you. Your order has been received.". A variable has been added to my message. It contains the percentage of the total amount of the order. In general, I think that this is a working option, but if there are errors, please write the correct answer. add_filter('woocommerce_thankyou_order_received_text', 'woo_change_order_received_text', 10, 2 ); function woo_change_order_received_text( $str, $order ) { // Get order total $order_total = $order->get_total(); $percent = get_option( 'wc-custom-percent' ); // Percentage $order_saving = (float)($percent * $order_total / 100); // Bonus amount $new_str = $str . ' You participate in the bonus program, your bonus interest from this order is' . $order_saving . ' euros. <a href="#">Learn more about the bonus program.</a>...