?
Solved

WordPress Excerpts

Posted on 2012-12-23
7
Medium Priority
?
860 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 11

Accepted Solution

by:
Ovid Burke earned 2000 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
Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
The purpose of this video is to demonstrate how to integrate Mailchimp with WordPress, by placing a Mailchimp signup form on a WordPress Page or Post. This will be demonstrated using a Windows 8 PC. Mailchimp will be used. Log into your Mailchi…
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…
Suggested Courses

762 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