I've been having issues with my blog template from a basic wordpress theme.
The issuse is that the footer & the side bar are somehow still contained within the container div. I've gone through the code countless times now and i just cannot see what the issues is, all the closing tags are in the correct place but it still buggers up.
th website i'm creating is dev.pearlofbeauty.co.uk/blog
the code that i'm using for the blog template:
<div class="container">
<div class="column_680 m_bottom_20">
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array(
'orderby' => 'date',
'order' => 'DESC',
'paged' => $paged
);
query_posts($args);
while ( have_posts() ) : the_post();
?>
<div class="column_210 m_top_55">
<?php the_title(); ?>
<p class="blog_info">
Date: <span><?php the_time('F d,') ?></span> <span><?php the_time('Y') ?></span><br />
Author: <span><?php echo the_author_meta('nickname', get_the_author_meta( 'ID' ) ); ?></span><br />
Comments: <span><?php comments_number() ?></span><br />
Categories: <span><?php the_category(', '); ?></span>
</p>
</div><!--end column_210-->
<div class="column_440 m_top_65 last">
<?php if( has_post_thumbnail() ){ the_post_thumbnail('blog'); }else{ ?>
<img src="<?php echo get_template_directory_uri(); ?>/images/blank-blog.png">
<?php } ?>
</div><!--end column_440-->
<div class="clear"></div>
<div class="post_content m_top_15">
<p><?php content('50') ?></p>
<a class="button read_more rounded" href="<?php echo get_permalink(); ?>">Read More</a>
</div>
<div class="clear"></div>
<?php endwhile; ?>
<div class="more_post m_top_15 m_bottom_185">
<?php echo pagination(); ?>
</div>
</div><!--end column_680-->
<!--sidebar-->
<?php get_sidebar(); ?>
<!-- End Sidebar -->
<div class="clear"></div>
</div><!--end container-->
<div class="clear"></div>
<?php get_footer(); ?>
The problem is the result of
<p><?php content('50') ?></p>
This part returns:
<h4 style="font-style: italic; color: #000000;">
"Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit..."
</h4>
<h5 style="color: #000000;">
"There is no one who loves pain itself, who seeks after it and wants to have it, simply because it is pain..."
</h5>
<div style="color: #000000;">
<div class="lc">
<h2 class="what"></h2>
<strong>Lorem Ipsum</strong> is simply dummy text of.
As you can see you're missing 2 closing div tags.
Related
I have a WordPress theme, where I want to use CPT UI with texonomy. There I want to show texonomy name, link, thumbnail of this texonomy and description.
All are working except description. Here is my coding:
<div class="catagory-section" id="know-desti">
<div class="container">
<div class="heading">
<strong>Know Your</strong> <span>Destination</span>
</div>
<div class="col-xs-12 category-listing">
<?php foreach (get_terms('destination') as $cat) : ?>
<div class="row margin-bottom-10">
<div class="col-sm-12 padding-0 post-listing">
<img src="<?php echo z_taxonomy_image_url($cat->term_id); ?>" class="cate-img" />
<h2 class="cate-heading margin-0"><?php echo $cat->name; ?></h2>
<p><?php _ex($description = term_description( $term_id, $taxonomy )); ?></p>
Know More
</div>
</div>
<?php endforeach; ?>
</div>
</div>
</div>
<div class="stone-img"></div>
Why is my description not working?
You can use this function
$taxonomy ='custom_taxonomy_type'; {like: product_cat}
echo term_description( $term_id, $taxonomy )
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.
I'm really newbie to wordpress theme development and I want to get recent 10 posts inside front-page.php and all posts inside the index.php (I have no idea if a better way is there) followed by pagination.
Update : I want to have a home page that shows 10 posts and a articles page that shows all posts.
Is this approach right? if it is, how do I do that?
after some research I found a solution to do that.
at first I created 2 pages called home and articles, then I changed Setting -> Reading :
Front Page -> home
and
Posts Page -> articles.
then I put the following in the index.php as articles page :
<?php
if (have_posts()) : while (have_posts()) : the_post();
get_template_part('content', get_post_format());
endwhile; endif;
?>
then inside of front-page.php :
<?php
// the query
$wpb_all_query = new WP_Query(array('post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => 10)); ?>
<?php if ($wpb_all_query->have_posts()) : ?>
<!-- the loop -->
<?php while ($wpb_all_query->have_posts()) : $wpb_all_query->the_post(); ?>
<div class="post">
<div class="col-xs-12 col-lg-6">
<div class="panel panel-default ">
<div class="panel-body">
<div class="col-xs-4">
<a href="<?php the_permalink(); ?>">
<?php if (has_post_thumbnail()) : ?>
<img src="<?php the_post_thumbnail_url(); ?>" alt="">
<?php else: ?>
<img
src="<?php bloginfo('template_directory'); ?>/assets/image/placeholder.jpg"
alt="">
<?php endif; ?>
</a>
</div>
<div class="col-xs-8">
<div class="title">
<a href="<?php the_permalink(); ?>">
<h2><?php the_title(); ?></h2>
</a>
</div>
<div class="content">
<p><?php echo substr(get_the_content(), 0, 320); ?>...</p></div>
<div class="read-more">
Read More
</div>
</div>
</div>
</div>
</div>
</div>
<?php endwhile; ?>
<!-- end of the loop -->
<?php wp_reset_postdata(); ?>
<?php else : ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
finally it works in the way exactly what I wanted.
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
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>