How to enqueue script if widget is displayed on page?

You should be able to call wp_enqueue_script() as part of your Widget output. Edit Quick-and-dirty, using the bare-bones Widgets API class example: <?php class wpse48337_Widget extends WP_Widget { public function __construct() { // widget actual processes } public function form( $instance ) { // outputs the options form on admin } public function update( $new_instance, … Read more

CSS classes for theme

There are many CSS classes generated by WordPress, depending on context. The Theme Review Guidelines include the following, WordPress-generated CSS classes: Alignment Classes: .aligncenter .alignleft .alignright Caption Related Classes: .wp-caption .wp-caption-text .gallery-caption Post Classes: .sticky Comment Classes: .bypostauthor Then, there are the body classes generated by body_class(). Then, there are the post classes generated by … Read more

Should we use get_template_part() in functions files instead of include_once?

Your functions.php doesn’t create output, so you should use locate_template(). Example: locate_template( ‘php/functions.nav-menu.php’, TRUE, TRUE ); You’ll find this function in wp-includes/theme.php. The first parameter is the file path relative to the theme root, the second tells WordPress to load it (or not), and the third to load it just once. Now a child theme … Read more

What is the difference between wp_register_sidebar_widget and register_widget?

wp_register_sidebar_widget() is part of the old widgets API. Sidebar widgets used to be built procedurally … in a non-reusable fashion (i.e. you could only ever have one of each). register_widget() was introduced with the new Widgets API and takes an object/class as an input rather than actual widget parameters. WordPress can instantiate as many copies … Read more

How to move page template files like page-{slug}.php to a sub-directory?

How Page Templates are loaded: According to the default WordPress Template Hierarchy, a page request loads a template based on the priority and naming as stated below: Custom Page Template: if defined in the page editor. page-{slug}.php page-{url-encoded-slug}.php: only for multi-byte characters. page-{id}.php page.php singular.php index.php Among these, singular.php and index.php are not actually page … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)