Return to Snippet

Revision: 5298
at February 25, 2008 14:47 by nijgnet


Initial Code
/*
 * Grabs the text content from a Page that is meant to be a blurb
 * on another Page.
 * 1. Create a Page and insert text to be used as the blurb.
 * 2. Give the post slug a name.
 * 3. Call get_blurb() from where the blurb should be inserted.
 *
 * @param pagename - post slug of the Page
 * @param keeptags - tag list to allow in the text
 * @return String - the blurb
 */
function get_blurb ($pagename, $keeptags='')
{
    $q = new WP_Query('pagename='.$pagename);
    $content = '';
    
    if ($content = $q->queried_object->post_content)
    {
        $content = strip_tags($content, $keeptags);
    }
    else {
        $content = 'This blurb does not exist. ';
    }
    return $content;
}

function beautify_blurb ($content, $isIndex=FALSE)
{
    if ($isIndex) {
        return preg_replace('/^<strong>/i', '<strong class="intro">',$content);
    }
    else {
        return preg_replace('/^<p><strong>/i', '<p class="intro"><strong>',$content);
    }
}

Initial URL


Initial Description


Initial Title
Grabs the textual content of a Post and style it

Initial Tags
wordpress

Initial Language
PHP