New answers tagged

0

Your question it make sense to me my friend but the get_categories don't have the option to order by "meta_value_num" and then order by custom fields. What you can do is order after you get the array using the usort php function: $all_subcategories = array('parent' => $categoryID); $categories = get_categories( $all_subcategories ); ...


0

Unfortunately there is no hook for above the fields (perhaps you might want to submit a patch/feature request on trac?) You'll have to get by with JavaScript: <p id="klantnr-field"> <label for="klantnr">Klantnummer<br> <input type="text" tabindex="20" size="10" value="" class="input" id="klantnr" ...


0

I just figured out myself how to do it Take a look at this example: $args = array(); $args['relation'] = 'OR'; foreach ( $tag_ids as $t ) { $args[] = array( 'key' => 'afz_entry_tags', 'value' => serialize( strval( $t->id ) ), 'compare' => 'LIKE' ); } $query->set( 'meta_query', $args ); I am getting ...


0

Ok, I solved this with a nice function, now the only thing left to do is to find a way to update all of the blog posts. doing this by hand will be really bad here is the code that I used add_action( 'save_post', 'myplugin_save_postdata' ); function myplugin_save_postdata( $post_id ) { if ( 'page' == $_POST['post_type'] ) { if ( ! current_user_can( ...


1

The meta_value field is longtext, which a quick google reports is 4,294,967,295 characters - I doubt you're exceeding that. Chances are it's an issue with PHP, specifically post_max_size - if this is less than the "huge amount of data" you are referring to, PHP will simply truncate $_POST and you end up with nothing.


0

try this second query $c_client_args = array( 'post_type' => 'clients_testimonials', 'posts_per_page' => 999, 'order' => 'ASC', 'meta_query' => array( 'relation' => 'OR', array( ...


2

If the code you have provided is the only code you are using to achieve what you want then thats incomplete code. Below is the tested version of code which works well. I hope this helps: /* Add the field to the checkout */ add_action('woocommerce_after_order_notes', 'my_custom_checkout_field'); function my_custom_checkout_field( $checkout ) { echo ...


-4

Here give full url of your file where it is located. unlink(public_path('file/to/delete')) as you are just providing file name in your code @unlink($author_profile_photo["file"]); and with if you want to prevent generating an error if the file does not exist.


2

What you're looking for are the filters that let you modify the page title. There is a new way of doing this since Wordpress 4.4, so I'm going to focus on that. If you happen to be using a version prior to 4.4 and you can't update, the alternative is the wp_title filter (not to be confused with the wp_title() function), which I can elaborate on if you'd ...


0

Here what I did & finally problem is solved. To make the code work just use get_term_meta and add true to be like this: $res .= get_term_meta($t_id,'publication_date',true); I hope this will help any one facing such issue. Also, those who use prefix need to add it before the field name as mentioned by P-S


1

Possible solutions: Check if there's a prefix which you setup for the custom field (https://en.bainternet.info/tax-meta-class-faq/#comment-1107) Go to the Tax-meta-class/Tax-meta-class.php file and find the function you're calling and debug the issue: // Tax-meta-class.php public function get_tax_meta($term_id,$key,$multi = false){ $t_id = ...


3

I am assuming your custom post type is also "series". Can you try this, it should work. $args = [ 'post_type' => 'series', 'posts_per_page' => -1, 'meta_query' => [ [ 'key' => 'series', 'value' => 19, 'compare' => '=', 'type'=>'NUMERIC' ] ...


2

add_action( 'save_post', array( $this, 'save_metabox', 10, 2 ) ); should be add_action( 'save_post', array( $this, 'save_metabox' ), 10, 2 ); If you enable debugging, you'll see a call_user_func_array error generated by this. Also, a few other things- You should check if $_POST['anotai_nonce'] is set before trying to use it in assignment on the first ...


0

I have solved my problem using below code.So may be helpful for someone.I have tried by reference style for autocomplete <script> var locations = '<?php echo $json;?>'; var locations_array = JSON.parse(locations); locations_array.sort(); function monkeyPatchAutocomplete2() { jQuery("#result").remove(); // Don't ...


0

This works for me (inside the loop)... <?php $date = get_post_meta($post->ID, 'CUSTOM-FIELD-HERE', true); if($date != ''){echo date("l jS F Y", strtotime($date));} ?>


2

Yes there is Option API to store site global data. You can store some global values using add_option() then can retrive values as get_option() Example: add_option( 'option_name', 'option_value', 'deprecated', 'yes' ); //OR update_option('option_name', 'option_value', 'yes'); //Get the value $your_data = get_option('option_name', 'option_default_value'); ...


0

Just in case someone got here looking for how to also add a Guest Description, here is my full implementation. If follows the same logic as the other answers, I just added a get_the_author_description filter and a function to overwrite the author Bio info (description). As the other solutions above, you pass it as a custom field (see image attached). ...


2

The Codex has an article that outlines how to do this: https://codex.wordpress.org/Customizing_the_Registration_Form It even provides an example: //1. Add a new form element... add_action( 'register_form', 'myplugin_register_form' ); function myplugin_register_form() { $first_name = ( ! empty( $_POST['first_name'] ) ) ? trim( $_POST['first_name'] ) : ...


0

I've checked another option and asigned my custom taxonomy to custom post type using its name but without capitals and space. 'postname' works with original 'Post Name' So for custom post type register_post_type( 'Post Name', $args ); I can use register_taxonomy( 'custom taxonomy', array( 'postname' ), $args ); And it works.


1

Yes, you can use Admin Columns Pro (paid plugin with free version) to use inline edit for custom fields columns just from the WordPress posts list. It even comes with sorting and filtering for columns. You can easily add new columns with this plugin. https://www.admincolumns.com/ There are also plugins that allows you to bulk edit custom fields from the ...


-1

global $wpdb; $excludeposts = "SELECT * FROM $wpdb->posts WHERE $wpdb->posts.post_status = 'publish' AND meta_key NOT LIKE %aa_% ORDER BY post_date DESC "; $main_query = new WP_Query( array( 'post__not_in' => $excludeposts, 'paged' => $paged ) ); while ($main_query->have_posts()) : $main_query->the_post(); //Stuff... endwhile; ...


0

woa, you saved my day with this answer, i was trying to filter posts by custom numeric field called type_price and i was trying to do it that way: 'meta_query' => array( array( 'key' => 'type_price', 'value' => array( 0, 500000 ), 'compare' => 'BETWEEN', 'type' => 'NUMERIC', )), but it should be this way ...


0

I think you have to use add_action() with something like this: add_action( 'woocommerce_edit_account_form', 'custom_address_to_edit' ); function custom_address_to_edit( $address ) { global $wp_query; if ( isset( $wp_query->query_vars['edit-address'] ) && $wp_query->query_vars['edit-address'] != 'billing' ) { return ...


0

Depending on your situation I don't recommend or condone doing this, but the answer to your question is to take a look at the $wpdb class and the dbDelta() function. This is the interface WordPress provides for adding custom tables. Be careful though, with great power comes great responsibility. Using $wpdb bypasses many of the built-in WordPress security ...


0

I have worked on your issue and found a solution after some Google. Note: Add the below mentioned code to theme's functions.php or any plugin's file. Code: This filter function will add a custom tab to the Products Data metabox <?php add_filter( 'woocommerce_product_data_tabs', 'add_my_custom_product_data_tab' , 99 , 1 ); function ...


0

Yes, it is possible to hide or show custom fields by user's role. Use current_user_can() for finding current user role. This function returns true if current user has capability or role. For example your current user is "wholesale" then you can use like this: <?php if( current_user_can('wholesale')) { ?> // stuff here for wholesale <?php } ...


0

CLARIFICATION FOR ALL : You use virtual products on your shop. On checkout page, you have created and set an additional checkbox for european VAT purpose. There is 3 cases related to this checkbox. Checkbox is hidden (default) Checkbox is visible when selected country is an european country: Checkbox disabled (default) => set the VAT value to ‘0’ ...



Top 50 recent answers are included