Undefined is_user_logged_in() error with Plugin Query code

require_once( wp_normalize_path(ABSPATH).’wp-load.php’); class Your_Plugin_Class { private $is_user_logged_in; add_action(‘init’, function(){ $this-> is_user_logged_in = is_user_logged_in(); echo ‘is_user_logged_in’.$this->is_user_logged_in; }); add_filter(‘woocommerce_billing_fields-2’,array( $this, ‘add_billing_field’ )); } public function add_billing_field( $fields = array() ) { if ( $this->is_user_logged_in ){ echo ‘add_billing_field’.$this->is_user_logged_in; return $fields; }else{ echo ‘add_billing_field’.$this->is_user_logged_in; } } }

How to get the number of pages when paginating comments?

Try get_comment_pages_count()? <?php get_comment_pages_count( $comments, $per_page, $threaded); ?> I’m guessing you’re outside the loop, since you’re calling get_comments(); in that case, you’ll need to pass your $comments object: $comments = get_comments(array( ‘post_id’ => $post_id, ‘status’ => ‘approve’ )); wp_list_comments(array( ‘page’ => 1, ‘per_page’ => 10, ‘avatar_size’ => 16, ), $comments); $comment_page_count = get_comment_pages_count( $comments );

Passing values between enclosing and enclosed shortcodes

You can try this plugin: /** * Plugin Name: My Boxes Shortcode * Author: birgire * Author URI: http://wordpress.stackexchange.com/a/121423/26350 */ add_action( ‘plugins_loaded’, array( ‘My_Boxes_Shortcode’, ‘get_instance’ ) ); if( ! class_exists( ‘My_Boxes_Shortcode’ ) ) { class My_Boxes_Shortcode { static private $instance = NULL; static public function get_instance() { if ( NULL === self::$instance ) self::$instance = … Read more

Get Posts by IDs (optionally)

It looks like WordPress doesn’t ignore empty post__in param. So you’ll have to do this yourself like this… $ids=”1,2,3″; if ( $ids ) { $arr = explode(“,” ,$ids); $args = array( ‘posts_per_page’ => $number, ‘post__in’ => $arr ); } else { $args = array( ‘posts_per_page’ => $number ); }