Show scheduled posts in archive page

Keep things simple – leave your archive templates alone and place this in your functions.php; add_action( ‘pre_get_posts’, function ( $wp_query ) { global $wp_post_statuses; if ( ! empty( $wp_post_statuses[‘future’] ) && ! is_admin() && $wp_query->is_main_query() && ( $wp_query->is_date() || $wp_query->is_single() ) ) { $wp_post_statuses[‘future’]->public = true; } }); Essentially, it says; If we’re on a … Read more

Most elegant way to enqueue scripts in function.php with foreach loop

You need to enqueue the scripts as well, not only register them. You can, however, just simply enqueue a script without registering it if you are not going to enqueue it conditionally. I would try something like this: (Untested and requires PHP5.4+) add_action( ‘wp_enqueue_scripts’, enqueue_scripts, 11 ); function enqueue_scripts() { /** * Build an array … Read more

Order custom posts by taxonomy?

I believe you need a tax_query like the following from the Codex: $args = array( ‘post_type’ => ‘post’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘people’, ‘field’ => ‘slug’, ‘terms’ => ‘bob’ ) ) ); $query = new WP_Query( $args ); In your case that would look something like: $args = array( ‘post_type’ => ‘books’, ‘tax_query’ … Read more

How to find meta_values to call

On the post edit screen you can have the »Custom Fields« meta box, looking somewhat like shown here. You might have to enable it via the screen options. This way you can see the meta data for the edited post, but underscored meta data won’t be shown, because it is hidden. To make the hidden … Read more

Query date in wordpress loop

You want to query for posts with event_date in the future but you have saved (or so it seems from a comment), your dates as: date(“F”, $unixtime).” “.date(“d”, $unixtime).”, “.date(“Y”, $unixtime); That is “textual month name” + “numeric day” + “numeric year”. There is no way to query/sort that format so that it matches a … Read more