Trying to Edit 'Blog' Template, to display full posts not excerpts - php

I'm working with a theme I paid for a long time ago, customized a bunch graphically and with the CSS and am pulling pieces of it into separate directory via iFrame Fancybox.
BUT, I'm trying to reformat the blog template - as currently it renders and populates when updated as:
Title
etc etc
A few lines of Content here/ then cuts of mid sentence.
Read More , etc // And these links just refresh the page?
So, I'm a bit novice with PHP & am wondering how I'd edit the below 'Blog Template' code to allow full posts text to display, not excerpts that are cut off in the middle:
<?php
/*
Template Name: Blog Template
*/
get_header();
?>
<div id="content">
<?php
//get exclusions for categories
$exclude = get_option($shortname.'_exclude_categories');
$exclude = str_replace(',,','|-',$exclude);
$exclude = str_replace(',','-',$exclude);
$exclude = substr($exclude, 0, -1);
$exclude = str_replace('|',',',$exclude);
query_posts('posts_per_page=&paged='.$paged.'&cat='.$exclude);
if(have_posts()) : while(have_posts()) : the_post();
?>
<div class="entry" id="post-<?php the_ID(); ?>">
<h1><?php the_title(); ?></h1>
<p class="meta">Added by <?php the_author_posts_link() ?> on <?php the_time('F jS, Y') ?>, filed under <?php the_category(', ') ?></p>
<div class="entry-content">
<p><?php the_post_thumbnail('wide'); ?></p>
<?php the_excerpt('Read the rest of this entry »'); ?>
<p><?php comments_popup_link('No Comments', '1 Comment', '% Comments'); ?> ~ Add your thoughts | Continue Reading</p>
</div><!-- e: entry content -->
</div><!-- e: entry -->
<?php
endwhile;
//endif;
?>
<div class="paginate">
<?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } ?>
</div>
<?php else : ?>
<h2 class="center">Not Found</h2>
<p class="center">Sorry, but you are looking for something that isn't here.</p>
<?php get_search_form(); ?>
<?php endif; ?>
</div><!-- e: content -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>

Replace the_excerpt() with the_content(), that's it.

Related

Adding shortcodes in wordpress php file

Hello im running the wishlist member plugin in my wordpress site but it seems that it doesnt block the archives pages. What Im trying to do is use this 2 shortcodes so it blocks the content the it shows in the archive page. How can I add this open and close shortcodes to the php file below:
[wlm_ismember] [/wlm_ismember]
This is the php code im using to put the shortcodes
<?php echo do_shortcode('[shortcode]');?
This is the file im working with, I want to put the [wlm_ismember] shortcode above <article <?php post_class(); ?>>, and [/wlm_ismember] below </article> so the article doesnt show.
<?php /* Loop Template used for index/archive/search */
$options = get_option('mh_options');
$excerpt_length = empty($options['excerpt_length']) ? '125' : $options['excerpt_length'];
?>
<?php echo do_shortcode('[wlm_ismember]');?>
<article <?php post_class(); ?>>
<div class="loop-wrap clearfix">
<div class="loop-thumb">
<a href="<?php the_permalink(); ?>">
<?php if (has_post_thumbnail()) { the_post_thumbnail('loop'); } ?>
</a>
</div>
<header class="loop-data">
<h3 class="loop-title"><?php the_title(); ?></h3>
<p class="meta"><?php $date = get_the_date(); echo $date; ?> // <?php comments_number(__('0 Comments', 'mh'), __('1 Comment', 'mh'), __('% Comments', 'mh')); ?></p>
</header>
<?php the_content(); ?>
</div>
</article>

Wordpress post not showing up title when redirected from permalink

I've created my own theme. On my front page (index.php), I am showing a snippet of posts, with 'Read More' link in the end. So when I click read more, I get redirected to that post's page (localhost/wordpress/2014/post-title/), but there, I can't see the title of the post, but all the content.
Code for snippet in index.php
<div id="blog" class="container">
<?php query_posts('showposts=3'); ?>
<?php if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?>
<div class="post col-md-4">
<h3><?php the_title(); ?></h3>
<div class="entry">
<?php the_post_thumbnail(); ?>
<?php the_excerpt(__('(more…)')); ?>
<p class="postmetadata">
<?php _e('Filed under:'); ?> <?php the_category(', ') ?> <?php _e('by'); ?> <?php the_author(); ?><br />
<?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?> <?php edit_post_link('Edit', ' | ', ''); ?>
</p>
</div>
</div>
<?php endwhile; ?>
<div class="navigation">
<?php posts_nav_link(); ?>
</div>
<?php endif; ?>
</div>
So how do I get the post title there?
I think people can't help you to solve this with this code. If that post's page doesn't show the post title, then you need to check on single.php
Probably, you may have forgot to add the <?php the_title(); ?> part in that single.php file.

Wordpress Post Thumbnail Issue (Only 1 thumbnail on frontpage)

I'm using the below code on index.php file of twentyeleven
get_header(); ?>
<div id="primary">
<div id="content" role="main">
<?php if ( have_posts() ) : ?>
<?php twentyeleven_content_nav( 'nav-above' ); ?>
<?php query_posts('cat=4&showposts='.get_option('posts_per_page')); ?>
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<div class="post-thumb-title">
<?php the_post_thumbnail(array(632,305));?>
<p class="thumb-title"><?php the_title(); ?></p>
</div>
<?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 -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
As you can see from the code above, I'm only showing the posts with Cat ID = 4 and I'm using css to overlay the title on the image thumbnail which is generated using the function "the_post_thumbnail" with a custom size.
The issue is that the frontpage is only showing the title of the posts and thumbnail only for the 1st post.
You can see the website here: http://fusion.fusionconstruction.co.uk/
Links to other posts with category ID 4 selected:
http://fusion.fusionconstruction.co.uk/fusion-media-at-revolution-round-1/
http://fusion.fusionconstruction.co.uk/fusion-launch-new-website-for-dean-downing/
I would like to display all the posts similar to the 1st one.
Thanks!
<?php query_posts('cat=4&showposts='.get_option('posts_per_page')); ?>
should probably be
<?php query_posts('cat=4&showposts='.get_option('posts_per_page')); ?>
That is, you shouldn't urlencode the ampersand. Hopefully this is what is messing up your query.
Also, the_post_thumbnail() will show the post's featured image, so for it to produce a thumbnail you need to make sure that all the posts have a featured image.

Wordpress Page Template Not Rendering

Our blog page is supposed to look something like this: http://livedemo00.template-help.com/wordpress_33821/?page_id=174
However it ends up looking like this - completely empty!
This is despite the fact that the page theme is set correctly and the template file contains the following code:
<?php
/**
* Template Name: Blog
*/
get_header(); ?>
<div class="box clearfix color2">
<div id="content" class="three_fourth">
<?php
$temp = $wp_query;
$wp_query= null;
$wp_query = new WP_Query();
$wp_query->query('showposts=5'.'&paged='.$paged);
?>
<?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header>
<h2><?php the_title(); ?></h2>
<div class="post-meta">
<div class="fleft">Posted in: <?php the_category(', ') ?> | <time datetime="<?php the_time('Y-m-d\TH:i'); ?>"><?php the_time('F j, Y'); ?> at <?php the_time() ?></time> , by <?php the_author_posts_link() ?></div>
<div class="fright"><?php comments_popup_link('No comments', 'One comment', '% comments', 'comments-link', 'Comments are closed'); ?></div>
</div><!--.post-meta-->
</header>
<?php echo '<div class="featured-thumbnail">'; the_post_thumbnail(); echo '</div>'; ?>
<div class="post-content">
<div class="excerpt"><?php $excerpt = get_the_excerpt(); echo my_string_limit_words($excerpt,50);?>Read more</div>
</div>
</article>
<?php endwhile; ?>
<?php if ( $wp_query->max_num_pages > 1 ) : ?>
<nav class="oldernewer">
<div class="older">
<?php next_posts_link('« Older Entries') ?>
</div><!--.older-->
<div class="newer">
<?php previous_posts_link('Newer Entries »') ?>
</div><!--.newer-->
</nav><!--.oldernewer-->
<?php endif; ?>
<?php $wp_query = null; $wp_query = $temp;?>
</div><!--#content-->
<?php get_sidebar(); ?>
</div>
<?php get_footer(); ?>
Unfortunately this theme doesn't have any documentation so I'm forced to find my own solution.
Actually I already faced this situation in WordPress.
Its not fault of your code. Might be WordPress Bug.
Try to change your page name once.
Like
<?php
/**
* Template Name: Blog_new
*/
?>
And login again and check if it is showing new custom page option or not.

Wordpress: single.php doesn't display the_content()

I'm creating a custom Wordpress Theme and I can't seem to get the single.php template to work. Below is the code I have written. The title comes up but the content doesn't. Any Ideas why it isn't?
<?php
/**
* The Template for displaying all single posts.
*/
get_header(); ?>
<div id="content" role="main">
<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
<h2><?php the_title(); ?></h2>
<small><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></small>
<div class="entry">
<?php the_content(); ?>
</div>
<p class="postmetadata"><?php the_tags('Tags: ', ', ', '<br />'); ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?> <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p>
</div>
</div><!-- #content -->
See here for a screenshot of the output:
the_content() is not displaying because it has to be inside the The Loop - take a look at the docs here »
You need to change your code to this:
if ( have_posts() ) : while ( have_posts() ) : the_post();
the_content();
endwhile;
else:
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
endif;
You can leave out the else if you are always sure you have content to display :) Or just take look at the original single.php where you can find The Loop always surrounds the_content()
edit:
Here is the whole single.php you might wanna use/start with:
<?php
/**
* The Template for displaying all single posts.
*/
get_header(); ?>
<div id="content" role="main">
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
<h2><?php the_title(); ?></h2>
<small><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></small>
<div class="entry">
<?php the_content(); ?>
</div>
<p class="postmetadata"><?php the_tags('Tags: ', ', ', '<br />'); ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?> <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p>
</div>
<?php endwhile; endif; ?>
</div><!-- #content -->
I just simply put the_post() above the_content() and it worked
I'm writing this because I had a similar problem. My content wasn't showing up. However my call to the_content was inside the The Loop. Furthermore, this was working on my development server but not on the production server.
I was able to solve this by removing all the plugins and then, one by one, add them back in.
Also, of course, if you have caching enabled, a good first step is to clear the cache.

Categories