WordPress.org

Ready to get started?Download WordPress

Forums

Just a tiny bit of PHP help. (3 posts)

  1. bluehorse2
    Member
    Posted 7 years ago #

    Ok simple WP content word replacement plugin.

    <?php
    /**
    Plugin Name: replace
    Author: bluehorse
    */
    add_filter('the_content', 'replace_the_content');
    function replace_the_content($content) {
    $content = str_replace('username', '<a href="http://www.usersurl.com">username', $content);
    return $content;
    }
    ?>

    Can anyone offer a little help on how to just insert say <a href="get_the_author_url">get_the_author_nickname</a> on to the end of the content.

    I can't figure out how to just insert things and my eyes are hurting. :S

    All links to other info would be appreciated I've seached and searched. Currently I'm stuck on http://uk2.php.net/manual/en/ref.strings.php

  2. Samuel Wood (Otto)
    Tech Ninja
    Posted 7 years ago #

    Can anyone offer a little help on how to just insert say get_the_author_nickname on to the end of the content.

    Like this?
    <?php
    function add_to_the_content($content) {
    $content .= '<a href="' . get_the_author_url() . '">' . get_the_author_nickname() . '</a>';
    return $content;
    }
    add_filter('the_content', 'add_to_the_content');
    ?>

  3. bluehorse2
    Member
    Posted 7 years ago #

    Thankyou :)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags