Solved

WordPress Excerpts

Posted on 2012-12-23
7
847 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
Comment Utility
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
Comment Utility
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
Comment Utility
The images are within your content or are they used as 'Featured Image'?
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Author Comment

by:raulmonda
Comment Utility
as  'Featured Image'
0
 
LVL 11

Expert Comment

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

Author Closing Comment

by:raulmonda
Comment Utility
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
Comment Utility
Great! Happy the problem is resolved.

Happy Holidays.

~ Mada
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
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…

763 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

12 Experts available now in Live!

Get 1:1 Help Now