I have stumbled across a problem, which makes both versions of the Blog different to each other when I'm not signed in to my site. Basically, I have built the site through WP. Once I've signed in the layout of the Blog Post is designed the way it is supposed to be like; completely laid out aesthetically and streamlined (image 1).
Blog Post Example 1
However, I've checked the site afterwards to find that the layout has shifted the wrong way somewhat and that the blog text has blended into the footer, making things look undesirable (image 2).
Blog Post Example 2
I have done everything in terms of deleting the cache and webpages just to refresh the whole site.
The code itself as I've double/triple-checked it again and again, but still no cigar.
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header">
<?php
if ( is_singular() ) :
the_title( '<h1 class="entry-title">', '</h1>' );
else :
the_title( '<h2 class="entry-title">', '</h2>' );
endif;
if ( 'post' === get_post_type() ) :
?>
</header><!-- .entry-header -->
<?php if ( has_post_thumbnail() ) { ?>
<?php the_post_thumbnail( array( 750, 750 )); ?>
<?php } ?>
<?php endif; ?>
<p class="article_date"><?php the_date(); ?></p>
<div class="blogTextExc">
<?php the_content(); ?>
Hello
</div>
<?php edit_post_link( 'Edit', '<div>', '</div>' ); ?>
</article><!-- #post-<?php the_ID(); ?> -->
Please help!!!!
You made some mistake in your code.
Header should be closed before if statement ( 'post' === get_post_type() )
Your code should look like this:
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header">
<?php
if ( is_singular() ) :
the_title( '<h1 class="entry-title">', '</h1>' );
else :
the_title( '<h2 class="entry-title">', '</h2>' );
endif;
?>
</header><!-- .entry-header -->
<?php if ( 'post' === get_post_type() ) :
if ( has_post_thumbnail() ) {
the_post_thumbnail( array( 750, 750 ));
}
endif; ?>
<p class="article_date"><?php the_date(); ?></p>
<div class="blogTextExc">
<?php the_content(); ?>
Hello
</div>
<?php edit_post_link( 'Edit', '<div>', '</div>' ); ?>
</article><!-- #post-<?php the_ID(); ?> -->
Related
Why can't I see the post content where as I can easily see the post title if I do a wordpress search. I have a custom post type "Artist" and I am using ACF.
<?php
if ( have_posts() ) : ?>
<?php
/* Start the Loop */
while ( have_posts() ) : the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header">
<?php the_title( sprintf( '<h2 class="entry-title">', esc_url( get_permalink() ) ), '</h2>' ); ?>
</header><!-- .entry-header -->
<div class="entry-summary">
<?php the_content(); ?>
</div><!-- .entry-summary -->
<footer class="entry-footer">
<?php edigital_entry_footer(); ?>
</footer><!-- .entry-footer -->
</article><!-- #post-## -->
You need to put "the content" function call inside the WordPress loop in order for it to output your content to the page like the following.
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; endif; ?>
Hope that helps, Cheers!!!
I set up a site for a photographer & she wanted to use her blog categories as her portfolio, which works fine, except for the fact that the infinite scrolling feature I'm using won't load all of the content for the excerpts.
The two items that it omits are the post thumbnail (image) and the horizontal row serving as a separator between the posts.
Any insight on this is appreciated - I'm using Paul Irish's infinite scroll plugin & the category excerpts are being called like so:
<?php get_header(); ?>
<section id="content" role="main">
<header class="header">
<h1 class="entry-title"><!-- <?php _e( 'Category Archives: ', 'themename' ); ?> --> <?php single_cat_title(); ?></h1>
<?php if ( '' != category_description() ) echo apply_filters( 'archive_meta', '<div class="archive-meta">' . category_description() . '</div>' ); ?>
</header>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?><div class="cat-thumbs align-right"><?php the_post_thumbnail(); ?></div>
<?php get_template_part( 'entry' ); ?>
<hr />
<?php endwhile; endif; ?>
<?php get_template_part( 'nav', 'below' ); ?>
</section>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
This is the entry template:
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header>
<?php if ( is_singular() ) { echo '<h1 class="entry-title">'; } else { echo '<h2 class="entry-title">'; } ?><?php the_title(); ?><?php if ( is_singular() ) { echo '</h1>'; } else { echo '</h2>'; } ?><?php edit_post_link(); ?>
<?php if ( !is_search() ) get_template_part( 'entry', 'meta' ); ?>
</header>
<?php get_template_part( 'entry', ( is_archive() || is_search() ? 'summary' : 'content' ) ); ?>
<?php if ( !is_search() ) get_template_part( 'entry-footer' ); ?>
</article>
For reference, this is how I'm calling the excerpts for the blog, which have no issue:
<section class="entry-content">
<div class="cat-thumbs align-right"><?php the_post_thumbnail(); ?></div>
<?php the_excerpt(); ?>
<em><p>
<?php comments_number( '0 comments', '1 comment', '% comments' ); ?>.
</p></em>
<div class="entry-links"><?php wp_link_pages(); ?></div>
</section>
<hr />
Link to example
Move <div class="cat-thumbs align-right"><?php the_post_thumbnail(); ?></div> and <hr> into the entry template.
I'm trying to make a slight adjustment to a wordpress template. I basically only want the code below to print if the_content() is empty. Currently, if it's empty, it still generates the article aka an ugly white box. I've been trying to put the code into a string and just do an if statement on the string, but concatenating all this code into a string isn't working for me. Any suggestions? Simpler way to do what I want to do, or is a concatenated string the best way? If so, can I get help putting this all into a string? THANKS!
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php if ( '' != get_the_post_thumbnail() ) : ?>
<div class="entry-thumbnail">
<?php the_post_thumbnail( 'featured-image' ); ?>
</div><!-- .entry-thumbnail -->
<?php endif; ?>
<header class="entry-header">
<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">',
'after' => '</div>',
'pagelink' => '<span class="page-link">%</span>',
) );
?>
</div><!-- .entry-content -->
<?php edit_post_link( __( 'Edit', 'singl' ), '<footer class="entry-meta"><span class="edit-link">', '</span></footer>' ); ?>
</article>
<?php
$content = get_the_content();
if($content != '') {
the_content();
} ?>
or
<?php if( $post->post_content != "" ) {
//do something or show content
}
I'm developing a wordpress theme for my blog and I'm having some difficulty.
When I make a new post, the first image of that post is displayed on the homepage. When the image is clicked, it links to the image file and shows the full size. I would like for it to automatically link to the post from which it came. I understand that you can choose what the image links to upon upload or in the editor. I would like for the images to link to their original post automatically, since I have other people writing on my blog, and I don't want them to have to do this each time.
As I understand it the content.php file controls the post format in this case. Here is the file from my theme. Or is it possible to use a function?
<?php
/**
* The default template for displaying content single/search/archive
*
* #package test
* #since test 0.1.0
*/
?>
<!-- START: content.php -->
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header">
<?php if ( is_single() ) : ?>
<h1 class="entry-title"><?php the_title(); ?></h1>
<?php else : ?>
<?php the_post_thumbnail(); ?>
<h1 class="entry-title">
<?php the_title(); ?>
</h1>
<?php endif; // is_single() ?>
</header><!-- .entry-header -->
<?php if ( 'post' == get_post_type() ) : ?>
<div class="entry-meta">
<?php posted_on(); ?>
<?php if ( is_sticky() && is_home() && ! is_paged() ) : ?>
<span class="label radius secondary"><?php _ex( 'Featured', 'Post format title', 'test' ); ?></span>
<?php endif; ?>
</div><!-- .entry-meta -->
<?php endif; ?>
<?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>', 'test' ) ); ?>
<?php wp_link_pages( array( 'before' => '<div class="page-link"><span>' . __( 'Pages:', 'test' ) . '</span>', 'after' => '</div>' ) ); ?>
</div><!-- .entry-content -->
<?php endif; ?>
<footer class="entry-meta">
<?php if ( 'post' == get_post_type() ) : ?>
<?php get_template_part('entry-meta', get_post_format() ); ?>
<?php endif; ?>
</footer><!-- #entry-meta -->
</article><!-- #post-<?php the_ID(); ?> -->
<!-- END: content.php -->
https://codex.wordpress.org/Function_Reference/the_post_thumbnail
example 1. To link Post Thumbnails to the Post Permalink in a specific loop, use the following within your Theme's template files:
<?php if ( has_post_thumbnail()) : ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >
<?php the_post_thumbnail(); ?>
</a>
<?php endif; ?>
I have my theme page.php as:
<?php /* The loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?> >
<header class="entry-header">
<div class="hd"><?php the_title(); ?></div>
<?php if ( has_post_thumbnail() && ! post_password_required() ) : ?>
<div class="video"><?php the_post_thumbnail(); ?></div>
<?php endif; ?>
<div class="hd"><?php //the_title(); ?></div>
</header><!-- .entry-header -->
<?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>' ) ); ?>
<!-- .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( '', true ); ?>
<?php endwhile; ?>
And I have made three page in wordpress blog, image and news and i also assigned them category for each. now i have installed php-exec plugin . Now I am writing some php code in page editor to retrieve blog data...
It working fine but it fetching data twice and now got it is becouse of page.php .
So can i have some condition on page.php if i am trying to fetch some data by cotegory then page.php data would not be display...
here is my code which i applied on blog page editor
<?php if (query_posts('cat=63&showposts=5')) : ?>
<?php while (have_posts()) : the_post();
// do whatever you want
?>
<div class="gallery_views">
<div class="hd"><?php the_title(); ?></div>
<?php // get_template_part( 'content', get_post_format() ); ?>
<?php // cup_post_nav(); ?>
<?php the_post_thumbnail(); ?>
<?php comments_template(); ?>
<b><?php the_title(); ?></b>
</div>
<?php endwhile; ?>
<?php else : ?>
Thanks in advance..
<?php if (query_posts('cat=63&showposts=5')) : ?>
<?php while (have_posts()) : the_post();
// do whatever you want
?><div class="gallery_views">
<div class="hd"><?php the_title(); ?></div>
<?php // get_template_part( 'content', get_post_format() ); ?>
<?php // cup_post_nav(); ?>
<?php the_post_thumbnail(); ?>
<?php comments_template(); ?>
<b><?php the_title(); ?></div>
<?php
break;
endwhile;
?>
<?php else : ?>
Add a break in your while, it'll stop after the first loop.