Hi there,
I've been sitting in front of the computer for 8 hours straight now to try to figure out how to create a custom [strong]single.php[/strong] page.
What I have done is to take a javascript slideshow gallery and integrate it into Wordpress with custom fields for the images, to be able to show a slideshow within a post.. So what I basically want to do is to "check if there is a slideshow present (by verifying if there is content in the first custom field), and then I want to display the single post as follows.
If there is a slideshow I want to show the page like this:
- Post Title
- Entry Meta
- Slide Show
- Post Content
- Entry Utility
And if there is no slideshow then I want to show it like this:
- Post Title
- Entry Meta
- Post Content
- Entry Utility
The code I have managed to build so far inside the single.php is like this:
<?php
// calling the header.php
get_header();
// action hook for placing content above #container
thematic_abovecontainer();
?>
<div id="container">
<div id="content">
<!-- Start the Loop. -->
<?php if ( have_posts() ) : while ( have_posts() ) : the_post();
// call the function in our functions.php file
bd_parse_post_variables(); // TO ACCESS VARIABLES FROM THE CUSTOM FIELDS
// these variables are now available:
// $post_var
// $post_images and $post_images_label
// $post_links and $post_links_label
// $post_files and $post_files_label
?>
<?php
global $post;
$postimageurl = get_post_meta($post->ID , 'image1', true); // To see if there is something in the custom field 'image1'
//if there is then print out the post title, entry meta and content
if ($postimageurl) {?>
<h1 class="entry-title"><?php echo __((get_the_title($post->ID))); ?></h1>
<div class="entry-meta"><a href="#">meta</a></div>
<!-- Display the Post's Content in a div box. -->
<div class="entry-content">
<!-- Display our Custom Field -->
<div id="photos" class="galleryview">
<?php while(count($post_images) > 0): ?>
<div class="panel">
<img src="http://capellasantroc.cat/wp-content/uploads/<?php echo array_shift($post_images); ?>" />
<div class="panel-overlay"></div>
</div>
<?php endwhile; ?>
</div>
<?php echo __((the_excerpt())); ?>
<?php // if there is nothing in the field then print out the normal post ?>
<?php } else { ?>
<?php // action hook creating the single post
thematic_singlepost();
?>
<?php } ?>
<!-- Stop The Loop (but note the "else:" - see next line). -->
<?php endwhile; else: ?>
<!-- The very first "if" tested to see if there were any Posts to -->
<!-- display. This "else" part tells what do if there weren't any. -->
<p>Sorry, no posts matched your criteria.</p>
<!-- REALLY stop The Loop. -->
<?php endif; ?>
<?php
// create the navigation above the content
thematic_navigation_above();
// calling the widget area 'single-top'
get_sidebar('single-top');
// calling the widget area 'single-insert'
get_sidebar('single-insert');
// create the navigation below the content
thematic_navigation_below();
// calling the comments template
thematic_comments_template();
// calling the widget area 'single-bottom'
get_sidebar('single-bottom');
?>
</div><!-- #content -->
</div><!-- #container -->
</div>
<?php
// action hook for placing content below #container
thematic_belowcontainer();
// calling the standard sidebar
thematic_sidebar();
// calling footer.php
get_footer();
?>