Forums

Using the_title() as a variable in the loop (3 posts)

  1. nickovich
    Member
    Posted 1 year ago #

    Hi,

    I am trying to integrate BinaryMoon's BMShots Plugin (http://www.binarymoon.co.uk/projects/bm-shots-automated-screenshots-website/) into a custom loop.

    In Twentyten, I tried to insert:

    When I declare $url directly, it works....

    $url = 'http://www.binarymoon.co.uk/';

    But when I try to assign it dynamically....

    <?php
       $url = the_title();
       echo $url;
       $width = 300;
       echo bm_mshot ($url, $width);
    ?>

    ... bm_mshot does not return anything. The post titles are plain URLs.

    So the_title() obviously is the output of a function, but how do I assign it to the $url variable? The end result is supposed to output a screenshot for each post (on the overview and the single post pages).

    Thanks for any pointers!

  2. nickovich
    Member
    Posted 1 year ago #

    OK, think I solved the PHP Dummie question:

    Used the_title_attribute instead, and explicitly set "echo" to 0 in the args.

    <?php
    $url = the_title_attribute('before=http://&echo=0');
    $width = 300;
    echo bm_mshot ($url, $width); ?>

    That way I only have to put the domain name into the post title, e.g. "youtube.com"

  3. alchymyth
    The Sweeper
    Posted 1 year ago #

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags