the_widget() and widget’s ID

I believe @One Trick Pony was right. Shortcode widgets have no ID, so I’ve found a way around. Firstly I used PHP rand function: $var = rand(); And then added the “var” to the ID, so it doesn’t collide with other shortcodes calling the same widget (each one has different random number at the end … Read more

Custom Menus, Widgets & Conditional Statements

if you want to show the menus only on child pages then you need to change your conditional statement: global $post; //only on children of 269 if (‘269’ == $post->post_parent){ //menu for Sport & Fitness pages ?> <div id=”seventh” class=”widget-area” role=”complementary”> <?php dynamic_sidebar( ‘sidebar-7’ ); ?> </div><!– #second .widget-area –> <?php //only on children of … Read more

How to rename wordpress Widget

The classes assigned to rendered Widgets are specified by the argument array passed to the register_sidebar() call used to register the sidebar. e.g.: <?php $args = array( ‘name’ => sprintf(__(‘Sidebar %d’), $i ), ‘id’ => ‘sidebar-$i’, ‘description’ => ”, ‘before_widget’ => ‘<li id=”%1$s” class=”widget %2$s”>’, ‘after_widget’ => ‘</li>’, ‘before_title’ => ‘<h2 class=”widgettitle”>’, ‘after_title’ => ‘</h2>’ … Read more

Pass variables from one widget to another widget

You don’t need to make it global. If your include a file from within a functions scope, any variables that you defined in that function (before that point) will be exposed in the included file as well. But because the variable you are talking about represents the state of the footer file inclusion (if I … Read more

Latest/Recent posts widget title link

I’ve updated your widget code to include a new field called “Title Link”. This, along with some additional markup, will create a link around your widget title. You’ll probably need to add better validation to the Title Link field. <?php /** * Widget Name: Recent Posts with Excerpts Widget * Description: A widget that allows … Read more

How to check if searchform.php is being included as widget?

Check if searchform is included? The get_search_form() function (that should be used) uses locate_template(‘searchform.php’); to display the search form. The later returns (as you can see from its source) the template filename if one is located So if you’re just wanting to catch the default way, then you should simply test ‘searchform.php’ === locate_template( ‘searchform.php’ … Read more

duplicate sidebar

Try giving a unique ID to each dynamic sidebar, via the id parameter passed to register_sidebar(): register_sidebar( array( ‘id’ => ‘essential’, ‘name’ => __(‘Essential Plan’), ‘before_widget’ => ”, ‘after_widget’ => ”, ‘before_title’ => ”, ‘after_title’ => ” ) ); register_sidebar( array( ‘id’ => ‘premier’, ‘name’ => __(‘Premier Plan’), ‘before_widget’ => ”, ‘after_widget’ => ”, ‘before_title’ … Read more

Insert custom content before widget title/after widget opening tag

You can use the dynamic_sidebar_params filter: add_filter( ‘dynamic_sidebar_params’, function( $params ) { // target a sidebar id: if( isset( $params[0][‘id’] ) && ‘sidebar-1’ === $params[0][‘id’] { // target a widget name: if( isset( $params[0][‘widget_name’] ) && ‘Text’ === $params[0][‘widget_name’] ) { // target a widget id: if( isset( $params[0][‘widget_id’] ) && ‘text-8’ === $params[0][‘widget_id’] ) … Read more

Using jQuery in widget development

You can hook into the DOMNodeInserted event to find out when your widget has been added to the side bar. jQuery(document).on(‘DOMNodeInserted’, ‘.widget-top’, function () { alert(jQuery(‘.widget-title’, this).text()); }); The code above will alert to any newly added widget. Once you’re hooked into the newly created widget, you can traverse it to find your specific class … Read more

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