Solved

WordPress Excerpts

Posted on 2012-12-23
7
852 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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

These days socially coordinated efforts have turned into a critical requirement for enterprises.
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 viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

831 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