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

How can I add an incremental class identifier to my sidebar widgets?

There doesn’t seem to be an easy way to do this. However, you can try this rather hackish approach: add_filter(‘dynamic_sidebar_params’, ‘my_sidebar_params_cb’); function my_sidebar_params_cb($params) { global $my_widget_counter; if (empty($my_widget_counter)) $my_widget_counter = 1; else $my_widget_counter++; $params[0][‘before_widget’] = str_replace(‘class=”‘, ‘class=”widget_nr_’.$my_widget_counter.’ ‘, $params[0][‘before_widget’]); return $params; }

How to exclude certain widget from showing up on home/front page? [duplicate]

I’ve found the exact solution to my question here: https://wordpress.stackexchange.com/a/17687/92505 Here’s the exact code I used after some modification to make it work on my situation. Add the following code to functions.php where ‘sidebar-1’ is your sidebar ID. ‘recent-posts’ is the name of the widget your want yo hide. 12 is the length of the … Read more

Authors details such as social media links, emails etc → Is this Meta or something else?

Add user contact methods using the user_contactmethods filter in your theme’s functions.php or via a plugin: User contact method entries are stored in the wp_usermeta table. The URL field is special; it’s stored in the user_url field in the wp_users table. // Add user contact methods add_filter( ‘user_contactmethods’,’wpse_user_contactmethods’, 10, 1 ); function wpse_user_contactmethods( $contact_methods ) … 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