but i need to have a one category that will use images for post title.
where?
a – in the single post?
b – in the category archive of these posts?
c – in the posts whereever they appear?
a:
possibly with a contional statement in single.php, such as
<?php if( in_category('whatever') ) { /*show image*/ } else { /*show title*/ } ?>
http://codex.wordpress.org/Function_Reference/in_category
b:
use a category template where you replace the title code with an image code;
http://codex.wordpress.org/Category_Templates
c:
like a: but in index.php (and archive.php, etc)
I want to show image instead of title in category archive.
But how should i find first or any image from that post?
thanks for trying to help
I’d suggest using Post Thumbnails (or “featured images” as they’re known in newer versions of WordPress).
http://codex.wordpress.org/Post_Thumbnails
I can’t figure out how to do this.
I do not use any theme i want to import it in existing site.
Using this link: http://www.wprecipes.com/how-to-get-the-first-image-from-the-post-and-display-it
that alchymythm have me i can get a link of image from post but don’t know how to use it?
It would be really great if someone could help me i need to make this work by tomorrow and i have no ideas 😐
Thanks.
To be more exact i am using the following code to display posts on my site:
<?php
$args = array( 'numberposts' => 3, 'category' => 3);
$lastposts = get_posts( $args );
foreach($lastposts as $post) : setup_postdata($post); ?>
<h2><a href="<?php the_permalink(); ?>"><?php echo catch_that_image() ?>
</a></h2>
<?php the_content(); ?>
<?php endforeach; ?>
Where <?php echo catch_that_image() ?> gets me the link to the image but i can’t show that image only link to image.
<h2><a href="<?php the_permalink(); ?>"><img src="<?php echo catch_that_image() ?>" alt="" />
</a></h2>
http://www.w3schools.com/tags/tag_IMG.asp
Uhm yeah i tried that ofc but i then figured out that code i entered in functions.php uses preg matach and i cannot display it.
So i used now different code from this site:
http://bavotasan.com/tutorials/retrieve-the-first-image-from-a-wordpress-post/
But i still cant figure out how to use it 😐