Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the Content Width theme feature, an attachment loop, and a search results loop #6

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@
add_theme_support( 'automatic-feed-links' );


/*-----------------------------------------------------------------------------------*/
/* Set the content width based on the theme's design and stylesheet
/*-----------------------------------------------------------------------------------*/
if ( ! isset( $content_width ) )
$content_width = 720; /* pixels */


/*-----------------------------------------------------------------------------------*/
/* register main menu
/*-----------------------------------------------------------------------------------*/
Expand Down
149 changes: 147 additions & 2 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,76 @@
<div id="primary">
<div id="content" role="main">

<?php
/*-----------------------------------------------------------------------------------*/
/* Start Search results loop
/*-----------------------------------------------------------------------------------*/

if( is_search() ) {

?>

<?php if ( have_posts() ) : ?>

<header class="page-header">
<h1 class="page-title"><?php printf( __( 'Search Results for: %s' ), '<span>' . get_search_query() . '</span>' ); ?></h1>
</header><!-- .page-header -->

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

<article class="post">

<h1 class="title">
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
<?php the_title() ?>
</a>
</h1>
<div class="post-meta">
<?php if( comments_open() ) : ?>
<span class="comments-link">
<?php comments_popup_link( __( 'Comment', 'break' ), __( '1 Comment', 'break' ), __( '% Comments', 'break' ) ); ?>
</span>
<?php endif; ?>

</div><!--/post-meta -->

<div class="the-content">
<?php the_content( 'Continue...' ); ?>

<?php wp_link_pages(); ?>
</div><!-- the-content -->

<div class="meta clearfix">
<div class="category"><?php echo get_the_category_list(); ?></div>
<div class="tags"><?php echo get_the_tag_list( '| &nbsp;', '&nbsp;' ); ?></div>
</div><!-- Meta -->

</article>

<?php endwhile; ?>

<!-- pagintation -->
<div id="pagination" class="clearfix">
<div class="past-page"><?php previous_posts_link( 'Newer &raquo;' ); ?></div>
<div class="next-page"><?php next_posts_link( ' &laquo; Older' ); ?></div>
</div><!-- pagination -->


<?php else : ?>

<article class="post error">

<h1 class="404"><?php _e( 'Nothing Found' ); ?></h1>

<div class="the-content">
<p><?php _e( 'Sorry, but nothing matched your search terms.' ); ?></p>
</div><!-- the-content -->

</article>

<?php endif; ?>

<?php } //end is_search(); ?>

<?php
/*-----------------------------------------------------------------------------------*/
Expand Down Expand Up @@ -116,7 +186,7 @@
/* Start Single loop
/*-----------------------------------------------------------------------------------*/

if( is_single() ) {
if( is_single() && !is_attachment() ) {
?>


Expand Down Expand Up @@ -168,13 +238,88 @@


<?php } //end is_single(); ?>

<?php
/*-----------------------------------------------------------------------------------*/
/* Start Attachment loop
/*-----------------------------------------------------------------------------------*/

if( is_attachment() ) {
?>

<?php if ( have_posts() ) : ?>

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

<article class="post">

<h1 class="title"><?php the_title() ?></h1>
<div class="post-meta">
<?php if( comments_open() ) : ?>
<span class="comments-link">
<?php comments_popup_link( __( 'Comment', 'less' ), __( '1 Comment', 'less' ), __( '% Comments', 'less' ) ); ?>
</span>
<?php endif; ?>

</div><!--/post-meta -->

<div class="the-content">

<?php echo wp_get_attachment_image( $post->ID, 'full' ); ?>

<?php if ( ! empty( $post->post_excerpt ) ) : ?>
<div class="entry-caption">
<?php the_excerpt(); ?>
</div>
<?php endif; ?>

</div><!-- the-content -->

<div class="meta clearfix">
<?php
$metadata = wp_get_attachment_metadata();
printf( __( '<span class="meta-prep meta-prep-entry-date">Published </span> <span class="entry-date"><abbr class="published" title="%1$s">%2$s</abbr></span> at <a href="%3$s" title="Link to full-size image">%4$s &times; %5$s</a> in <a href="%6$s" title="Return to %7$s" rel="gallery">%8$s</a>', 'less' ),
esc_attr( get_the_time() ),
get_the_date(),
esc_url( wp_get_attachment_url() ),
$metadata['width'],
$metadata['height'],
esc_url( get_permalink( $post->post_parent ) ),
esc_attr( strip_tags( get_the_title( $post->post_parent ) ) ),
get_the_title( $post->post_parent )
);
?>
</div><!-- Meta -->

</article>

<?php endwhile; ?>

<?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( '', true );
?>


<?php else : ?>

<article class="post error">
<h1 class="404">Nothing posted yet</h1>
</article>

<?php endif; ?>


<?php } //end is_attachment(); ?>


<?php
/*-----------------------------------------------------------------------------------*/
/* Start Page loop
/*-----------------------------------------------------------------------------------*/

if( is_page()) {
if( is_page() && !is_attachment() ) {
?>

<?php if ( have_posts() ) : ?>
Expand Down
2 changes: 1 addition & 1 deletion style.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Theme URI: http://lessmade.com/themes/less
Author: Jared Erickson
Author URI: http://jarederickson.com
Description: A super simple theme that can be customized using LESS variables
Version: 1.1
Version: 1.2.1
License: GNU General Public License

*/
Expand Down