WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] PHP statement (3 posts)

  1. staceyzav
    Member
    Posted 1 year ago #

    Hi - I've created some custom fields (from the "Advanced Custom Field" plugin) and I'm trying to combine some PHP statements (that I have been able to get to work alone) that will look to see if those values have been entered and then based on which ones have been entered it will allow me to return some HTML code. Here is the logic I am after:

    • IF is home - return sidebar named video (the following code works by itself)

    <?php /* Widgetized sidebar */
        if ( is_home() ) dynamic_sidebar('vid'); ?>

    • ELSE: if is NOT home AND "gallery" field has been entered

    echo: <div class="gallery"><?php the_field('gallery'); ?></div>

    • ELSE IF: if is NOT home AND gallery field NOT entered AND video field IS entered
    echo
    <a href="<?php the_field('video_url'); ?><?php the_post_thumbnail(); ?></a>

    • ELSE IF: is NOT home and gallery and video fields NOT entered

    echo
    <?php the_post_thumbnail(); ?>

  2. staceyzav
    Member
    Posted 1 year ago #

    I ended using page templates, so never mind (moderators, feel free to delete). Thanks anyway!

  3. Andrew
    Forum Moderator
    Posted 1 year ago #

    I think your posts can still benefit the WordPress community, so I'll leave it.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.