New answers tagged

0

This work for me, kindly try it, Thanks Templates is loaded into cpt file, which was located at custom_plugin -> app -> cpt -> cpt_article.php Template is located custom_plugin -> app -> templates add_filter( 'single_template', 'load_my_custom_template', 99, 1 ); function load_custom_templates($single_template) { global $post; if ($post-...


0

I finally figure it out, I didn't call the method on instance correctly, inside the if statement if ($val->idworkType == $post['worktype']). I used this $post['worktype'] instead of this $post->worktype.


0

I added the capabilities now through this code. I'm not happy with my solution and it would be great if someone could find a proper way to add to the filter. I would be honestly interested to know how to make it properly work. add_action( 'admin_init', 'jp_add_atum_caps_to_shop_manager'); function jp_add_atum_caps_to_shop_manager() { if(!user_can( 217 , '...


0

From what we have to go on, it sounds as though your locations will become WooCommerce product categories (or tags). You can also create new categories if you're already using WooCommerce's default category.


0

We've been using WP-PostViews for years and it has never failed us. It adds a column with view count that is incremented with every load of the page - also works well with cached sites.


0

In order to rename you have to alter your code like bellow. You code was missing absolute path of the directory. That's why your code was not working. Adding ABSPATH will fix the code. rename( ABSPATH . "wp-content/uploads/Directory/Clients/$Client_Name", ABSPATH . "wp-content/uploads/Directory/Clients/$New_Name" ); Why not you use ...


0

For anyone having the same trouble, I am now using a workaround from the accepted answer on the following question: https://wordpress.stackexchange.com/a/30723/181214 I am using the solution beyond the "EDIT: Another Option" which is working fine for slugs, names, singular names etc. function get_labels() { // return a default slug if(!...


0

According to CMB2 documentation, instead of <img src="<?php echo get_post_meta( get_the_ID(), 'author_sign', true) ?>" alt=""> you should use something like <?php echo wp_get_attachment_image( get_post_meta( get_the_ID(), 'author_sign', true ), 'medium' ); ?> or <img src="<?php echo ...


0

Filtering posts based on multiple custom taxonomy terms based on logical "AND", "OR" condition in wordpress rest api. Here is what you need to do in the newer versions of Wordpress (v5 and above) Lets say you have two custom taxonomies: sector and offerings. Getting all posts that are tagged with taxonomy ID 51 "OR" 52 beloning ...


0

I have used School Management System for Wordpress which you can find it on CodeCanyon. This premium plugin comes with handy features and one of them is paying for Courses or Exams.


0

I know this is a bit late so I am going to post my answer for people who might encounter the same scenario. There are few things that you can do: Option 1: Request a backup of your website from hosting company and then compare live version with that backup (as suggested by @RiddleMeThis) Option 2: You can you check meta_key column of wp-options table to see ...


0

I had to compile my SCSS to CSS using a compiler. I used this online compiler but of course others will work as well. Now everything works.


0

When working with the API recently I found if the authentication header with the consumer key as the username and the consumer secret as the password is present and valid this sets the current user global as the matched user. I found the core executes the REST route until current_user_can is called, at which point if the header was missing or invalid the ...


0

Yes, you need to set up your store in 5 steps for details visit https://www.buildthis.io/how-to/use-woocommerce-open-online-store-wordpress/


0

Use the ABSPATH constant defined in the wp-config.php: $filename = ABSPATH . 'wp-content/uploads/webcam/webcamimage.jpg'; You don't have to use basename() function since it would return only the last component from the full file path, i.e. webcamimage.jpg, and it isn't what you want to use with filemtime() function.


1

there is a simple plugin if you want to use called Woocommerce Extended Coupon Features Free. This is a freemium plugin but adds enough options to be able to do what you want. Link for the plugin https://wordpress.org/plugins/woocommerce-auto-added-coupons/


0

You can try to add conditional code like this: <?php if (is_page ('thank-you')){ ?> // script goes here <?php } ?> NOTE: Replace the thank-you with your page slug or you can even replace it with the page ID and add your tracking code just below //script goes here. One more way is to do it via plugin, here is a link to such plugin https://...


1

This one is tricky. You need to remove a hooked function which is a member of dynamically created class instance and the usual methods like remove_action( 'hook_name', 'hook_function', priority ) and even remove_action( 'hook_name', array( 'class_name', 'member_function' ), priority ) won't work. I once had to solve a similar problem. Mine was more ...


0

The reason your wpdb call fails is because there is no wpdb. You've taken the incorrect route of using a standalone PHP file, so there is no WordPress API. WordPress never gets loaded. That's not how you do AJAX in WordPress. The solution is to do the AJAX call correctly and register a REST API endpoint. E.g. in a plugin or a themes functions.php, register ...


0

You can simply add your menu page like this, I hope it's a simple approach class MyPlugin{ function __construct() { add_action('admin_menu', array($this, 'add_menu_page_fun')); } // Add Menu Page function add_menu_page_fun() { add_menu_page( __('My Plugin Page','myplugin-menupage'), //Page title ...


-1

Does the get-contacts.php script work ok if you load it directly, e.g. in your browser or from the command line, or in some test javascript? Maybe you don't have the path correct. Instead of providing a partial path you could provide an absolute path. Is the reuse directory in the root of your web space? If so set url like this: (Edited for the URL you ...


1

As @Rup has said in a plugin PHP file you should not have any HTML or any characters at all outside of the PHP opening and closing tags <?php and ?>. It's possible sometimes that you have invisible whitespace before or after these tags which can generate this error. One workaround (also as @Rup says) is to makesure your PHP is valid and leave off the ...


2

That's not how filters work. Much like a filter in real life, something goes in, it gets changed, and the result goes out. Filters always take in a parameter and return something. They're an opportunity to change something So if we take this: $review_num_fetch = apply_filters('tourmaster_review_num_fetch', 5); This means the plugin uses 5, but it has given ...


0

I've written something very similar with Contact Form 7. Instead of a Country -> City relation, the relation is Car make -> Car model -> car year. https://bdwm.be/how-to-create-dynamically-populated-cascading-dropdown-lists-for-contact-form-7/ You could start from a CSV file that looks like this: Country, City Germany, Berling Germany, Stuttgart ...


0

I used https://wpsheeteditor.com/. the other solutions were great if you wanted to do all pages, I'd have done the SQL query, but there were about 30 pages that needed doing and 40 that didn't. Even if a few just needed to be changed back I'd have done that but this sheet editor plugin was a huge help.


0

The site you linked isn't a Wordpress. You can make custom Wordpress URL's using Wordpress's URL Rewrite API. See https://codex.wordpress.org/Rewrite_API/add_rewrite_rule#Example , e.g.: function custom_rewrite_basic() { add_rewrite_rule('^anythinghere/([0-9]+)/?', 'index.php?page_id=$matches[1]', 'top'); } add_action('init', 'custom_rewrite_basic'); This ...


0

Thank @Stephen Harris for the above answer :) Just a very important note, when using the loop start/end you need the code below to prevent unwanted trigger of your code in the head. if ( $query->is_main_query() ): ... code here endif;


0

You can do this with https://woocommerce.com/products/woocommerce-subscriptions/ It can be similar to Amazons " subscribe and save " Here is also a Tutorial https://jilt.com/blog/create-a-woocommerce-subscribe-and-save-system/ Hope it helps.


0

Simply add this to your functions.php or plugin code (and replace YOURCUSTOMTYPE and YOURCUSTOMTAXONOMY). (I got the code from generatewp) add_action( 'restrict_manage_posts', 'filter_backend_by_taxonomies' , 99, 2); function filter_backend_by_taxonomies( $post_type, $which ) { // Apply this to a specific CPT if ( 'YOURCUSTOMTYPE' !== $post_type ) ...


0

Try this to get you started. This creates a shortcode [alldevelopers] that displays a list of all developers. Pretty basic but can be heavily extended and duplicted. (Not tested) add_shortcode( 'alldevelopers', 'show_all_developers' ); function show_all_developers(){ $users = get_users( [ 'role__in' => [ 'developers' ] ] ); foreach ( $users as $...


1

This is a great question. I have never seen any kind of framework inside Wordpress for building forms, and after a bit of searching now to verify this, I don't think there is one, although I'm sure others will correct me if there is ;-) So, you probably need to hand code forms as you would with a fresh HTML page. However, there are a bunch of guidelines out ...


0

It depends how you want to uniquely identify users. Some options to uniquely identify people might be the: The Wordpress User ID. If people are logged in then using their WP User ID is a good option. The Wordpress session ID. This is unique to the session; People will get a new session after some amount of time, and if they change browser or clear their ...


1

I've modified your code and moved $ip inside the function. That way the variable is easily accessible from the function itself. function cptpost() { if (!empty($_SERVER["HTTP_CLIENT_IP"])) { $ip = $_SERVER["HTTP_CLIENT_IP"]; } elseif (!empty($_SERVER["HTTP_X_FORWARDED_FOR"])) { $ip = $_SERVER["...


0

There are open/free APIs that allow geolocation based on the IP address. IP address of a mobile should be geo-correct. I use this site, with a CURL function to return the Geo information. Go to the URL in the code to get details on the return values. function grabIpInfo($ip) { //$ip = '185.164.57.189'; // france //$ip = '110.33.122.75'; // australia ...


0

As @mozboz explained, WordPress is changing the values of $_POST, $_GET, $_REQUEST, and $_COOKIE. If you need the raw values, use the function filter_input(), and make sure to keep security concerns in mind. Example: $test = filter_input( INPUT_POST, 'test', FILTER_SANITIZE_STRING );


0

I tried it step by step and finally succeeded. Step 1 - hello.py I tried to create the hello.py file with Atom on Windows 10 and uploaded it to a Linux server for many times. It could run with the "python3 hello.py" command, but always failed to run when using the "./hello.py" command. I had to create it on the Linux server and the "....


0

Yes, it's the expected behaviour. There's information on why it works like this here, and this function which can help in removing slashes from larger data structures: https://developer.wordpress.org/reference/functions/stripslashes_deep/ In the short term, if you can live without JSON for this field, why not just remove it, and if you need multiple hidden ...


0

good day dear Davemackey - hello Michael Field its been a long time that this has been asked - but anyway.. here my little idea that i can come up with.. Not the best answer but I tried to solve my own problem the best way I could. Getting a list of plugins This will not return ALL plugins but it will return the top rated ones: $plugins = plugins_api('...


0

It's best not to copy the entire WooCommerce templates directory into your theme's /woocommerce/templates directory. When WC updates their templates, your copies of the old templates may cause things to break, plus there will be warnings displayed in the admin area notifying you that your theme contains outdated templates. This presents a maintenance problem,...


0

Add a HTML Widget to your footer and place the content in there. WordPress Admin > Appearance > Widgets. I've just tested with the following JavaScript snippet and this works as expected. <script type="text/javascript"> console.log('Hello World') </script>


0

Yes, this absolutely is possible. There are a couple of steps that you would need to take to get this working; Check that the user is currently on the front page, you can use the is_front_page function for this, you may need to use is_home or even both depending on your configuration and requirements. Check that the user is currently logged in, you can use ...


0

What do you consider to be the home page? Do you want to change what is answering on the / url on your website? If so, I think that you can use the init hook and use wp_redirect() function to send your user wherever you want based on the result of wp_get_current_user() result. Something like that. add_action('init', function () { if ($user = ...


0

Managed to get this fixed, I dont know why this is the way it is, I'd appreciate a explanation I had to go down to my footer and make sure the structure was the follow: </footer> <?php wp_footer(); ?> </body> </html> If <?php wp_footer(); ?> is above </footer> the plugin doesnt work So I'll be awarding bounty to any ...


1

If you are looking for old versions of a plugin in the WordPress repository (like WooCommerce), you can go to the plugin's page on WordPress.org/plugins, then look in the right column under the plugin's Tags for the link to "Advanced View". Click on that, then scroll all the way down and select from the dropdown under Previous Versions to download ...


0

The following plugin is the solution you're looking for : WP Rollback. It allows you to retrieve any anterior version of any plugin or theme activated on your administration. Of course, before to do anything, you should save all your files and database just in case something bad happens. Hope it helps. Install WP Rollback from the catalog. Activate it in ...


2

It seems like your theme may be using the wp_is_mobile function incorrectly as it should not be used for theme specific styling, etc and is also unreliable as it only inspects the browser User-Agent. As I don't know what your theme is, I cannot say for definite if that is the case but see this answer for more information about that if you're interested. As ...


0

Here is some point you must understand. Monster Insights loads scripts to handle the analytics Scripts are being loaded either header or footer In order to load the scripts in your template you must include wp_head() and wp_footer() You may disable one of them by testing one by one. Another option could be hard coding analytics script in your template file. ...


0

Use this plugin to show visually on a page https://wordpress.org/plugins/show-hooks/


1

I found the plugin by running a search for the string "text_dd" in the wp-content/plugins/ directory. Looks like this specific plugin (which provides text_dd, column_dd and section_dd shortcodes) is called "dnd-shortcodes" and contains the following snippet of information: Plugin Name: Drag and Drop Shortcodes Plugin URI: http://...


0

I agree that fuxia's answer above gives the preferred approaches. But while I was trying to wrap my head around the OOP solution I hit upon a way of doing it that sets and then unsets both the filter and a global variable: function my_function() { // Declare the global variable and set it to something global $my_global; $my_global = '...


Top 50 recent answers are included