• Resolved saralex

    (@saralex)


    Hello, I’m trying to add a resource box (this is the “author bio” that is below an article body and it’s also known as your “signature”) at the end of every article.

    Obviuosly, each author will its own resource box. I thought about using the “About yourself” field in the user profile to store a url to a .php file containing the signature of the individual user.

    My intention is then to retrive the url to include the .php file at the end of the article. Sort of:

    <?php include(the_author_description();) ?>

    But this line of code doesn’t work.
    Any suggestion?

    Thank you and sorry for my not so good english.
    Alex

Viewing 2 replies - 1 through 2 (of 2 total)
  • Unless you’re doing something extra complex, just have each author put their miniature biography in the “About Yourself” box. That way, the information can be edited inside WP, instead of manually editing a PHP file.

    Please take a look at the Author Template Tags and see if using a combination of those can do what you want.

    Instead of separate files, can all this be done with conditional statements in the single.php template file?

    if (get_the_author_nickname() == "saralex") {
     // do something
    } elseif (get_the_author_nickname() == "Another Name") {
     // do something else
    } else {
     // when all else fails, do the default
    }

    Consider taking a look at this tutorial: PHP Easy PHP Tutorial for WordPress Users

    Other notes:
    -WordPress template tags that begin with “the_” generally output (print) the information. Template tags that begin with “get_” usually return the information for use inside a function.

    -In PHP coding, a semi-colon (“;“) is used to denote the end of a line of code. Using it inside a function such as include() will cause errors.

    Now, if you were to include a file like you originally wanted, your best bet would be to use something like the following:

    <?php include( get_bloginfo('wpurl') . '/wp-content/my-includes/' . get_the_author_ID() . '.php' ); ?> where get_the_author_ID returns the user ID (a number) for the author.

    Thread Starter saralex

    (@saralex)

    Thank you very much.
    Your answer is truly GREAT.

    Thanks again for your help.

    All the best,
    Alex

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Author resource box’ is closed to new replies.