{"id":17033632,"date":"2023-09-07T15:22:52","date_gmt":"2023-09-07T15:22:52","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/plugin-throws-error-4\/"},"modified":"2023-09-07T15:22:52","modified_gmt":"2023-09-07T15:22:52","slug":"plugin-throws-error-4","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/plugin-throws-error-4\/","title":{"rendered":"Plugin throws error"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Hi Richard<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We are using this snippet to get sub page by slug something like wp-json\/wp\/v2\/pages?path=\/parent-slug\/child-slug<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>add_filter('rest_page_query', function ($args, $request){\n$path = $request-&gt;get_param('path');\nif (!empty($path)) {\n$pageByPath = get_page_by_path($path, OBJECT, 'page');\n\/\/ overwrite the page id with the page id by path\n$args&#091;'p'] = $pageByPath-&gt;ID;\n}\nreturn $args;\n}, 10, 2);<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">When we install your plugin it throws error.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"template":"","class_list":["post-17033632","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/17033632","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/17033632\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=17033632"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}