Wordpress posts page is not showing posts list - wordpress

Im trying to setup custom posts page. I was trying to use home.php, and custom page template. After that i choose in the setting part "Reading Settings" my blog page. Problem is that when i go on www.domain.tld/blog im getting single blog post page, not a list of blogs. When i switch blog template to some other url, then everything is fine but still is not using custom template. In that case wp are using home.php
home.php
<?php
/**
* Blog listing
*/
?>
<?php get_header() ?>
<div id="blog" class="page_wrapper">
<div class="hedaer_mini_part">
<?php get_template_part('parts/navigation'); ?>
<div class="container">
<hr>
<h1>Blog</h1>
<div class="search">
<?php echo get_search_form( ); ?>
<?php
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 0;
$query = new WP_Query(array('category_name' => 'blog', 'post_type' => 'post', 'paged' => $paged));
if ($query->have_posts() || $paged >= 1 && $paged <= $wp_query->max_num_pages) :
?>
</div>
</div>
</div>
<div class="blog_lista">
<div class="container">
<div class="news_list_wrapper">
<?php
// Start the loop.
while ($query->have_posts()) : $query->the_post();
?>
<div class="news_list_item ffs-able">
<a href="<?php the_permalink(); ?>">
<div class="row">
<div class="col-sm-5">
<div class="news_list_image">
<!-- <img src="" /> -->
<?php if(has_post_thumbnail()) { ?>
<img src="<?php the_post_thumbnail_url('list_size'); ?>" alt="<?php the_title() ?>" />
<?php } ?>
</div>
</div>
<div class="col-sm-7">
<div class="news_list_content">
<h3 class="title"><?php the_title() ?></h3>
<div class="body">
<?php echo wp_trim_words(get_the_content(), 90); ?>
</div>
<div class="date">
<?php the_time('j. F Y.'); ?>
</div>
</div>
</div>
</div>
</a>
</div>
<?php
// End the loop.
endwhile;
?>
</div>
<div class="news_pagination">
<hr>
<?php the_posts_pagination(array('mid_size' => 1, 'prev_text' => '<', 'next_text' => '>')); ?>
</div>
<?php
else :
echo 'There is no blog posts..';
endif;
?>
</div>
</div>
</div>
<?php get_footer(); ?>

You need to add these codes to index.php and not home.php. That might fix the issue.

Related

open the wordpress custom post type permalink in modal window

Normally in wordpress permalink will open to a single page. but this time the goal is to open the custom post type permalink in modal window. I have lots of custom post type, and I only like to apply the modal in the doctor custom post type .
how could I achieve this? here is my code:
<div class="slider-wrapper">
<div class="center-doc">
<!--start connect to db-->
<?php $args = array(
'post_type' => 'doctor',
'posts_per_page' => -1,
'orderby' => 'post_date',
'order' => 'DESC',
'post_status' => 'publish',
);
$posts = get_posts( $args );
foreach ( $posts as $post ): setup_postdata( $post );
?>
<!--end connect to db-->
<div class="slider-box">
<a href="<?php the_permalink(); ?>"> <!-- PERMALINK TO OPEN MODAL-->
<div class="feature-img"> <?php if (has_post_thumbnail()) : ?> <?php the_post_thumbnail(); ?>
<?php else : ?> <img src="<?php echo get_template_directory_uri(); ?>/img/default-img.png" alt="<?php the_title(); ?>">
<?php endif; ?><!--/pro pic-->
</div>
<h6><?php the_title(); ?></h6>
<div class="content"><?php the_excerpt(); ?></div>
</a>
</div>
<!-- MODAL WINDOW TO OPEN WHEN PERMALINK CLICKED-->
<div id="modal" class="modal-window">
<div>
<i class="fa fa-times-circle" aria-hidden="true"></i>
<div class="detail-wraper">
<div class="detail-info">
<h3><?php the_title(); ?></h3>
<div class="details">
<?php the_content(); ?>
</div>
</div>
</div>
</div>
</div>
<?php endforeach; wp_reset_postdata(); ?>
</div>
I am using Wordpress 5.9.3 version.

Chrome issue with wordpress posts

I have an issue with my site on Chrome. On firefox everything is ok, but when I open my page with chrome I don't see the first post on page, there is a blank space there when it should be, I can see that this post is in the code when I inspect this page. I'm searching for an answer for few days and don't know why is this happening. Anyone had a problem like that? please help me.
I'm loading my posts with wp query from category, im using also a clip path in css (but I tried to comment in and check page and same issue was there).
<div class="container">
<div class="row">
<div class="col-12">
<h1 class="home-title text-center">Aktualności</h1>
<?php
$query = new WP_Query( array(
'post_type' => 'post',
'post_status' => 'publish',
'category_name' => 'aktualnosci',
'posts_per_page'=> -1 ) ); ?>
<?php if( $query->have_posts() ) : while( $query->have_posts() ) : $query->the_post(); ?>
<div class="post-short">
<div class="row">
<div class="col-md-6 col-sm-12">
<a href="<?php the_permalink(); ?>">
<img src="<?php echo wp_get_attachment_url( get_post_thumbnail_id( $post->ID ) ); ?>" class="project_pics">
</a>
</div>
<div class="col-md-6 col-sm-12">
<h3 class="post-short_title text-center"><?php the_title(); ?></h3>
<?php the_date('d.m.Y', '<p class="text-center post-date">', '</p>'); ?>
<div class="excerpt">
<?php the_excerpt(); ?>
</div>
</div>
</div>
</div>
<?php endwhile; endif; wp_reset_postdata(); ?>
</div>
</div>
This is my code for displaying posts.
and page is szkola.webwitch.pl if anyone can check it
Thanks.

Wordpress loop only showing one record in query post

I have a Wordpress Site or its Blog section I did a WP_Query post.
The loop is within a custom template its showing only one record while I have few post entries.
I think I have done correctly...
Please do let me why it is not looping the records.
<?php get_header();
?>
<div id="body">
<div class="container">
<div class="row-fluid">
<div class="span9">
<?php
$arr = array(
'post_type' => 'post',
'posts_per_page' => 10,
'orderby' => 'date',
'order' => 'DESC',
'post_status' => 'publish'
);
$query = new WP_Query($arr);
if(count($query->posts) > 0):
$i = 0;
?>
<?php while($query->have_posts()): $i++;?>
<?php $query->the_post();
if(has_post_thumbnail(get_the_ID())){
$url_thumbnail = get_the_post_thumbnail(get_the_ID(), 'thumb_700x260', array('alt' => trim(get_the_title())));
$url_thumbnail_news = get_the_post_thumbnail(get_the_ID(), 'thumb_700x260', array('alt' => trim(get_the_title())));
} else {
$url_thumbnail = '<image src="'.get_template_directory_uri().'/images/no-thumbnail.jpg" title="No Thumbnail" alt="Free Nile Theme - Wordpress Theme from ThemeLead" />';
$url_thumbnail_news = '<image src="'.get_template_directory_uri().'/images/no-thumbnail-news.jpg" title="No Thumbnail" alt="Free Nile Theme - Wordpress Theme from ThemeLead" />';
}
?>
<?php if($i==1):?>
<div class="drop-shadow lifted"> <a class="nile-thumnail" href="<?php echo get_permalink(get_the_ID())?>" title="<?php the_title()?>"><?php echo $url_thumbnail;?></a> </div>
<div class="the_post">
<h2 class="bj-title"><a href="<?php echo get_permalink(get_the_ID())?>" title="<?php the_title()?>">
<?php the_title();?>
</a></h2>
<div class="bj-date">
<?php the_date();?>
<?php the_time();?>
</div>
<div class="bj-des">
<?php the_excerpt();?>
</div>
<a href="<?php the_permalink();?>" title="<?php the_title()?>" class="read-more">
<?php _e('Read more', APP_TD);?>
</a> </div>
<?php endif;?>
<?php endwhile;?>
<?php endif;?>
<?php // Reset Query
wp_reset_query(); ?>
<div class="navigation">
<div class="alignleft">
<?php previous_posts_link('« Previous') ?>
</div>
<div class="alignright">
<?php next_posts_link('More »') ?>
</div>
</div>
</div>
<div class="span3"> <?php echo get_default_sidebar();?> </div>
</div>
</div>
</div>
<?php get_footer();?>
Try removing the 'if($i==1)' and corresponding 'endif;' line

What would make the_date function in wordpress only show up on random posts

I am working on a website for a client and I specifically needed to modify a given wordpress template. The template uses the get_template_part function to call the content. So for the loop on the index page it should be showing the_date under the header but for some reason it is showing up on some of the posts and not all.
index.php
<?php get_header(); ?>
<!-- Content -->
<div class="container contentarea">
<div class="row">
<div class="column-content">
<div id="content" role="main">
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<!-- Call content.php -->
<?php get_template_part( 'content' ); ?>
<?php endwhile; ?>
<div class="clearfix"></div>
<div class="paging">
<?php if(function_exists('lugada_kriesi_pagination')) : lugada_kriesi_pagination(); else: ?>
<?php global $wp_query; $total_pages = $wp_query->max_num_pages; if ( $total_pages > 1 ) { ?>
<div id="nav-below" class="navigation">
<div class="nav-previous"><?php next_posts_link(__( '<span class="meta-nav">«</span> Older posts', 'newzeo' )) ?></div>
<div class="nav-next"><?php previous_posts_link(__( 'Newer posts <span class="meta-nav">»</span>', 'newzeo' )) ?></div>
</div>
<?php } endif; ?>
</div>
<?php else : ?>
<article id="post-0" class="post no-results not-found">
<header class="entry-header">
<h1 class="entry-title">Nothing Found</h1>
</header>
<div class="entry-content">
<p>Sorry, we can't find post you request. Please try search for a related post.</p>
</div>
</article>
<?php endif; ?>
</div> <!-- #content -->
</div> <!-- .column-content -->
<div class="column-sidebar nomargin">
<?php get_sidebar(); ?>
</div>
</div>
</div>
<?php get_footer(); ?>
content.php
<div class="content-box bucket">
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?> itemscope itemtype="http://schema.org/Article" >
<h2 class="entry-header">
<div class="entry-meta clearfix" >
<!-- Sticky post -->
<?php if (is_sticky()) : ?>
<div class="sticky-label"></div>
<?php endif; ?>
<!-- Post title -->
<?php the_title(); ?>
</div> <!-- .entry-meta -->
</h2> <!-- .header -->
<!-- Content -->
<div class="entry-content clearfix" itemprop="description">
<?php the_date('','<p><strong>','</strong></p>',true); ?>
<?php the_content('Continue reading'); ?>
<div class="clearfix"></div>
<?php wp_link_pages( array('before' => '<div class="page-link"> <span> Pages: </span>', 'after' => '</div>')); ?>
</div>
<div class="entry-meta footerbox" >
<!-- Category -->
<span class="cat-links">
<span>Posted in</span>
<?php echo get_the_category_list(', '); ?>
</span>
<!-- If single & have tag -->
<!-- Tag -->
<?php if ( is_single() ): if (has_tag()) : ?>
<span class="sep"> | </span>
<span class="tag-links">
<span>Tagged</span>
<?php echo get_the_tag_list('',', ',''); ?>
</span>
<?php endif; ?>
<?php edit_post_link('Edit', '<span class="edit-link"><span class="sep"> | </span>', '</span>'); ?>
<div class="socialshareboxsingle clearfix">
Share this post, let the world know <?php lugada_social_button();?>
</div>
<?php endif; ?>
</div> <!-- .footer -->
</div> <!-- article -->
</div>
<hr class="post-shadow"/>
<!-- If its single, a user has filled out their description and this is a multi-author blog, show a bio on their entries -->
<?php if ( is_single() ) : ?>
<?php if ( get_the_author_meta( 'description' ) && ( ! function_exists( 'is_multi_author' ) || is_multi_author() ) ) : ?>
<div class="content-box">
<div id="author-info">
<div id="author-avatar">
<?php echo get_avatar( get_the_author_meta( 'user_email' ), 80 ); ?>
</div>
<div id="author-description">
<h2 >About <?php echo get_the_author(); ?></h2>
<?php the_author_meta( 'description' ); ?>
</div>
<div id="author-link" class="clearfix">
<?php if ( get_the_author_meta( 'user_url' )) : ?>
<span>Add my circles on Google+ : </span>
<span itemprop="author"><?php echo get_the_author(); ?></span>
<br/>
<?php endif; ?>
<a href="<?php echo get_author_posts_url( get_the_author_meta( 'ID' ) ); ?>">
View all posts by <?php echo get_the_author(); ?><span class="meta-nav">→</span>
</a>
</div>
</div>
</div>
<hr class="post-shadow"/>
<?php endif; endif; ?>
They're not random posts. Read the Codex:
When there are multiple posts on a page published under the SAME DAY, the_date() only displays the date for the first post (that is, the first instance of the_date()). To repeat the date for posts published under the same day, you should use the Template Tag the_time() or get_the_date() (since 3.0) with a date-specific format string.
Change:
<?php the_date('','<p><strong>','</strong></p>',true); ?>
To:
<p><strong><?php the_time('F j, Y'); ?></strong></p>

the_author is empty when not logged in

Is there a reason why the_author should return an empty string on the first page when the user is not logged in, but return the author name just as it should when more posts are loaded through AJAX ?
The loop is the same in both cases.
Please help me resolve this issue as I'm clueless and I need it fixed ASAP to launch my site.
Here's the whole index.php:
<?php
get_header();
get_sidebar();
?>
<!-- MAIN DIV -->
<div id='content_and_floater'>
<?php get_template_part('social_floater'); ?>
<div id='content'>
<?php get_template_part('loop'); ?>
</div>
</div>
<?php get_template_part('loader'); ?>
<!-- MAIN DIV -->
<?php
get_footer();
?>
And here's how the infinitePaginator calls the loop in functions.php (the function is called when scrolled down to the bottom or the loader link is clicked):
function wp_infinitepaginate(){
$loopFile = $_POST['loop_file'];
$paged = $_POST['page_no'];
$posts_per_page = get_option('posts_per_page');
# Load the posts
query_posts(array('paged' => $paged ));
get_template_part( $loopFile );
exit;
}
You can see the behaviour at test.nowillnoskill.net.
In single posts it's not working either. My guess is that query_posts(array('paged' => $paged )); changed something in the query, but I don't know what is it.
I tried to insert setup_postdata($post); just after the_post() in loop.php as I found that worked for someone, but it doesn't for me.
I also tried to insert
query_posts(array('paged' => 1 ));
before calling the loop file in index.php, but no posts at all were shown.
Here is my loop.php:
<?php while ( have_posts() ) : the_post() ?>
<!-- POST1 -->
<article class='post'>
<header class='post_header'>
<?php
global $current_user;
$current_user = wp_get_current_user();
if (!empty($current_user)) {
$pid = get_the_id();
$uid = $current_user->ID;
$title = (is_favorite($pid, $uid)) ?
'Remove from favorites' :
'Add to favorites';
$trans = (is_favorite($pid, $uid)) ?
'' :
' transparent';
?>
<div>
<h2>
<a href="<?php the_permalink(); ?>">
<?php the_title(); ?>
</a>
</h2>
<?php if (is_user_logged_in()) { ?>
<a title='<?php echo $title ?>' class='post_favorite' href='#' alt='fpid=<?php echo $pid ?>uid=<?php echo $uid ?>'>
<span class='symbol<?php echo $trans ?>'>R</span>
</a>
<?php } ?>
</div>
<div class='post_header_div'>
<strong class='post_category'>
<?php echo get_the_category_list(', '); ?>
</strong>
<strong class='post_author'>
<span class='symbol'>U</span>
<?php the_author(); ?>
</strong>
</div>
<div>
<span class='post_author'>
<?php edit_post_link('[edit]'); ?>
</span>
</div>
<?php } ?>
</header>
<figure class='post_image'>
<!--<img src='design/img/flashkick.png' alt='logo' />-->
<?php the_post_thumbnail(); ?>
</figure>
<div class='post_perex'>
<?php the_content('Read more'); ?>
</div>
<div class='space'></div>
<footer class='post_footer'>
<div class='post_footer_top'>
<div class='post_tags'>
<?php the_tags('', '', ''); ?>
</div>
<div class='post_time'>
<time datetime="<?php the_time('Y-m-d'); ?>" pubdate>
<span class='symbol'>P </span>
<?php relative_post_the_date(); ?>
</time>
</div>
</div>
</footer>
<div class='space'></div>
</article>
<?php endwhile; ?>
Author informations are given by Wordpress in post informations.
Try to do a var_dump on your query_posts result, you should find where the author name is stored, to display it properly.
Can you please show your loop template ? At least the part displaying the author.

Resources