misterm2015
Forum Replies Created
-
Forum: Plugins
In reply to: [Custom Permalinks] lastest update now crashing sitesDamn, same here. How do I downgrade to 0.7.21 ?
Thanks
D
Forum: Hacks
In reply to: Masonry posts duplicating when hiding postsHmmm, I undid what I did above, as it was pretty pointless.
I tried to display how many posts were being displayed using count($posts), which always came out as 10, which is what I set in the reading prefs.
The theme generated the first 10 posts in the index.php file, while the following posts loaded are generated in the functions file. Is this normal?
index
<?php global $more; $more = 0; ?> <?php if (have_posts()) : while ( have_posts() ) : the_post(); ?> <div class="masonr"> <div <?php post_class('post'); ?>> <!-- uses the post format --> <?php if(!get_post_format()) { get_template_part('format', 'standard-small'); } else { $format = get_post_format(); if ($format == 'image') {get_template_part('format', 'image-small');} else if ($format == 'gallery') {get_template_part('format', 'gallery-small');} else {get_template_part('format', $format);} } ?> </div><!-- post--> </div> <?php endwhile; ?>
functions
//----------------------------------- // Load More AJAX Call //----------------------------------- // if(!function_exists('cr_load_more')){ add_action('wp_ajax_cr_load_more', 'cr_load_more'); add_action('wp_ajax_nopriv_cr_load_more', 'cr_load_more'); function cr_load_more(){ if(!wp_verify_nonce($_POST['nonce'], 'cr_ajax')) die('Invalid nonce'); if( !is_numeric($_POST['page']) || $_POST['page']<0 ) die('Invalid page'); $args = ''; if(isset($_POST['archive']) && $_POST['archive']){ $args = $_POST['archive'] .'&'; } $args .= 'post_status=publish&posts_per_page='. get_option('posts_per_page') .'&paged='. $_POST['page']; if(isset($_POST['archive']) && $_POST['archive'] && strlen(strstr($_POST['archive'],'post-format'))>0){ $args = array( 'post_status' => 'publish', 'tax_query' => array( array( 'taxonomy' => 'post_format', 'field' => 'slug', 'terms' => $_POST['archive'] ) ), 'posts_per_page' => get_option('posts_per_page'), 'paged' => $_POST['page'] ); } ob_start(); $query = new WP_Query($args); while( $query->have_posts() ){ $query->the_post(); ?> <div class="masonr"> <div <?php post_class('post'); ?>> <?php if(!get_post_format()) { get_template_part('format', 'standard-small'); } else { $format = get_post_format(); if ($format == 'image') {get_template_part('format', 'image-small');} else if ($format == 'gallery') {get_template_part('format', 'gallery-small');} else {get_template_part('format', $format);} } ?> </div><!-- post--> </div> <?php } wp_reset_postdata(); $content = ob_get_contents(); ob_end_clean(); echo json_encode( array( 'pages' => $query->max_num_pages, 'content' => $content ) ); exit; } } ?>
Forum: Hacks
In reply to: Masonry posts duplicating when hiding postsThanks for the reply bcworkz
I did try using pre_get_posts just after posting this, but found myself going down the wrong track, excluding the post ID, which didn’t work, but did work with the cat ID, thinking I could add the excluded posts to their own additional category, then exclude that, but still produced duplicates.
add_action( 'pre_get_posts', 'rc_modify_query_exclude_category' ); function rc_modify_query_exclude_category( $query ) { if ( ! is_admin() && $query->is_main_query() && ! $query->get( 'cat' ) ) { $query->set( 'cat', '-49' ); } }
So, I’ve managed to exclude without the plugin, but still in the same position of not knowing how to handle the post counts :/
I guess the added complication is that each new set of posts displayed will have different numbers of posts hidden. :/
I’ve seen multiple loops used, but my PHP is only very slight, so is all above my head.
Forum: Themes and Templates
In reply to: [Fukasawa] Infinite Scroll not workingWhat a shame, such a great theme. When I scroll down with infinite scroll enabled on my site, I see a large blank space at the bottom of the screen. The page also jumps up and down as in petrchutny.cz too.