How to store and receive variables in WP sessions?

Sessions aren’t enabled in wordpress by default, if you want to activate php sessions add this at the beginning of your functions.php: if (!session_id()) { session_start(); } You now can use $_SESSION[‘your-var’] = ‘your-value’; to set a session variable. Take a look at the PHP documentation on sessions. Update: There was a second answer, which, … Read more

wp_query with custom post type only returning last posted

Using $wp_query as your variable is a bad idea as it is something WordPress uses itself. For returning as many results as you would like you can use posts_per_page in your query. There are many more parameters you can query with in WordPress. $custom_wp_query = new WP_Query(‘posts_per_page=10&post_type=events’);