Skip to:

Re: adding widgets to a custom page



OK I still need a little help here:

I am creating custom pages on my site the following way:
in bp-custom.php I am adding:

define(‘BP_MYPAGE_SLUG’, ‘mypage’);

function mypage_page_setup_root_component()
global $bp;
bp_core_add_root_component( BP_MYPAGE_SLUG );
add_action( ‘plugins_loaded’, ‘mypage_page_setup_root_component’, 2 );

function bp_show_mypage_page() {
global $bp, $current_blog, $wpdb;

if ( $bp->current_component == BP_MYPAGE_SLUG && $bp->current_action == ” ) {
// The first variable here must match the name of your template file below
bp_core_load_template( ‘mypage’, true );
add_action( ‘wp’, ‘bp_show_mypage_page’, 2 );

I am also creating a file called mypage.php inside my theme. this works great and already many custom pages like that.
What I want is to add the content of a widget (for example activity widget) into this page.

here is what i did: i created a new sidebar in functions.php lets assume its called mysidebar:

register_sidebars( 1,
‘name’ => ‘mysidebar’,
‘before_widget’ => ‘

‘after_widget’ => ‘

‘before_title’ => ‘

‘after_title’ => ‘


then within my newly created file called mypage.php i have the following code:
<?php if ( !function_exists('dynamic_sidebar')
|| !dynamic_sidebar(‘mysidebar’) ) : ?>

<a href="/wp-admin/widgets.php?s=&show=&sidebar=mysidebar”>

then i added the site activity widget in the admin to the mysidebar that I created.

So far it all works great. my problem is that when the widget gets added to my custom page mpage.php it pretty much goes all over the page and messes up things like the left hand side navigation menu, options-bar etc.
even placing it within html table doesnt help as it seems that it is trying to conform to the 3 widget areas I have on other sections of my site (like home page etc).
How do I control the location of the widget’s content on a custom page like that?

Help is much appreciated!



Skip to toolbar