Wp-query causing problems with the_content();
Try adding wp_reset_postdata(); after the endwhile; statement.
Try adding wp_reset_postdata(); after the endwhile; statement.
You can exclude categories from your posts page using pre_get_posts function exclude_category( $query ) { if ( $query->is_home() && $query->is_main_query() && !is_admin()) { $query->set( ‘cat’, ‘-1347’ ); } } add_action( ‘pre_get_posts’, ‘exclude_category’ ); Might be better to use the category slug or I.D. Same with the tag. There’s also 5 parameters you might want to … Read more
You really should be using custom posts to do what you’re trying to do, but to answer your question here’s a solution (put this in your functions.php file): add_shortcode( ‘job-posts’, ‘rt_list_posts_by_category’ ); function rt_list_posts_by_category($atts) { $a = shortcode_atts( array( ‘link1’ => ‘#’, ‘link2’ => ‘#’, ‘link3’ => ‘#’, ), $atts ); // arguments for function … Read more
Setup cron job You want to do some action (i.e. publishing a post) periodically, so first you need to schedule a cron job. Cron jobs are actions, that are fired periodically at some sort of a time interval. You can either use (non-perfect) WordPress Cron or replace it with a real cron job on your … Read more
Now I’ve understand the question, and yes, it makes sense. The filter additions and the third function do not change at all, what change are the first two functions. There is 2 cases: [AuthorName] part in the url is equivalent sanitize_title($guestauthor) where $guestauthor is what is saved in the ‘guest-author’ custom field [AuthorName] part is … Read more
You can create a new role and add specific capabilities. Or you can conditionally remove access to Edit Posts and any other admin menu items.
Changing the post_type property of a post is easy, but there are a few con’s you would need to consider here before doing so Non hierarchical post types (like post) behaves way different that hierarchical post types (like page). I’m not going to explain everything here, but in general, most importantly, non hierarchical post types … Read more
If you want to check if a post has a password, and that the password has been entered, check both post_password_required() and $post->post_password: $post = get_queried_object(); if ( ! post_password_required( $post ) && ! empty( $post->post_password ) ) { // Post has a password, but has been entered. }
There was an associated post to this one that shed light on this answer. When registering the post type, I was not setting enough fields in the ‘supports’ array of the register_post_type. Adding author, whatdayaknow, gives me the data I’m looking for. Thanks to @milo for being on the right path! register_post_type(self::POST_TYPE, array( ‘labels’ => … Read more
Even better way is to check the current post position in query: global $wp_query; while (have_posts()) : the_post(); $my_class=””; if ( $wp_query->current_post == 0 ) $my_class=” first”; if ( $wp_query->current_post == $wp_query->post_count – 1 ) $my_class=” last”; ?><div class=”post<?php echo $my_class; ?>”><?php … if ( $wp_query->current_post == $wp_query->post_count – 1 ) echo ‘THE CONTENT UNDER … Read more