Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Custom Page template, Not displaying page, but displaying post. WordPress

  • SOLVED

**********UPDATE*******************
Looks like Featured Content Gallery is causing my problem, I disable that plugin and all works ok, enable it and all page links point to the last featured post

Anyone else having issues with Featured Content Gallery and WP 3.1.2?

***************************************


I have a few PAGES, and have the following code to display the page, but it is showing the last few POST instead of the actual page data.


<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

<div class="post">
<h1><?php the_title(); ?></h1>
<?php the_content(__('Read more'));?><div class="clear"></div><?php edit_post_link('(Edit)', '', ''); ?>
</div>

</div>

<?php endwhile; else: ?>

<p><?php _e('Sorry, no posts matched your criteria.'); ?></p><?php endif; ?>

Answers (7)

2011-04-29

Ryan Riatno answers:

Can you give the url of your website? as your code should be work fine..


Ryan Riatno comments:

I have tested it (Featured Content Gallery) version 3.2.0 with wp 3.1.2 and works just fine, just a javascript problem.
What version of Featured Content Gallery you have used?


69developer comments:

Latest versions of both.

It works ok if I select: Select here to use individual post or page IDs and put in the post id's

It does not work if I select:
Select here to use category selection and put in featured for my category.
The gallery will work but my pages quit working and try to show the last post.


Ryan Riatno comments:

Make sure you have to fill the exact name of category. For example "featured" is not the same with "Featured".


69developer comments:

its the exact name.


Ryan Riatno comments:

Try to change the query_post in featured content plugin. Open "options.php" in plugin folder,
and around line '55' change the "category_name" with "cat"

<?php query_posts('category_name=' . get_option('gallery-category') . '&showposts=' . get_option('gallery-items')); ?>
change to :
<?php query_posts('cat=' . get_option('gallery-category') . '&showposts=' . get_option('gallery-items')); ?>

And fill the category ID in plugin options page. You can find the category id in category page when you hover it, and notice the number like "...taxonomy=category&tag_ID=3...".

2011-04-29

AdamGold answers:

Where is this code located? Is this the whole code?


69developer comments:

This is the whold code for the page template.


<?php
/*
Template Name: SubPage
*/
?>
<?php get_header(); ?>

<div id="content">

<div id="contentleft">

<div class="postarea">

<h3>TEST</h3>

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

<div class="post">
<h1><?php the_title(); ?></h1>
<?php the_content(__('Read more'));?><div class="clear"></div><?php edit_post_link('(Edit)', '', ''); ?>
</div>

</div>

<?php endwhile; else: ?>

<p><?php _e('Sorry, no posts matched your criteria.'); ?></p><?php endif; ?>

</div>



</div>

<?php get_footer(); ?>


AdamGold comments:

Try to go to Settings -> Reading in your WordPress Admin panel and set the “Front page displays” settings to "A static page" and not "Recent posts".


69developer comments:

I had already had that set to static page.


AdamGold comments:

Try

<?php
global $post;
query_posts('p=' . $post->ID);

if (have_posts()) : while (have_posts()) : the_post(); ?>



<div class="post">

<h1><?php the_title(); ?></h1>

<?php the_content(__('Read more'));?><div class="clear"></div><?php edit_post_link('(Edit)', '', ''); ?>

</div>



</div>



<?php endwhile; else: ?>



<p><?php _e('Sorry, no posts matched your criteria.'); ?></p><?php endif; ?>


69developer comments:

Seems like on all pages the value of the Post->ID is the same.


AdamGold comments:

Try echoing wp_query and paste here the result:
var_dump($wp_query);


AdamGold comments:

Sorry, forgot to call the variable:
global $wp_query;
var_dump($wp_query);

2011-04-29

John Cotton answers:

What is the name of the file that contains that code?


69developer comments:

page-sub.php


John Cotton comments:

And if the slug of the page you want to display "sub" or have you set this as the page template in the dashboard?


69developer comments:

Set as page template in the dashboard.

2011-04-29

David Navarrete answers:

rename the template to subpage.php

greatings


69developer comments:

Tried that, same results.


David Navarrete comments:

you re-add the template on the wordpress admin?


69developer comments:

I renamed the file and then changed the template for the page to the new file.

2011-04-29

Kannan Sanjeevan answers:

Try renaming the template page as <strong>sub-page.php</strong>


69developer comments:

Tried that, same results.


Kannan Sanjeevan comments:

Try this


<?php

/*

Template Name: SubPage

*/

?>

<?php get_header(); the_post();?>



<div id="content">



<div id="contentleft">



<div class="postarea">



<div class="post">

<h1><?php the_title(); ?></h1>

<?php the_content();?>

<div class="clear"></div><?php edit_post_link('(Edit)', '', ''); ?>

</div>



</div>


</div>


</div>



<?php get_footer(); ?>

2011-04-29

Hardeep Singh answers:

Please share site URL and list of files in the theme.

This could be page.php related problem.

2011-04-30

Just Me answers:

Maybe you can take a look at this page http://www.featuredcontentgallery.com/install-setup/
Use the plugin in it's default setting first. If it works start fine tuning it.

All you need to add is the code to the theme file where you want it to show up and the custom field articleimg to the post you want to use it in. The value should be the FULL path to the image.

I hope this helps.