i have a problem with my wordpress theme. It works, but when i would like to turn the comments off, it doesn't show me the excerpt.
The first picture shows how it look like when comments are allowed, the second picture shows it when comments are not allowed.
Comments allowed
Comments off
Here is the code snippet from content.php page:
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header">
<div class="entry-header-title">
<?php if ( is_single() ) : ?>
<h1 class="entry-title"><?php the_title(); ?></h1>
<?php else : ?>
<h1 class="entry-title">
<?php the_title(); ?>
</h1>
<?php endif; // is_single() ?>
<span class="entry-meta-date">
<?php twentythirteen_entry_date(); ?>
<span>|</span>
<?php if ( comments_open() && ! is_single() ) : ?>
<span class="entry-comments" >
<?php comments_popup_link( '<span class="leave-reply">' . __( 'Leave a Reply', 'twentythirteen' ) . '</span>', __( '1 Comment', 'twentythirteen' ), __( '% Comments', 'twentythirteen' ) ); ?>
</span><!-- .entry-comments -->
</span><!-- .entry-meta -->
<?php if ( has_post_thumbnail() && ! post_password_required() ) : ?>
<div class="entry-thumbnail">
<?php the_post_thumbnail(); ?>
</div>
<?php endif; ?>
</div>
</header><!-- .entry-header -->
<?php if ( is_search() ) : // Only display Excerpts for Search ?>
<div class="entry-summary">
<?php the_excerpt(); ?>
</div><!-- .entry-summary -->
<?php else : ?>
<div class="entry-content">
<?php the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentythirteen' ) ); ?>
<?php wp_link_pages( array( 'before' => '<div class="page-links"><div class="page-links-title">' . __( 'Pages:', 'twentythirteen' ) . '</div>', 'after' => '</div>', 'link_before' => '<div>', 'link_after' => '</div>' ) ); ?>
</div><!-- .entry-content -->
<?php endif; ?>
<footer class="entry-meta">
<?php endif; // comments_open() ?>
<div class="entry-labels">
<?php twentythirteen_entry_meta(); ?>
</div>
<div class="entry-share">
<?php if( function_exists('ADDTOANY_SHARE_SAVE_KIT') ) { ADDTOANY_SHARE_SAVE_KIT(); } ?>
</div>
<div class=".post-spacer">
</div>
</footer><!-- .entry-meta -->
</article><!-- #post -->
<div class="linkwithin_div"></div>
You accidentally deleted an <?php endif;?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header">
<div class="entry-header-title">
<?php if ( is_single() ) : ?>
<h1 class="entry-title"><?php the_title(); ?></h1>
<?php else : ?>
<h1 class="entry-title">
<?php the_title(); ?>
</h1>
<?php endif; // is_single() ?>
<span class="entry-meta-date">
<?php twentythirteen_entry_date(); ?>
<span>|</span>
<?php if ( comments_open() && ! is_single() ) : ?>
<span class="entry-comments" >
<?php comments_popup_link( '<span class="leave-reply">' . __( 'Leave a Reply', 'twentythirteen' ) . '</span>', __( '1 Comment', 'twentythirteen' ), __( '% Comments', 'twentythirteen' ) ); ?>
</span><!-- .entry-comments -->
</span><!-- .entry-meta -->
//THIS ONE
<?php endif; // comments_open() ?>
<?php if ( has_post_thumbnail() && ! post_password_required() ) : ?>
<div class="entry-thumbnail">
<?php the_post_thumbnail(); ?>
</div>
<?php endif; ?>
</div>
</header><!-- .entry-header -->
<?php if ( is_search() ) : // Only display Excerpts for Search ?>
<div class="entry-summary">
<?php the_excerpt(); ?>
</div><!-- .entry-summary -->
<?php else : ?>
<div class="entry-content">
<?php the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentythirteen' ) ); ?>
<?php wp_link_pages( array( 'before' => '<div class="page-links"><div class="page-links-title">' . __( 'Pages:', 'twentythirteen' ) . '</div>', 'after' => '</div>', 'link_before' => '<div>', 'link_after' => '</div>' ) ); ?>
</div><!-- .entry-content -->
<?php endif; ?>
<footer class="entry-meta">
<div class="entry-labels">
<?php twentythirteen_entry_meta(); ?>
</div>
<div class="entry-share">
<?php if( function_exists('ADDTOANY_SHARE_SAVE_KIT') ) { ADDTOANY_SHARE_SAVE_KIT(); } ?>
</div>
<div class=".post-spacer">
</div>
Related
Currently, I'm attempting to have a two-columned post display layout on my index page, but unfortunately, none of my tries seem to work. My idea is to have them shown like this:
Article one Article two
Article three Article four
Article five Article six
Instead, however, they're shown like this:
Article one
Article twoArticle three
And so forth. In my content.php file, the following is the code I have:
<?php
/**
* #package dazzling
*/
?>
<div class="row"> <div class="col-sm-12 col-md-6">
<div class="thumbnail" style="padding: 0px;">
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<div class="caption"><header class="entry-header page-header">
<h3><?php the_title(); ?> <small style="color: inherit;"><li class="glyphicon glyphicon-new-window"></li></small></h3>
<?php if ( 'post' == get_post_type() ) : ?>
<small class="entry-meta">
<?php dazzling_posted_on(); ?><?php if ( ! post_password_required() && ( comments_open() || '0' != get_comments_number() ) ) : ?>
<span class="comments-link"><li class="glyphicon glyphicon-comment"></li> <?php comments_popup_link( __( 'Leave a comment', 'dazzling' ), __( '1 Comment', 'dazzling' ), __( '% Comments', 'dazzling' ) ); ?></span>
<?php endif; ?>
<?php if ( 'post' == get_post_type() ) : // Hide category and tag text for pages on Search ?>
<?php
/* translators: used between list items, there is a space after the comma */
$categories_list = get_the_category_list( __( ', ', 'dazzling' ) );
if ( $categories_list && dazzling_categorized_blog() ) :
?>
<span class="cat-links"><li class="glyphicon glyphicon-folder-open"></li>
<?php printf( __( ' %1$s', 'dazzling' ), $categories_list ); ?>
</span>
<?php endif; // End if categories ?>
<?php endif; // End if 'post' == get_post_type() ?>
<?php edit_post_link( __( 'Edit', 'dazzling' ), '<li class="glyphicon glyphicon-pencil"></li> <span class="edit-link">', '</span>' ); ?>
</small><!-- .entry-meta -->
<?php endif; ?>
</header><!-- .entry-header -->
<?php if ( is_search() ) : // Only display Excerpts for Search ?>
<?php the_excerpt(); ?>
<p><a class="btn btn-default read-more" href="<?php the_permalink(); ?>"><?php _e( 'Continue reading', 'dazzling' ); ?> <span class="glyphicon glyphicon-chevron-right"></span></a></p>
</div><!-- .entry-summary -->
<?php else : ?>
<?php if ( has_post_thumbnail()) : ?>
<a href="<?php the_permalink(); ?>" style="float: left; margin-right: 10px;" title="<?php the_title_attribute(); ?>">
<?php the_post_thumbnail( 'medium', array( 'class' => 'img-thumbnail' )); ?>
</a>
<div class="caption">
<?php the_excerpt(); ?>
</div>
<?php else : ?>
<?php the_excerpt(); ?>
<?php endif; ?>
<p><a class="btn btn-default read-more" href="<?php the_permalink(); ?>"><?php _e( 'Continue reading', 'dazzling' ); ?> <span class="glyphicon glyphicon-chevron-right"></span></a></p>
<?php
wp_link_pages( array(
'before' => '<div class="page-links">'.__( 'Pages:', 'dazzling' ),
'after' => '</div>',
'link_before' => '<span>',
'link_after' => '</span>',
'pagelink' => '%',
'echo' => 1
) );
?>
</div><!-- .entry-content -->
<?php endif; ?>
<br>
</article></div></div></div>
<!-- #post-## -->
Could you all please explain if I'm doing anything wrong here? Thank you!
The easiest solution would probably be a CSS approach. If you assign a class to each post that is printed on the page, you could then float half to the right, and half to the left. Here is an example:
Sample HTML
<div class="wrapper">
<div class="post">Sample Post 1 Content</div>
<div class="post">Sample Post 2 Content</div>
<div class="post">Sample Post 3 Content</div>
<div class="post">Sample Post 4 Content</div>
<div class="post">Sample Post 5 Content</div>
<div class="post">Sample Post 6 Content</div>
</div>
Corresponding CSS
.post:nth-child(odd) {
float:left;
width:50%;
}
.post:nth-child(even) {
float: right;
width:50%;
}
Here is a demo where you can see this approach in action.
I have a custom post type (called 'discount') that I am trying to display in the twentythirteen theme. I created a custom page file called discount-page.php to create my own template for this post type. I'm not sure where I need to place the wp_query code, however. Here's what the default page.php looks like, with an addition of the new template name:
<div id="primary" class="content-area">
<div id="content" class="site-content" role="main">
<?php /* The loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header">
<?php if ( has_post_thumbnail() && ! post_password_required() ) : ?>
<div class="entry-thumbnail">
<?php the_post_thumbnail(); ?>
</div>
<?php endif; ?>
<h1 class="entry-title"><?php the_title(); ?></h1>
</header><!-- .entry-header -->
<div class="entry-content">
<?php the_content(); ?>
<?php wp_link_pages( array( 'before' => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'twentythirteen' ) . '</span>', 'after' => '</div>', 'link_before' => '<span>', 'link_after' => '</span>' ) ); ?>
</div><!-- .entry-content -->
<footer class="entry-meta">
<?php edit_post_link( __( 'Edit', 'twentythirteen' ), '<span class="edit-link">', '</span>' ); ?>
</footer><!-- .entry-meta -->
</article><!-- #post -->
<?php comments_template(); ?>
<?php endwhile; ?>
</div><!-- #content -->
</div><!-- #primary -->
Now, I'm fairly sure that in order for my posts to actually show their content, I need to add this block of code to the discount-page.php:
<?php
$query = new WP_Query( array('post_type' => 'discount', 'posts_per_page' => 5 ) );
while ( $query->have_posts() ) : $query->the_post(); ?>
// Your code e.g. "the_content();"
<?php endif; wp_reset_postdata(); ?>
<?php endwhile; ?>
I just have no idea where to add it? It seems to break the page no matter where I add it.
You just have to change a couple of lines of code for it to work.
<div id="primary" class="content-area">
<div id="content" class="site-content" role="main">
<?php /* The loop */ ?>
<?php
$query = new WP_Query( array('post_type' => 'discount', 'posts_per_page' => 5 ) );
while ( $query->have_posts() ) : $query->the_post(); ?> ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header">
<?php if ( has_post_thumbnail() && ! post_password_required() ) : ?>
<div class="entry-thumbnail">
<?php the_post_thumbnail(); ?>
</div>
<?php endif; ?>
<h1 class="entry-title"><?php the_title(); ?></h1>
</header><!-- .entry-header -->
<div class="entry-content">
<?php the_content(); ?>
<?php wp_link_pages( array( 'before' => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'twentythirteen' ) . '</span>', 'after' => '</div>', 'link_before' => '<span>', 'link_after' => '</span>' ) ); ?>
</div><!-- .entry-content -->
<footer class="entry-meta">
<?php edit_post_link( __( 'Edit', 'twentythirteen' ), '<span class="edit-link">', '</span>' ); ?>
</footer><!-- .entry-meta -->
</article><!-- #post -->
<?php comments_template(); ?>
<?php endwhile; wp_reset_postdata(); ?>
</div><!-- #content -->
</div><!-- #primary -->
If you want the super simple version of it removing everything else. Try this:
<div id="primary" class="content-area">
<div id="content" class="site-content" role="main">
<?php
$query = new WP_Query( array('post_type' => 'discount', 'posts_per_page' => 5 ) );
while ( $query->have_posts() ) : $query->the_post();
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<div class="entry-content">
<?php the_content(); ?>
</div>
</article>
<?php endwhile; wp_reset_postdata(); ?>
</div>
</div>
Can someone advise where to comment out the page title in Coraline theme? I've tried different things and it does not work. Here's my page.php
<div id="content-container">
<div id="content" role="main">
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php if ( is_front_page() ) { ?>
<h2 class="entry-title"><?php the_title(); ?></h2>
<?php } else { ?>
<h1 class="entry-title"><?php the_title(); ?></h1>
<?php } ?>
<div class="entry-content">
<?php the_content(); ?>
<?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'coraline' ), 'after' => '</div>' ) ); ?>
<?php edit_post_link( __( 'Edit', 'coraline' ), '<span class="edit-link">', '</span>' ); ?>
</div> <!-- .entry-content
</div> <!-- #post-## -->
<?php comments_template( '', true ); ?>
<?php endwhile; ?>
</div><!-- #content -->
</div><!-- #content-container -->
I would assume it would be this line:
<h1 class="entry-title"><?php the_title(); ?></h1>
To comment out, replace with:
<!--<h1 class="entry-title"><?php the_title(); ?></h1>-->
You can also just leave the Title box empty when creating a new page in the admin panel.
I am using wordpress and twenty twelve child as my theme.
I made a website for funny pictures, and basically what I want is the image inside every page to act like a link to a next image. Heres some example sites with this feature: DailyHaHa and Meme-lol.com You see if you click the image, it will take you to next image page. I'm working on local machine so I can't give link to my website. Here is my content.php:
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php if ( is_sticky() && is_home() && ! is_paged() ) : ?>
<div class="featured-post">
<?php _e( 'Featured post', 'twentytwelve' ); ?>
</div>
<?php endif; ?>
<div class="entry-header">
<?php the_post_thumbnail(); ?>
<?php if ( is_single() ) : ?>
<div class="post-header">
<div class="entry-title">
<?php the_title(); ?>
</div>
<span class="inline-div">
<span class="entry-bar"><li><?php echo "Added "; wp_days_ago(); ?></li> </span>
<li><?php comments_popup_link( '<span class="leave-reply">' . __( 'Be first to comment', 'twentytwelve' ) . '</span>', __( '1 comment', 'twentytwelve' ), __( '% comments', 'twentytwelve' ) ); ?></li>
<!-- .comments-link -->
<span class="edit"><li><?php edit_post_link( __( 'Edit', 'twentytwelve' ), '<span class="edit-link">', '</span>' ); ?></li></span>
</span>
<?php else : ?>
<div class="entry-title">
<?php the_title(); ?>
</div>
<span class="inline-div">
<span class="entry-bar"><li><?php echo "Added "; wp_days_ago(); ?></li> </span>
<li><?php comments_popup_link( '<span class="leave-reply">' . __( 'Be first to comment', 'twentytwelve' ) . '</span>', __( '1 comment', 'twentytwelve' ), __( '% comments', 'twentytwelve' ) ); ?></li>
<!-- .comments-link -->
<span class="edit"><li><?php edit_post_link( __( 'Edit', 'twentytwelve' ), '<span class="edit-link">', '</span>' ); ?></li></span>
</span>
<?php endif; // is_single() ?>
</div><!-- .entry-header -->
<?php if ( is_search() ) : // Only display Excerpts for Search ?>
<div class="entry-summary">
<?php the_excerpt(); ?>
</div><!-- .entry-summary -->
<?php else : ?>
<div class="entry-content">
<?php the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentytwelve' ) ); ?>
<?php wp_link_pages( array( 'before' => '<div class="page-links">' . __( 'Pages:', 'twentytwelve' ), 'after' => '</div>' ) ); ?>
</div><!-- .entry-content -->
<?php endif; ?>
<div class="share-buttons">
<a class="facebook-button" target="_blank" onclick="return !window.open(this.href, 'Facebook', 'width=640,height=300')" href="http://www.facebook.com/sharer/sharer.php?u=<?php the_permalink(); ?>"><img src="/images/share.png" /></a>
<a class="tweet-button" target="_blank" href="http://twitter.com/share"><img src="/images/tweet.png" /></a>
</div>
<div class="nav2">
<span class="previous-button">
<?php next_post_link( '%link', '<img src="/images/prev.png" alt="Previous"/>' ); ?>
</span>
<span class="random-post">
<?php $randomPost = $wpdb->get_var("SELECT guid FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' ORDER BY rand() LIMIT 1");
echo '<img src="/images/random.png" alt="Random"/>'; ?>
</span>
<span class="next-button">
<?php previous_post_link( '%link', '<img src="/images/Next.png" alt="Next"/>' ); ?>
</div>
<br />
</span>
</article><!-- #post -->
You need to get the featured image of the post first.
<?php // Display the thumbnail of the previous post ?>
<span class="previous-button"> <?php
$prevPost = get_previous_post();
$prevthumbnail = get_the_post_thumbnail($prevPost->ID); ?>
<?php previous_post_link('%link', $prevthumbnail); ?>
</span>
<?php // Display the thumbnail of the next post ?>
<span class="next-button"> <?php
$nextPost = get_next_post();
$nextthumbnail = get_the_post_thumbnail($nextPost->ID); ?>
<?php next_post_link('%link', $nextthumbnail); ?>
</span>
My client wants to have his news page with 3 columns and 3 posts on the page.
Each column has a title name, date, the excerpt and read more function.
Like this: http://rikvandoorn.nl/nieuws_pagina.jpg
Cause my PHP knowledge isn't that good, i was looking for some tutorials to create the 3 column page. But al those tutorials are outdated, in lack of information or they don't seem to work that well.
And the "leave a reply" can be moved to the single.php.
So i hope some of you can provide me some help.
This is my current content.php
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<div class="aside">
<h1 class="entry-title"><?php the_title(); ?></h1>
<div class="entry-content">
<?php the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentytwelve' ) ); ?>
</div><!-- .entry-content -->
</div><!-- .aside -->
<footer class="entry-meta">
<?php echo get_the_date(); ?>
<?php if ( comments_open() ) : ?>
<div class="comments-link">
<?php comments_popup_link( '<span class="leave-reply">' . __( 'Leave a reply', 'twentytwelve' ) . '</span>', __( '1 Reply', 'twentytwelve' ), __( '% Replies', 'twentytwelve' ) ); ?>
</div><!-- .comments-link -->
<?php endif; // comments_open() ?>
<?php edit_post_link( __( 'Edit', 'twentytwelve' ), '<span class="edit-link">', '</span>' ); ?>
</footer><!-- .entry-meta -->
</article><!-- #post -->
Set up the wordpress loop
<?php if ( have_posts() ) : while ( have_posts() ) : the_post();?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<div class="aside">
<h1 class="entry-title"><?php the_title(); ?></h1>
<div class="entry-content">
<?php the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentytwelve' ) ); ?>
</div><!-- .entry-content -->
</div><!-- .aside -->
<?php edit_post_link( __( 'Edit', 'twentytwelve' ), '<span class="edit-link">', '</span>' ); ?>
</article><!-- #post -->
<?php endwhile; endif; wp_reset_query(); ?>
and then in the admin go to Settings > General > Reading - select 3 in 'Blog pages show at most'