What code do I “comment out” to remove the loop from this Custom Taxonomy
What code do I “comment out” to remove the loop from this Custom Taxonomy
What code do I “comment out” to remove the loop from this Custom Taxonomy
I quess that it would be easiest for you to store date as unix timestamp in post meta – than you can easily filter posts by post meta less than current timestamp (or any other date timestamp). See this example (not exactly for your code, but you’ll catch the punch line: $args = array( ‘post_type’ … Read more
If you store the event start date in _event_start_date, then you can check the value of this field against current date: if (strtotime(get_post_meta($id, ‘_event_start_date’, true)) > time()){ // future event } else { // past event }
function comment_author_id($query) { $author_id = get_query_var( ‘hotel_name’ ); if ($author_id) { $query->set(‘author’, $author_id); } } add_action( ‘pre_get_posts’, ‘comment_author_id’ );
All you need is to use pre_get_posts action to hook to add author_id to the query based on your custom custom_user_id query var: add_action( ‘pre_get_posts’, ‘filter_by_custom_user_id’ ); function filter_by_custom_user_id( $query ) { // Apply only on frontend, for gallery post type archive, for main query and if custom_user_id query var is set. if( ! is_admin() … Read more
I found my problem, because I’s causing the issue by myself unknowingly. I’m posting the answer for you to debug if something like this can cause the issue: I’s using the following code to include all the CPT entries to the default loop. And that’s causing the issue. It’s directing the posttype archive to default … Read more
@DarrenLee, to add multiple post types on your code, you just make a change on function cpt_rewrite_rules. Create an array of your post types, put function cpt_generate_date_archives inside loop. function cpt_rewrite_rules($wp_rewrite) { $post_types = array( ‘book’, ‘movie’, ‘etc’ ); //create post_types array $rules = array(); foreach( $post_types as $post_type ) { /* generate date archives … Read more
has_archive was set to true and my understanding is that now when I goto /articles I am supposed to see all posts of type article. Nowhere in your code is articleS mentioned, the slug of the post type is article, so the URL of its archive should be /article/. If you want it to be … Read more
Figured it out. A conditional in content.php in template-parts/ checked whether the content is_archive. I assume the functionality behind is_archive is whether the file was launched from archive.php. Since it wasn’t it didn’t fire. Final step was redirecting to a custom content-post-type.php in template-parts that doesn’t have the is_archive check. Seems like it all works … Read more
By default, WordPress does not offer a way of editing archives. (archive templates are utterly useless in any real life applications, if any cares about my opinion). You would have to create a theme option/settings page, where you would control the styling of an archive template. But, quicker would be to just not use an … Read more