Save/update post_meta with Gutenberg from the panel
I found out this bug https://github.com/WordPress/gutenberg/issues/4989 If an attribute get data from meta, and then post is saved/updated, it always return as undefined
I found out this bug https://github.com/WordPress/gutenberg/issues/4989 If an attribute get data from meta, and then post is saved/updated, it always return as undefined
I think I’d build that upon and already existing plugin that does the counting for me. I have made quite good experience with Post Views Counter as it also lets you use it in WP_Query. But WP-PostViews looks promising as well. Choose one. Next I’d query posts by view count from a WordPress cron event … Read more
To avoid an infinite loop on transition_post_status hook when using wp_update_post(), try: add_action(‘transition_post_status’, ‘new_product_add’, 10, 3); function new_product_add($new_status, $old_status, $post) { if( $old_status != ‘publish’ && $new_status == ‘pending’ && !empty($post->ID) && $post->post_type === ‘product’ ) { $term = get_term_by(‘name’, ‘فروش پیج اینستاگرام’, ‘product_cat’); wp_set_object_terms($post->ID, $term->term_id, ‘product_cat’, true); // unhook this function so it doesn’t … Read more
So, it simply turns out that the method I usually use to save post meta doesn’t work in this context, even though it does in when using the classic editor. I don’t know why this is, but I did find another article (https://www.codeinwp.com/blog/make-plugin-compatible-with-gutenberg-sidebar-api/) and there was a line in there that eventually led me to … Read more
This is not currently possible with query arguments alone (realm of filtering raw SQL query and such). If your task is not time-critical then I suggest to wait for upcoming WP 3.1 release. It will feature much more flexible querying capabilities for custom fields. See Advanced Metadata Queries for post on upcoming improvements.
‘meta_query’ is what you’re looking for: http://scribu.net/wordpress/advanced-metadata-queries.html
The plugin ‘Post Types Order‘ was the culprit. As Scribu pointed out above the plugin is filtering the Raw SQL query which it shouldn’t be doing. As a result, the argument ‘suppress_filters‘ wasn’t stopping the query being modified and the ‘orderby‘ argument was being completely ignored. As to how this behavior can be stopped, I’m … Read more
You can use update_post_meta() to save an array of values. It will be automatically serialized and unserialized. update_post_meta($post_id, ‘math’, array($a, $b, $c));
Have you checked the classes on your <body> element? It depends on the theme but WordPress has a function body_class() that dynamically adds a bunch of useful classes in there. It may look like this: <body class=”archive category category-news category-2 two-column content-sidebar”> As you can see it is a powerful helper as you can easily … Read more
Yes, the save action has a nonce already. But you don’t know it – so you cannot validate it. Besides that, you may want to fill a meta box from other places like a user profile or the dashboard, and then you need your own nonce anyway. An example from my current work: There is … Read more