Wordpress Use Theme for Blog Only - wordpress

I wish to use the Pinbin theme for my Wordpress blog only. I have created a custom theme for everything else, but for the blog, I would like to use this theme.
I took the main index php file from this template, along with the header and footer files. I renamed the header and footer files, and changed the header/footer calls to these files rather than the ones used by the rest of the site.
I assigned the theme to a page, but it's not showing any posts. The code is as follows:
<?php if (have_posts()) : ?>
<div id="post-area">
<?php while (have_posts()) : the_post(); ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php if ( has_post_thumbnail() ) { ?>
<div class="pinbin-image"><?php the_post_thumbnail( 'summary-image' ); ?></div>
<div class="pinbin-category"><p><?php the_category(', ') ?></p></div>
<?php } ?>
<div class="pinbin-copy"><h2><a class="front-link" href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
<p class="pinbin-date"><?php the_time(get_option('date_format')); ?> </p>
<?php the_excerpt(); ?>
<p class="pinbin-link">→</p>
</div>
</div>
<?php endwhile; ?>
Any ideas on why I'm not seeing anything?
Thanks, S

The index.php file is used as a backup if there's no other template defined, you'll have to edit a different file if you want to edit a certain page type. See template hierarchy in the WordPress codex.
+
You forgot an endif; at the bottom of your file.

Related

Wordpress - Adding editor content to a page with a template

In most Wordpress themes, they make use of Wordpress templates that can be chosen for a page. Now, in this particular theme, when you choose a template for a page, it discards the content you add in the editor section.
Surely you should be able to enable this somewhere? How can this be done or does it differ from theme to theme?
Add the loop and the_content() template tag in the page template. Look at the page.php template in your theme folder for the exact markup needed for your theme:
// Start the Loop.
while ( have_posts() ) : the_post();
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php the_title( '<header class="entry-header"><h1 class="entry-title">', '</h1></header>' ); ?>
<div class="entry-content">
<?php
the_content();
wp_link_pages();
?>
</div><!-- .entry-content -->
</article><!-- #post-## -->
<?php
endwhile;

Custom templates, custom post type, and single page problems

I have set up a custom post type for a few sub sections of the website I am currently working on in wordpress. I need the custom post types to feed onto a template (which I have working) but I have a few questions and non working things. The read more link is not working, as in not showing up at all even? Also when I click the title links n the posts to go to the full post, they go to the correct url but there is no content in the body. I'm thinking I need to add more in the custom template.
Here is the template code :
<?php
/* Template Name:News */
?>
<?php get_header(); ?>
<div class="decade1">
<ul id="news_list">
<?php global $post; query_posts( 'post_type=news&orderby=ID&order=desc' ); while (have_posts()) : the_post(); ?>
<li>
<div class="fea_del">
<h2><?php the_title(); ?></h2>
<p><?php the_field('post_content',$post->ID); ?></p>
<a <?php $p=get_permalink( $post->ID ); ?> href="<?php echo $p; ?>" class="entire_job">Read More</a>
</div>
</li>
<?php endwhile; wp_reset_query(); ?>
</ul>
</div>
<?php get_footer(); ?>
The most important issue is the posts not showing up on their individual pages. Thanks!!

Why the_content doesn't work in wordpress single.php

My code:
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div class="posts" id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<h2>
<?php the_title(); ?>
</h2>
<div class="entry">
<?php the_content();?>
</div>
</div><!--post end-->
<?php endwhile; ?>
<?php else : ?>
<h3>no content</h3>
<?php endif; ?>
I put the code into my customed wordpress theme file single.php. Why it can't output the post content, it can output the post title. thank you.
You can try the following to see if it works instead of the_content
<?php echo wpautop($post->post_content); ?> // content with p tags
<?php echo $post->post_content; ?> //without p tags
Also an option
<?php echo wpautop( get_the_content() ); ?> // content with p tags
see if that works for you.
When developing Wordpress themes it's advisable for you to switch the debug mode (found on your installation's root in wp-config.php) to true. This will alert you if you have any errors.
In your case, try out the <?php the_excerpt(); ?>.
Also, this may sound a bit dumb, but do you actually have posts? Not pages or rather content in that post?
Many a times i have come across queries from developers or first time theme developers about not able to show the_content() on their custom template page.
The issue is that the_content() function runs inside the WP loop so for example
if (have_posts()) {
while (have_posts()) {
the_post();
the_content();
}
} ?>
This will work, but in some cases you want to call the function outside the loop – the solution for that is:
echo $post->post_content;

Page contents not showing on wordpress

What kind of WordPress function do you use to show the page contents?
I used the_content to show the post contents, but what about the page contents?
I have tried everything, but I haven't found a function that displays the page contents of WordPress.
Also, I have created a basic page.php file, and in the file I have:
<div id="pages">
<li><?php wp_list_pages() ?></li>
</div>
Now, why do my index.php have my list of pages even though I didn't use the inlcude or require function?
Keep in mind I created my own theme and site, and I'm trying to put it in WordPress for the first time.
Thanks!!
The function wp_list_pages() lists all the pages. If you want to list all the recent posts you should use
index.php
<?php get_header(); ?>
<?php while ( have_posts() ) : the_post(); ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<h2 class="entry-title"><?php the_title(); ?></h2>
<div class="entry-content">
<?php the_content(); ?>
</div>
</div>
<?php endwhile; // end of the loop. ?>
<?php get_sidebar(); // If you have sidebar ?>
<?php get_footer(); ?>
page.php
<?php get_header(); ?>
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<h2 class="entry-title"><?php the_title(); ?></h2>
<div class="entry-content">
<?php the_content(); ?>
</div>
</div>
<?php endwhile; // end of the loop. ?>
<?php get_sidebar(); // If you have sidebar ?>
<?php get_footer(); ?>
Make sure you check the default twentyeleven and twentyten themes to get idea of how to code WordPress Themes.

WordPress: next_posts_link() doesn't work before page template loop

I have an archive page template that I've built that has a successful navigation at the end of the loop. However, now I want to add an additional navigation at the top. However, after I copied and pasted the exact code, the 'Previous Entries' displays and links correctly, but 'Next Entries' never shows up as it does in the bottom navigation.
In my page-archive.php file, this is gist of my code:
<div class="navigation top">
<?php next_posts_link('Next Entries') ?> <!-- Doesn't appear to show up! -->
<?php previous_posts_link('Previous Entries') ?>
</div>
<?php $page = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts("showposts=1&paged=$page");
while ( have_posts() ) : the_post() ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<h3><a href="<?php the_permalink() ?>" ><?php the_title(); ?></a></h3>
<?php the_content(); ?>
</div>
<?php endwhile; ?>
<div class="navigation bottom">
<?php next_posts_link('Next Entries') ?>
<?php previous_posts_link('Previous Entries') ?>
</div>
I understand that a Page template is not the ideal method to create an archive page, so if there is a different method for producing a full customizable archive page, please inform me!
Currently, I'm using my home.php file to display static content, so the page-archive.php is a method to direct users to the actual "Blog" portion of the site.
Try to put this string:
<?php $page = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts("showposts=1&paged=$page");?>
to the very top of the page. You need to do that because next_posts_link and prev_posts_link calls use some global variables set by query_posts call.

Resources