{"id":39764,"date":"2015-10-29T10:40:29","date_gmt":"2015-10-29T10:40:29","guid":{"rendered":"https:\/\/wordpress.org\/plugins-wp\/rest-api-filter-fields\/"},"modified":"2020-06-29T19:24:31","modified_gmt":"2020-06-29T19:24:31","slug":"rest-api-filter-fields","status":"closed","type":"plugin","link":"https:\/\/tl.wordpress.org\/plugins\/rest-api-filter-fields\/","author":14653621,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_crdt_document":"","version":"1.0.8","stable_tag":"1.0.8","tested":"5.4.19","requires":"4.4","requires_php":"","requires_plugins":"","header_name":"WP REST API - filter fields","header_author":"Stephan van Rooij","header_description":"","assets_banners_color":"","last_updated":"2020-06-29 19:24:31","external_support_url":"","external_repository_url":"","donate_link":"https:\/\/github.com\/sponsors\/svrooij","header_plugin_uri":"https:\/\/github.com\/svrooij\/rest-api-filter-fields","header_author_uri":"https:\/\/svrooij.io","rating":5,"author_block_rating":0,"active_installs":300,"downloads":33439,"num_ratings":0,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description","installation","faq","changelog"],"tags":[],"upgrade_notice":[],"ratings":{"1":0,"2":0,"3":0,"4":0,"5":"10"},"assets_icons":[],"assets_banners":[],"assets_blueprints":{},"all_blocks":[],"tagged_versions":["1.0.0","1.0.1","1.0.2","1.0.3","1.0.4","1.0.5","1.0.6","1.0.7","1.0.8"],"block_files":[],"assets_screenshots":[],"screenshots":[],"jetpack_post_was_ever_published":false},"plugin_section":[],"plugin_tags":[1556,1118,2299,23853],"plugin_category":[],"plugin_contributors":[86679],"plugin_business_model":[],"class_list":["post-39764","plugin","type-plugin","status-closed","hentry","plugin_tags-api","plugin_tags-json","plugin_tags-rest","plugin_tags-rest-api","plugin_contributors-svrooij","plugin_committers-svrooij"],"banners":[],"icons":{"svg":false,"icon":"https:\/\/s.w.org\/plugins\/geopattern-icon\/rest-api-filter-fields.svg","icon_2x":false,"generated":true},"screenshots":[],"raw_content":"<!--section=description-->\n<p>Since wordpress version 4.9.? wordpress includes the functionality provided by this plugin in the core of wordpress.<\/p>\n\n<p>Checkout https:\/\/developer.wordpress.org\/rest-api\/using-the-rest-api\/global-parameters\/#_fields for functionality included in the wordpress core,\nthey made it even better by filtering the amount of data pulled from the database.<\/p>\n\n<p>This plugin will no longer be maintained since it has been superseded by the core functionality.<\/p>\n\n<p>The <a href=\"https:\/\/wordpress.org\/plugins\/rest-api\/\">wp-rest-api-v2<\/a> returns a lot of properties.\nIt could be very useful (or mobile-data-friendly) to only return the properties needed by the application.<\/p>\n\n<p>If you only want titles and links of some articles it doesn't make sense to return the content or the excerpt.<\/p>\n\n<p>This isn't limited to posts, it also works on custom posttypes, categories, pages, terms, taxonomies and comments.<\/p>\n\n<p>Instead of returning:<\/p>\n\n<pre><code>{\n  \"id\": 2138,\n  \"date\": \"2015-10-25T15:31:03\",\n  \"guid\": {\n    \"rendered\": \"http:\/\/worldofict.nl\/?p=2138\"\n  },\n  \"modified\": \"2015-10-25T15:31:03\",\n  \"modified_gmt\": \"2015-10-25T14:31:03\",\n  \"slug\": \"rechtenvrije-fotos\",\n  \"type\": \"post\",\n  \"link\": \"http:\/\/worldofict.nl\/tip\/2138-rechtenvrije-fotos\/\",\n  \"title\": {\n    \"rendered\": \"Rechtenvrije foto&#8217;s\"\n  },\n  \"content\": {\n    \"rendered\": \".. A lot of content .. \"\n  },\n  \"excerpt\": {\n    \"rendered\": \" .. A lot of content ...\"\n  },\n  \"author\": 2,\n  \"featured_image\": 2139,\n  \"comment_status\": \"open\",\n  \"ping_status\": \"open\",\n  \"sticky\": false,\n  \"format\": \"standard\",\n  \/\/.. even more tags ....\n}\n<\/code><\/pre>\n\n<p>It can return (with <code>fields=id,title.rendered,link<\/code> as GET parameter)<\/p>\n\n<pre><code>{\n  \"id\": 2138,\n  \"link\": \"http:\/\/worldofict.nl\/tip\/2138-rechtenvrije-fotos\/\",\n  \"title\": {\n    \"rendered\": \"Rechtenvrije foto&#8217;s\"\n  }\n}\n<\/code><\/pre>\n\n<h4>Notes<\/h4>\n\n<ol>\n<li>If you specify fields so it wouldn't return data the default response is send back to the client.<\/li>\n<li>(for developers) something wrong with this plugin? <a href=\"https:\/\/github.com\/svrooij\/rest-api-filter-fields\/\">Github<\/a><\/li>\n<li>If you liked the plugin <a href=\"https:\/\/github.com\/sponsors\/svrooij\">consider sponsoring me<\/a><\/li>\n<\/ol>\n\n<!--section=installation-->\n<p>Installing this plugin is really easy.<\/p>\n\n<p>Just search the plugin directory for <code>rest api filter fields<\/code> and press install.\nOr download it right from <a href=\"https:\/\/github.com\/svrooij\/rest-api-filter-fields\/releases\">Github<\/a> and copy the <code>rest-api-filter-fields<\/code> directory in the archive to <code>wp-content\/plugins\/<\/code>.<\/p>\n\n<!--section=faq-->\n<dl>\n<dt><h3>Do you add data to the response?<\/h3><\/dt>\n<dd><p>No, this plugin only removes entries.\nWhen you want to add <a href=\"https:\/\/github.com\/svrooij\/rest-api-filter-fields\/issues\/5\">featured_images<\/a>, I recommend using <a href=\"https:\/\/wordpress.org\/plugins\/better-rest-api-featured-images\/\">better-rest-api-featured-images<\/a><\/p><\/dd>\n<dt><h3>How about nested propterties?<\/h3><\/dt>\n<dd><p>You can filter on nested properties with a '.' like 'title.rendered'. Not sure if this also works on arrays. <a href=\"https:\/\/github.com\/svrooij\/rest-api-filter-fields\/issues\">Existing issues<\/a> or <a href=\"https:\/\/github.com\/svrooij\/rest-api-filter-fields\/issues\/new\">Submit issue<\/a><\/p><\/dd>\n<dt><h3>Does this also work for my custom posttype?<\/h3><\/dt>\n<dd><p>Yes, we picked 20 as priority (default = 10) for activating.\nThis mean this plugin is probably activated last, so all custom post types should already be loaded.\nBut this only works if you made it public for the api.\nSee <a href=\"https:\/\/developer.wordpress.org\/rest-api\/extending-the-rest-api\/adding-rest-api-support-for-custom-content-types\/\">Adding REST API Support for Custom Content Types<\/a> for more information.<\/p><\/dd>\n<dt><h3>I found a bug, what should I do?<\/h3><\/dt>\n<dd><p>All the bugs\/issues are maintained on <a href=\"https:\/\/github.com\/svrooij\/rest-api-filter-fields\/issues\">github.com\/svrooij\/rest-api-filter-fields<\/a>\nso please create an issue (or a pull request with a fix) there.<\/p><\/dd>\n\n<\/dl>\n\n<!--section=changelog-->\n<h4>1.0.8<\/h4>\n\n<ul>\n<li>Final version before being archived.<\/li>\n<li>This update will <strong>disable<\/strong> the functionality in wordpress 5.0 and above and show a message in the admin dashboard.<\/li>\n<\/ul>\n\n<h4>1.0.7<\/h4>\n\n<ul>\n<li>Filter fields enabled on users <a href=\"https:\/\/github.com\/svrooij\/rest-api-filter-fields\/issues\/9\">Issue #9<\/a><\/li>\n<li>Bumped wordpress version<\/li>\n<\/ul>\n\n<h4>1.0.6<\/h4>\n\n<ul>\n<li>Filter fields enabled on custom taxonomies <a href=\"https:\/\/github.com\/svrooij\/rest-api-filter-fields\/issues\/6\">Issue #6<\/a>, thanks to <a href=\"https:\/\/github.com\/denisyilmaz\">Denis Yilmaz<\/a> for the fix!<\/li>\n<\/ul>\n\n<h4>1.0.5<\/h4>\n\n<ul>\n<li>Support for embedded fields (when you include the <code>_embed<\/code> GET parameter!).<\/li>\n<li>The <code>_links<\/code> field doesn't get stripped anymore.<\/li>\n<li>Taking the first element of an collection with <code>first<\/code>, like <code>_embedded.author.first.name<\/code>.<\/li>\n<li>Moved all the logic to a separate class, so it won't intervene the Wordpress core.<\/li>\n<\/ul>\n\n<h4>1.0.4<\/h4>\n\n<ul>\n<li>Updated readme.<\/li>\n<\/ul>\n\n<h4>1.0.3<\/h4>\n\n<ul>\n<li>Filter on nested fields <a href=\"https:\/\/github.com\/svrooij\/rest-api-filter-fields\/issues\/1\">Issue #1<\/a> implemented. Please test and leave a response <a href=\"https:\/\/github.com\/svrooij\/rest-api-filter-fields\/issues\/1\">here<\/a>.<\/li>\n<\/ul>\n\n<h4>1.0.2<\/h4>\n\n<ul>\n<li>Added filtering for categories <a href=\"https:\/\/github.com\/svrooij\/rest-api-filter-fields\/issues\/4\">Issue #4<\/a><\/li>\n<li>Tested on Wordpress version 4.6.1<\/li>\n<\/ul>\n\n<h4>1.0.1<\/h4>\n\n<ul>\n<li>Bumped tested wordpress version to 4.4<\/li>\n<li>Metadata update (personal website is https only :D)<\/li>\n<\/ul>\n\n<h4>1.0.0<\/h4>\n\n<ul>\n<li>First release of rest-api-filter-fields<\/li>\n<\/ul>","raw_excerpt":"Filter the properties returned by the Wordpress rest api V2 (only needed until wordpress 4.9)","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/tl.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/39764","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tl.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/tl.wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/tl.wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=39764"}],"author":[{"embeddable":true,"href":"https:\/\/tl.wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/svrooij"}],"wp:attachment":[{"href":"https:\/\/tl.wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=39764"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/tl.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=39764"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/tl.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=39764"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/tl.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=39764"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/tl.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=39764"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/tl.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=39764"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}