WordPress.org

Support

Support » How-To and Troubleshooting » Calling a function

Calling a function

Viewing 12 replies - 1 through 12 (of 12 total)
  • Anyone have any input? Still banging my head…

    shirazdrum
    Member

    @shirazdrum

    Assuming that the function actually exist.

    <?php bjaq_form() ?>

    Yes I think this is it…

    function bjaq_form() {
    
        global $aErrors;
    
        $sContent = "";
    
    	if (get_request_var("bjaq_action") == "bjaq_success") {
            $sContent .=  '<div id="bjaq-result">Successfully submitted message!
                <a href=".">Submit another</a>.</div>';
    	} else {
    
            $bjaq_error = "";
            if (get_request_var("bjaq_action") == "bjaq_error") {
                $err_type = get_request_var("bjaq_error");
    
                if (!isset($aErrors[$err_type])) {
                    $err_type = "unknown";
                }
    
                $sContent .= '<div id="bjaq-result">' . $aErrors[$err_type] . '</div>';
            }
    
            $sContent .= bjaq_form_html()
                . ' <div id="bjaq-result">' . ($bjaq_error ? $bjaq_error : '') . '</div>';
    	}
    
    	$sContent .= '</noscript>';
    
    	$sContent = '<h3>Ask A Question</h3>' . PHP_EOL . $sContent;
    
    	echo($sContent);
    }

    Now I just don’t know how to get the form in my sidebar… There is nothing in the widgets options…

    shirazdrum
    Member

    @shirazdrum

    ^^^READ….UP^^^

    I don’t understand?

    shirazdrum
    Member

    @shirazdrum

    <?php bjaq_form(); ?>

    THIS IS HOW YOU CALL THE FUNCTION.

    Yes I understand that, but I am unfamiliar with PHP. I have tried adding the following <?php bjaq_form(); ?> to my functions.php but had no luck. I don’t know where to put the piece of code is what I was trying to say.

    shirazdrum
    Member

    @shirazdrum

    I see. You need to put it where you want the form to show. IF sidebar, put it in the sidebar, if single post, put it in single and so on. It doesn’t go inside your function.php. The code you wrote above should already be in there. Hope that helps.

    shirazdrum
    Member

    @shirazdrum

    Of course the password to your site would be nice as well 🙂

    Great! Thanks! I got it to show in the sidebar now. I will see what I can do about getting it to look right. Thanks!

    shirazdrum
    Member

    @shirazdrum

    Great, now you can style it with css.

    On it! Thanks again for the help!

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Calling a function’ is closed to new replies.