I’ve a problem in only category page on my website.
If I open console dev, I find this error:
Error: TypeError: Cannot read property 'postcount' of undefined
at Object.n.AjaxLoadMore.success (ajax-load-more.min.js?ver=5.4.3:6)
at ajax-load-more.min.js?ver=5.4.3:6
ajax-load-more.min.js?ver=5.4.3:6 Error Msg: Cannot read property 'postcount' of undefined
ajax-load-more.min.js?ver=5.4.3:6 ALM Error started in adminajax
the strange thing is that if I click on the button 3 times then the posts are loaded. The problem is only in one category and 6 articles are not loaded. Can you help me? Thank you
]]>As of last night I am getting this error in my console
Error: TypeError: Cannot read property ‘postcount’ of undefined
at Object.n.AjaxLoadMore.success (ajax-load-more.min.js?ver=5.4.3:6)
at ajax-load-more.min.js?ver=5.4.3:6
Happened randomly as far as I can tell.
]]>I’ve been using this handy script from digital mash to keep horizontally gridded posts nicely lined up for a while now. It basically inserts a clearing break every 5 posts, or how ever many you choose.
However, in a current project, I’m using the attachment toolbox described here to display images and descriptions in a horizontal grid with five columns.
Problem is I can’t combine the two, because the attachment system uses a foreach loop instead of the standard $post loop.
Here’s my code so far:
<?php
function attachment_toolbox($size = thumbnail) {
if($images = get_children(array(
'post_parent' => get_the_ID(),
'post_type' => 'attachment',
'numberposts' => -1, // show all
'post_status' => null,
'post_mime_type' => 'image',
))) {
echo '<br class="clearboth" /><h3>Other Editions:<h3><ul class="otherEds">';
foreach($images as $image) {
$attimg = wp_get_attachment_image($image->ID,$size);
$atturl = wp_get_attachment_url($image->ID);
$attlink = get_attachment_link($image->ID);
$postlink = get_permalink($image->post_parent);
$atttitle = apply_filters('the_title',$image->post_title);
$attcontent = ($image->post_content);
echo '<li class="onecolfive left fivecolmargin"><div class="bookimage">'.$attimg.'</div>';
echo '<p>'.$atttitle.'</p>';
echo '<p>'.$attcontent.'</p></li>';
}
echo '</ul>';
}
}
?>
If any body knows how I could modify this to insert a clearing break every 5 attachments, I’d be really pleased to learn.
Thanks!
J
]]>I am running the Mimbo3.0 theme with feature content gallery plugin. And i want the post to display from the category “articles” but the first post is always hidden, I try to tweek the if statements, but it would crash if i do anything but the current code. any ideas why?
for sheimagazine.com
<?php get_header(); ?>
<?php if (have_posts()) { ?>
<div id="content">
<?php
$postCount = 0;
$page = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts( 'paged=$page&post_per_page=-1&category_name=Articles&showposts=5');
// change from $query_posts( 'paged=$page&post_per_page=-1&cat=' . get_query_var('cat')
while (have_posts()) { the_post();
if( $postcount == 0 ) {
//GETS LATEST OR STICKY POST
?>
<div id="fcg"><?php include (ABSPATH . '/wp-content/plugins/featured-content-gallery/gallery.php'); ?></div>
<!--END LEAD/STICKY POST-->
<div id="more-posts">
<h3><?php _e('Recent Posts','Mimbo'); ?></h3>
<?php
}
if( $postcount > 0 && $postcount <= 4 ) {
//GETS NEXT FOUR EXCERPTS
?>
<div class="clearfloat recent-excerpts">
<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>">
<?php echo get_post_image (get_the_id(), '', '', '' .get_bloginfo('template_url') .'/scripts/timthumb.php?zc=1&w=105&h=85&src='); ?></a>
<h4><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a> <span class="commentcount">(<?php comments_popup_link('0', '1', '%'); ?>)</span></h4>
<p class="date"><?php the_time('n/d/y'); ?> • </p>
<?php the_excerpt(); ?>
</div>
<?php //GETS NEXT HEADLINES
}
else {
ob_start();
echo '<li><a href="';
the_permalink();
echo '">';
the_title();
echo '</a></li>';
$links[] = ob_get_contents();
ob_end_clean();
}
$postcount ++;
}
}
else {
?>
<?php } ?>
<?php
if(count($links)): ?>
<h3><?php _e('Older Posts','Mimbo'); ?></h3>
<ul class="headlines"><?php echo join("\n", $links); ?></ul>
<?php endif; ?>
</div><!--END RECENT/OLDER POSTS-->
<div id="featured-cats">
<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Mimbo Sidebar 2') ) : ?><?php endif; ?>
</div>
</div><!--END CONTENT-->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
Thanks.
]]>I’m also using this snippet of code to call a CSS class when the the 3rd column has a post:
<? if ( $postcount%3 == 0 ) { echo ' last'; } ?>
Obviously I need to include a postcount in the loop to get this to work and at the moment the code above does not know when to call the .last style.
Please could some one give me a hand with this.
Thank you very much.
P.S. This is the code from the page I’m working on:
<?php get_header(); ?>
<div id="work_wrap">
<h2 class="headers">Recent work </h2>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div id="work">
<div class="work_item<? if ( $postcount%3 == 0 ) { echo ' last'; } ?>">
<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php echo get_post_image (get_the_id(), '', '', '' .get_bloginfo('template_url') .'/scripts/timthumb.php?zc=1&w=300&h=177&src='); ?></a>
<p><?php foreach((get_the_category()) as $category) { echo $category->cat_name . ''; } ?>: <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
</div><!--END WORK ITEM CLASS-->
</div>
<?php endwhile; ?>
<?php include (TEMPLATEPATH . '/pagination.php'); ?>
<?php else : ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
</div><!--END WORK_WRAP WRAPPER-->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
]]>I am currently developing an events blog. i am able to display events based on dates. i have three nav tabs–> now running, future, expired. i want to display the number of posts in the tab itself (inspired by killerstartups.com). i am using expiration as custom field for setting expiration date. i tried to use this code in header.php
]]>`<?php query_posts(get_post_custom_values(‘expiration’)); ?>
<?php while (have_posts()) : the_post(); ?><?php
$currentdate = Date(“Ymd”);
$expirationdate = get_post_custom_values(‘expiration’);if (is_array($expirationdate)) {
$expirestringarray = implode($expirationdate);
}
$expirestring = str_replace(“/”,””,$expirestringarray);if ( $expirestring > $currentdate ) {
$count_posts = wp_count_posts();
}
endwhile;
echo “Now Running ( $count_posts )”;
?>
Just a quick question. On my frontpage, there is a short archive ‘list’, with postcounts after every month. It looks like this:
may (34)
april (41)
march (33)
The code for this is:
<ul>
<?php wp_get_archives('type=monthly&show_post_count=1'); ?>
</ul>
My question: Is it possible to count all the posts, EXCEPT the ones in 1 specific category? The reason for this is that I am excluding the posts in this category on my front page (and archive page) too.
Thanks in advance!
]]>