Skip to content

Instantly share code, notes, and snippets.

@catchthemes

catchthemes/functions.php Secret

Created Jun 25, 2014
Embed
What would you like to do?
<?php
// Function to show the loop content
function catchthemes_theloop() {
global $post, $catchthemes_theme_options_settings;
$options = $catchthemes_theme_options_settings;
do_action( 'catchthemes_before_post' ); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php do_action( 'catchthemes_before_post_header' ); ?>
<header class="entry-header">
<h1 class="entry-title">
<?php if ( is_page() ) {
the_title();
}
else { ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute();?>"><?php the_title(); ?></a>
<?php
}
if( is_post_type_archive( 'testimonials' ) || is_singular( 'testimonials' ) ) {
$designation = get_post_meta( $post->ID, 'catchthemes_author_designation', true );
if( $designation ) {
echo ' | <span class="testimonial-meta">'.esc_attr( $designation ).'</span>';
}
} ?>
</h1>
<?php if ( ( is_single() || is_archive() || is_author() || is_front_page() ) && ( !is_singular( 'testimonials' ) && !is_singular( 'services' ) && !is_post_type_archive( 'testimonials' ) ) ) {
?>
<footer class="entry-meta">
<span class="by-author vcard"><?php _e( 'By ', 'catchthemes' ); ?><a class="url fn n" href="<?php echo get_author_posts_url( get_the_author_meta( 'ID' ) ); ?>" title="<?php echo esc_attr(get_the_author_meta( 'display_name' ) ); ?>" rel="author"><?php the_author(); ?></a></span>
<span class="date updated"><?php the_time(get_option('date_format')); ?></span>
<?php if( has_tag() ) : ?>
<span class="cat-links"><?php the_tags(''); ?></span>
<?php endif;
if ( ( comments_open() || '0' != get_comments_number() ) && $options[ 'commenting_setting' ] != 'disable' ) : ?>
<span class="comments-link"><?php comments_popup_link( __( 'No Comments', 'catchthemes' ), __( '1 Comment', 'catchthemes' ), __( '% Comments', 'catchthemes' ) ); ?></span>
<?php endif; ?>
</footer><!-- .entry-meta -->
<?php
}
elseif( is_singular( 'testimonials' ) || is_post_type_archive( 'testimonials' ) ) {
?>
<footer class="entry-meta">
<span class="date updated"><?php the_date( 'j F Y' ); ?></span>
</footer><!-- .entry-meta -->
<?php
}
?>
</header>
<?php do_action( 'catchthemes_after_post_header' ); ?>
<?php do_action( 'catchthemes_before_post_content' ); ?>
<div class="entry-content clearfix">
<?php
if( is_archive() || is_author() || is_home() || is_post_type_archive( 'testimonials' ) ) {
$photos = get_children( array('post_parent' => $post->ID, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID') );
if( has_post_thumbnail() || !empty ( $photos ) ) {
if ( has_post_thumbnail() ) {
$image = get_the_post_thumbnail( $post->ID, 'blog' );
}
else {
$image = catchthemes_get_first_attached_image ( 'blog' );
}
echo '
<div class="thumb">
<a href="' . get_permalink() . '" title="Permalink to '.the_title( '', '', false ).'">
'.$image.'
</a>
</div><!-- .thumb -->';
echo '<div class="content">';
the_excerpt();
echo '</div><!-- .content --> ';
}
else {
echo '<div class="content-full">';
the_excerpt();
echo '</div><!-- .content-full --> ';
}
}
elseif ( is_search() ) {
the_excerpt();
}
else {
the_content();
// copy this <!--nextpage--> and paste at the post content where you want to break the page
wp_link_pages(array(
'before' => '<div class="pagination clearfix">'.__( 'Pages:', 'catchthemes' ),
'after' => '</div>',
'link_before' => '<span>',
'link_after' => '</span>',
'pagelink' => '%',
'echo' => 1
) );
}
?>
</div><!-- .entry-content -->
<?php do_action( 'catchthemes_after_post_content' ); ?>
</article><!-- .post -->
<?php do_action( 'catchthemes_after_post' );
if ( is_singular( 'testimonials' ) || is_singular( 'services' ) || ( $options[ 'commenting_setting' ] == 'disable' ) || ( is_page() && $options[ 'commenting_setting' ] == 'page' ) ) {
echo '<!-- comments disabled -->';
}
else {
do_action( 'catchthemes_before_comments_template' );
comments_template();
do_action( 'catchthemes_after_comments_template' );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment