WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Mass Updating Posts with a set Image (5 posts)

  1. MCM
    Member
    Posted 2 years ago #

    Crazy question is it possible to update X amount of posts with a image/featured image.

    i.e. I have a number of posts from a specific category for which I have no image.

    I would like to use the same image for all the psots in that category either as a featured image OR place the html code at the top of the page to point to a image I have stored.

    Is this possible at all?

  2. Jonathan Dingman
    Member
    Posted 2 years ago #

    I would do something like this...

    $has_featured = has_post_thumbnail(55);
    if ( in_category(3) && !$has_featured ) { echo "<img ... "; }

    That way it will check for the category and that it doesn't already have a featured image set.

    Something along those lines should work.

  3. MCM
    Member
    Posted 2 years ago #

    Where would I place that? functions.php?

  4. Jonathan Dingman
    Member
    Posted 2 years ago #

    Yes, you are correct.

  5. MCM
    Member
    Posted 2 years ago #

    It works, code slightly modified to get it to work...

    <?php
    	$has_featured = has_post_thumbnail(55);
    	if ( !$has_featured )
    	{
    	echo '<img src="logo.png" alt="my text" />';
    	}
    	?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags