Support » Fixing WordPress » How can I call a function into another function?

  • microtag

    (@microtag)


    How can I call a function into another function?

    Example:

    <?php
    query_posts(‘tag=one’);
    ?>
    show only post with tag one…but if tag is a variable?

    How insert <?php single_tag_title(); ?> instead of one ???

    If try:

    <?php
    query_posts(‘tag=<?php single_tag_title(); ?>’);
    ?>

    I’ve get an error..
    How can I resolved it?

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • Michael Torbert

    (@hallsofmontezuma)

    WordPress Virtuoso

    An argument can’t be a function, but it can be a variable. I’m not exactly sure what you’re trying to do, but if you can store the return value of one function as a variable, and then use that in your parameters.
    I don’t know if this would be a solution for you or not, just based on the one line of code.

    Michael Torbert

    (@hallsofmontezuma)

    WordPress Virtuoso

    Well that’s not exactly true, an argument can be a function, but not the way you’re doing it.
    Why do you have an extra <?php and ?>… does query_posts() step out of PHP?

    microtag

    (@microtag)

    I’ve many post with tags..
    In sidebar, into archive page, I would insert this code:

    <?php
    query_posts(‘tag=iphone+video&showpost=10’);
    ?>

    Works correctly…show only post with tags iphone and video..but if I would change “iphone” with current tags I’ve many problems…

    Ex:

    <?php
    query_posts(‘tag=<?php single_tag_title(); ?> +video&showpost=10’);
    ?>

    ok, so how do you place the variable in the function?

    i have converted the argument into a variable:
    <?php $current_tag = single_tag_title("", false); ?>
    now
    <?php single_tag_title(); ?>
    is
    $current_tag
    am i right?

    now how can i add that variable to this function (replacing the tag “coldplay” with “$current_tag”)

    <?php
    echo '	';
    if ( is_tag(coldplay) ) {
     ' &raquo;  '; include(TEMPLATEPATH . '/articles/coldplay.php');
    }
    echo '
    ';
    ?>

    how is the final code?
    please help me thanks! i have been hours trying to solve it

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How can I call a function into another function?’ is closed to new replies.