WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Nested php function help! (5 posts)

  1. whatachamp
    Member
    Posted 2 years ago #

    A little nested php question:
    I want to retrieve wordpress bookmarks with a certain category:
    <?php wp_list_bookmarks('title_li=&category_name=CUSTOMFIELD-ISSUE'); ?>
    and this category will be set on posts with the custom field 'issue':

    <?php
    global $wp_query;
    $postid = $wp_query->post->ID;
    echo get_post_meta($postid, 'issue', true);
    ?>

    How do I merge these two functions? My php-writing needs work, I know ;O)
    Thanks

  2. Apsira
    Member
    Posted 2 years ago #

    If you are using PHP 5.3 you can get more Javacript-like behaviour with an anonymous function:

    <?php
    function outer() {
        $inner=function() {
            echo "test\n";
        };
    
        $inner();
    }
    
    outer();
    outer();
    
    inner(); //PHP Fatal error:  Call to undefined function inner()
    $inner(); //PHP Fatal error:  Function name must be a string
    ?>

    Output:

    test
    test

  3. whatachamp
    Member
    Posted 2 years ago #

    Not sure I understand your reply Apsira. Anyway, I got there in the end, here is the code I used for any one who's interested:

    [Code moderated as per the Forum Rules. Please use the pastebin]

  4. I think Apsira is spamming, but I just can't tell.

    Can you post the code on pastebin? :)

  5. whatachamp
    Member
    Posted 2 years ago #

    Yeah I think Aspira was spamming too.
    My code is in the pastebin: http://pastebin.com/myMq1EaQ
    Thanks Ipstenu

Topic Closed

This topic has been closed to new replies.

About this Topic