New answers tagged

0

I've finally figured out the problem. All the code, in all it's variations was fine and works, except for one tiny thing. The variable '$name' is used by the WordPress system to display the blog name, and as I was using that as my variable for the name field on my form it was causing issues. Who knew. Anyway, I simply changed it to use '$fullName' and ...


0

WordPress has this built in. As long as you have a page template created in PHP it will give you an option to use the template when creating a new page. You can create a page template by adding this short snippet to the top of your PHP file. <?php /* Template Name: Example Template */ ?> For example, you could copy page.php and add the above code, ...


0

fortunately ftp server had install nginx and i used x-accel-redirect inside downlod server to solve my problem. thanks for your helps:)


0

You can easily get it all with these plugins 1.WP User Frontend - This is for user register & Login forms and user profile pages. 2.WP User Frontend - For product uploads.change Post type from Post to product. 3.User can comment of any post or products. 4.WP Product Review Lite - this was easy to make. it has more features for ratings. 5.WooCommerce ...


0

Finally solved the issue. The problem was with the missing comma in the key-value array. It took me some time to found it. The error message was misleading: "Error output could not be translated from the native locale to UTF-8." WordPress SVN repository is doing code analyse before using pre-commit hook. I hope this will be useful for someone else too.


1

Wow, your plugin is very useful. #@^%$@ -> rysunok. That's so amazing!!! About your problem, I guess you copied and pasted the special characters from other into your php files, so it caused this error. My solution: Try opening the file in Notepad++, click on Encoding tab at top menu, you will see the current encoding of your file, choose Encode in UTF-8 ...


1

Remove "array" from your arguments declaration: public function widget(array $args, $instance) should be public function widget($args, $instance)


0

It seems that your software for finding URLs in the database does not find any matches, it might be worth double-checking it with some other method, please see my reply here Wrong domain in uploads folder for more details. If the CSS file is one of your theme CSS files then most likely the CSS file URL is not stored in the database at all. I would advise ...


1

If you have bought a theme you should have support for other languages. See the chapter Internationalization in the theme developer handbook for more information, or e.g. more specific on translation functions like __() the Code Reference. If you independently developed a theme, you probably forgot about this element. If not, check if your theme not have ...


1

When I disable Content Visibility for Divi Builder then the tag goes away. Seems suspicious... maybe they got hacked or maybe they are bad cookies. Will try to move this to the proper reporting channels. AoD Technologies LLC is the developer. Edit: wanted to temper this with a third possibility of tracking the usage of their plugin Edit 2: the developer ...


1

Autocomplete tag in form settings does not work anymore (as today Contact Form 7 plugin version 5.1.3. The only solution which worked for me was to add custom attributes thanks to https://stackoverflow.com/a/46316728/1720476. E.g. if You have FirstName and LastName fields, where You want to disable autocomplete. Add this into functions.php file: ...


1

The short version is that you will need to do the lookup much sooner. As pointed out in comments, a 404 status can only be sent with the headers. There are a few ways that you can solve this issue. I would do it with a class. That class would use a few hooks but most importantly, one would be early on, say "init", for example. That would be when I would ...


0

You can use sanitization and escaping functions that WordPress provides for example, you might need to do this: $sanitize_value = sanitize_text_field( $_POST[$this->unique] ); Here are the detail that you needed. https://codex.wordpress.org/Validating_Sanitizing_and_Escaping_User_Data


0

Run this SQL query on your site's WordPress database update wp_options set option_value='' where option_name='_site_transient_update_plugins'; This will force WordPress to check for plugin updates.


0

This case is possible with FedEx WooCommerce Shipping with Print Label. All you need is the following free add-ons and the code below. Hide WooCommerce Shipping Methods based on Shipping Class and Zones Skip Shipping calculation based on WooCommerce Shipping Class These free plugins as well as, a similar case is already explained very well in the ...


-1

I got a plugin Elementor Addon Elements having the features which I mentioned in the question. Any other answers for this issue are acceptable.


0

The problem has been partially resolved. The plug-in provider said that you need to install the older version of the "advanced-gutenberg-v1.10.12" plugin, edit the blocks and later update the plugin


0

Please try to use following code add_filter( 'aws_title_search_result', 'my_aws_title_search_result', 10, 3 ); function my_aws_title_search_result( $title, $post_id, $product ) { $text1 = get_post_meta( $post_id, '_tyre_size_field', true ); $text2 = get_post_meta( $post_id, '_load_speed_field', true ); $text3 = get_post_meta( $post_id, '...


0

Ideally, the plugin should take of everything. After migration, the user should not do any manual adjustments except for clearing the re-saving the permalinks. I think the plugin that you use for migration may be broken or has some issues. If its broken, I wont fix migration issues at the target site might require tons of time in troubleshooting and ...


0

Your script should looks like this. function js_enqueue_scripts() { global $post; $text2 = get_post_meta( $post->ID, '_load_speed_field', true ); $text3 = get_post_meta( $post->ID, '_tyre_brand_field', true ); $text4 = get_post_meta( $post->ID, '_brand_model_field', true ); $text5 = get_post_meta( $post->ID, '_run_flat_field',...


0

As @WebElaine commented on this question I tried the following code which worked for me. First, remove the slug from the permalink function na_remove_slug( $post_link, $post, $leavename ) { if ( 'services' != $post->post_type || 'publish' != $post->post_status ) { return $post_link; } $post_link = str_replace( '/' . $post->post_type ....


1

Since you can see the homepage, things are going well. For the search and replace, use whatever is your new url for your homepage. If it is just an IP, then use that one, just make sure you make similar replace, e.g: If you search for oldsite.com it's ok to replace with #.#.#.# but not with http://#.#.#.#, since you will end up with http://http://#.#.#.# for ...


0

Firstly, you will need to lave the hook there. Deprecation just signals to developers that they should not use it, and that it will be removed in future. So you're stuck with it for now. So really deprecation is a communications issue, not really a code issue. One helpful thing WordPress does provide in this situation is the function do_action_deprecated(). ...


-1

Please try this : add action parameter in data. data: { action:"this_ajax_action",image_attachment_id: document.getElementById("image-preview").getAttribute('src') }, add in functions.php add_action( 'wp_ajax_this_ajax_action', 'this_ajax_action_callback' ); add_filter( 'wp_ajax_nopriv_this_ajax_action', 'this_ajax_action_callback'); function ...


0

Hi please try below code jquery : $('#saveMediaButton').click(function(e) { e.preventDefault(); $.ajax({ url : my_ajax_object.ajax_url, type : 'post', data : { action : 'action_upload_img', image_attachment_id : document.getElementById("image-preview").getAttribute(...


1

Disclaimer: this is clumsy, someone might have a better suggestion. But here's one idea: Leave WordPress configured with your support@mydomain.com settings. Set up Woo with the sales@mydomain.com address (WooCommerce -> Settings -> Emails -> From Address). Hook woocommerce_mail_callback with your own function that temporarily hooks phpmailer_init to change ...


2

Why only the second? Because dbDelta() supports CREATE TABLE table_name format only. I.e. Exactly "CREATE TABLE" followed by (one space and) the table name. More specifically, dbDelta() uses this regular expression pattern: CREATE TABLE ([^ ]*) when parsing the queries into an array indexed by the table name; i.e. array( 'table_1' => 'query', 'table_2' =...


1

One way to get it to work would be to do it like this: global $wpdb; $wpdb->hide_errors(); // Require upgrade // Set charset $collate = ''; if ( $wpdb->has_cap( 'collation' ) ) { $collate = $wpdb->get_charset_collate(); } require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); $queries = array(); array_push($queries, " CREATE TABLE IF NOT ...


0

Why do you have curly brackets in there? Maybe sanitize/process the query string with htmlspecialchars() first. The error is complaining about non-standard characters...which is what your curly brackets are doing. Build the query string with the $ip value, convert with htmlspecialchars(), then add the URL to the query string. Pass that variable to the ...


0

Not sure if you're looking for an "automated" way of doing this, but in code you can get an array of all co-authors by using $authors = get_coauthors();. Once you have your authors array, you can loop through it and use each author object's ID to get posts by that author: $authors = get_coauthors(); foreach ( $authors as $author ) { $args = array( '...


2

You have not added wp_ajax_nopriv so that is the reason for ajax failure for non-logged in users. public function register() { add_action( 'wp_ajax_tidplus' , array( $this, 'post' ) ); add_action( 'wp_ajax_nopriv_tidplus' , array( $this, 'post' ) ); } Please do this change and check.


0

According to the docs, I needed to set the terms using post ID. So after every insert, I used the ID to set the terms https://codex.wordpress.org/Function_Reference/wp_set_post_terms Someone might find this useful.


0

Please try below code my-plugin.php file <?php /** Plugin Name: My Plugin Plugin URI: http://##### Description: This plugin just for test Author: Chetan Vaghela Version: 1.0.0 Author URI: http://che##la.###/ */ if ( ! defined('ABSPATH') ){ die; } if(!defined('MY_PLUGIN_PATH')) { define( 'MY_PLUGIN_PATH', plugin_dir_path(__FILE__) ); } ...


0

While I think you are looking for a plugin, I think this answer might help some people who search for a similar answer. If you have access to your functions.php file, you can easily make this happen. First we'll alter the orderby parameter of the search query in order to filter them by page title. Here is a snippet that I tested and will alter you search ...


0

I do something like this:- // Make sure we don't expose any info if called directly if ( ! defined('ABSPATH') ){ die; } if(!defined('MY_PLUGIN_PATH')) { define( 'MY_PLUGIN_PATH', plugin_dir_path(__FILE__) ); } if( ! class_exists('MyBestPlugin') ){ class MyBestPlugin { public function __construct(){ ...


0

OK, I think may have fixed it by doing this... $http = new WP_Http(); $response = $http->request( $url, array('timeout' => 20)); $response = is_array($response) ? $response : array($response); if( is_wp_error($response) && isset($response) && $response['response']['code'] != 200 ) { return false; }


2

Your logic for your updated if statement is wrong. if( !is_wp_error($response) && $response['response']['code'] != 200 ) Here you are saying; if NOT wp_error AND response code NOT 200 return false. So your not actually catching the WP_Error I believe what you are after is something like: if ( is_wp_error($response) || $response['response']['code']...


0

Look at line 63 of the code https://developer.wordpress.org/reference/functions/map_meta_cap/ If you don't provide a specific post, it is not allowed. Your code is mixing meta capabilities with primitive capabilities. (yours are all plural or primitive) "Meta" capabilities, e.g. 'edit_post', 'edit_user', etc., are capabilities used by map_meta_cap() to ...


0

The issue here is variable scoping. You're trying to access a global variable locally. // Global scope. $api_response = null; function get_user_info( $type ) { // Local scope. if ( $api_response === null ) { // make api reqest. // $api_response = api request data; return $api_response[ $type ]; } else { ...


3

Yes, this is true because WooCommerce cart is only initialized on the front-end (or if it's a front-end request): But it fails because $woocommerce->cart is always null. So in WooCommerce 3.6.4 (current release as of writing) or later, you can manually initialize the cart like so: // Load cart functions which are loaded only on the front-end. ...


0

I was able to solve this by checking if the term exists, and then using tax_input in wp_insert_post() // Check if the category exists $category_term = term_exists(trim($category), 'formula_types', 0); // Create category if it doesn't exist if (!$category_term) { $category_term = wp_insert_term(trim($category), 'formula_types', array('parent' => 0)); ...


1

category__in is used for built-in post categories, not for custom taxonomies. You can try something like this: $args = array( 'post_type' => 'tribe_events', 'meta_query' => array( array( 'key' => '_EventStartDate', 'value' => array( $start_date, $end_date ), 'compare' => 'BETWEEN', ...


0

I think you are headed down the right path, but I think that func_get_args() is only going to give you the arguments passed to that function. That is how I have always used it in the past. I took a different approach that I think might work. I found debug_backtrace() to be helpful in debugging Actions and Filters before. And the 4th element in that array it ...


0

You do not need to use file_get_contents for remote request. The function that you should be looking at is wp_remote_get or wp_remote_post depending on what data you want to send to the api before receiving a response. In any case your code should be somewhat similar to: $request = wp_remote_get( 'http://example.com' ); $response = wp_remote_retrieve_body( ...


0

Can you drop this in and let us know what $content looks like? <?php $c = curl_init(); curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); curl_setopt($c, CURLOPT_URL, "A WORKING API"); $content = curl_exec($c); curl_close($c); echo '<pre>'; print_r($content); echo '</pre>'; I am curious if this is a WordPress issue or just a CORS ...


0

Have you added the custom field into a post? In my experience, using the custom field in functions.php, plugins, templates, or whatever doesn't put the field as an option in any post. Adding the field manually into any post WILL make it available to any post after that. And you don't need ACF (Advanced Custom Fields plugin) to use custom fields, unless you ...


1

I like the idea of running this through a schedule event in WordPress, https://codex.wordpress.org/Function_Reference/wp_schedule_event Here is a snippet that hopefully will get you there: <?php if(!wp_next_scheduled('daily_plugin_check')){ wp_schedule_event( time(), 'daily', 'daily_plugin_check' ); } add_action( 'daily_plugin_check', '...


0

You can mange this by adding the following to your functions.php file. Checking todays timestamp for the days you want the plugin active - on the off days the plugin is disabled. $timestamp = time(); // Timestamp $day = date( 'D', $timestamp ); // Get day from timestamp $active = array( 'Mon', 'Wed', 'Fri', 'Sat' ); // Days plugin to be active if (...


0

If you want a HTML checkbox to be checked by default just add "checked" attribute: printf("<input type='checkbox' name='ins_street_address_shortcode' %s /> checked", $checkval);


1

Actually, your code is working, as long as $val == 'on'. Did you try debugging by doing echo $val ? If it's still not working, try hard refreshing (Ctrl + F5) your webpage, checkboxes tend to keep their state on normal refresh (F5). Also, please put your code directly on this forum, so the code is always accessible for future viewers ;)


Top 50 recent answers are included