Add meta data to the menu
related post: http://www.kriesi.at/archives/improve-your-wordpress-navigation-menu-output
related post: http://www.kriesi.at/archives/improve-your-wordpress-navigation-menu-output
Not sure about the linked class – it seems they collect metaboxes immediately and so there is no information regarding what post is being viewed. In general though – yes it is possible. To add a metabox: add_action( ‘add_meta_boxes’, ‘myplugin_add_my_custom_box’,10,2); See the source code here. This add_meta_boxes hook passes two variables: the post type and … Read more
Why don’t you use a simple function with an argument to achieve that, the code is something like this: function wpse63585_event_list( $fresh = true ) { echo ‘<ul class=”event-items”>’; $yesterday = time() – 24*60*60; $compare = $fresh ? ‘>’ : ‘<‘; $args = array( ‘post_type’ => ‘wr_event’, ‘posts_per_page’ => -1, // show all posts ‘meta_key’ … Read more
You will need to add custom query vars: add_filter(‘rest_query_vars’, ‘wpse225850_add_rest_query_vars’); function wpse225850_add_rest_query_vars($query_vars) { $query_vars = array_merge( $query_vars, array(‘meta_key’, ‘meta_value’, ‘meta_compare’) ); return $query_vars; } Now, get your posts at example.com/wp-json/wp/v2/posts?filter[meta_key]=property_featured&filter[meta_value]=1. You can follow this ticket for more info.
I assume that you want to use propertysq custom field/post meta in the title and you use Yoast SEO. ( Correct me if I’m wrong ) So, use this is your functions.php function wpse239252_hook_title($title) { global $post; // make sure the post object is available to us if(is_singular()){ // check we’re on a single post … Read more
Turns out it’s the helpfully titled rest_prepare_categoryfilter function prepare_restful_categories($response, $item, $request) { // Do stuff to categories } add_filter(‘rest_prepare_category’, ‘prepare_restful_categories’, 10, 3);
WordPress search in posts table. You must change the search query by adding a postmeta table (with LEFT JOIN) and then add your own conditions to WHERE clause. <?php /** * Extend WordPress search to include custom fields * * https://adambalee.com */ /** * Join posts and postmeta tables * * http://codex.wordpress.org/Plugin_API/Filter_Reference/posts_join */ function cf_search_join( … Read more
My question is, is there a similar selector for when you don’t know the post type of a post beforehand? No, at the current time of writing there is not. The fundamental problem is that the REST API doesn’t provide a generic mechanism for getting a post type given a post ID. You can retrieve … Read more
the simple solution would be to paste this snippet of code in your theme’s functions.php file : add_action(‘wp_head’,’keywords_and_desc’); function keywords_and_desc(){ global $post; if (is_single()||is_page()){ if(get_post_meta($post->ID,’my_keywords’,true) != ”) echo ‘<meta content=”‘.get_post_meta($post->ID,’my_keywords’,true).'” name=”keywords”>’; if(get_post_meta($post->ID,’my_description’,true) != ”) echo ‘<meta content=”‘.get_post_meta($post->ID,’my_description’,true).'” name=”description”>’; } } And the just add keywords and description using the built in custom fields on a … Read more
I would recommend using MetaBoxes. A nice tutorial is here: http://www.farinspace.com/wpalchemy-metabox/