Support » Plugin: PHP Code Widget » Code String Not Executing Properly / User Error?

  • Resolved Doctor Psyringe

    (@nicholasdesuza)


    Ok, so I’ve been coding up loads of ads for my website to get that extra revenue edge. But I want my Authors to have the Ability to not only change the Ad Content, but Enable it and Disable it.

    So – for all of my custom post types and regular post types/pages – the following works in conjunction with my WordPress Editor User Interface;

    <?php if(!$oswc_widget_ad_hide) { ?>
    <table style=”width: 300px;” border=”0″>
    <tbody><tr><td>
    <?php if ($widgetadvertisement) { ?>
    <?php echo $widgetadvertisement; ?>
    <?php } else { ?>
    <script>adcodeirrelevant</script>
    <?php } ?>
    </td></tr><tr>
    <td style=”text-align: center;”>
    <span style=”font-size: xx-small;”>Advertisement</span>
    </td></tr></tbody>
    <?php } ?>

    oswc_widget_ad_hide – Enable or Disable
    widgetadvertisement – The Content, with a Default if no is data provided.

    This code doesn’t work in the widget. In fact, the same effect occurs then I plug that .php into a Unwrapped Text as this PHP Widget, so perhaps I already have .php enabled and the goal of this code should be resolved elsewhere. Nonetheless, it damages the template, moves the footer to the sidebar. Ok… so maybe that code is wrong for the purpose, being outside “the loop”. Of course I coded a version using a variation of;

    <?php global $wp_query;
    if(is_object($wp_query->queried_object) && $wp_query->queried_object->ID)
    {
    echo get_post_meta($wp_query->queried_object->ID, ‘customfieldname’, true);
    }
    ?>

    Not that I got that working either, if anything it damaged the code and turned the widget into a title line. By the way, saying there is a method to get this code working, is this widget available Unwrapped, surprised it’s not available in that form.

    Thanks!

    https://wordpress.org/plugins/php-code-widget/

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Code String Not Executing Properly / User Error?’ is closed to new replies.