I'm new to Wordpress and just created my first template.
In the functions.php I have put the following code, that function what I understand should call the plugins from the plugins directory:
if (function_exists('register_sidebar')) {
register_sidebar(array(
'name' => 'Widgetized Area',
'id' => 'widgetized-area',
'description' => '',
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
'after_title' => ''
));
}
I do see all the plugins, and in the widget screen I also see the 'widgets' screen and it allows me to drag widgets into the working area.
The website itself displays the plugin's html but neither js nor css is working.
What am I missing?
Above code that you have added in your functions.php is to register sidebar not to call any plugin. It do not have any connection to plugin.
You can call sidebar you added in template as follow:
if ( is_active_sidebar( 'widgetized-area' ) ) {
dynamic_sidebar( 'widgetized-area' );
}
Related
I'm creating a custom theme and in my contact page i want to add a widget to display google maps map throught Wp Google Map plugin but i can't show the map in my page.
In my functions.php i have this:
function arphabet_widgets_init() {
register_sidebar(array(
'name' => 'My_Widgtet_Area',
'id' => 'map-area',
'before_widget' => '<div>',
'after_widget' => '</div>',
'before_title' => '<h2 class="rounded">',
'after_title' => '</h2>',
));
}
In my html file:
<?php
$map = get_page_by_title( 'Mapa' );
echo $map->post_content;
?>
In my page content:
[wpgmza id="1"]
How can i display or associate the widget to my page?
Thank's
You can add the map directly using the given shortcode or you can add the shortcode in the widget and add the widget in page.
To add the map directly in the page using shortcode
echo do_shortcode('[wpgmza id="1"]');
To add widget in the page
dynamic_sidebar('map-area');
Hope it helps...
Please ask if you have any doubts.
I am working on a WordPress site. While adding some widget in widget section, I got some issue.
I add some thing in primary widget area and right widget area, and when I refresh the widget page my added content got disappear although it is displaying in the front-end of WordPress,but now I am not able to edit that content from admin section.
My code is as follows:
add_filter( 'sidebars_widgets', 'disable_sidebar_L_widgets' );
function disable_sidebar_L_widgets( $sidebars_widgets ) {
if (!is_front_page() ) $sidebars_widgets['primary-widget-area'] = false;
return $sidebars_widgets; }
add_filter( 'sidebars_widgets', 'disable_sidebar_R_widgets' );
function disable_sidebar_R_widgets( $sidebars_widgets ) {
if (!is_front_page() ) $sidebars_widgets['right-widget-area'] = false;
return $sidebars_widgets;
}
Edit functions.php and locate for register_sidebar function. Change the id to small caps example :
register_sidebar( array(
'name' => __( 'Main Sidebar', ),
'id' => 'sidebar-1',
'before_widget' => '',
'after_widget' => "",
'before_title' => '',
'after_title' => '',
) );
I am learning wordpress. Now I want to install a simple photo gallery plugin. For that I have downloaded plugin from internet. Now how to integrate that so that I can find from the front-end in a particular position.
Thank you.
Your theme should have specific areas to put the plugins in.
If not You should open the php file of the template that you want to display the plugin in and add this code:
if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Your plugin name') ) :
endif;
Now, open your functions.php and add this:
if ( function_exists('register_sidebar') ) {
register_sidebar( array(
'name' => 'Your plugin name',
'id' => 'login-widget',
'before_widget' => '<section class="login-widget">',
'after_widget' => '</section>',
'before_title' => '<span class="widget-title">',
'after_title' => '</span>')
);
}
after you are done with that, you can go to your administrator page, click on Appearance -> Widgets and then drag the plugin name from the list to the dock named "Your plugin name"
I'm following multiple tutorials that all tell me to put this into my functions.php to add a widget area:
<?php
if ( function_exists('register_sidebar') )
register_sidebar(array(
'before_widget' => '',
'after_widget' => '',
'before_title' => '<div class="title">',
'after_title' => '</div>',
));
?>
Once I upload that file and try to change anything, like post or edit a post I get a white screen directly after hitting publish or any other action button.
Is there something wrong with that code? Or am I missing something when it comes to adding widget areas to my template?
Wordpress doesn't like blank lines on the functions.php page..
I'm new to WordPress theming and have downloaded the Starker's WP theme from starkers
My question is, as this is an updated theme based on new twentyten for WordPress 3.0, do I need all the code in the functions.php file as it all seems to make reference to default twentyten theme?
I'm am doing a CMS and was wondering if there is any important code I need in this functions.php file?
Thanks.
It depends on what stuff you are going to incorporate in your theme. You don't need that all unless you want.
The minimum you need is for sidebar integration, here is an example:
if ( function_exists('register_sidebar') )
register_sidebar(array(
'before_widget' => '<div class="side">',
'after_widget' => '</div></div>',
'before_title' => '<div class="sidebar_title">',
'after_title' => '</div><div class="side_content">',
));
This is usually helpful when you want to assign what should come before or after the sidebar.
For example, I created a theme using Starker's theme and here is all what is present in my functions.php file:
<?php
if ( function_exists('register_sidebar') )
register_sidebar(array(
'before_widget' => '<div class="side">',
'after_widget' => '</div></div>',
'before_title' => '<div class="sidebar_title">',
'after_title' => '</div><div class="side_content">',
));
// add thumbnail support to theme, options will be automatically visible in admin
if (function_exists('add_theme_support')) add_theme_support( 'post-thumbnails' );
?>