Add loop shortcode
Upcoming SlideShare
Loading in...5
×
 

Add loop shortcode

on

  • 414 views

 

Statistics

Views

Total Views
414
Views on SlideShare
414
Embed Views
0

Actions

Likes
0
Downloads
1
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

CC Attribution-ShareAlike LicenseCC Attribution-ShareAlike License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Add loop shortcode Add loop shortcode Document Transcript

  • add_loop_shortcode.php 2011-11-06<?php/*Plugin Name: Loop ShortcodePlugin URI: http://semperfiwebdesign.com/Description: Adds a [loop] shortcode for embedding The Loop.Version: 2.0Author: Semper Fi Web DesignAuthor URI: http://semperfiwebdesign.com/*/add_shortcode( loop, pdb_sfwd_loop );function pdb_sfwd_loop( $atts, $content = null ) { $atts = shortcode_atts( array( /*** filter shortcode options ***/ "pagination" => true, "query" => , "category_name" => , "post_type" => , "order" => , "orderby" => , "meta_key" => ), $atts ); $the_query = new WP_Query(); if( $atts[pagination] == true ) $atts[paged] = get_query_var(paged); unset($atts[pagination]); $the_query->query( http_build_query( $atts ) ); ob_start(); /*** output buffering for convenience***/ while ( $the_query->have_posts() ) : $the_query->the_post(); $id = $the_query->post->ID; /*** allow use of id variable ***/ $content = str_replace( $id, "$id", $content ); echo do_shortcode ( $content ); /*** run shortcodes in the loop ***/ endwhile; if( $pagination == true ) { ?> <div class="navigation"> - 1/2 -
  • add_loop_shortcode.php 2011-11-06 <div class="alignleft"><?php previous_posts_link( « Previous )?></div> <div class="alignright"><?php next_posts_link( More »,$the_query->max_num_pages ) ?></div> </div><?php } wp_reset_postdata(); return ob_get_clean(); /*** return output buffer contents ***/}?> - 2/2 -