• Resolved gyar29

    (@gyar29)


    I am attempting to display or not display a form based on the current page.

    I am attempting to not display the form if the current page is my affiliate page. The form links to the affiliate page so if the reader is on the page I don’t need the form displayed.

    The form now displays on every page.

    Any help would be appreciated.

    Current Code:

    `<?php
    if($post_id != “affiliate-center”){
    print “<div id=\”cbsidebar\” style=\”width:175px;margin:10px auto 10px;display:block;text-align:center\”><form action=\”https://www.mysite.com/affiliate-center/\” method=\”post\” accept-charset=\”UTF-8\”><p style=\”font-size:x-small\”>75% Commisions Great Affiliate Tools</p>
    <label for=\”CB_ID\”>Affiliate ID :</label>
    <input id=\”hop\” name=\”hop\” type=\”text\” value=\”\” />

    <input type=\”submit\” value=\”Go To The Affiliate Center\”/></form></div>”;
    }
    else {
    print “”;
    }
    ?>`

    Thank you

Viewing 8 replies - 1 through 8 (of 8 total)
  • if($post_id != "affiliate-center")

    “affiliate-center” isn’t an id (a number). Try using something like if(!is_single('affiliate-center')).

    Thread Starter gyar29

    (@gyar29)

    esmi,

    Thanks for the reply, however; that was not the solution. Perhaps if I were a bit more descriptive of what I am trying to accomplish.

    I am attempting to get the form I listed in the original post to display based on the page the user is on. The form is in the sidebar. The page_id for that page is 106. However, attempting to use that id as the variable that triggers whether or not the form appears is not working.

    Because I am using permalinks for SEO purposes the url of the page shows up as the page’s title. So the post_id=106 is not actually in the url for the page, and because of that $_GET[‘post_id’] or $_POST is not pulling in the variable.

    I see in the permalink settings that %postname% is the name of the specific page that permalinks is using. Would that be the trigger variable I need?

    if postname==pagename then the trigger?

    Or must I somehow incorporate a WordPress hook in order to parse the variable prior to triggering the form?

    I’ve attempted to use the_title, post_id, and some other variables I can’t remember now as the trigger variable. None seem to work.

    Any help would be appreciated.

    So the post_id=106 is not actually in the url for the page

    No but it’s still the page’s id – no matter what custom permalink structure you’re using.

    If you want the form to only appear on the page with an id of 106, try using:

    <?php if( is_page('106') ):?>
    [ form markup goes here ]
    <?php endif;?>
    Thread Starter gyar29

    (@gyar29)

    esmi,

    Thanks I’ll try that.

    Thread Starter gyar29

    (@gyar29)

    esmi,

    You are “THE MAN”. That Works! Thank you very very much. Was about to throw the computer against the wall.

    Glad to hear that you got it working. ?? The resolved check box is that-a-way —>

    Thanks a lot esmi, it`s really good working also in another situations… : )

    rock. thanks!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘If page_id =”” do not display form’ is closed to new replies.