How to make wordpress sidebar

2019-09-02 01:20发布

问题:

Hello on my website I have a Blog that is powered by wordpress, i was able to make a simple theme that is the same as the website however i cannot create a side bar, does anyone know how to do it heres the code from the sidebar file

    <?php if ( is_active_sidebar( 'sidebar-1' ) ) : ?>
    <div id="secondary" class="widget-area" role="complementary">
        <?php dynamic_sidebar( 'sidebar-1' ); ?>
    </div><!-- #secondary -->
<?php endif; ?>

I do not have a functions file i just have a header, index, footer and side bar,i am just wanting a simple sidebar that shows recent posts, and browsing by date. Any help is welcomed thanks.

Oh a link to the site jp creative vision

回答1:

I was able to get a friend of mine who uses wordpress as him main development method, he showed me how to do what i needed, was missing the functions file like i thoght. Anyone else stuck on this here is a great post on it

Wordpress adding sidebar theme



回答2:

This should be easiest way without going to function.php and all, try this one:

create a php file with name of your sidebar e.g TEMP with this name sidebar-TEMP.php (just add prefix 'sidebar-' before your sidebar script)

in that file put all your sidebar code.

and to call put this code:

<?php get_sidebar( 'TEMP' ); // (avoid your prefix here) ?>

thanks.



标签: wordpress