Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function custom_alsolikequery_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
- remove_all_filters('posts_orderby');
- query_posts($the_query);
- // Reset and setup variables
- $output = '';
- $temp_title = '';
- $temp_link = '';
- $temp_url = '';
- // the loop
- $exclude = $GLOBALS['current_id'];
- $args = array(
- 'post__not_in' => array($exclude), 'post_type'=>'our-work', 'orderby'=>'rand', 'posts_per_page'=>'3'
- );
- query_posts($args);
- if ( have_posts() ) : while ( have_posts() ) : the_post();
- $temp_title = get_the_title($post->ID);
- $temp_link = get_permalink($post->ID);
- $img_url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
- // output all findings - CUSTOMIZE TO YOUR LIKING
- $output .= "<li class='workitem workitem2' style='background:url($img_url); background-repeat: no-repeat!important;
- background-size: cover!important;
- background-position: center center!important;'><a href='$temp_link'><span>$temp_title</span></a></li>
- ";
- endwhile; else:
- $output .= "nothing found.";
- endif;
- wp_reset_query();
- return $output;
- }
- add_shortcode("loopalsolike", "custom_alsolikequery_shortcode");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement