Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function custom_query_shortcode($atts) {
- // EXAMPLE USAGE:
- // [loop the_query="showposts=100&post_type=page&post_parent=453"]
- // Defaults
- extract(shortcode_atts(array(
- "the_query" => ''
- ), $atts));
- // de-funkify query
- $the_query = preg_replace('~�*([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $the_query);
- $the_query = preg_replace('~�*([0-9]+);~e', 'chr(\\1)', $the_query);
- // query is made
- query_posts($the_query);
- // Reset and setup variables
- $output = '';
- $temp_title = '';
- $temp_link = '';
- // the loop
- if (have_posts()) : while (have_posts()) : the_post();
- $temp_title = get_the_title($post->ID);
- $temp_link = get_permalink($post->ID);
- // output all findings - CUSTOMIZE TO YOUR LIKING
- $output.='<div class="one-sixth">';
- $output.='<p><a href="'.$temp_link.'">'.$temp_title.'</a></p>';
- $output.='<p><a href="'.genesis_get_custom_field('host_url').'">'.genesis_get_custom_field('host_url').'</a></p>';
- $output.='</div>';
- endwhile;
- $output.='<div class="clear-line"></div>';
- else:
- $output.='nothing found.';
- endif;
- wp_reset_query();
- return $output;
- }
- add_shortcode("loop", "custom_query_shortcode");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement