henballs
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: Hostname / FTP server for when installing a WordPress PluginThanks!
Got it, thanks for all your help ya’ll!
Use
is_paged()
and notis_page()
Thanks, but now I just get one post per every page (home & page) after making those changes.
function limit_posts_per_page() { if ( is_front_page() || is_home() ) return 'LIMIT 0, 10'; } add_filter('pre_option_posts_per_page', 'limit_posts_per_page');
The
The settings -> reading -> posts per page
is now blank.Hmmmmmmm
My mind is boggled. The first filter
limit_posts_per_page
with the if statement I tried works. But only for is_home() or is_page(). Not both. Whyyy? ??I still get 4 posts on every single page after removing that filter and adding the one you suggested.
The
settings -> reading -> posts per page -> 4
is still there.This filter doesn’t seem to work.
Yeah I just checked the setting and it says 4.
I just tried that, the subsequent pages are also returning 10 (and not 4). Still doesn’t work.
function limit_posts_per_page() { if ( is_front_page() ) return 10; else return 4; } add_filter('pre_option_posts_per_page', 'limit_posts_per_page');
I don’t get it because is_front_page() == is_page() returns false…
Hmm those seem to not work.
I get the desired effects when I do these two if statements.
if ( is_home() ) return 10;
returns 10 posts on home page (and every other page)
then..
if ( is_page() ) return 4;
returns 4 pages on a page (and on the home page)
So if I combine the two, it should solve my problem. But it doesn’t. This if statement only does one or the either:
if ( is_home() ) return 10; else return 4;
*sadface*
in my functions.php :
function limit_posts_per_page() { if ( is_home() ) // works return 10; elseif ( is_page() ) // not working?? return 3; else return undefined; } add_filter('pre_option_posts_per_page', 'limit_posts_per_page');
Still all pages return 10 posts.
Now if I did the following, my pages would have 4 posts! which is what I want. So why won’t my original if statement work as I intend?
if ( is_page() ) {
return 4;
}Shoot, there’s another problem
return 5; // default: 5 posts per page
isn’t working. All my pages now return 10 posts.Trying to debug it now.
functions.php looks like
<?php add_theme_support( 'post-thumbnails' ); ?> <?php function new_excerpt_more($more) { global $post; return '<br><a class="moretag" href="'. get_permalink($post->ID) . '"> Read more...</a>'; } add_filter('excerpt_more', 'new_excerpt_more'); function custom_excerpt_length( $length ) { return 20; } add_filter( 'excerpt_length', 'custom_excerpt_length', 999 ); function limit_posts_per_page() { if ( is_home() ) return 7; else return 3; // default: 3 posts per page } add_filter('pre_option_posts_per_page', 'limit_posts_per_page'); ?>
Hi Triptripper thanks so much for the help and the link.
Forum: Fixing WordPress
In reply to: Which file is used to edit HTML of next_posts_link page?Is there any way to edit / add html to subsequent older “pages”
I can edit their CSS by targeting
.paged
in my main style sheet. But how do I edit the HTML?Forum: Themes and Templates
In reply to: Why is the opening tag body and div included in the header.php?Thanks Andrew.
Forum: Fixing WordPress
In reply to: Next_and_Previous_Links lead to blank page.Hey it worked thanks so much for the help!
Forum: Fixing WordPress
In reply to: Next_and_Previous_Links lead to blank page.Sorry there’s actually not an infinite loop. The problem is it seems that the get_next_post() at the end is not appearing.
<?php get_header(); ?> <!-- start of loop --> <?php while ( have_posts() ) : the_post(); ?> <!-- first three posts on the first page --> <?php if ( !is_paged() && ( $wp_query->current_post <= 2 ) ) : ?> <?php if ( $wp_query->current_post == 0 ) : ?> <div class="first_three_container"> <?php endif; ?> <!-- do stuff for first three posts --> <div class="post" <?php post_class() ?>> <?php the_post_thumbnail( array(280,280) ); ?> <h2> <a href="<?php the_permalink() ?>"> <?php the_title(); ?> </a> </h2> <?php the_excerpt(); ?> </div> <?php if ( $wp_query->current_post == 2 ) : ?> </div> <!-- end first_three_container --> <?php endif; ?> <?php else : ?> <!-- do stuff for the rest of the posts --> <div id="blog-posts" <?php post_class() ?>> <?php the_post_thumbnail( array(180,180) ); ?> <h2> <a href="<?php the_permalink() ?>"> <?php the_title(); ?> </a> </h2> <?php the_excerpt(); ?> <span class="entry-date"><?php echo get_the_date(); ?></span> </div> <?php endif; ?> <?php endwhile; ?> <?php echo get_next_posts_link('Go to next page'); ?>