Hide widget to non-logged in users without plugin (functions.php) [closed]

Tested on Twenty Fourteen and works. Change the loop_start hook to another position if needed. The code goes at the end of your child themes functions.php file. function wpsites_register_widget() { register_sidebar( array( ‘name’ => ‘Logged In Only Widget’, ‘id’ => ‘members-widget’, ‘before_widget’ => ‘<div>’, ‘after_widget’ => ‘</div>’, ) ); } add_action( ‘widgets_init’, ‘wpsites_register_widget’ ); add_action( … Read more

Widget “Save” resetting jQuery hidden fields

You’re looking for jQuery.live(), or jQuery’s livequery plugin, depending on what you’re seeking to do. (The second is the proper one if you need to use onChange events.) As things stand, your jQuery hooks are not called when the save button is called, because the form’s tags are reloaded using ajax, and jQuery(document).ready() is, obviously, … Read more

WordPress “include TEMPLATEPATH” or?

Long answer short: the absolute-best answer, for template-part files in a subdirectory, is to use locate_template() I would recommend referencing the stylesheet path for template file includes, so that those template part files can be easily over-ridden by Child Themes. So, ideally, you should use get_stylesheet_directory_uri(). Some differences/explanation of all the functions listed by @kaiser: … Read more

Using tabs in admin widgets [closed]

The problem is that you’re not using unique IDs (#tabs, #tabs-1 …), because widgets have multiple instances (the same IDs are used by the instance form the “Available Widgets” area). So just prepend or append the widget instance ID to your identifiers to make them unique: … <div id=”tabs-<?php echo $this->id; ?>”> <ul> <li><a href=”#tabs-<?php … Read more

How to execute SQL SELECT query and see the results?

Have a look at the $wpdb class, it does exactly what you want: $myrows = $wpdb->get_results( “SELECT id, name FROM mytable” ); Try to avoid SQL queries for basic operations though. WordPress offers you many convenience functions for 80% of the tasks you would every come up with. They provide a nicer interface and preserve … Read more

Different rss feeds in a single dashboard widget

Yes, @toscho is right, the url works with an array of feeds adresses. And if you have 5/6 feeds, the total of items should be 20/24. For clear separation, I think it’s better to run the wp_widget_rss_output function n number of times, and prepare a previous array with titles and addresses and iterate through it. … Read more

Big side banners

Register sidebars for the banners, then use the text widget to place your code in it. The default widget will strip some HTML code, so you may want to use something less invasive like my Unfiltered Text Widget.

Call sidebar from a template

Impossible with get_sidebar(). From that function’s body: function get_sidebar( $name = null ) { do_action( ‘get_sidebar’, $name ); $templates = array(); if ( isset($name) ) $templates[] = “sidebar-{$name}.php”; $templates[] = ‘sidebar.php’; So if you pass a $name or any other custom value to the function, they will be set between two fixed strings. You can … Read more

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