• I am a WP and PHP novice so I am in over my head, but that’s only ‘cuz I got thrown into the deep end of the pool. I am trying to add some logic to display content on certain pages, not on others. I’ve made some progress but having issues. Here is the plan:

    On certain pages with an post type of “EVENT” I want content to appear, but not on OTHER pages with an post type of “EVENT”. The problem I am running into is that part of the content is appearing on ALL event pages even if they don’t meet the criteria. The logic is intended to be this:

    If the page is post_type “EVENT”, AND if the indicated table contains a field with a record CAT which matches the current “POST ID”, AND contains a record TYPE which matches value “1”, display table cells which contain text “Presented by: “, an href and an image, else display table cells which contain  .

    The problem is that the text “Presented by: ” is appearing on ALL the even pages, regardless of whether they meet the criteria or not — which would tend to indicate a problem with the logic code — but by the same token the href and image are correctly appearing ONLY on the pages that meet the criteria and are NOT appearing on along with the rogue text on pages which do not meet the criteria.

    I am sure it is a coding error on my part but I am not sure what. ANY help anyone could give would be GREATLY appreciated. The code involved is below (oh, and I should mention that the code in question is in the HEADER.PHP file):

    if($post->post_type=='event') {
    
    $q1=mysql_query("SELECT *
    FROM table_name
    WHERE type = 1
    AND cat = $post->ID ");
    
    $row_diamond=mysql_fetch_object($q1);
    if ($q1){
    ?>
    <td width="115" align="right" valign="middle" id="diamond1"><strong style="position:relative;bottom:-25px;">Presented by: </strong></td>
    <td id="diamond2" width="190">
    &nbsp;
    <a href="<?=$row_diamond->website?>"  title="<?=$row_diamond->website_title?>" target="_blank"   style="cursor:pointer;"><img style="position:relative;bottom:5px;" src="<?php bloginfo('siteurl'); ?>/wp-content/plugins/sean_event/files/<?=$row_diamond->image?>" alt="<?=$row_diamond->alt_text?>"border="0"></a> <br />
    </td>
    <?php
    } else{
    ?>
    <td width="115" align="right" valign="middle" id="diamond1">&nbsp;</td>
    <td id="diamond2" width="190">&nbsp;</td>
    <?php
    }
    }
    ?>
Viewing 1 replies (of 1 total)
  • Thread Starter LDMartin1959

    (@ldmartin1959)

    display table cells which contain . should be:

    display table cells which contain a non-breaking space.

Viewing 1 replies (of 1 total)
  • The topic ‘Template logic: Conditional display coding partially failing’ is closed to new replies.