Solved

WordPress Excerpts

Posted on 2012-12-23
7
854 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 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
Independent Software Vendors: 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!

 

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

726 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