Actions and Scripts WordPress
Removing Default WordPress Profile Fields. Code checked, everything is working.
1 2 3 4 5 6 7 |
add_filter('user_contactmethods','hide_profile_fields',10,1); function hide_profile_fields( $contactmethods ) { unset($contactmethods['aim']); unset($contactmethods['jabber']); unset($contactmethods['yim']); return $contactmethods; } |
Adding a Horizontal Line Button to the WordPress Visual Editor.
1 2 3 4 5 |
function enable_more_buttons($buttons) { $buttons[] = 'hr'; return $buttons; } add_filter("mce_buttons", "enable_more_buttons"); |
Custom sidebar for website homepage
To create a new sidebar, you need to create a file sidebar-home.php in the root folder of your template. We put the contents of the file into it sidebar.php.
And replace part of the sidebar code:
1 |
<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?> |
For this code:
1 |
<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar( 'home-sidebar' ) ) : ?> |
Next, on the main page, replace the code:
1 |
<?php get_sidebar(); ?> |
to the code:
1 2 3 4 5 6 7 |
<?php if ( is_home() ) : get_sidebar('home'); else : get_sidebar(); endif; ?> |
Next, in order to be able to add widgets to our new sidebar, you need to register it in WordPress using the register_sidebar function.
1 2 3 4 5 6 7 8 |
register_sidebar(array( 'name'=>'home-sidebar', 'id' => 'home-sidebar', 'before_widget' => '<li id="%1$s" class="widget %2$s">', 'after_widget' => '</li>', 'before_title' => '<h2 class="widgettitle">', 'after_title' => '</h2>', )); |
Good luck in developing user-friendly sites on CMS WordPress.
/*
- Basic web design course;
- Site layout;
- General course on CMS WordPress and continuation of the course on template development;
- Website development in PHP.