• Ani

    (@vesnagaga)


    I have function get_quote() in function.php(customizr theme). When I call that function from some page with <?php echo get_quote(); ?>, nothing happens.
    What am I doing wrong?

Viewing 10 replies - 1 through 10 (of 10 total)
  • What are you trying to do?

    Thread Starter Ani

    (@vesnagaga)

    I have 5 citations that this function should randomly write on the pages on which the function call. Did I put the function in the right place?
    Simply, the function needs to reprint some text. I hope that you understand what I need, because my English is not so good.
    Thanks in advance.

    I’m no php expert, but I can see that is not the way to do it. echo command simply helps you render HTML, not call a function.

    If your skills are up to it, take a look at the php snippets which use Hooks and that will show you the right direction.

    Thread Starter Ani

    (@vesnagaga)

    I have a website on which the function call in the same way, and everything works as it should. But when I insert the same code to WordPress, nothing happens.
    Anyway, thanks for the advice.

    If you really want to be able to use php code when editing page/posts, probably you should look at some plugin, e.g. http://wordpress.org/plugins/insert-php
    or this older one, that should still work:
    http://wordpress.org/plugins/exec-php

    Thread Starter Ani

    (@vesnagaga)

    Now something is happening 🙂 I get the same message with both the plugins…
    Fatal error: Call to undefined function get_quote () in C: \ xampp \ htdocs \ wordpress \ wp-content \ plugins \ insert-php \ insert_php.php (48): eval () ‘d code on line 1
    Again, the main function is in function.php, because I need to call function from a few pages.

    Don’t know what to say, to me it works, just tested calling a function which is in my child theme functions.php.
    I see you always write function.php, is it just a typo?

    Thread Starter Ani

    (@vesnagaga)

    I just mentioned that a function I call put in the Theme Functions (functions.php). I thought that someone told me, if I put it in the wrong place. In any case, thanks.

    Sorry Vesnagaga, it’s just that I didn’t get if you put that in the right or the wrong place, because of that missing “s”.
    If you say :

    Again, the main function is in function.php, because I need to call function from a few pages.

    I don’t know if:
    a) is a typo, then is the right place (but not suggested, should be better to not modify customizr theme, create a child theme with its functions.php and there put your functions). In this case I cannot help ’cause to me works, I don’t know if you made something wrong ’cause I cannot see your code.
    b) Since function.php doesn’t exists in customizr theme then you created this file and, assuming you wrote that function right, it’s the wrong place.

    Anyway, now it works?

    Thread Starter Ani

    (@vesnagaga)

    Sorry, it is typo. Maybe you’re right, I should use child theme. I’ll try to, because nothing else has worked.
    Thank you.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Problem with calling function’ is closed to new replies.