Add category to post meta
you can use get_the_category_list() it will show a list of the categories of the post, you can also use get_the_category() it will return an array, you can iterate it to format it, you can find examples here.
you can use get_the_category_list() it will show a list of the categories of the post, you can also use get_the_category() it will return an array, you can iterate it to format it, you can find examples here.
If you “Import” Products, i assume you use the wp_insert_post function? In that case, you can use the meta_input argument like this: $args[‘meta_input’] = array( ‘meta_key_1’ => ‘meta_value_1’, ‘meta_key_2’ => ‘meta_key_2′, … ); Other than that, if you know EXACTLY what you’re doing, you could look into inserting the data directly by using the wpdb … Read more
meta_query should be an array of arrays like: … ‘meta_query’ => [ [ ‘key’ => ‘…’, ‘value’ => ‘…’, ], ], …
guid doesn’t affect the image URL, it is just used as a unique identifier. It could be random gobbledygook and as long as it is unique it wouldn’t make a difference. It should be safe to use postmeta as long as you aren’t using any plugins that would potentially completely overwrite all postmeta associated with … Read more
There’s no caching system in WordPress core that would cause the issues you’re having. The post meta cache (WP_Object_Cache) is not persistent. Its purpose is to ensure that meta data is only loaded once per page, not every time get_post_meta(), for example, is used, but it does not cache those queries across page loads. Therefore … Read more
You should use init action hook. From the codex: init is useful for intercepting $_GET or $_POST triggers. The following code is just a sample and is untested: function wpse283607_handle_submit() { // check if form is POSTed and nonce is valid if ( ‘POST’ === $_SERVER[‘REQUEST_METHOD’] && wp_verify_nonce( $_REQUEST[‘_wpnonce’], ‘my-action’ ) ) { if ( … Read more
Back up your database first, then run this query in phpMyAdmin (or if you don’t have phpMyAdmin, run the query out of functions.php on an admin hook using $wpdb->query): UPDATE wp_postmeta SET meta_key = ‘_logo’ WHERE meta_key = ‘_thumbnail_id’ This will preserve all of the current IDs and just change the name of the meta … Read more
To be compatible with ACF you should first find out how ACF is saving checkboxes values to database. As I now this is serialized array. When we know that we must save our frontend checkboxes in the same way. The good news is you can pass only array to update_post_meta and WordPress will take care … Read more
get_the_author_meta applies a filter get_the_author_{$field}, i.e. in your case it will be get_the_author_description: function stripp($value) { return str_replace(array(‘<p>’,'</p>’), ”, $value); } add_filter(‘get_the_author_description’, ‘stripp’); In case the p tag has attributes, you may have to modify the above accordingly, or use preg_replace.
You can add custom meta fields for doing so. Here, is sample code for adding a meta field for post type post. For more details please refer to link. <?php /************************************************************************/ function myPrice_meta_box() { add_meta_box(‘myPrice_field’, ‘Price’, ‘myPrice_meta_box_callback’, ‘post’, ‘normal’, ‘high’); } add_action(‘add_meta_boxes’, ‘myPrice_meta_box’); /** * Prints the box content. * * @param WP_Post $post The … Read more