WordPress.org

Ready to get started?Download WordPress

Forums

Post title manipulation (3 posts)

  1. Pipuks
    Member
    Posted 7 years ago #

    To make few themes identical to original designs I am trying to make this function work properly:

    <?php
    function pcom_title($title) {
        $title = explode(" ", $title);
        $return_title = '<span class="blue">';
        for ($i = 0; $i <= sizeof($title); $i++) {
            if ($i == 1) {
                $return_title .= $title[$i] . '</span>';
            } else {
                $return_title .= $title[$i] . ' ';
            }
        }
    }
    ?>

    Funny that it works if I manually pass value to it, but when I try to call this function from my theme following way it fails:

    <?php
    pcom_title(bloginfo('name'));
    ?>

    It just prints out 1 line with no modifications. It seems as it was some kind of text that is impossible to split.

    Anyone could suggest anything?

  2. quincewyss
    Member
    Posted 7 years ago #

    use the seo title plugin. it will help u do this all from the admin area.

  3. Pipuks
    Member
    Posted 7 years ago #

    Could you be more specific?

    I need to highlight 1st word of the title. How can above mentioned plugin help me?

Topic Closed

This topic has been closed to new replies.

About this Topic