{"id":4853,"date":"2009-02-24T20:23:59","date_gmt":"2009-02-24T20:23:59","guid":{"rendered":"https:\/\/wordpress.org\/plugins-wp\/pjw-query-child-of\/"},"modified":"2011-03-30T11:57:53","modified_gmt":"2011-03-30T11:57:53","slug":"pjw-query-child-of","status":"publish","type":"plugin","link":"https:\/\/mya.wordpress.org\/plugins\/pjw-query-child-of\/","author":11357,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_crdt_document":"","version":"1.10","stable_tag":"1.10","tested":"3.1.4","requires":"2.0","requires_php":"","requires_plugins":"","header_name":"PJW Query Child Of","header_author":"Peter Westwood","header_description":"","assets_banners_color":"","last_updated":"2011-03-30 11:57:53","external_support_url":"","external_repository_url":"","donate_link":"https:\/\/www.paypal.com\/cgi-bin\/webscr?cmd=_xclick&business=paypal%40ftwr%2eco%2euk&item_name=Peter%20Westwood%20WordPress%20Plugins&no_shipping=1&cn=Donation%20Notes&tax=0&currency_code=GBP&bn=PP%2dDonationsBF&charset=UTF%2d8","header_plugin_uri":"http:\/\/blog.ftwr.co.uk\/wordpress\/query_child\/","header_author_uri":"http:\/\/blog.ftwr.co.uk\/","rating":0,"author_block_rating":0,"active_installs":40,"downloads":6117,"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":0},"assets_icons":[],"assets_banners":[],"assets_blueprints":{},"all_blocks":[],"tagged_versions":["0.01","0.02","1.00","1.10"],"block_files":[],"assets_screenshots":[],"screenshots":[],"jetpack_post_was_ever_published":false},"plugin_section":[],"plugin_tags":[9922,170,1626],"plugin_category":[],"plugin_contributors":[77581],"plugin_business_model":[],"class_list":["post-4853","plugin","type-plugin","status-publish","hentry","plugin_tags-child","plugin_tags-page","plugin_tags-query","plugin_contributors-westi","plugin_committers-westi"],"banners":[],"icons":{"svg":false,"icon":"https:\/\/s.w.org\/plugins\/geopattern-icon\/pjw-query-child-of.svg","icon_2x":false,"generated":true},"screenshots":[],"raw_content":"<!--section=description-->\n<p>This plugin allows you to run loops within your WordPress templates where you query for children of the current page.<\/p>\n\n<p>The plugin extra arguments to the list of arguments supported by query_posts().<\/p>\n\n<p>The query argument <code>child_of<\/code> is used to add a WHERE to the database query to limit the pages returned to those with a post_page equal to the argument provided.<\/p>\n\n<p>The query argument <code>child_limit<\/code> is used to limit the number of pages returned.<\/p>\n\n<p>The query argument <code>child_offset<\/code> is used to offset the limiting to allow for pagination if required.<\/p>\n\n<!--section=installation-->\n<ol>\n<li>Upload to your plugins folder, usually <code>wp-content\/plugins\/<\/code><\/li>\n<li>Activate the plugin on the plugin screen.<\/li>\n<li>Use the new query variables in calls to query_posts()<\/li>\n<\/ol>\n\n<!--section=faq-->\n<dl>\n<dt>How can I use this in a page template?<\/dt>\n<dd><p>The plugin is used when you call query_posts() from a theme template file so as to run your own query.<\/p>\n\n<p>The following code is an example of what you could do to generate a list of the first 10 child pages from a parent page:<\/p>\n\n<pre><code>&lt;div id=\"children\"&gt;\n        &lt;dl&gt;\n        &lt;?php query_posts('static=true&amp;child_limit=10&amp;child_of='.$id.'&amp;order=ASC'); ?&gt;\n        &lt;?php if(have_posts()) : while (have_posts()) : the_post(); ?&gt;\n        &lt;dt&gt;&lt;a href=\"&lt;?php the_permalink();?&gt;\"&gt;&lt;?php the_title();?&gt;:&lt;\/a&gt;&lt;\/dt&gt;\n                &lt;dd style=\"\"&gt;&lt;em&gt;&lt;?php the_excerpt(); ?&gt;&lt;\/em&gt;&lt;\/dd&gt;\n        &lt;?php endwhile; endif; ?&gt;\n        &lt;\/dl&gt;\n&lt;\/div&gt;\n<\/code><\/pre><\/dd>\n<dt>How can I create a a page template which lists children of children?<\/dt>\n<dd><p>If you want to create a hierarchical display with children of children then you will need to use nested loops which requires some care.<\/p>\n\n<p>You will need to have the most up-to-date version of this plugin and then you can use the examples which are included with it in the page-templates folder.<\/p>\n\n<p>The basic loops needed for a nested solution are as follows:<\/p>\n\n<pre><code>&lt;div id=\"children\"&gt;\n        &lt;dl&gt;\n        &lt;?php query_posts('static=true&amp;posts_per_page=-1&amp;post_parent='.$id.'&amp;order=ASC'); ?&gt;\n        &lt;?php if(have_posts()) : while (have_posts()) : the_post(); ?&gt;\n        &lt;?php   $inner_query = new WP_Query(\"post_type=page&amp;posts_per_page=-1&amp;post_parent={$id}&amp;order=ASC\");\n                while ($inner_query-&gt;have_posts()) : $inner_query-&gt;the_post(); ?&gt;\n                    &lt;dt&gt;&lt;a href=\"&lt;?php the_permalink();?&gt;\"&gt;&lt;?php the_title();?&gt;:&lt;\/a&gt;&lt;\/dt&gt;\n                    &lt;dd style=\"\"&gt;&lt;em&gt;&lt;?php the_excerpt(); ?&gt;&lt;\/em&gt;&lt;\/dd&gt;\n        &lt;?php endwhile; endwhile; endif; ?&gt;\n        &lt;\/dl&gt;\n&lt;\/div&gt;\n<\/code><\/pre><\/dd>\n<dt>How do I set an excerpt for a Page?<\/dt>\n<dd><p>If you want to set an excerpt for a page then you need to install my Page Excerpt plugin and this will add an excerpt box to the \"Edit Page\" so that you can enter one.<\/p>\n\n<p>This plugin can be found here: http:\/\/wordpress.org\/extend\/plugins\/pjw-page-excerpt\/<\/p><\/dd>\n\n<\/dl>\n\n<!--section=changelog-->\n<h4>v0.01<\/h4>\n\n<ul>\n<li>Initial Release<\/li>\n<\/ul>\n\n<h4>v0.02<\/h4>\n\n<ul>\n<li>Fix logical bug.<\/li>\n<\/ul>\n\n<h4>v1.00<\/h4>\n\n<ul>\n<li>Improved release with added child_limit and child_offset variables<\/li>\n<\/ul>\n\n<h4>v1.10<\/h4>\n\n<ul>\n<li>Added page template examples to documentation and repository.<\/li>\n<li>Added extra FAQ answers.<\/li>\n<li>Changed the child_of query variable to rewrite to using post_parent instead if the WordPress version is new enough (v2.6 or later)<\/li>\n<\/ul>","raw_excerpt":"This plugin allows you to run loops within your WordPress templates where you query for children of the current page.","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/mya.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/4853","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mya.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/mya.wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/mya.wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=4853"}],"author":[{"embeddable":true,"href":"https:\/\/mya.wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/westi"}],"wp:attachment":[{"href":"https:\/\/mya.wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=4853"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/mya.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=4853"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/mya.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=4853"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/mya.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=4853"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/mya.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=4853"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/mya.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=4853"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}