Get all posts by post_author
The shortest possible answer would be to correct ‘post_author’ to ‘author’, since that is the key WP is looking for. If a key is incorrect or misspelled it will be ignored, as was the case with ‘post_author’.
The shortest possible answer would be to correct ‘post_author’ to ‘author’, since that is the key WP is looking for. If a key is incorrect or misspelled it will be ignored, as was the case with ‘post_author’.
You need Post Status Transitions actions function notify_me_for_pending( $post ) { $user_info = get_userdata ($post->post_author); $strTo = array (’[email protected]’); $strSubject=”Fstoppers: ” . $user_info->user_nicename . ‘ submitted a post’; $strMessage=””” . $post->post_title . ‘” by ‘ . $user_info->user_nicename . ‘ was submitted a post for review at ‘ . wp_get_shortlink ($post->ID) . ‘&preview=true. Please proof.’; wp_mail( … Read more
As setup_postdata is messing with global variables that might be (most probably: are) used by other loops (including The Loop), you should always reset these variables to what they should be—according to the main query (i.e., what WordPress thinks the user wanted in the first place). In addition, setup_postdata is provided with (a reference to) … Read more
Another option is to use the do_shortcode() function. This will make WordPress run the shortcode as if it was in the content editor. So where you want your post tags to appear just put. <?php echo do_shortcode(‘[post_tags]’); ?>
Add this to single.php, and make sure you paste in inside the loop. <?php setPostViews(get_the_ID()); ?> Lastly, to display the number of views a post has, just add this where you want it to be displayed: <?php echo getPostViews(get_the_ID()); ?> . <?php // function to display number of posts. function getPostViews($postID){ $count_key = ‘post_views_count’; $count … Read more
I think you are searching for the get_tags() function. You would need to place it into the single-post.php (or single.php if your theme doesn’t have a single-post.php) (to find the right template file you can always look up at WordPress Template Hierarchy). To echo a list of tags with the aboved linked function you would … Read more
You can exclude posts from archive pages with thee help of pre_get_posts action. Usually pre_get_posts is used to modify main query, so it’s best solution for your problem. function my_custom_get_posts( $query ) { if ( is_admin() || ! $query->is_main_query() ) return; if ( $query->is_archive() ) { $query->set( ‘post__not_in’, array( 7, 11, 21 ) ); } … Read more
The plugin has a filter drh_allow_rest_api which determines whether the current user has full access and can skip the whitelist check. By default this is just is_user_logged_in(): /** * Allow carte blanche access for logged-in users (or allow override via filter) * * @return bool */ private function allow_rest_api() { return (bool) apply_filters( ‘dra_allow_rest_api’, is_user_logged_in() … Read more
Inside the Loop, try something like the following: <?php if ( get_post_format() && in_array( get_post_format(), array( ‘audio’, ‘video’ ) ) ) { // The current post has either the // audio or video post format; // enqueue a script wp_enqueue_script( $handle, $src ); } ?> Now that WordPress can handle inline script-enqueueing, this should work … Read more
Another method can be like this, On the current post when you save look for youtube video in the content, if found save it to the transient ‘videos’ and the post_id (for the link to the post later) insted of regex im using parse_url() and parse_str() add_action( ‘save_post’, ‘save_youtube_videos’ ); function save_youtube_videos( $post_id ) { … Read more