WordPress.org

Forums

PHP Code Widget
[resolved] eval error or if statement not working (2 posts)

  1. J
    Member
    Posted 1 year ago #

    I am using this in conjunction with the Advanced Custom Fields plugin. (so the_field() code is related to that)

    Here is the code:

    <?php if ( the_field('downloadable_material') != ") { ?>
    <div class="material">
    <h4>Supplemental Material:</h4>
    <a href="<?php the_field('downloadable_material'); ?>"><i class="icon-download-alt"></i> - Download Supplemental Material</a>
    </div>
    <?php } else { }; ?>

    If downloadable_material (a file attachement field) has a file, it shows up and links correctly.
    if it is empty the whole thing still shows up on the page, (but with an empty link).

    The similar thing is happening with another statement in the same widget:

    <?php if ( the_field('links_and_resources') != " ) { ?>
    <h4>Resources:</h4>
    <p><?php the_field('links_and_resources'); ?></p>
    <?php } else { }; ?>

    Now this second one works in a strange way. it shows nothing when empty and shows the content of the field when it has something but it does not show the h4 “Resources:” at all. and if I add the <div class="material"></div> wrapped around the two lines between the if statement it generates the same error as below.

    I assumed the if statement was not written correctly. but any change I make to it results in the following error:

    Parse error: syntax error, unexpected T_STRING in execphp.php(44) : eval()’d code on line 5

    Any idea what is off here?

    Thanks

    http://wordpress.org/extend/plugins/php-code-widget/

  2. J
    Member
    Posted 1 year ago #

    Ok my bad. syntax issues.

    solution is here if anyone cares

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags