PDA

View Full Version : Home page content



marko3333
12-10-2010, 06:28 PM
Hi,

There is something wrong with the home page. I can only write Posts on the home page. With my theme there is a section for the home page which has a slideshow of the posts and then below there is a section for writing home page custom content. When I write something and save it, it doesn't show up on the webpage. If anyone has any ideas, that would be great.

http://www.pokerpouch.com

Here is the home.php

<?php
global $shortname;

$number_posts = (get_option('posts_per_page')) ? get_option('posts_per_page') : 6;

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;

if (is_active_widget('widget_myFeature')) {
$category = "showposts=$posts&cat=-".$options['category'];
} else {
$category = "showposts=".$posts;
}
query_posts($category."&paged=$paged&showposts=$number_posts");

get_header();

//Featured Content Gallery section on the homepage
if (is_home() && !isset($_GET['paged'])) :?>
<?php if(function_exists('gallery_styles')) :?>
<div id="fcg-slides">
<?php include (ABSPATH . '/wp-content/plugins/featured-content-gallery/gallery.php'); ?>
</div>
<?php elseif(isset($_GET['preview']) && isset($_GET['template'])):?>
<div id="fcg-slides">
<img src="<?php bloginfo('template_url')?>/images/fcg-feature-demo.jpg" alt="Plugin Demo" />
</div>
<?php endif;?>
<?php endif; ?>

<?php if (have_posts()) : ?>
<?php
$i = 0;
while (have_posts()) {
the_post();
include(dirname(__FILE__).'/post.php');

//Insert custom content between posts
if ($html = get_option($shortname.'_custom_html_'.$i)) {
echo "<div class='customhtml'>$html</div>";
}
$i++;
}
?>
<?php endif; ?>

<div class="navigation">
<p class="alignleft"><?php previous_posts_link('Latest posts'); ?></p>
<p class="alignright"><?php next_posts_link('Older posts'); ?></p>
</div>

<?php get_footer(); ?>

renegadeandy
12-10-2010, 08:28 PM
Is this possibly just a setting you can change in the WordPress admin panel?!

If allow custom content is enabled (if there is a setting)

perhaps it while loop is not being executed i.e getPosts() is returning 0?

marko3333
12-10-2010, 10:21 PM
Hi,

thanks for the response, the only way that I can write something on the home page custom content is if I have a post first. I don't want to have any posts on the home page. Its kind of a weird set-up... Is there any way that I can change this?
Thanks for your help

Mark

renegadeandy
12-10-2010, 10:51 PM
Yeah there is!!!

the bit of code you care about is this bit:



<?php if (have_posts()) : ?>
<?php
$i = 0;
while (have_posts()) {
the_post();
include(dirname(__FILE__).'/post.php');

//Insert custom content between posts
if ($html = get_option($shortname.'_custom_html_'.$i)) {
echo "<div class='customhtml'>$html</div>";
}
$i++;
}
?>
<?php endif; ?>


So what that is saying is - :

If we have posts

--for each post that we do have insert some custom content + continue as we were!
If you wanted a bit of custom code on EVERY home page regardless of the number of posts you have you could just add this bit of code above the coded section I pasted above :




<?php echo "<h2>Demo custom content</h2>" ?>



so your total code would look
something like this:



<?php
global $shortname;

$number_posts = (get_option('posts_per_page')) ? get_option('posts_per_page') : 6;

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;

if (is_active_widget('widget_myFeature')) {
$category = "showposts=$posts&cat=-".$options['category'];
} else {
$category = "showposts=".$posts;
}
query_posts($category."&paged=$paged&showposts=$number_posts");

get_header();

//Featured Content Gallery section on the homepage
if (is_home() && !isset($_GET['paged'])) :?>
<?php echo "<h2>Demo custom content</h2>"; ?>
<?php if(function_exists('gallery_styles')) :?>
<div id="fcg-slides">
<?php include (ABSPATH . '/wp-content/plugins/featured-content-gallery/gallery.php'); ?>
</div>
<?php elseif(isset($_GET['preview']) && isset($_GET['template'])):?>
<div id="fcg-slides">
<img src="<?php bloginfo('template_url')?>/images/fcg-feature-demo.jpg" alt="Plugin Demo" />
</div>
<?php endif;?>
<?php endif; ?>

<?php if (have_posts()) : ?>
<?php
$i = 0;
while (have_posts()) {
the_post();
include(dirname(__FILE__).'/post.php');

//Insert custom content between posts
if ($html = get_option($shortname.'_custom_html_'.$i)) {
echo "<div class='customhtml'>$html</div>";
}
$i++;
}
?>
<?php endif; ?>

<div class="navigation">
<p class="alignleft"><?php previous_posts_link('Latest posts'); ?></p>
<p class="alignright"><?php next_posts_link('Older posts'); ?></p>
</div>

<?php get_footer(); ?>


Now that may need some changes - because I couldnt check the code + try running it because obviously I dont have access to your setup!

Hope this helps.

marko3333
12-11-2010, 12:48 AM
Hi,

Thanks for the help, I put the code in and on the home page says "Demo custom content" above the slide. I checked to see if I could write anything and it still doesn't work. Do you have any other suggestions? thanks again for the help

Mark