开发者

Using an include inside an echo

开发者 https://www.devze.com 2023-02-01 10:04 出处:网络
I am trying to insert this search form into my wordpress header. I found where php calls for the user-uploaded logo, and would like to insert the form immediately after.

I am trying to insert this search form into my wordpress header. I found where php calls for the user-uploaded logo, and would like to insert the form immediately after.

Search form include:

<?php include ('wp-content/themes/thematic/searchform.php'); ?>

Functions.php echo:

function childtheme_override_blogtitle(){

    global $up_options;

    echo '<div id="blog-title"><span><a href="' . get_bloginfo('url') . '/" title="' . get_bloginfo('name') . '" rel="home"><img src="' . $up_options->logo . '" alt="" /></a></span></div>';

}

add_action('thematic_header','childtheme_override_blogtitle',3);

function childtheme_override_blogdescription(){

I tried inserting the form as a separate div, but this keeps the form from centering with the rest of the main content. So I am trying insert the form where php creates the div. You c开发者_开发问答an see my current progress here: texturly.com


There's a function for including the theme's searchform..
http://codex.wordpress.org/Function_Reference/get_search_form

Just call it inside your function or appropriate file.

<?php get_search_form(); ?>

There's an example filter on the above codex page to, should you want to override searchform markup from within your functions file.

EDIT: Regarding placement inside the function, i'd write it a little something like this.

function childtheme_override_blogtitle(){
    global $up_options;
    ?>

    <div id="blog-title">
        <span><a href="<?php bloginfo('url'); ?>" title="<?php bloginfo('description'); ?>" rel="home"><img src="<?php echo $up_options->logo; ?>" alt="" /></a></span>
        <?php get_search_form(); ?>
    </div>

    <?php
}

Of course move that search form where you want it, i just reformatted how the HTML is generated so you'll have an easier time adjusting it.

Hope that helps.

0

精彩评论

暂无评论...
验证码 换一张
取 消