don’t publish custom post type post if a meta data field isn’t valid

You can stop the post from saving all together with minor JQuery hacks and validate the fields before saving on the client side or server side with ajax: first we add our JavaScript to capture the submit/publish event and use it to submit our own ajax function before the actual submit: add_action(‘wp_print_scripts’,’my_publish_admin_hook’); function my_publish_admin_hook(){ if … Read more

Add custom fields to wp native gallery settings

Thanks for your code. I’ve investigated this issue further (this is not an integer formatting problem). The only solution I came up with for number fields is to monkey patch more WP JS. Here is entire code with modifications which supports any input type: add_action(‘print_media_templates’, function(){ ?> <script type=”text/html” id=”tmpl-custom-gallery-setting”> <h3>Custom Settings</h3> <label class=”setting”> <span><?php … Read more

How do I set the default admin sort order for a custom post type to a custom column?

Solution from a cross post over at StackExchange from @birgire: The problem is that you run the clientarea_default_order callback too late. To fix that you only have to change the priority from the default one that’s 10: add_action( ‘pre_get_posts’,’clientarea_default_order’); to the priority of 9: add_action( ‘pre_get_posts’,’clientarea_default_order’, 9 ); But you don’t actually need two pre_get_posts … Read more

Max length of meta_value

Both usermeta.meta_value and postmeta.meta_value are stored as LONGTEXT. Here’s how the MySQL docs describe the size of a LONGTEXT data type: “A TEXT column with a maximum length of 4,294,967,295 or 4GB (232 – 1) characters. The effective maximum length is less if the value contains multi-byte characters. The effective maximum length of LONGTEXT columns … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)