• sribharath

    (@sribharath)


    hi ,

    i want to show only thumbnail of the last post with out any text or title of a particular category .

    i am using custom fields , so any pls tell me the code and help me out

    with regards’

    sribharath

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter sribharath

    (@sribharath)

    any one pls ?

    Thread Starter sribharath

    (@sribharath)

    any one ?

    NB: Please make a backup of your page template before trying this:

    This is something I use in my template to show my last 4 posts from the work category (displaying only an image that links to the posts) and have modified to show the last one post which I hope will also work for you:

    <?php
    //get posts from category named work
    	$categories_to_include = get_cat_ID('work');
    	$the_query = new WP_Query('cat='.$categories_to_include.'&showposts=1&orderby=post_date');
    	?>
    <?php while ($the_query->have_posts()) : $the_query->the_post(); ?>
    <div class="postWrapper" id="post-<?php the_ID(); ?>">
    <div class="post"><a href="<?php the_permalink() ?>" rel="bookmark"><?php $values = get_post_custom_values("thumbnail-name"); echo $values[0]; ?></a></div>
    <p class="postMeta"><?php edit_post_link(__('Edit'), ''); ?></p>
    </div></div>
    <?php endwhile; ?>

    change category from work to name of your category
    change thumbnail-name to your custom field name

    Hope that helps get you on right track…

    Hi !
    I think custom fields are complicated so I’m trying to show a different picture in every excerpt and I need to know what is the line code necessary to do it.

    I need to know how I can show a picture in every post with the picture named as post ID.

    I think it should be something like this:
    <?php echo ‘<img src=”https://www.myserver.com/wp-content/images/postID.jpg&#8221; alt=”my picture!!” />’; ?>

    I think $post->ID is the answer but I don’t know what I slhould do.

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘code to show only thumbnail of particular category’ is closed to new replies.