• Here’s what I am trying to do: I want to have the option to upload a file to my images directory and as long as the file matches the page title.jpg it will display the image. otherwise it should display the plain text of the title. So here’s what I’ve started with inside the loop:

    <?php $filename = 'images/' the_title_attribute(0) '.jpg';
    if (file_exists($filename)) { ?>
    
    <img src="<?php echo $filename; ?>" alt="<?php the_title(); ?>">
    
    <?php } else { ?>
    <h2><?php the_title(); ?></h2>
    <?php } ?>

    This actually works with the exception of the part where I am trying to declare the file name. I know I am doing it wrong but I want the_title_attribute so that each page can have an image as a title dynamically (so to speak). help! ??

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Using an Image instead of page title’ is closed to new replies.