How to change home or site url using action hooks or filter?

Ok. Then you can use template_redirect hook and wp_is_mobile() conditional tag. wp_is_mobile() will work on device only. If you resize the window then it will not work. Now you can try this kind of code in your functions.php file add_action(‘template_redirect’, ‘redirecting_to_mobile_site’); function redirecting_to_mobile_site(){ if( wp_is_mobile() ){ wp_redirect( ‘http://m.example.com’, 301 ); exit; } }

Fatal Error relating to sessions.php

I fixed it by: 1) checking wordpress version in: /home/myusername/public_html/version.php 2) downloading this version package from wordpress website 3) addingwp-includes/session.php file from downloaded package into /home/myusername/public_html/wp-includes/session.php (that file was empty or not existing)

How to use an associative array in post__in with WP_Query?

Take a look at PHP’s array_values function. Alternatively, you could typecast. Note that if the array is in serialized form as you have put it above, you will have to unserialize it first, in either case. $numerical_array = array_values( unserialize( ‘a:1:{s:8:”post-134″;s:3:”134″;s:8:”post-136″;s:3:”136″;}’ ) ); or $numerical_array = (array) unserialize( ‘a:1:{s:8:”post-134″;s:3:”134″;s:8:”post-136″;s:3:”136″;}’ );

Is it acceptable to treat a filter like an action?

All actions are actually filters internally. So yes, you can do things in a filter hook. However, be mindful of which filters and what you’re doing. Some filters are ran everywhere, and doing expensive operations on them may lead to massive slowdowns. Also beware of recursion. If your expensive operation triggers the very filter you’ve … Read more

PHP Script for last login time

I found it. After a lot of research I found the way to hook into logout and get user data, and as i was looking for that i found the exact answer i was looking for. function users_last_login() { $cur_login = current_time(‘mysql’); $userinfo = wp_get_current_user(); update_user_meta( $userinfo->ID, ‘last_login’, $cur_login ); } add_action(‘clear_auth_cookie’, ‘users_last_login’, 10); Thanks … Read more

Remove wp_admin_bar fail on wordpress 4.0

You must use show_admin_bar(false); for disabling admin bar to disable admin bar for all except admin add this to functions.php add_action(‘after_setup_theme’, ‘remove_admin_bar’); function remove_admin_bar() { if (!current_user_can(‘administrator’) && !is_admin()) { show_admin_bar(false); } } you can refer about that here

Change behavior of the tag

It sounds like this is a problem with the way your theme is setup, since what you describe isn’t the usual behaviour of the more tag. The first part of your post suggests there’s some built-in Javascript in your theme causing the read more to expand the post text rather than take you to the … Read more

Sort posts by custom fields value using dropdown menu

Instead of query_posts try using WP_Query class. http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters This is example from codex: $args = array( ‘post_type’ => ‘my_custom_post_type’, ‘meta_key’ => ‘age’, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘ASC’, ‘meta_query’ => array( array( ‘key’ => ‘age’, ‘value’ => array( 3, 4 ), ‘compare’ => ‘IN’, ), ), ); $query = new WP_Query( $args );