New answers tagged

0

I've found a solution using Ajax with native Javascript as follows: // Filename send2server.js const sendToServer = function() { /* Prepare the object to be sent: ********************************************************************/ var params = new FormData(); params.append('action', 'update_sql'); // update_sql is implemented in ...


0

If you were to use WP_Query to retrieve a list of posts, you can then access the number of posts using 'found_posts'. e.g. (from the support pages) $query = new WP_Query( array( 'author' => 123, 'post_type' => 'posts_comcurso' ) ); Would return all posts with a userid of 123 in your selected post type. Then access the number of posts like so: $count = ...


1

I can see a few issues with this approach: If the user doesn't belong to a site yet, they won't get redirected correctly because $redirect_url won't be defined. If the user belongs to more than 1 site, they will always be redirected to the site with the lowest ID, not necessarily the one they're trying to log into. Have you tried any Azure SSO plugins? I ...


0

WP loads jQuery in no conflict mode, so you can either swap $() for jQuery(), or wrap it in a function, e.g. (function($) { // Code using `$` ... })(jQuery);


1

Am I in the right direction? Yes, and I'd also use the REST API if I were you. I have tried following instructions but I always get error 404. That is actually normal if the request method is not POST — e.g. using the browser to manually access/visit the endpoint at example.com/wp-json/real-estate-lite/v1/endpoint whereby the (HTTP) request method is (or ...


0

I see you're using functions such as the_permalink that echo their values, but don't return them, yet you're using them as if they do return values, which they don't. Aside from a few exceptions, WP functions that start with the_ don't return data, they echo it, so you have to use functions such as get_permalink etc For example: $foo = the_title(); // <- ...


1

Is there any issue with my code? Yes, there is. get_categories() returns an array of terms, e.g. WP_Term objects or a list of term IDs, so you can't simply do return $categories;. Instead, For a basic list such as Foo category, Bar category, etc. (i.e. no category links), you can simply set the fields parameter to names which then gives you a list of ...


0

I had the same question and the same issue. But with some changes to your code, you can hide the Wordpress login and password fields, and still keep the social logon button. Just add the code below to your theme's functions.php file /** * This hides the login and password fields so only the social login button is visible */ add_action( 'login_head', '...


2

There's no way to do this without a bit of programming. You need to look at these pieces: A Wordpress hook like save_post lets you do something when a post is saved or updated wp_mail is how you send an email get_field is how you look at the value of an ACF field. You'd need to write some code to put them together how you want to, but the details of doing ...


0

With the help of @mozboz I have solved my issue. The original post is updated with the answer. However, for whatever reason people are asking that I also post the answer here. So here it is: public function my_custom_post_type_the_content($content_object) { global $post; if( $post->post_type == 'my_custom_post_type' && ( ...


0

As your code looks quite generic, the obvious answer and thing to debug is that either the if condition is not true when you're expecting it to be, or $media_content isn't getting generated as you expect. Are you 100% sure that on all the other sites the post_type is 'my_custom_post_type' when you expect it to be? You can debug things like this by ...


5

I'm not aware of any other way but to use both add_action lines, for a single function. Example: function my_enqueue_sripts_function_name(){ // your enqueue logic here } add_action('wp_enqueue_scripts', 'my_enqueue_sripts_function_name' ); add_action('admin_enqueue_scripts', 'my_enqueue_sripts_function_name' ); There's no rule that forbids ...


1

Your best bet would be hooking into the post type transition and creating the second (custom) post (type) via PHP. Here is a function that can accomplish just that: // Automatically create a news (regular post in category ID 1 = news) when a wiki post (custom post type) has been published function nxt_create_news($new_status, $old_status, $nxt_wiki_post) { ...


0

I think you will have a difficult time trying to find a plugin that offer this exact functionality. IMHO, I'm guessing you will need to develop this on your own, or hire a developer. If you want to build it yourself, I can recommend a few resources to get you started. Swiper is an excellent slider that I often use, and there are a number of ways to associate ...


1

Assuming the pharmacy's inventory management software can be connected to via API of some sort, you will need to write custom scripts which trigger when an order is placed within your WordPress environment. In case of WooCommerce, read up on the hook woocommerce_checkout_order_processed for example. Probably most important though - read up on the API ...


1

What you want to do cannot be done in a shortcode. wp_signon needs to set some HTTP headers for the cookie, but it's too late. When your browser recieves a webpage, it recieves some headers that tell it what it's recieving and stuff like wether it succeeded or not, is it a 404, what cookies there are etc. Then it has a body which contains the webpage itself, ...


0

This is just a half answer, but I wanted to share my findings. When adding a new term via the Add Term screen /wp-admin/edit-tags.php?taxonomy=work_type&post_type=work, AJAX is being used and it is not handling the $_FILES array, so it is empty. If you disable JS in your browser temporarily, then reload the page, add a new tag along with an image, then ...


2

its better to include your assets with admin_enqueue_scripts for your question add_action('admin_head', 'grup_custom_admin_post_css'); function grup_custom_admin_post_css() { $allow_post_types = array('custom_role', 'custom_role_2', 'etc'); $allow_roles = array('post_type', 'post_typ_2'); $current_user = wp_get_current_user(); if (...


0

Its better to register this role with add_role ( docs ) before adding it to user Also, if you want to change roles attribute, try set_role instead of add_role


1

EDIT: Original answer was inaccurate as you can do this with wp_update_post and the meta_input field As per the updated question and comments this is possible with wp_update_post (or wp_insert_post for a new record) using the meta_input key on the array, e.g.: $metaValues = array( 'key1' => 'value1', 'key2' => 'value2', // ... as many ...


1

To complement @Radek's answer, here is another way to use his solution. public function sanitize_callback ( $options ) { $saved_options = $this->get_option( 'your_option_name' ); $options = $this->sanitize_options( $options ); if ( is_array( $saved_options ) && is_array( $options ) ) { $options = array_merge( $...


1

Is there anything special for dealing with $_POST in this case? Maybe, if you can elaborate more on what you mean by "special"? But as with other PHP arrays, you should always check if the POST variable is actually set before attempting to use it: // Example for the Edit_Email_1 input: if ( isset( $_POST['Edit_Email_1'] ) ) { return $_POST['...


0

So it looks like get_ancestors() is the function you need to be able to figure out what 'level' something is. The number of results returned from get_ancestors corresponds to your 'level' number, with 0 results meaning parent page. And so the problem you have is that this number isn't available as a query argument. Therefore, perhaps the simplest option ...


0

One option is to pass the post ID as a url parameter when the edit link is clicked. For example, in some template user can see a list of one's posts. Each post has an edit link and the post id appended to the link as a url parameter. <ul> <?php foreach( $users_posts as $users_post ) : ?> <li> <span><?php ...


0

check out this link. It will help you. follow it. It is quite simple https://pluginrepublic.com/add-custom-fields-woocommerce-product/#add-woocommerce-custom-fields-programmatically


0

For multiple Custom Post Types adjust like this $query->set( 'post_type', array( 'post', 'custom1', 'page' ) && array( 'post', 'custom2', 'page' ) );


0

The problem was here: <input type="file" id="_themename-advert-create-image" name="_themename-advert-create-image" /> It should be: <input type="file" id="_themename-advert-create-image" name="_themename-advert-create-image[]" /> Still can't understand why I should add [] in my name, ...


1

You can make the meta data private, and not visible on the Custom Fields list, by appending underscore to the meta key. I.e. _accesstype_visibility You can find more details in the WP Developer docs, https://developer.wordpress.org/plugins/metadata/managing-post-metadata/#hidden-custom-fields EDIT 24.7.2020 Here's an example how to use is_protected_meta() ...


1

https://developer.wordpress.org/reference/functions/wp_add_inline_script/ should be a preferred option nowadays EDIT: From the docs above: function mytheme_enqueue_typekit() { wp_enqueue_script( 'mytheme-typekit', 'https://use.typekit.net/.js', array(), '1.0' ); wp_add_inline_script( 'mytheme-typekit', 'try{Typekit.load({ async: true });}catch(e){}' ); ...


0

Hopefully you have access to your server (i.e. you don't use a wordpress.com website but have your own server). You'll have to connect to the server with either SFTP or SSH (via the use of scp to copy files) or another similar protocol and upload the files to wherever you want. In order to use these, you generally have a special URL and you'll need a login/...


0

You may want to take a look at the WP Basic Crud plugin made by Labarta. Users may add a new contact, edit it, and view the list table. The plugin creates a table named wp_cte when it is being activated.


Top 50 recent answers are included