/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function custom_query_shortcode($atts) { // EXAMPLE USAGE: // [loop the_query="showposts=100&post_type=page&post_parent=453"] // Defaults "the_query" => '' ), $atts)); // de-funkify 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 .= "<li><a href='$temp_link'>$temp_title</a></li>"; endwhile; else: $output .= "nothing found."; endif; wp_reset_query(); return $output; } add_shortcode("loop", "custom_query_shortcode"); [loop the_query="showposts=20&post_type=page&post_parent=453&ord=ASC"]