{"id":18748,"date":"2012-06-24T22:14:40","date_gmt":"2012-06-24T22:14:40","guid":{"rendered":"https:\/\/wordpress.org\/plugins-wp\/shauns-wp-query-shortcode\/"},"modified":"2012-10-20T14:06:46","modified_gmt":"2012-10-20T14:06:46","slug":"shauns-wp-query-shortcode","status":"publish","type":"plugin","link":"https:\/\/sa.wordpress.org\/plugins\/shauns-wp-query-shortcode\/","author":7270592,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_crdt_document":"","version":"1.2","stable_tag":"trunk","tested":"3.4.2","requires":"3.0","requires_php":"","requires_plugins":"","header_name":"Shaun's WP Query Shortcode","header_author":"Shaun Scovil","header_description":"","assets_banners_color":"","last_updated":"2012-10-20 14:06:46","external_support_url":"","external_repository_url":"","donate_link":"http:\/\/mynewsitepreview.com\/donate\/","header_plugin_uri":"http:\/\/mynewsitepreview.com\/shauns-wp-query-shortcode\/","header_author_uri":"http:\/\/shaunscovil.com\/","rating":5,"author_block_rating":0,"active_installs":10,"downloads":2455,"num_ratings":1,"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":"1"},"assets_icons":[],"assets_banners":[],"assets_blueprints":{},"all_blocks":[],"tagged_versions":[],"block_files":[],"assets_screenshots":{"screenshot-2.png":{"filename":"screenshot-2.png","revision":"1539300","resolution":"2","location":"plugin"},"screenshot-1.png":{"filename":"screenshot-1.png","revision":"1539300","resolution":"1","location":"plugin"}},"screenshots":{"1":"A basic example of how to use this plugin","2":"Code that can be used as a template to write a compatible plugin"},"jetpack_post_was_ever_published":false},"plugin_section":[],"plugin_tags":[527,170,86,1626,528],"plugin_category":[57],"plugin_contributors":[83145],"plugin_business_model":[],"class_list":["post-18748","plugin","type-plugin","status-publish","hentry","plugin_tags-custom","plugin_tags-page","plugin_tags-post","plugin_tags-query","plugin_tags-type","plugin_category-taxonomy","plugin_contributors-sscovil","plugin_committers-sscovil"],"banners":[],"icons":{"svg":false,"icon":"https:\/\/s.w.org\/plugins\/geopattern-icon\/shauns-wp-query-shortcode.svg","icon_2x":false,"generated":true},"screenshots":[{"src":"https:\/\/ps.w.org\/shauns-wp-query-shortcode\/trunk\/screenshot-1.png?rev=1539300","caption":"A basic example of how to use this plugin"},{"src":"https:\/\/ps.w.org\/shauns-wp-query-shortcode\/trunk\/screenshot-2.png?rev=1539300","caption":"Code that can be used as a template to write a compatible plugin"}],"raw_content":"<!--section=description-->\n<p>Written as a platform for plugin developers, this simple-yet-powerful plugin allows you to run a custom WP_Query using shortcode, then display the results any way imaginable using compatible nested shortcodes.<\/p>\n\n<h4>How It Works<\/h4>\n\n<p>Add the following shortcode to any WordPress post or page:<\/p>\n\n<pre><code>[wpquery orderby=\"rand\"] [wpq_index] [\/wpquery]\n<\/code><\/pre>\n\n<p>In the example above, the <code>[wpquery]<\/code> shortcode performs a WP_Query using <strong>orderby=\"rand\"<\/strong> to display the results in random order. A full list of query parameters can be found here: <a href=\"http:\/\/codex.wordpress.org\/Class_Reference\/WP_Query#Parameters\" title=\"WP_Query\">WP_Query<\/a>.<\/p>\n\n<p>Next, the nested <code>[wpq_index]<\/code> shortcode displays the results of the custom WP_Query as an unordered list of post title links.<\/p>\n\n<h4>Why It Rocks<\/h4>\n\n<p>Written as a platform for plugin developers, this simple-yet-powerful plugin allows developers to write compatible plugins that manipulate the way post data is displayed - without needing to write functions and shortcode parameters to first retrieve the post data.<\/p>\n\n<p>The <code>[wpq_index]<\/code> shortcode function included in this plugin is just a simple example of what it can do. Any plugin that performs a WP_Query could be rewrtitten and optimized to work with this plugin, eliminating a lot of unnecessary code.<\/p>\n\n<p>Best of all, this plugin gives users total control over the WP_Query being performed!<\/p>\n\n<!--section=installation-->\n<ol>\n<li>Upload <code>shauns-wp-query-shortcode.php<\/code> to the <code>\/wp-content\/plugins\/<\/code> directory<\/li>\n<li>Activate the plugin through the 'Plugins' menu in WordPress<\/li>\n<li>In a post or page, place the nested shortcode: <code>[wpquery] [wpq_index] [\/wpquery]<\/code><\/li>\n<li>Replace <code>[wpq_index]<\/code> with shortcode from any other compatible plugin<\/li>\n<\/ol>\n\n<!--section=faq-->\n<dl>\n<dt>Why did you develop this plugin?<\/dt>\n<dd><p>Two of my earlier plugins - <a href=\"http:\/\/wordpress.org\/extend\/plugins\/sorttable-post\/\" title=\"SortTable Post\">SortTable Post<\/a> and <a href=\"http:\/\/wordpress.org\/extend\/plugins\/jqdock-post-thumbs\/\" title=\"jqDock Post Thumbs\">jqDock Post Thumbs<\/a> - essentially did the same thing: They got post data via WP_Query, then used a Javascript library to display certain information in a unique and interesting way.<\/p>\n\n<p>Many of the feature requests I received for those plugins came from folks who wanted more granular control over the data that was retrieved by WP_Query (e.g. only show posts of a particular category \/ tag \/ post-type \/ taxonomy).<\/p>\n\n<p>The only way I could accommodate those feature requests was to add more shortcode parameters to the plugin, but I was also adding shortcode parameters to handle how the post data was displayed. After a while, things started getting out of hand.<\/p>\n\n<p>This plugin was the solution.<\/p>\n\n<p>By separating the shortcode for 'getting post data' from the shortcode for 'displaying post data', I was able to simplify the shortcodes for users.<\/p><\/dd>\n<dt>What shortcode parameters does `[wpquery]` accept?<\/dt>\n<dd><p>It accepts all of the same parameters as <a href=\"http:\/\/codex.wordpress.org\/Class_Reference\/WP_Query#Parameters\" title=\"WP_Query\">WP_Query<\/a>.<\/p><\/dd>\n<dt>Where can I find compatible plugins?<\/dt>\n<dd><p>Going forward, all of my plugins that use WP_Query will require this plugin to be installed. You can find my plugins here: <a href=\"http:\/\/profiles.wordpress.org\/sscovil\" title=\"Shaun's Profile\">Shaun's Profile<\/a><\/p>\n\n<p>To find compatible plugins written by other authors, try searching the WP Plugin Repository for \"Shaun's WP Query Shortcode\".<\/p>\n\n<p>If you're real savvy, you can even write your own compatible plugins! Just use the <code>mnsp_wpq_index<\/code> function that comes with this plugin as a template...and if you upload it to the repository, make sure you let people know that it requires Shaun's WP Query Shortcode to work!<\/p><\/dd>\n<dt>How can I request support or report a bug?<\/dt>\n<dd><p>Please post your question as a comment on the apporpriate plugin page of my website: <a href=\"http:\/\/mnsp.co\/\" title=\"MyNewSitePreview.com\">MyNewSitePreview.com<\/a><\/p><\/dd>\n\n<\/dl>\n\n<!--section=changelog-->\n<h4>1.2<\/h4>\n\n<ul>\n<li>Modified the <code>wpq_index<\/code> shortcode function to exclude the current post\/page from the list.<\/li>\n<\/ul>\n\n<h4>1.1<\/h4>\n\n<ul>\n<li>Added function to detect array expressions in shortcode parameters and convert them to arrays. This allows you to set WP_Query parameters such as <code>category__and<\/code>, <code>category__in<\/code>, <code>category__not_in<\/code>, etc.<\/li>\n<li>Thanks to <a href=\"http:\/\/stackoverflow.com\/users\/492901\/netcoder\" title=\"Netcoder\">Netcoder<\/a> for providing this <a href=\"http:\/\/stackoverflow.com\/questions\/11267434\/php-how-to-turn-a-string-that-contains-an-array-expression-in-an-actual-array\/11267511#comment14814921_11267511\" title=\"solution\">solution<\/a>!<\/li>\n<\/ul>\n\n<h4>1.0<\/h4>\n\n<ul>\n<li>First public release.<\/li>\n<\/ul>","raw_excerpt":"This extensible plugin allows you to run a custom WP_Query using a simple shortcode, then display the results using compatible nested shortcodes.","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/sa.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/18748","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sa.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/sa.wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/sa.wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=18748"}],"author":[{"embeddable":true,"href":"https:\/\/sa.wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/sscovil"}],"wp:attachment":[{"href":"https:\/\/sa.wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=18748"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/sa.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=18748"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/sa.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=18748"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/sa.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=18748"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/sa.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=18748"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/sa.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=18748"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}