Wordpress Discussion
Out of context: Reply #9
- Started
- Last post
- 164 Responses
- fadein110
@pockets - here is the full function. Thanks again!
function custom_alsolikequery_shortcode... {
// Defaults
extract(shortcode_atts(array(
"the_query" => ''
), $atts));// de-funkify query
$the_query = preg_replace('~�*([0-9a-f... 'chr(hexdec("\\1"))', $the_query);
$the_query = preg_replace('~�*([0-9]+);~e', 'chr(\\1)', $the_query);// query is made
remove_all_filters('posts_orderb...
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...- has to be a shortcode as it needs to be inserted into the content here and there.fadein11
- truncated? wheres the whole thingpockets
- "..." ?pockets
- code looks all sorts of fuckedpockets
- paging fadeinpockets
- i give uppockets
- Sorry UK time... That code works fine except excluding the current postfadein11
- ah yes it is truncated - thought it would be okay as short.fadein11
- It was 11am and I had to go to bed - thought I had commented that but hadn't - apologies.fadein11
- 11pm - God I need coffee.fadein11