auto load posts in single.php - wordpress

i'm trying to auto load all my post in single.php i have tried several plugins but neither works
what's might be the problem i have also tried several nav-menu but i can't find what the problem is
i have the same problem in this question
https://wordpress.stackexchange.com/questions/102604/enable-infinite-scroll-on-single-php
this is my single page
<?php
/**
* The template for displaying all single posts
*
* #link https://developer.wordpress.org/themes/basics/template-hierarchy/#single-post
*
* #package NewsCard
*/
get_header();
newscard_layout_primary(); ?>
<main id="main" class="site-main">
<?php
while ( have_posts() ) :
the_post();
get_template_part( 'template-parts/content', get_post_type() );
the_post_navigation();
// If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() ) :
comments_template();
endif;
endwhile; // End of the loop.
?>
</main><!-- #main -->
</div><!-- #primary -->
<?php
do_action('newscard_sidebar');
if ( $newscard_settings['newscard_footer_featured_posts_hide'] === 0 ) {
$footer_newscard_cat = absint($newscard_settings['newscard_footer_featured_post_categories']);
$footer_post_type = array(
'posts_per_page' => 4,
'post__not_in' => get_option('sticky_posts'),
'post_type' => array(
'post'
),
);
if ( $newscard_settings['newscard_footer_featured_latest_post'] == 'category' ) {
$footer_post_type['category__in'] = $footer_newscard_cat;
}
$footer_newscard_get_featured_post = new WP_Query($footer_post_type); ?>
<div class="container">
<section class="featured-stories">
<h2 class="stories-title"><?php echo esc_html($newscard_settings['newscard_footer_featured_posts_title']); ?></h2>
<div class="row gutter-parent-14">
<?php while ($footer_newscard_get_featured_post->have_posts()) {
$footer_newscard_get_featured_post->the_post(); ?>
<div class="col-sm-6 col-lg-3">
<div class="post-boxed">
<?php if ( has_post_thumbnail() ) { ?>
<div class="post-img-wrap">
<div class="featured-post-img">
</div>
<div class="entry-meta category-meta">
<div class="cat-links"><?php the_category(' '); ?></div>
</div><!-- .entry-meta -->
</div><!-- .post-img-wrap -->
<?php } ?>
<div class="post-content">
<?php if ( !has_post_thumbnail() ) { ?>
<div class="entry-meta category-meta">
<div class="cat-links"><?php the_category(' '); ?></div>
</div><!-- .entry-meta -->
<?php } ?>
<?php the_title( '<h3 class="entry-title">', '</h3>' ); ?>
<?php if ( 'post' === get_post_type() ) { ?>
<div class="entry-meta">
<?php newscard_posted_on(); ?>
</div>
<?php } ?>
</div><!-- .post-content -->
</div><!-- .post-boxed -->
</div><!-- .col-sm-6 .col-lg-3 -->
<?php }
// Reset Post Data
wp_reset_postdata(); ?>
</div><!-- .row -->
</section><!-- .featured-stories -->
</div><!-- .container -->
<?php }
get_footer();
?>

Related

How can i increase number of post on each row in wordpress col-6 module-content grid

i am working on a wordpress news theme. On that theme there is sidebar with "col-3"and "col-6 module-content" for news thumb. Now its showing 2 thumb on each row. I want to show 3 thumb on each row. How can i do so? bellow the content.php file of the theme.
<?php
/**
* Template part for displaying posts
*
* #link https://codex.wordpress.org/Template_Hierarchy
*
* #package Online_News
*/
?>
<div class="col-6 module-content">
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php if( is_sticky() ){ ?>
<div class="favourite"><i class="fa fa-star"></i></div>
<?php } ?>
<?php if(has_post_thumbnail()):?>
<div class="list-img">
<?php the_post_thumbnail('online-news-feature-thumb');?>
</div>
<?php endif;?>
<div class="news-content">
<?php if ( 'post' === get_post_type() ) : ?>
<div class="entry-meta">
<?php $disable_post_meta = online_news_get_option('disable_postmeta');
if('false'== !$disable_post_meta): ?>
<?php online_news_posted_on();?>
<?php endif;?>
<?php $disable_categories = online_news_get_option('disable_categories');
if('false'== !$disable_categories): ?>
<div class="category-link">
<?php online_news_category();?>
</div>
<?php endif;?>
</div><!-- .entry-meta -->
<?php endif; ?>
<header class="entry-header">
<?php
if ( is_single() ) :
the_title( '<h1 class="entry-title">', '</h1>' );
else :
the_title( '<h3 class="entry-title">', '</h3>' );
endif;
?>
</header><!-- .entry-header -->
<div class="entry-content">
<?php the_excerpt();?>
<?php $readmore_text = online_news_get_option('readmore_text'); ?>
<a class="more-link" href="<?php the_permalink();?>"><?php echo esc_html($readmore_text);?></a>
</div><!-- .entry-content -->
</div>
</article><!-- #post-## -->
</div>
You can simply change the div class from col-6 into col-4.
<div class="col-4 module-content">
Cheers!

ACF Pagination not working when the_content is present

I have this custom template in Wordpress which includes a script that paginates ACF fields. Here is the source code:
<?php get_header(); ?>
<div class="container">
<div class="row">
<div class="col-xs-12">
<h1 class="pagetitle"><?php the_title(); ?></h1>
</div> <!-- col -->
</div> <!-- row -->
</div> <!-- container -->
<?php
if( get_query_var('page') ) {
$page = get_query_var( 'page' );
} else {
$page = 1;
}
$row = 0;
$files_per_page = 30; // How many images to display on each page
$files = get_field( 'fisier' );
$total = count( $files );
$pages = ceil( $total / $files_per_page );
$min = ( ( $page * $files_per_page ) - $files_per_page ) + 1;
$max = ( $min + $files_per_page ) - 1;
?>
<div class="container">
<div class="row">
<div class="col-md-8">
<section id="content">
<div class="wrapper">
<?php while ( have_posts() ) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; ?>
<?php if( have_rows('fisier') ): ?>
<div class="article-files">
<h4>Files</h4>
<div class="row">
<?php while ( have_rows('fisier') ) : the_row();
$row++;
if($row < $min) { continue; }
if($row > $max) { break; }
?>
<div class="col-xs-12 file">
<?php $x = 0; ?>
<?php $file = get_sub_field('link'); if( $file ): ?>
<i class="fa fa-angle-right" aria-hidden="true"></i> <?php the_sub_field('nume_fisier'); ?>
<div class="file-description"><?php the_sub_field('descriere'); ?></div>
<?php $x = 1; ?>
<?php endif; ?>
<?php $file = get_sub_field('fisier_intern'); if( $file ): ?>
<i class="fa fa-angle-right" aria-hidden="true"></i> <?php the_sub_field('nume_fisier'); ?>
<div class="file-description"><?php the_sub_field('descriere'); ?></div>
<?php $x = 1; ?>
<?php endif; ?>
<?php if( $x == 0 ): ?>
<i class="fa fa-angle-right" aria-hidden="true"></i> <?php the_sub_field('nume_fisier'); ?>
<div class="file-description"><?php the_sub_field('descriere'); ?></div>
<?php $x = 1; ?>
<?php endif; ?>
</div>
<?php endwhile; ?>
</div>
<div class="file-pagination">
<?php
echo paginate_links( array(
'base' => get_permalink() . '%#%' . '/',
'format' => '?page=%#%',
'current' => $page,
'show_all' => false,
'prev_text' => __('«'),
'next_text' => __('»'),
'total' => $pages
));
?>
</div> <!-- file-pagination -->
</div>
<?php endif; ?>
</div> <!-- wrapper -->
</section> <!-- content -->
</div> <!-- col -->
<div class="col-md-4">
<aside id="sidebar">
<?php get_sidebar(); ?>
</aside> <!-- aside -->
</div> <!-- col -->
</div> <!-- row -->
</div> <!-- container -->
<?php get_footer(); ?>
The code above doesn't display the pagination links but if I remove this part:
<?php while ( have_posts() ) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; ?>
Everything works perfectly. Any idea about how I can fix this?
Thanks
Solved the problem! I had to move the pagination settings after the_content() as shown below:
<?php get_header(); ?>
<div class="container">
<div class="row">
<div class="col-xs-12">
<h1 class="pagetitle"><?php the_title(); ?></h1>
</div> <!-- col -->
</div> <!-- row -->
</div> <!-- container -->
<div class="container">
<div class="row">
<div class="col-md-8">
<section id="content">
<div class="wrapper">
<?php while ( have_posts() ) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; ?>
<?php
if( get_query_var('page') ) {
$page = get_query_var( 'page' );
} else {
$page = 1;
}
$row = 0;
$files_per_page = 30; // How many images to display on each page
$files = get_field( 'fisier' );
$total = count( $files );
$pages = ceil( $total / $files_per_page );
$min = ( ( $page * $files_per_page ) - $files_per_page ) + 1;
$max = ( $min + $files_per_page ) - 1;
?>
<?php if( have_rows('fisier') ): ?>
<div class="article-files">
<h4>Files</h4>
<div class="row">
<?php while ( have_rows('fisier') ) : the_row();
$row++;
if($row < $min) { continue; }
if($row > $max) { break; }
?>
<div class="col-xs-12 file">
<?php $x = 0; ?>
<?php $file = get_sub_field('link'); if( $file ): ?>
<i class="fa fa-angle-right" aria-hidden="true"></i> <?php the_sub_field('nume_fisier'); ?>
<div class="file-description"><?php the_sub_field('descriere'); ?></div>
<?php $x = 1; ?>
<?php endif; ?>
<?php $file = get_sub_field('fisier_intern'); if( $file ): ?>
<i class="fa fa-angle-right" aria-hidden="true"></i> <?php the_sub_field('nume_fisier'); ?>
<div class="file-description"><?php the_sub_field('descriere'); ?></div>
<?php $x = 1; ?>
<?php endif; ?>
<?php if( $x == 0 ): ?>
<i class="fa fa-angle-right" aria-hidden="true"></i> <?php the_sub_field('nume_fisier'); ?>
<div class="file-description"><?php the_sub_field('descriere'); ?></div>
<?php $x = 1; ?>
<?php endif; ?>
</div>
<?php endwhile; ?>
</div>
<div class="file-pagination">
<?php
echo paginate_links( array(
'base' => get_permalink() . '%#%' . '/',
'format' => '?page=%#%',
'current' => $page,
'show_all' => false,
'prev_text' => __('«'),
'next_text' => __('»'),
'total' => $pages
));
?>
</div> <!-- file-pagination -->
</div>
<?php endif; ?>
</div> <!-- wrapper -->
</section> <!-- content -->
</div> <!-- col -->
<div class="col-md-4">
<aside id="sidebar">
<?php get_sidebar(); ?>
</aside> <!-- aside -->
</div> <!-- col -->
</div> <!-- row -->
</div> <!-- container -->
<?php get_footer(); ?>

Wordpress Pagination

I have a wordpress site : There is a problem with the pagination.. When I click on 2'nd page it shows up the first one(index page). The other pages are working. Can you help me?
I looked up for errors in the loop but i didn't found anything!
this my index.php code
<?php get_header(); ?>
<div id="content">
<?php if(get_option('freshlife_featured_content_enable') == 'on') { ?>
<div id="featured-content">
<div class="heading">
<span class="heading-text"><?php _e('Featured Articles', 'themejunkie'); ?></span>
</div> <!-- end .heading -->
<ul>
<?php
$counter = 1;
query_posts( array(
'showposts' => get_option('freshlife_featured_post_num'),
'tag' => get_option('freshlife_featured_post_tags')
) );
if( have_posts() ) : while( have_posts() ) : the_post();
?>
<li class="featured-<?php echo $counter; ?>"><?php the_post_thumbnail('featured-thumb', array('class' => 'entry-thumb')); ?><span class="entry-date"><abbr title="<?php the_time('F j, Y'); ?> at <?php the_time('g:i a'); ?>"><?php echo human_time_diff(get_the_time('U'), current_time('timestamp')) . __(' ago', 'themejunkie'); ?></abbr></span><h2 class="entry-title"><?php the_title(); ?></h2></li>
<?php $counter++; endwhile; endif; wp_reset_query(); ?>
</ul>
</div> <!-- end #featured-content -->
<?php } ?>
<div class="heading">
<span class="heading-text"><?php _e('All Stories', 'themejunkie'); ?></span>
</div> <!-- end .heading -->
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php include(TEMPLATEPATH. '/includes/templates/loop.php'); ?>
<?php endwhile; ?>
<div class="clear"></div>
<?php if (function_exists('wp_pagenavi')) wp_pagenavi(); else { ?>
<div class="pagination">
<div class="left"><?php previous_posts_link(__('Newer Entries', 'themejunkie')) ?></div>
<div class="right"><?php next_posts_link(__('Older Entries', 'themejunkie')) ?></div>
<div class="clear"></div>
</div> <!-- end .pagination -->
<?php } ?>
<?php else : ?>
<?php endif; ?>
</div> <!-- end #content -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
It's hard to say without looking at the WP_Query generated by the requests.
But I do see something that might be causing problems, query_posts alters the main query, that could be messing with the pagination.
Try to use get_posts instead query_posts, so the main loop is not affected.
A more detailed explanation can be found here

Wordpress category template is showing posts from all categories instead of specific category posts

I have an archive page that's set up to display category specific posts. However, instead of showing only the posts from a given category on the category page, it's showing all posts. For an example, see here.
Here's the code I'm using on my archive.php page. I know it's improper use of the loop, but I'm not sure how to fix it. Thanks for the help.
<?php get_header(); ?>
<div id="content">
<div id="inner-content" class="wrap clearfix">
<h1 class="blogTitle" style="margin:10px 0 3px 0;">Blog Title</h1>
<nav class="blogNav" role="navigation">
<?php bones_blog_nav(); // Adjust using Menus in Wordpress Admin ?>
</nav>
<div id="main" class="eightcol first clearfix" role="main">
<div class="catwhiteBg">
<?php if (is_category()) { ?>
<h1 class="catTitle">
<span><?php _e("", "bonestheme"); ?></span> <?php single_cat_title(); ?>
</h1>
<?php echo category_description( $category_id ); ?>
<?php } elseif (is_author()) { ?>
<div class="authorTop">
<?php
$curauth = (get_query_var('author_name')) ? get_user_by('slug', get_query_var('author_name')) : get_userdata(get_query_var('author'));
?>
<div class="author-pic"><?php echo get_avatar( $curauth->user_email, '80' ); ?></div>
<div class="author-name"><span style="font-weight: 200; color: #575757;">POSTS BY:</span>
<?php echo $curauth->first_name; ?> <?php echo $curauth->last_name; ?>
</div>
<div class="author-bio"><?php echo $curauth->description; ?></div>
<div class="author-twitter"><span>twitter</span></div>
</div>
<?php } elseif (is_day()) { ?>
<h1 class="archive-title h2">
<span><?php _e("Daily Archives:", "bonestheme"); ?></span> <?php the_time('l, F j, Y'); ?>
</h1>
<?php } elseif (is_month()) { ?>
<h1 class="archive-title h2">
<span><?php _e("Monthly Archives:", "bonestheme"); ?></span> <?php the_time('F Y'); ?>
</h1>
<?php } elseif (is_year()) { ?>
<h1 class="archive-title h2">
<span><?php _e("Yearly Archives:", "bonestheme"); ?></span> <?php the_time('Y'); ?>
</h1>
<?php } ?>
</div>
<div class="psts">
<?php
global $wp_query;
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
if ( get_query_var('paged') ) {
$paged = get_query_var('paged');
} elseif ( get_query_var('page') ) {
$paged = get_query_var('page');
} else {
$paged = 1;
}
query_posts(array('posts_per_page' => '8','paged'=>$paged));
?>
<?php
$count = 1;
while (have_posts()) : the_post(); ?>
<div class="sixcol small pst<?php if ((isset($count)) && ($count % 2 == 0 )) { echo ' last';} // same logic to add class of last to last item in row of two ?>" id="post-<?php the_ID(); ?>">
<article id="post-<?php the_ID(); ?>" role="article">
<div class="thumb-wrapper mobile">
<?php if(has_post_thumbnail()) { $image_src = wp_get_attachment_image_src( get_post_thumbnail_id(),'post-thumb' ); echo '<img src="' . $image_src[0] . '" width="100%" class="post-thumb" />'; } ?>
<header class="post-thumb-header">
<h2 class="post-title"><?php the_title(); ?></h2>
</header> <!-- end article header -->
<p class="meta"><?php the_category(', '); ?></p>
</div>
<section class="mobile-content">
<?php the_excerpt(); ?>
</section>
</article> <!-- end article -->
</div>
<?php $count++; ?>
<?php endwhile; ?>
<nav class="wp-prev-next">
<?php echo rb_pagination(); ?>
</nav>
</div> <!-- end .psts -->
</div> <!-- end #main -->
<?php get_sidebar(); // sidebar 1 ?>
</div> <!-- end #inner-content -->
</div> <!-- end #content -->
<?php get_footer(); ?>
I think you're overriding the original query with this line:
query_posts(array('posts_per_page' => '8','paged'=>$paged));
Can you swap this line with this, and let me know the results?
global $query_string;
query_posts( $query_string . "&posts_per_page=8&paged=$paged" );
if that fails try this:
query_posts(array('posts_per_page' => '8','paged'=>$paged, 'cat' => $category_id ));

the content function is ignoring more tag

I'm doing "page of post" in twenty eleven theme. Problem is that the_content function ignores more tag and show the whole post. It work just fine in index page.
My code:
/*
Template Name: Page Of Posts
*/
?>
<?php get_header(); ?>
<div id="primary">
<div id="content" role="main">
<?php
$args= array(
'category_name' => '');
query_posts($args);
if ( have_posts() ) : ?>
<?php twentyeleven_content_nav( 'nav-above' ); ?>
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', get_post_format() ); ?>
<?php endwhile; ?>
<?php twentyeleven_content_nav( 'nav-below' ); ?>
<?php else : ?>
<article id="post-0" class="post no-results not-found">
<header class="entry-header">
<h1 class="entry-title"><?php _e( 'Nothing Found', 'twentyeleven' ); ?></h1>
</header><!-- .entry-header -->
<div class="entry-content">
<p><?php _e( 'Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.', 'twentyeleven' ); ?></p>
<?php get_search_form(); ?>
</div><!-- .entry-content -->
</article><!-- #post-0 -->
<?php endif; ?>
</div><!-- #content -->
</div><!-- #primary -->
Please help!
Can you list a file you are requesting with get_template_part('content', get_post_format() ) it should be in the theme folder named like content-gallery.php(or any other post_format).
Anyway, you can try the good old:
<?php global $more; $more = 0; ?>
Place it before the call for the content.

Resources