Skip to:
Content
Pages
Categories
Search
Top
Bottom

How To Hard Code Widgets Into Member Themes

Viewing 6 replies - 1 through 6 (of 6 total)

  • @mercime
    Participant

    @mercime

    Basically, you just delete or not add the function and the closing tag that makes the sidebar dynamic or widgetized.

    For example, open up WPMU’s default theme’s sidebar.php. You will see near the top of the file …

    <div id="sidebar" role="complementary">
    <ul>
    <?php /* Widgetized sidebar, if you have the plugin installed. */
    if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?>
    <li>
    <?php get_search_form(); ?>
    </li>
    etc
    etc
    etc

    and the file ends ends with

    <?php endif; ?>
    </ul>
    </div>

    So you delete the

    <?php 	/* Widgetized sidebar, if you have the plugin installed. */
    if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?>

    near the top of the sidebar.php file and delete

    <?php endif; ?> near the bottom of the sidebar.php file

    The codes before, in between and after these are hardcoded now. Your members cannot change anything in the sidebar.


    surfartculture
    Participant

    @surfartculture

    I wanna members can change sidebars, i wanna let members add sidebars widgets on their own profiles, how can I do this?


    @mercime
    Participant

    @mercime

    @surfartculture – you have many threads regarding this including https://buddypress.org/forums/topic/god-help-me wherein you’ll find a helpful code regarding this matter from Boone Gorges:

    global $bp;
    if ( $bp->loggedin_user->id == 1 ) {
    /* Display the stuff you want user 1 to see */
    } else if ( $bp->loggedin_user->id == 2 ) {
    /* Stuff you want user 2 to see */
    } /* etc */

    But you have to give more information about your installation so that forum volunteers can help you out specific on your install.

    1. What WPMU version?

    2. What BuddyPress version?

    3. What theme are you using?

    4. Site URL?


    dainismichel
    Participant

    @dainismichel

    OK, this helps as well

    https://codex.wordpress.org/Customizing_Your_Sidebar

    Now, how can I find where to put those customizations if I’ve

    copied bp-default and named it bp-default-members

    copied bp-sn-parent and named it bp-sn-parent-members

    appropriately called bp-sn-parent-members from bp-default-member’s style.css file

    …what I mean is that when I look at sidebar.php. it looks like it’s putting the same code into all 3 sidebars to me…so how do I put the customization I want into the sidebar I select?

    Also, since this is BuddyPress, how do I make sure that I’m pulling in “Recent Posts” from the member blog and not from all blogs…maybe that’s what happens anyway…

    and how do I define what people will see when viewing a member’s posts? Is that one of the existing sidebars? I actually hope not, since I want to code that differently.


    dainismichel
    Participant

    @dainismichel

    For example: Where would I put “<?php wp_list_categories(‘title_li=’ . __(‘Categories:’)); ?>” to have the categories show up in the rightmost sidebar?

    What file do I put the code into and where?

    Where do I put the code for each individual sidebar?


    dainismichel
    Participant

    @dainismichel

    Ahh, I think I may be asking the wrong question.

    Can you give me a code snippet that would hard code, for example, categories into a specific sidebar and show me how to go from there (inserting code for specific widgets into specific sidebars) on my own?

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How To Hard Code Widgets Into Member Themes’ is closed to new replies.
Skip to toolbar