Thumbnails missing after add_filter
-
Hi All,
I added the following call to my functions.php and have now lost the thumbnails on my home page.
Any suggestions? If I comment out the call to add_filter then they show up again.
# Pre-fetch for posts function setcat_pre_posts($query) { if ($query->is_home) // Assuming you want this to apply when it's your home page { $domain = preg_replace("/^(.*\.)?([^.]*\..*)$/", "$2", $_SERVER['HTTP_HOST']); $domainstr = substr($domain, 0, -4); $sitecat_id = get_category_by_slug($domainstr)->term_id; $generalcat_id = get_category_by_slug('general')->term_id; $cats = $sitecat_id.','.$generalcat_id; $query->set('cat', $cats); } return $query; } add_filter('pre_get_posts', 'setcat_pre_posts');
I should probably post this as well. Here’s the code being used in functions.php to get the thumbnail.
# Displays post image attachment (sizes: thumbnail, medium, full) function dp_attachment_image($postid=0, $size='thumbnail', $attributes='') { if ($postid<1) $postid = get_the_ID(); if ($images = get_children(array( 'post_parent' => $postid, 'post_type' => 'attachment', 'numberposts' => 1, 'post_mime_type' => 'image',))) foreach($images as $image) { $attachment=wp_get_attachment_image_src($image->ID, $size); ?><img src="<?php echo $attachment[0]; ?>" <?php echo $attributes; ?> /><?php } }
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Thumbnails missing after add_filter’ is closed to new replies.