Add custom field to the archive page?

Using the Advanced Custom Fields plugin you can assign options pages to you custom posttype like this: if( function_exists(‘acf_add_options_page’) ) { acf_add_options_page(array( ‘page_title’ => ‘YOUR_PAGE_TILE Options’, ‘menu_title’ => ‘YOUR_MENU_TITLE Options’, ‘menu_slug’ => ‘options_YOUR_SLUG’, ‘capability’ => ‘edit_posts’, ‘parent_slug’ => ‘edit.php?post_type=YOUR_CUSTOM_POSTTYPE_SLUG’, ‘position’ => false, ‘icon_url’ => ‘dashicons-images-alt2’, ‘redirect’ => false, )); } That way you get an … Read more

How to return Meta data from the REST API?

The first parameter passed to register_meta() is always post for posts, Pages (post type of page) and custom post types. However, the REST API Handbook says that: Prior WordPress 4.9.8, meta fields set to show_in_rest using register_meta are registered for all objects of a given type. If one custom post type shows a meta field, … Read more

Is there a way to get protected meta fields through any of the available built-in WordPress APIs? (xmlrpc, wp-json)

To me, the simplest solution would be creating additional field in JSON response and populating it with selected post meta: function create_api_posts_meta_field() { // “tribe_venue” is your post type name, // “protected-fields” is a name for new JSON field register_rest_field( ‘tribe_venue’, ‘protected-fields’, [ ‘get_callback’ => ‘get_post_meta_for_api’, ‘schema’ => null, ] ); } add_action( ‘rest_api_init’, ‘create_api_posts_meta_field’ … Read more

How to correctly call custom field dates into a posts_where filter using SQL statements

Thanks to AmbitiousAmoeba for the answer. The following improved code solves the problem: function filter_where( $where=”” ) { global $wpdb; $where .= ” AND (($wpdb->postmeta.meta_key = ‘original_date’ AND $wpdb->postmeta.meta_value >= ‘2000-01-01’) AND ($wpdb->postmeta.meta_key = ‘original_date’ AND $wpdb->postmeta.meta_value <= ‘2004-12-31’)) “; return where; } add_filter(‘posts_where’, ‘filter_where’); query_posts($query_string); while (have_posts()) : the_post(); the_content(); endwhile;

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