Solved

WordPress Excerpts

Posted on 2012-12-23
7
849 Views
Last Modified: 2012-12-24
Hi Experts,

On my WP blog categories are listing the excerpts of the posts. Each single-post has a photo. How can i show in category page inside each post excerpt a thumbnail of the picture post has?

Many thanks in advance for help.

Regards,
Raul M.
0
Comment
Question by:raulmonda
  • 4
  • 3
7 Comments
 
LVL 11

Accepted Solution

by:
Ovid Burke earned 500 total points
ID: 38717810
You may need a tweak to your template(s) to include the_post_thumbnail().

Full documentation: http://codex.wordpress.org/Function_Reference/the_post_thumbnail
0
 

Author Comment

by:raulmonda
ID: 38718294
Thank you for answer. Ive checked the link you posted but still doesnt work. The posts have thumbnails,  add_theme_support( 'post-thumbnails' ) is included in functions.php. My php files are:
Category.php
<?php
/**
 *
 * archive.php
 *
 * The archive template. Used when a category, author, or date is queried.
 * Note that this template will be overridden by category.php, author.php, and date.php for their respective query types. 
 *
 * More detailed information about template’s hierarchy: http://codex.wordpress.org/Template_Hierarchy
 *
 */
get_header(); ?>
			<?php get_sidebar('top'); ?>
			<?php
			if (have_posts()) {
				global $posts;
				$post = $posts[0];
				theme_ob_start();

				if (is_category()) {
					echo '<h4>' . single_cat_title('', false) . '</h4>';
					echo category_description();
				} elseif (is_tag()) {
					echo '<h4>' . single_tag_title('', false) . '</h4>';
				} elseif (is_day()) {
					echo '<h4>' . sprintf(__('Daily Archives: <span>%s</span>', THEME_NS), get_the_date()) . '</h4>';
				} elseif (is_month()) {
					echo '<h4>' . sprintf(__('Monthly Archives: <span>%s</span>', THEME_NS), get_the_date('F Y')) . '</h4>';
				} elseif (is_year()) {
					echo '<h4>' . sprintf(__('Yearly Archives: <span>%s</span>', THEME_NS), get_the_date('Y')) . '</h4>';
				} elseif (is_author()) {
					the_post();
					echo theme_get_avatar(array('id' => get_the_author_meta('user_email')));
					echo '<h4>' . get_the_author() . '</h4>';
					$desc = get_the_author_meta('description');
					if ($desc) {
						echo '<div class="author-description">' . $desc . '</div>';
					}
					rewind_posts();
				} elseif (isset($_GET['paged']) && !empty($_GET['paged'])) {
					echo '<h4>' . __('Blog Archives', THEME_NS) . '</h4>';
				}
				theme_post_wrapper(array('content' => theme_ob_get_clean(), 'class' => 'breadcrumbs'));

				/* Display navigation to next/previous pages when applicable */
				if (theme_get_option('theme_top_posts_navigation')) {
					theme_page_navigation();
				}

				/* Start the Loop */
				while (have_posts()) {
					the_post();
                                       
					get_template_part('content', 'excerpt');
				}

				/* Display navigation to next/previous pages when applicable */
				if (theme_get_option('theme_bottom_posts_navigation')) {
					theme_page_navigation();
				}
			} else {
				theme_404_content();
			}
			?>
			<?php get_sidebar('bottom'); ?>
<?php get_footer();

Open in new window


content-excerpt.php
<?php
/**
 *
 * content*.php
 *
 * The post format template. You can change the structure of your posts or add/remove post elements here.
 * 
 * 'id' - post id
 * 'class' - post class
 * 'thumbnail' - post icon
 * 'title' - post title
 * 'before' - post header metadata
 * 'content' - post content
 * 'after' - post footer metadata
 * 
 * To create a new custom post format template you must create a file "content-YourTemplateName.php"
 * Then copy the contents of the existing content.php into your file and edit it the way you want.
 * 
 * Change an existing get_template_part() function as follows:
 * get_template_part('content', 'YourTemplateName');
 *
 */

global $post;
theme_post_wrapper(
		array(
			'id' => theme_get_post_id(),
			'class' => theme_get_post_class(),
                        'thumbnail' => theme_get_post_thumbnail(),
                        
			'title' => '<a href="' . get_permalink($post->ID) . '" rel="bookmark" title="' . strip_tags(get_the_title()) . '">' . get_the_title() . '</a>',
			'heading' => theme_get_option('theme_' . (is_home() ? 'posts' : 'single') . '_article_title_tag'),
			'before' => theme_get_metadata_icons('date,author,edit', 'header'),
			'content' => theme_get_excerpt(array('auto' => true)),
                        'after' => theme_get_metadata_icons('category,tag,comments', 'footer')
		)
);

?>

Open in new window


Ive tried many variants to include the_post_thumbnail() with no result.

Any idea where to look further on?
Thanks in advance.
Regards,
Raul M.
0
 
LVL 11

Expert Comment

by:Ovid Burke
ID: 38718312
The images are within your content or are they used as 'Featured Image'?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:raulmonda
ID: 38718343
as  'Featured Image'
0
 
LVL 11

Expert Comment

by:Ovid Burke
ID: 38718378
What Framework and Theme are you using? Can you find where the function theme_post_wrapper() is defined?
0
 

Author Closing Comment

by:raulmonda
ID: 38718388
Im using a theme generated by Artisteer v4. the function is in wrappers.php and it has the code
function theme_post_wrapper($args = '') {
	$args = wp_parse_args($args, array(
			'id'        => '',
			'class'     => '',
			'title'     => '',
			'heading'   => 'h2',
			'thumbnail' => '',
			'before'    => '',
			'content'   => '',
			'after'     => ''
		)
	);
	extract($args);
	if (theme_is_empty_html($title) && theme_is_empty_html($content))
		return;
	if ($id) {
		$id = ' id="' . $id . '" ';
	}
	if ($class) {
		$class = ' ' . $class;
	}
	?>
	<article<?php echo $id; ?> class="art-post art-article <?php echo $class; ?>">
                                <?php
if (!theme_is_empty_html($title)) {
	echo '<'.$heading.' class="art-postheader">'.$title.'</'.$heading.'>';
}
?>
                                                <?php echo $before; ?>
                <?php echo $thumbnail; ?><div class="art-postcontent clearfix"><?php echo $content; ?></div>
                                <?php echo $after; ?>
                </article>
	<?php
}

Open in new window


Anyway, i solved the problem. I have a  local site version where i test all new modifications before i add them to the live blog. For some reason it doesnt works on local server, but it works on the live blog. I may mess up things on my local since is the testing one.
Thank you for your involvement.

Regards,
Raul M.
0
 
LVL 11

Expert Comment

by:Ovid Burke
ID: 38718512
Great! Happy the problem is resolved.

Happy Holidays.

~ Mada
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
myqsl update statement on phpMyAdmin 8 21
mysql update statement effect only some rows 4 26
converting numbers with php 3 28
CSS z-index issue 3 19
In order to have all security and back ups taken care of, WordPress users can sign up for services with WP Engine.
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
The purpose of this video is to demonstrate how to set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now