Jul 10, 2012 - Wordpress Comments Off on PressWork: Show featured posts with full text
PressWork: Show featured posts with full text
From http://support.presswork.me/discussion/560/show-full-content-of-all-posts-on-homepage/p1
Using the PressWork theme, it’s possible to show the featured posts on the home page with the full text, rather than have them be automatically cut off.
Here’s how:
- Create a new file called custom-actions.php
- In this file, paste the following code:
<?php function custom_pw_posts_featured() { echo pw_function_handle(__FUNCTION__); global $pw; $rightcon = ''; $bool = true; if(function_exists('has_post_thumbnail') && has_post_thumbnail() && (function_exists('has_post_format') && !has_post_format('gallery') && !has_post_format('video') && !has_post_format('image'))) { echo '<a href="'.get_permalink().'">'; if($pw==1) { $thumb = 'sticky'; $class = 'alignnone'; } else { $thumb = 'thumbnail'; $class = 'alignleft'; } the_post_thumbnail($thumb, array('class'=>$class)); echo '</a>'; $rightcon = ''; } else { if(has_post_format("image")) $bool = false; } ?> <div<?php echo $rightcon; ?>> <?php pw_post_header(); ?> <?php custom_pw_post_content($bool); ?> </div> <?php } remove_action('pw_index_sticky_post_middle', 'pw_posts_featured'); remove_action('pw_index_featured_post_middle', 'pw_posts_featured'); add_action('pw_index_sticky_post_middle', 'custom_pw_posts_featured'); add_action('pw_index_featured_post_middle', 'custom_pw_posts_featured'); function custom_pw_post_content($ignore_image = false, $excerpt_length = 55, $hide_readmore = false, $display_excerpt = false) { echo pw_function_handle(__FUNCTION__); ?> <div> <?php if(function_exists('has_post_format') && !is_singular()) { $format = get_post_format(); if(empty($format) || has_post_format('image')) { if(has_post_format('image')) $size = 'full'; elseif(empty($ignore_image)) $size = 'small'; else $size = 'thumbnail'; if(function_exists('has_post_thumbnail') && has_post_thumbnail()) { if(empty($ignore_image) || has_post_format('image')) { echo '<a href="'.get_permalink().'">'; the_post_thumbnail($size, array( 'class' => 'alignleft' )); echo '</a>'; } } else { if(has_post_format('image')) the_content(); } if(empty($format)) { the_content('Read more →'); } } elseif(has_post_format('gallery')) { // new gallery post format global $post; $images = get_children( array( 'post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order', 'order' => 'ASC', 'numberposts' => 999 ) ); if ( $images ) : $total_images = count( $images ); $image = array_shift( $images ); $image_img_tag = wp_get_attachment_image( $image->ID, 'full' ); ?> <a href="<?php the_permalink(); ?>"><?php echo $image_img_tag; ?></a> <p><em><?php printf( _n( 'This gallery contains <a %1$s>%2$s photo →</a>', 'This gallery contains <a %1$s>%2$s photos →</a>', $total_images, "presswork" ), 'href="' . get_permalink() . '" title="' . sprintf( esc_attr__( 'Permalink to %s', "presswork" ), the_title_attribute( 'echo=0' ) ) . '" rel="bookmark"', number_format_i18n( $total_images ) ); ?></em> </p> <?php endif; ?> <?php } else { // new aside || link || audio || video || image post format echo '<div>'; the_content(''); echo '</div>'; } } ?> </div> <?php } remove_action('pw_index_post_middle', 'pw_post_content', 11); add_action('pw_index_post_middle', 'custom_pw_post_content', 11);
- Upload the file to the /wp-content/uploads directory
Now all home page posts should appear with full text