alexdbd
Forum Replies Created
-
I’m having the same issue.
The topic can be marked as, and now is marked as, resolved, yes.
The
functions.php
andpost-loop.php
code looks fine to me, but since the code of your current and olderindex.php
seems like far less, and ordered differently than I’ve seen before, I can’t be 100% certain that I know what code should be in yourpost-loop.php
andindex.php
… It feels to me like theindex.php
should have more than it does, and that it has more code about displaying posts than I’m used to seeing. So maybe revert it to where it works and experiment with different sets of code in thepost-loop.php
. As reference, my files are these:index.php:
<!DOCTYPE html> <?php // get the header and start the <body> from header.php get_header(); ?> <div id="masthead"> <table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td> <div class='pagegroup'><a href="<?php // get theme options from the database $family2010options = get_option( 'family2010_options' ); // include the alternate group url if present if ($family2010options['groupurl']) { echo $family2010options['groupurl']; } else { echo get_option('home'); } ?>/" ><?php // include the alternate group text if present if ($family2010options['groupname']) { echo $family2010options['groupname']; } else { bloginfo('description'); } ?></a></div> <div class='pagetitle'><a href="<?php echo get_option('home'); ?>/" ><?php bloginfo('name'); ?></a></div> </td></tr></table> </div> <! Start sidebar --> <?php // load the sidebar from sidebar.php get_sidebar(); ?> <!-- end sidebar --> <! Start main page content --> <div id="wikitext" role="main"> <?php if (! is_single()) : ?> <?php if ( is_404() || is_category() || is_day() || is_month() || is_year() || is_search() || is_paged() ) { ?> <?php /* If this is a 404 page */ if (is_404()) { ?> <?php /* If this is a category archive */ } elseif (is_category()) { ?> <h2><?php single_cat_title(''); ?> category</h2> <?php /* If this is a yearly archive */ } elseif (is_day()) { ?> <h2><?php the_time('l, j F Y'); ?> archives</h2> <?php /* If this is a monthly archive */ } elseif (is_month()) { ?> <h2><?php the_time('F Y'); ?> archives</h2> <?php /* If this is a yearly archive */ } elseif (is_year()) { ?> <h2><?php the_time('Y'); ?> archives</h2> <?php /* If this is a search archive */ } elseif (is_search()) { ?> <h2>Search for '<?php the_search_query(); ?>'</h2> <?php } ?> <?php } ?> <?php endif; // is_single ?> <?php if (is_search()) : ?> <p><form method="get" id="searchform" action="<?php bloginfo('url'); ?>/"> <div><input type="text" value="<?php the_search_query(); ?>" name="s" id="s" /> <input type="submit" id="searchsubmit" value="Search" /> </div> </form><br /></p> <?php endif; ?> <?php if (have_posts()) : // loop to get posts from the database and display them get_template_part( 'post-loop' ); ?> <! Show navigation buttons only if infinite scroll itself deactivated--> <?php wp_link_pages(); ?> <?php else : ?> <h2 class="center">Not Found</h2> <p class="center">Sorry, but you are looking for something that isn't here.</p> <?php $efcDoSearch = TRUE; ?> <?php endif; ?> <?php if (is_page('search') || $efcDoSearch) : ?> <form method="get" id="searchform" action="<?php bloginfo('url'); ?>/"> <div><input type="text" value="<?php the_search_query(); ?>" name="s" id="s" /> <input type="submit" id="searchsubmit" value="Search" /> </div> </form> <?php endif; ?> <!--PageText--> <!--PageRightFmt--> </div> <!-- end wikitext --> <?php // get the page footer and end the <body> from footer.php get_footer(); ?>
post-loop.php:
<?php while (have_posts()) : the_post(); ?> <div class="post" id="post-<?php the_ID(); ?>"> <?php if (is_page()) : ?> <h2><?php the_title(); ?></h2> <?php else : ?> <p style="margin-bottom:-5px;"><small> <?php if ( is_home() || is_page() ) { the_time('j F'); } else { the_time('j F Y'); } ?> <?php if (! is_single()) : ?> . <?php comments_popup_link('Reply', '1 Reply', '% Replies'); ?> <?php edit_post_link('Edit', ' . ', ''); ?> <?php endif; ?> </small></p> <h2 style="margin-top:0px;"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2> <?php endif; ?> <div class="entry"> <?php the_content('Read the rest of this entry ?'); ?> </div> <?php if (is_single()) : ?> <div id="postmeta"> <p> <?php global $user_level; get_currentuserinfo(); if ($user_level > 2) { echo '<a class="noprint" href="'; echo (get_edit_post_link($post->ID)); echo '" accesskey="e">Edit this entry.</a>'; } ?> Posted on <?php echo get_the_time('l, j F Y', $post->ID); ?> at <?php echo get_the_time('', $post->ID); ?> and filed under <?php the_category(', ', '', $post->ID) ?>. </p> </div> <?php comments_template(); ?> <?php endif; ?> </div> <?php endwhile; ?>
And relevant parts of functions.php:
add_theme_support( 'infinite-scroll', array( 'container' => 'wikitext', 'render' => 'infinite_scroll_render', 'footer' => 'footer', 'wrapper' => false ) ); function infinite_scroll_render() { get_template_part( 'post-loop' ); // this is the same file that we use in index.php to render the posts initially visible }
This index.php is quite different from what my theme started out with, but I think the code you want is this:
<?php if (have_posts()) : while (have_posts()) : the_post(); update_post_caches($posts); ?> <div class="post" id="post-<?php the_ID(); ?>"> <h2>" rel="bookmark"><?php the_title(); ?></h2> <div class="info"> <span class="date"><?php the_time(__('F jS, Y', 'inove')) ?></span> <?php if ($options['author']) : ?><span class="author"><?php the_author_posts_link(); ?></span> <?php endif; ?> <?php edit_post_link(__('Edit', 'inove'), '<span class="editpost">', '</span>'); ?> <span class="comments"><?php comments_popup_link(__('No comments', 'inove'), __('1 comment', 'inove'), __('% comments', 'inove'), '', __('Comments off', 'inove')); ?></span> <div class="fixed"></div> </div> <div class="content"> <?php the_content(__('Weiterlesen...', 'inove')); ?> <div class="fixed"></div> </div> </div> <?php endwhile; else : ?>
But really I think that you need to split the
<?php endwhile; else : ?>
into<?php end while;?>
that is in thepost-loop.php
and<?php else : ?>
that is just below the code you move topost-loop.php
(remember that you should useget_template_part( 'post-loop' );
in place of the whole chunk of code you move topost-loop.php
).That looks exactly like the same thing I ran into on my blog before it all settled down and worked right, so definitely try my suggested fix above.
As far as I know Jetpack Stats are managed by WordPress.com, so wherever the data is stored it isn’t in the blog’s database or anywhere on your site. You can get to site stats on WordPress.com at https://wordpress.com/#!/my-stats/, so that is where a download option is likely to be if it will be anywhere, but I can’t find one there myself. It would be nice if they provided a way to export the data, but it appears that they don’t.
Did you disable infinite scroll, because the site doesn’t seem to use it right now?
Anyway, I think your problem is in the
'render' => false,
line. One thing to try that may fix your problem would be to create a file, call itpost-loop.php
, that contains the loop to grab posts. This file should have its contents copied fromindex.php
where the loop should be right now (and in fact you can then replace that part ofindex.php
withget_template_part( 'post-loop' );
) and start with the line<?php while (have_posts()) : the_post(); ?>
while ending with the line<?php endwhile; ?>
. Your adding of infinite scroll support would contain'infinite_scroll_render',
where you currently havefalse
as therender
value. That refers to a new function you’d add to thefunctions.php
(where the add support code is anyways) that is the following:function infinite_scroll_render() { get_template_part( 'post-loop' ); }
See if that helps with the problem you’re seeing.
Thanks, that fixed the issue of not returning to the home page. But I find that only about less than 1/3 of the time, when you go to posts on the first infinite load, that the browser returns the scroll position to where you were before going to the post’s page. So I’d still like it if you (or anyone else) had any ideas of how to get the site to automatically return the scroll posit to where the visitor was before loading a post. This is a low priority issue, what you already helped me fix was the big issue here, but one that I’d love to see working someday if possible.
Hmm. I’m at a loss for further ideas, then… There may be some other system (or plugin) that overwrites the theme support that is hiding the Gravatars, but I don’t know what that would be. You could test with another theme and if the Gravatars don’t show up there then it isn’t theme code that is the problem. If they do show up then you at least know the theme code is blocking Gravatars, but after all you just tried with my suggestions I don’t know what would be blocking it. Sorry I can’t be of more help.
See if pasting this code works for
functions.php
: https://pastebin.com/QRdVGT3W. This combines your pastebin contents of the file with my function.So try my suggestion just above, revert to your working
functions.php
and then paste the code from my first post here just below the<?php
line. This is seemingly more complicated than it should be to get this to work…Make sure the code you paste is not between existing functions, perhaps by putting it just below the
<?php
line. This may fix your issue as well.I think around line 205 is code that you didn’t just paste in, or at least based on the old pastebin that is the case. As you should know if you are maintaining a custom theme, the
}
characters are ending if statements, loops, or functions, so perhaps all you need to do is delete one of them from line 205?Okay, so maybe it is good to show you the whole of my site’s (https://alex.clst.org/dbd)
comments.php
as an example of how that file should be put together:<?php // Do not delete these lines if ('comments.php' == basename($_SERVER['SCRIPT_FILENAME'])) die ('Please do not load this page directly. Thanks!'); if (!empty($post->post_password)) { // if there's a password if ($_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password) { // and it doesn't match the cookie ?> <p class="nocomments">This post is password protected. Enter the password to view replies.</p> <?php return; } } ?> <!-- You can start editing here. --> <?php if ($comments) : ?> <br /><h3 id="comments"><?php comments_number('No Replies', 'One Reply', '% Replies' );?> to “<?php the_title(); ?>”</h3> <?php wp_list_comments('type=comment&callback=comment_callback'); // replaces older code to use the Gravatar-supported comment display of WordPress 3.x+ ?> <?php else : // this is displayed if there are no comments so far ?> <?php if ('open' == $post->comment_status) : ?> <!-- If comments are open, but there are no comments. --> <?php else : // comments are closed ?> <!-- If comments are closed. --> <p class="nocomments">Replies are closed.</p> <?php endif; ?> <?php endif; ?> <div class="noprint"> <?php if ('open' == $post->comment_status) : ?> <?php if ( get_option('comment_registration') && !$user_ID ) : ?> <p>You must be <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?redirect_to=<?php echo urlencode(get_permalink()); ?>">logged in</a> to post a reply.</p> <?php else : ?> </br> <?php comment_form(); // Replaces old <form> block to support Jetpack comment form ?> <?php endif; // If registration required and not logged in ?> <?php endif; // if you delete this the sky will fall on your head ?> </div>
My theme is likewise based on TwentyTen. The code I put in an earlier post here of mine should go just in the
functions.php
. You can modify thestyle
attributes of parts of the comment_callback to your liking. See if this works, it will be faster than me reading your site’s code, and as both are based on TwentyTen nothing terrible should come of you pasting wholesale my site’s code.Yes, but aren’t you using the TwentyTen theme? Because you really shouldn’t manually edit any themes that are not custom themes you develop. So I’d be hesitant to suggest you make any modifications to the theme as I originally suggested.