Support » Themes and Templates » how to include any script output into WP_tag as a parameter?

  • Hi all!
    I am trying to include a PHP (or cgi, doesn’t matter) script output into a get_archives() tag instead ‘before’ parameter
    for example:
    <?php get_archives(‘postbypost’,’10’,’html’,”,'<?php include(‘file.php’); ?>’,”); ?>
    but i can’t…
    how to do that?

Viewing 5 replies - 1 through 5 (of 5 total)
  • You can’t nest <?php?> tags.

    You could try include('file.php') as the argument, but that won’t work in the way you’re after as it outputs and evaluates the file contents rather than just return it as a string (which is what you need here). If your host is running PHP 4.3.0 or greater, use:

    <?php get_archives('postbypost','10','html','', file_get_contents('file.php'),''); ?>

    Thank you Kafka!
    It works great, but only for the file contents, not for the script output.
    Actually i want to have a random quote as ‘before’ parameter. Could you please help me with this?

    I am triyng to use ‘witty text’ rundomizer plugin like this:
    <?php get_archives(‘postbypost’,’5′,’html’,witty(),'<br><br>’,”); ?>
    but it works only for the first post from five. How to do it for all fives?

    You could assign the output of Witty Text to a variable, which is then passed to get_archives(). However, since Witty Text doesn’t return its output, we’ll have to work around that:

    $witty = ob_get_contents();
    get_archives('postbypost','5','html',"$witty",'<br /><br />','');

    Note this won’t generate a new “witty text” for each line displayed through get_archives(). For something like that you’re looking at customizing the get_archives() code.

    Thank you, Kafka!
    It works great.
    I’ll try to customize function get_archives()
    Are you talking about this code (from /wp-includes/template-functions-general.php)?
    /* link navigation hack by Orien */
    function get_archives_link($url, $text, $format = ‘html’, $before = ”, $after = ”) {
    $text = wptexturize($text);
    $title_text = wp_specialchars($text, 1);

    if (‘link’ == $format) {
    return “\t<link rel=’archives’ title=’$title_text’ href=’$url’ />\n”;
    } elseif (‘option’ == $format) {
    return “\t<option value=’$url’>$before $text $after</option>\n”;
    } elseif (‘html’ == $format) {
    return “\t

  • $before$text$after
  • \n”;
    } else { // custom
    return “\t$before$text$after\n”;

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘how to include any script output into WP_tag as a parameter?’ is closed to new replies.