Support » Fixing WordPress » Using a variable in an array?

  • Resolved Jenny Beaumont

    (@jennybeaumont)


    Hi there,

    I’m looking for some basic php help trying to use the get_bookmarks function, but with a variable in the place of the category_name.

    I’m starting with this code that I found in the codex:

    <?php
    $bookmarks = get_bookmarks( array(
    				'orderby'        => 'name',
    				'order'          => 'ASC',
    				'category_name'  => 'Related Sites'
                              ));
    
    // Loop through each bookmark and print formatted output
    foreach ( $bookmarks as $bm ) {
        printf( '<a class="relatedlink" href="%s">%s</a><br />', $bm->link_url, __($bm->link_name) );
    }
    ?>

    But instead of 'category_name' => 'Related Sites'
    I’d like to do use something to the equivelant of 'category_name' => 'the_title()'

    Which of course doesn’t work. This only displays the title without allowing it to be used as the variable.

    Yes, each page will have the same name as the link category. And no, I feel there are too many categories to use an if/else statement – also because I would like to be able to add link categories and pages without having to touch this code.

    Can anyone help?
    thanks!
    -jennyb

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Using a variable in an array?’ is closed to new replies.