WordPress Blog Not Displaying Posts - php

I've created a custom template using the twentythirteen template. When I activate the template the blog posts disappear from the front page. I've used the same process to make the new template as I did for my own.
You can see my blog page here, http://www.gnarlydigital.com/blog/ and the new blog that I'm working on is here, http://www.flowdirectpumps.com/news/.
I've tripled checked all the code and both templates are identical. I've uploaded the Gnarly Digital template and it works.
Can anyone see anything obvious?
This is the index.php file
<?php get_header(); ?>
<div class="container pageContent">
<div class="row">
<div class="col-md-12">
<?php if ( have_posts() ) : ?>
<?php /* The loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', get_post_format() ); ?>
<?php endwhile; ?>
<?php twentythirteen_paging_nav(); ?>
<?php else : ?>
<?php get_template_part( 'content', 'none' ); ?>
<?php endif; ?>
</div>
</div>
</div>
<?php get_footer(); ?>

Related

Removing automatic PHP page heading* (not title)

So I'm working on my blog page which uses a different page template, PHP isn't exactly my forte, and I feel like it should be a simple solution to remove the page header, but its all a bit out of my reach. This is my site, and my code looks like this:
<?php
/**
* Template Name: Blog
*/
get_header();
get_template_part( "closer" ); ?>
<div class="container">
<div class="row">
<div id="primary" <?php bavotasan_primary_attr(); ?>>
<?php
if ( have_posts() ) :
while ( have_posts() ) : the_post();
get_template_part( 'content', get_post_format() );
endwhile;
bavotasan_pagination();
else :
get_template_part( 'content', 'none' );
endif;
?>
</div>
<?php get_sidebar(); ?>
</div>
</div>
try to change this way,
Appearance > Editor > content-page.php (on the right side bar)>
Find: this statement
the_title();
and simply comment it out.
//the_title();
or do the above change in content.php file
I gave up, and used display: none in my CSS. Probably not the best way to go, but it works.

Wordpress loop for static front page template not working

I have a static wordpress front page. I want the code that works on my regular blog template to work on the homepage too.
Currently, it only shows one post. The code in the main index.php is this...
<?php if ( have_posts() ) : ?>
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', get_post_format() );
?>
<?php endwhile; ?>
<?php wp_pagenavi(); ?>
<?php else : ?>
<?php get_template_part( 'content', 'none' ); ?>
<?php endif; ?>
content.php calls this....
<div class="col-md-4">
<?php the_excerpt(); ?>
</div><!-- /col-md-4 -->
This works great while on the blog page. But i can't get this exact same content on to the static home page. I know I need a different query for homepage but no idea what that is. Any help appreciated!
Your code looks right to me, you can try to reset the loop and query the posts again.
<?php
rewind_posts();
query_posts( $args );
while ( have_posts() ) : the_post();
?>
<!-- Do stuff... -->
<?php endwhile; ?>
global $query_string;
query_posts($query_string.'&post_type=post&posts_per_page=15');
Adding this on top of your code should work. Try it out.

wordpress custom page template displaying posts twice

I'm not a wordpress expert, so wondering if someone can help me. I created a custom page template for one page so I could aggregate and display posts from one category on that page. However, I created one post in that category so far, but it gets displayed twice on the page. The posts that get pulled in from the category get displayed in the "div id=main" div. Here is the page template code:
<?php /* Template Name: Deals Page */ ?>
<?php get_header(); ?>
</div>
//<?php while ( have_posts() ) : the_post(); ?>
<div id="title-bar">
<h1 class="bar-entry-title container"><?php the_title(); ?></h1>
</div>
<?php endwhile; ?>
<div class="container col-md-12"><!-- restart previous section-->
<div id="primary" class="content-area col-md-8">
<main id="main" class="site-main" role="main">
<?php query_posts('category_name=deals &posts_per_page=20'); ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php the_title( '<h2>', '</h2>' ); ?>
<?php the_content(); ?>
//<?php get_template_part( 'content', 'page' ); ?>
<?php endwhile; // end of the loop. ?>
<?php
// If comments are open or we have at least one comment, load up the comment template
if ( comments_open() || '0' != get_comments_number() )
comments_template();
?>
</main><!-- #main -->
</div><!-- #primary -->
<?php get_sidebar(); ?>
<?php get_sidebar('footer'); ?>
<?php get_footer(); ?>
Do you know why it is displaying the post twice? I can't see why.
You are running two loops. Your comment line is outside of the PHP on the 5th line.
Change this //<?php while ( have_posts() ) : the_post(); ?>
to this <?php // while ( have_posts() ) : the_post(); ?>
Also comment out the first <?php endwhile; ?> around line 9 or else you will get a PHP error

Twentyeleven used post format

I am developing a theme and using twentyeleven theme as my base theme
Twenty eleven uses <?php get_template_part( 'content', get_post_format() ); ?>
To fetch post
SO this codes work properly in index.php
But when i use in custom page template
it doesnt get fomratted propely
<?php
/*
Template Name: Vote Page Template
*/
get_header(); ?>
<div id="primary">
<div class="container">
<head>
</head>
<?php if ( have_posts() ) : ?>
<?php /* Start the Loop */ ?>
<?php while ( have_posts()) : the_post(); ?>
<?php get_template_part( 'content', get_post_format() ); ?>
<?php endwhile; ?>
<?php endif; ?>
</div>
</div>
<?php get_footer(); ?>
Proper Format
Unproper Format

issue with post format in wordpress on a custom page template

Hey guys so I am trying to have a loop run to get all the post that are within a certain category on a page, for some reason nothing happens though?
Code :
<?php
/*
Template Name: djequip
*/
get_header(); ?>
<div id="primary">
<div id="content" role="main">
<?php /*query_posts('test');uncategorized*/
if ( have_posts() ) : while ( have_posts() ) : the_post();
get_template_part( 'content', get_post_format() );
endwhile; endif; ?>
</div><!-- #content -->
</div><!-- #primary -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
Let me know if you can help, thanks a ton!
<?php /* Template Name: TEMPLATE NAME */ ?>
<?php get_header();?>
<?php query_posts('category_name=CATEGORY NAME'); ?>
<?php while (have_posts()) : the_post(); ?>
<?php the_excerpt(); ?>
<?php endwhile; ?>
Is this what you mean?
the_excerpt
can be changed to
the_content
Also I'd just like to add that you can put divs in there around the WP PHP.

Categories