{"id":110982,"date":"2011-05-26T08:00:00","date_gmt":"2011-05-26T08:00:00","guid":{"rendered":"https:\/\/www.weixiaoduo.com\/plugins\/2024\/02\/22\/mini-loops\/"},"modified":"2021-06-17T05:55:00","modified_gmt":"2021-06-17T05:55:00","slug":"mini-loops","status":"publish","type":"post","link":"https:\/\/www.weixiaoduo.com\/plugins\/mini-loops\/","title":{"rendered":"Mini Loops"},"content":{"rendered":"<p>Widget for mini post loops.<\/p>\n<p>Show most recent posts, posts from categories, and more. Can be displayed via widgets, shortcodes, and template tags.<\/p>\n<p>Development is now happening at the <a href=\"https:\/\/github.com\/trepmal\/mini-loops\" rel=\"nofollow ugc\">GitHub Repo<\/a><br \/>\nExplanation of options:<\/p>\n<h4>Widget Display<\/h4>\n<p><strong>Title:<\/strong> Your recent posts widget\u2019s title on your sidebar. Default: Recent Posts<br \/>\n    [miniloop title=\u201dRecent Posts\u201d]<br \/>\n    get_miniloops( array(\u2018title\u2019 => \u2018Recent Posts\u2019 ) );<\/p>\n<p><strong>Title URL:<\/strong> The page the title should link to. Default: none<br \/>\n    [miniloop title_url=\u201d\/blog\/\u201d]<br \/>\n    get_miniloops( array(\u2018title_url\u2019 => \u2018\/blog\/\u201d ) );<\/p>\n<h4>Building the Query<\/h4>\n<p><strong>Number of Posts:<\/strong> Number of posts to be displayed. Default: 3<br \/>\n    [miniloop number_posts=3]<br \/>\n    get_miniloops( array(\u2018number_posts\u2019 => 3 ) );<\/p>\n<p><strong>Post Offset:<\/strong> Number of posts to skip before displaying the list. Default: 0<br \/>\n    [miniloop post_offset=0]<br \/>\n    get_miniloops( array(\u2018post_offset\u2019 => 0 ) );<\/p>\n<p><strong>Maximum Age:<\/strong> Don\u2019t show posts more than X days old Default: 0<br \/>\n    [miniloop maximum_age=0]<br \/>\n    get_miniloops( array(\u2018maximum_age\u2019 => 0 ) );<\/p>\n<p><strong>Post Author:<\/strong> Get author\u2019s post. By ID. Default: none<br \/>\n    [miniloop post_author=0]<br \/>\n    get_miniloops( array(\u2018post_author\u2019 => 0 ) );<\/p>\n<p><strong>Post Type:<\/strong> Post type to display. Default: post<br \/>\n    [miniloop post_type=post]<br \/>\n    get_miniloops( array(\u2018post_type\u2019 => \u2018post\u2019 ) );<\/p>\n<p><strong>Post Status:<\/strong> Post status to display. Primarily useful to show upcoming (future) posts. But be creative! Default: publish<br \/>\n    [miniloop post_status=publish]<br \/>\n    get_miniloops( array(\u2018post_status\u2019 => \u2018publish\u2019 ) );<\/p>\n<p><strong>Order By:<\/strong> What order the posts should be displayed in. Default: date<br \/>\n    [miniloop order_by=date]<br \/>\n    get_miniloops( array(\u2018order_by\u2019 => \u2018date\u2019 ) );<\/p>\n<p><strong>Order:<\/strong> Ascending (good for order by title) or Descending (good for order by date) Default: DESC<br \/>\n    [miniloop order=DESC]<br \/>\n    get_miniloops( array(\u2018order\u2019 => \u2018DESC\u2019 ) );<\/p>\n<p><strong>Ordering by the values of <code>some_key<\/code><\/strong> (works well if the values of <code>some_key<\/code> are strings\/words):<br \/>\n    [miniloop order_by=meta_value order_meta_key=some_key]<br \/>\n    get_miniloops( array(\u2018order_by\u2019 => \u2018meta_value\u2019, \u2018order_meta_key\u2019 => \u2018some_key\u2019 ) );<\/p>\n<p><strong>Ordering by the numeric values of <code>some_key<\/code><\/strong> (works well if the values of <code>some_key<\/code> are numbers\/integers):<br \/>\n    [miniloop order_by=meta_value_num order_meta_key=some_key]<br \/>\n    get_miniloops( array(\u2018order_by\u2019 => \u2018meta_value_num\u2019, \u2018order_meta_key\u2019 => \u2018some_key\u2019 ) );<\/p>\n<p><strong>Show posts in reverse order?<\/strong> Perhaps you want the 3 most recent posts, but you want the oldest of those to be displayed first. If so, check this. Default: 0<br \/>\n    [miniloop reverse_order=0]<br \/>\n    get_miniloops( array(\u2018reverse_order\u2019 => 0 ) );<\/p>\n<p><strong>Shuffle post order?<\/strong> Shuffle the order of the posts matching your query. Perhaps showing the 5 most recent posts in randomized order. Default: 0<br \/>\n    [miniloop shuffle_order=0]<br \/>\n    get_miniloops( array(\u2018shuffle_order\u2019 => 0 ) );<\/p>\n<p><strong>Ignore sticky posts?<\/strong> Treat sticky posts as normal posts. I recommend ignoring, or the number of posts displayed may be inconsistent. Default: 1<br \/>\n    [miniloop ignore_sticky=1]<br \/>\n    get_miniloops( array(\u2018ignore_sticky\u2019 => 1 ) );<\/p>\n<p><strong>Exclude sticky posts?<\/strong> Don\u2019t show sticky posts at all. Default: 0<br \/>\n    [miniloop exclude_sticky=0]<br \/>\n    get_miniloops( array(\u2018exclude_sticky\u2019 => 0 ) );<\/p>\n<p><strong>Only sticky posts?<\/strong> Show only sticky posts. Default: 0<br \/>\n    [miniloop only_sticky=0]<br \/>\n    get_miniloops( array(\u2018only_sticky\u2019 => 0 ) );<\/p>\n<p><strong>If viewing a single post, exclude it?<\/strong> If viewing a single post, remove it from the widget display. Default: 1<br \/>\n    [miniloop exclude_current=1]<br \/>\n    get_miniloops( array(\u2018exclude_current\u2019 => 1 ) );<\/p>\n<p><strong>Get posts from current category (if archive)?<\/strong> If viewing an archive, only show posts from the same category. Default: 0<br \/>\n    [miniloop current_category=1]<br \/>\n    get_miniloops( array(\u2018current_category\u2019 => 1 ) );<\/p>\n<p><strong>Get posts from first category (if single)?<\/strong> If viewing a single post, only show posts from the first category. Default: none<br \/>\n    [miniloop current_single_category=1]<br \/>\n    get_miniloops( array(\u2018current_single_category\u2019 => 1 ) );<\/p>\n<p><strong>Get posts from current author (if single or archive)?<\/strong> Show more posts from the current author. Default: none<br \/>\n    [miniloop current_author=1]<br \/>\n    get_miniloops( array(\u2018current_author\u2019 => 1 ) );<\/p>\n<p><strong>Categories:<\/strong> Comma separated list of category IDs to pull from. Use negative ID numbers to exclude a category. Default: none<br \/>\n    [miniloop categories=\u201d1,8,13\u2033]<br \/>\n    get_miniloops( array(\u2018categories\u2019 => \u20181,8,13\u2019 ) );<\/p>\n<p><strong>Tags:<\/strong> Comma separated list of tag IDs to pull from. Use negative ID numbers to exclude a tag. Default: none<br \/>\n    [miniloop tags=\u201d15,40,88\u2033]<br \/>\n    get_miniloops( array(\u2018tags\u2019 => \u201815,40,88\u2019 ) );<\/p>\n<p><strong>Custom Taxonomies:<\/strong> A clunky way to support custom taxonomies. Default: none. To include terms 5, 6, 9 from taxonomy \u201cGenre\u201d do this:<br \/>\n    [miniloop tax=\u201dgenre=5,6,9\u2033]<br \/>\n    get_miniloops( array(\u2018tax\u2019 => \u2018genre=5,6,9\u2019 ) );<\/p>\n<p><strong>Custom Fields:<\/strong> For listing posts that have certain meta data. Default: none. To list posts that have a custom field \u2018favorite_color\u2019 with a value of \u2018blue\u2019 do this:<br \/>\n    [miniloop custom_fields=\u201dfavorite_color=blue\u201d]<br \/>\n    get_miniloops( array(\u2018custom_fields\u2019 => \u2018favorite_color=blue\u2019 ) );<\/p>\n<p><strong>Exclude Posts:<\/strong> A comma separated list of post IDs to exclude. Default: none<br \/>\n    [miniloop exclude=\u201d15,200,1032\u2033]<br \/>\n    get_miniloops( array(\u2018exclude\u2019 => \u201815,200,1032\u2019 ) );<\/p>\n<h4>Display<\/h4>\n<p><strong>Before Items:<\/strong> Text\/HTML to insert before the post list. Default: <code><\/p>\n<ul><\/code><br \/>\n    [miniloop before_items=\u201d\u201d]<br \/>\n    get_miniloops( array(\u2018before_items\u2019 => \u201d ) );<\/p>\n<p><strong>After Items:<\/strong> Text\/HTML to insert after the post list. Default: <code><\/ul>\n<p><\/code><br \/>\n    [miniloop after_items=\u201d\u201d]<br \/>\n    get_miniloops( array(\u2018after_items\u2019 => \u201d ) );<\/p>\n<p><strong>Item Format:<\/strong><br \/>\nHTML and shortcodes to format each item<\/p>\n<h4>Shortcodes<\/h4>\n<ul>\n<li>[ml_title]<\/li>\n<li>[ml_url]<\/li>\n<li>[ml_excerpt] Attributes: length (100), wlength (0), after (\u2018\u2026\u2019), space_between (0), after_link (1), custom (0), strip_tags (1), strip_shortcodes (1)\n<ul>\n<li>length = excerpt length in characters (0 for none, -1 for full length)<\/li>\n<li>wlength = excerpt length in words<\/li>\n<li>after = what to show after the excerpt<\/li>\n<li>space_between = force space between excerpt and \u2018after\u2019<\/li>\n<li>after_link = make the \u2018after\u2019 link to the post<\/li>\n<li>custom = 1 to default\/customized excerpts, 0 to trim by lentgh<\/li>\n<li>strip_tags = 1 to strip HTML tags, 0 to keep. <strong>CAREFUL:<\/strong> it is not generally recommended to keep the tags. Character excerpts may break tags, and thus break an entire page\u2019s layout.<\/li>\n<li>strip_shortcodes = 1 to strip shortcodes, 0 to keep<\/li>\n<li>up_to_more = 1 to get everything up to the <code><!--more--><\/code> tag (the \u2018more\u2019 text), if it exists, otherwise use char\/word limit excerpt. 0 use char\/word limited excerpt<\/li>\n<li>after_with_more = (with up_to_more) 1 to use the \u2018after\u2019 text with the \u2018more\u2019 text, 0 to add nothing after the \u2018more\u2019 text<\/li>\n<\/ul>\n<\/li>\n<li>[ml_content]<\/li>\n<li>[ml_comment_count]<\/li>\n<li>[ml_author]<\/li>\n<li>[ml_author_link]<\/li>\n<li>[ml_author_avatar] Attributes: size (92), default (\u201d), alt (false)\n<ul>\n<li>size = avatar size, in pixels<\/li>\n<li>default = default if no gravatar. See Settings > Discussion<\/li>\n<li>alt = alt text<\/li>\n<\/ul>\n<\/li>\n<li>[ml_field] Attributes: name, single (1), separator (\u2018, \u2018), reverse (0)\n<ul>\n<li>name = custom field name<\/li>\n<li>single = 1 get single value, 0 get all values matching name<\/li>\n<li>separator = string to separate each value<\/li>\n<li>reverse = 0 default order, 1 reverse display order<\/li>\n<\/ul>\n<\/li>\n<li>[ml_taxonomy] Attributes: taxonomy, separator (\u2018, \u2018), link (0), justone (0), reverse (0)\n<ul>\n<li>taxonomy = taxonomy slug<\/li>\n<li>separator = string to separate each term<\/li>\n<li>link = 1 to link categories to their archive page, 0 for no links<\/li>\n<li>justone = 1 to show just first category, 0 to show all<\/li>\n<li>reverse = 0 default order, 1 reverse display order<\/li>\n<\/ul>\n<\/li>\n<li>[ml_tax] Alias to [ml_taxonomy]<\/li>\n<li>[ml_category] Shortcut for [tax taxonomy=category]<\/li>\n<li>[ml_tag] Shortcut for [tax taxonomy=post_tag]<\/li>\n<li>[ml_date] Attributes: format (\u2018F j, Y\u2019)\n<ul>\n<li>format = PHP-style date format<\/li>\n<\/ul>\n<\/li>\n<li>[ml_class] Attributes: class\n<ul>\n<li>class = classes to display in addition to the traditional post classes<\/li>\n<\/ul>\n<\/li>\n<li>[ml_image] Attributes: from, cfname, class, width (50), height (50), crop, fallback\n<ul>\n<li>from (options: thumb, attached, customfield, first)\n<ul>\n<li><em>from<\/em> \u2018thumb\u2019 post thumbnail\/featured image <code>[ml_image from=thumb]<\/code><\/li>\n<li><em>from<\/em> \u2018attached\u2019 first attached image <code>[ml_image from=attached]<\/code><\/li>\n<li><em>from<\/em> \u2018customfield\u2019 get from custom field <code>[ml_image from=customfield]<\/code><\/li>\n<li><em>from<\/em> \u2018first\u2019 first image in post <code>[ml_image from=first]<\/code><\/li>\n<\/ul>\n<\/li>\n<li>since 1.1.3, you can pass a comma-separated list to use as fallbacks. <code>[ml_image from=\"thumb,first\"]<\/code><\/li>\n<li>cfname = custom field to use if from=customfield <code>[ml_image from=customfield cfname=thumbnail]<\/code><\/li>\n<li>class = class for image<\/li>\n<li>width = width of image<\/li>\n<li>height = height of image<\/li>\n<li>crop = 1 to crop, 0 to scale (not implemented yet)<\/li>\n<li>fallback = URL of image to use if \u2018from\u2019 doesn\u2019t return anything<\/li>\n<li>cache = set to \u2018clear\u2019 to generate new thumbnails. It is not recommended that you leave this option on. <code>[ml_image from=thumb cache=clear]<\/code><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>Inside of Item Format, shortcodes can be used without the <code>ml_<\/code> prefix.<\/p>\n<h4>Sample Item Formats<\/h4>\n<p>Format 1: https:\/\/s.w.org\/extend\/plugins\/mini-loops\/screenshot-2.png<\/p>\n<p>(before: <code><\/p>\n<ul><\/code> after: <code><\/ul>\n<p><\/code>)<\/p>\n<li><\/li>\n<p><a href=\"[url]\" rel=\"nofollow ugc\">[image from=customfield<br \/>\n    cfname=image width=50 height=50 class=alignright<br \/>\n    fallback=\u2019http:\/\/dummyimage.com\/50\u2032][title]<\/a><br \/>\n    [excerpt wlength=30 space_between=1 after=\u201d\u2026\u201d after_link=1]<\/p>\n<p>    By [author] on [date format=\u201dn\/j\/y\u201d]<\/p>\n<\/p>\n<p>Format 2: https:\/\/s.w.org\/extend\/plugins\/mini-loops\/screenshot-3.png<\/p>\n<p>(before: <code><\/p>\n<ul><\/code> after: <code><\/ul>\n<p><\/code>)<\/p>\n<li><\/li>\n<p>[date format=\u201dF j, Y\u201d]<br \/><a href=\"[url]\" rel=\"nofollow ugc\"><br \/>\n    [image from=customfield cfname=image width=180 height=100<br \/>\n    class=aligncenter fallback=\u2019http:\/\/placekitten.com\/180\/100\u2032]<\/a><br \/>\n    [excerpt length=90 space_between=1 after=\u201d\u2026\u201d after_link=1]<\/p>\n<\/p>\n<p>Format 3: https:\/\/s.w.org\/extend\/plugins\/mini-loops\/screenshot-4.png<\/p>\n<p>(before: \u2014 after: \u2013)<\/p>\n<p><a href=\"[url]\" rel=\"nofollow ugc\">[title]<br \/>\n    [image from=customfield cfname=image width=140 height=140<br \/>\n    class=aligncenter fallback=\u2019http:\/\/placepuppy.it\/200\/300&text=++woof++\u2019]<\/a><\/p>\n<h3>Template Tag<\/h3>\n<p>use <code>miniloops( $args )<\/code> or <code>get_miniloops( $args )<\/code><\/p>\n<p>Like WordPress function, the \u2018get_\u2019 variant will simply return the results.<\/p>\n<p>Here are the acceptable arguments and their default values:<\/p>\n<pre><code>$args = array(\n        'title' => __( 'Recent Posts', 'mini-loops' ),\n        'hide_title' => 0,\n        'title_url' => '',\n        'number_posts' => 3,\n        'post_offset' => 0,\n        'post_type' => 'post',\n        'post_status' => 'publish',\n        'order_by' => 'date',\n        'order' => 'DESC',\n        'reverse_order' => 0,\n        'shuffle_order' => 0,\n        'ignore_sticky' => 1,\n        'only_sticky' => 0,\n        'exclude_current' => 1,\n        'categories' => '',\n        'tags' => '',\n        'tax' => '',\n        'custom_fields' => '',\n        'exclude' => '',\n        'before_items' => '<ul>',\n        'item_format' => '<li><a href=\"[url]\">[title]<\/a><br \/>[excerpt]<\/li>',\n        'after_items' => '<\/ul>',\n        );\nget_miniloops( $args );\n<\/code><\/pre>\n<h4>Shortcode<\/h4>\n<pre><code>[miniloop]\n<\/code><\/pre>\n<p>Use with all args listed above<br \/>\ne.g. <code>[miniloop number_posts=10]<\/code><\/p>\n<p><strong>Exception \u2013 \u2018item_format\u2019 must be handled differently<\/strong><\/p>\n<p>New way (since v0.9):<\/p>\n<p>Create a custom field named <code>ml_format<\/code> and save the item format there. Then adjust your <code>[miniloop]<\/code> shortcode<br \/>\ne.g. <code>[miniloop number_posts=10][ml_format][\/miniloop]<\/code><\/p>\n<p>If needed, you can change the custom field. Just pass the name of the new custom field to the <code>[ml_format]<\/code> shortcode<br \/>\ne.g. <code>[miniloop number_posts=10][ml_format name=\"new_field\"][\/miniloop]<\/code><\/p>\n<p>Old way:<\/p>\n<p>\u2018item_format\u2019 must go into the content of the shortcode, and square brackets must be replaced with curly brackets.<br \/>\ne.g. <code>[miniloop number_posts=10]{title}by {author}<br \/>[\/miniloop]<\/code><\/p>\n<p>Also, if you are using html inside the item_format, you must add this into the HTML editor, else your markup will be rendered, not parsed<\/p>\n<h4>Planned<\/h4>\n<ul>\n<li>true image cropping for remote images<\/li>\n<\/ul>\n<h3>Other Languages<\/h3>\n<ul>\n<li>French (Thanks <a href=\"http:\/\/twitter.com\/maoneetag\" rel=\"nofollow ugc\">@maoneetag<\/a>)<\/li>\n<\/ul>\n<h4>Bilingual?<\/h4>\n<p>Send your mo\/po files to me at trepmal (at) gmail.com<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Get recent posts, posts from categories, and more. Display as widget or with shortcodes and template tags.<\/p>\n","protected":false},"author":65,"featured_media":107999,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"slim_seo":{"title":"Mini Loops - \u8587\u6653\u6735\u63d2\u4ef6\u76ee\u5f55","description":"Get recent posts, posts from categories, and more. Display as widget or with shortcodes and template tags."},"footnotes":""},"categories":[1],"tags":[3289,3290,1445,473,986],"class_list":["post-110982","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-category-posts","tag-most-recent","tag-recent","tag-recent-posts","tag-thumbnail"],"_links":{"self":[{"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/posts\/110982","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/users\/65"}],"replies":[{"embeddable":true,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/comments?post=110982"}],"version-history":[{"count":0,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/posts\/110982\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/media\/107999"}],"wp:attachment":[{"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/media?parent=110982"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/categories?post=110982"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/tags?post=110982"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}