WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] php functions inside template (3 posts)

  1. ebenezer357
    Member
    Posted 1 year ago #

    Hi everyone,
    Im coding in some php codes inside a template i'm building and i need to include a php inside another php but it gives me an error. This is what i have:

    <?php
    if(qtrans_getLanguage()=='en') {
    echo "<?php more_fields('Author') ?>;"
    } else
    {
    echo "Esta página esta en Español";
    }
    ?>

    Apparently it doens't let me include php functions inside another php. I tried to declare a variable with the result of <?php more_fields('Author') ?>; but didn't work either because in order to create a variable i need to have it inside a <?php right? or is there a way to declare variables without having to do them inside the <?php ??????

    Anybody please help me out!

    Thanks in advance for your help!

    Note: Im using qTranslate and MoreFields for Translation and Custom Fields.

  2. alchymyth
    Forum Moderator
    Posted 1 year ago #

    what is the exact error message?

    there is likely to be a semicolon missing at the end of the 'echo' line.

    generally, the echo function should be able to echo whatever you want, but it won't execute the php code.

    I don't know the more_fields() function (is that from a plugin?), but have you tried,
    either:

    echo more_fields('Author');

    or:

    more_fields('Author');
  3. ebenezer357
    Member
    Posted 1 year ago #

    Thank you alchymyth!!!
    more_fields('Author'); fixed my problem! Thanks a lot! :)

Topic Closed

This topic has been closed to new replies.

About this Topic