Hi @Carson:
A simple function to address what you are asking for might be the function yoursite_user_has_posts()
which leverages the built in WP_Query
class:
function yoursite_user_has_posts($user_id) {
$result = new WP_Query(array(
'author'=>$user_id,
'post_type'=>'any',
'post_status'=>'publish',
'posts_per_page'=>1,
));
return (count($result->posts)!=0);
}
You can then call it from your theme like this:
<?php
$user = wp_get_current_user();
if ($user->ID)
if (yoursite_user_has_posts($user->ID))
echo 'Thank you for writing!';
else
echo 'Get Writing!';
?>
Related Posts:
- Possible to turn off autosave for single custom post type
- Searching multiple custom post types and pages
- Correctly delete posts with meta and attachments [duplicate]
- Can’t get post id on page that is a custom post type archive
- Is it possible to change the URL of custom post types to hide the post type slug?
- Querying custom post type with 2 custom fields (date-range)
- Is it possible to create an “export to PDF” option?
- manage posts custom column is not populating data from meta boxes
- Order Posts by Taxonomy and Meta Value
- Custom comment status possible?
- Group Custom post type in a page by its taxomony tag
- Getting taxonomy terms used by custom post type
- How do I echo the post type?
- Categories not working as expected with custom post type
- Custom Post Type rewrite rules not working, how to alter the rewrite order?
- error in Advanced Search Form for Custom Post Types in WordPress array_key_exists() expects parameter 2to be array, string given
- Merge multiple custom post types in a single archive template
- Problem adding column to WC Subscription [closed]
- Custom Post Type | Fatal Error on register_post_type()
- query posts and custom post type with meta key
- Custom Post Types for Support Ticket plugin?
- How to sort custom post type posts in default order by multiple fields?
- Displaying a form for filtering in custom post type listing
- Query string parameters from custom fields, inconsistent results
- How can I update the permalink everywhere for a custom post type?
- create a template page for a post
- Adding Show Less/More link to Custom Post Meta
- custom admin screen or setting screen for a custom post type [duplicate]
- How to assign permissions for a CPT to a user
- Using POST method in meta box, no results
- Displaying Posts from Custom Post Types
- Global $post shows null in some of my custom post types archive pages
- 404 in custom post type feed with mistake permalink
- Custom post type editor uses old tinyMCE
- Custom Type add Transitions
- Pagination not working on custom query on a page
- How to properly delete custom post type posts programmatically
- Query within a foreach within a query (queryception)
- How do I get_the_postID() for a custom post that uses ACF repeater field?
- CMB2 metabox create select with list of post from CPT
- get_post_permalink() and custom permalink rewriting
- Custom post type name and assigning custom taxonomy
- Custom post type – how to name file?
- custom post creation on front page – on submit a search is done
- Query Custom Posts – Add To Selection
- WordPress custom taxonomy page
- How great custom post type can be?
- count & sum the value of custom field of the author post in dynamic posts
- Set priority to permalinks
- Display a Custom Post Type with Advanced Custom Fields on Homepage
- How to list posts by terms
- How to display all terms from all taxonomies in post, but separately for each taxonomy?
- Add a comments meta box to the custom post type
- Ordering Post by Meta Key (Not Working)
- Enforce all custom posts have specific custom fields
- Sortable column with custom taxonomy in custom posts type
- creating a custom post template
- Showing custom post user wise with different color in wordpress
- 2 custom posts types, in their own columns, one pagination for both
- Post to type posts in subdirectory. [closed]
- Post data in separate divs with incrementing class using WP_Query
- send email to all registered users when post expires
- Add number in increment of one to DIV ID
- Make title field multiline in the add new custom post page?
- How to list groupings and keep pagination
- rewrite rules add a folder in the path
- Custom Post Types and Taxonomies
- Featured image in admin on custom post type
- Previous and Next posts
- Post_type doesn’t work for widgets?
- why does my post loop break the page?
- show only one category posts in admin
- How to add custom permalink struct with DYNAMIC author to a Custom Post Type
- WPNavi pagination links not working on custom pages
- Rewrite Rule for custom post type link with or without taxonomy terms
- How to add to taxonomies to a post type
- Custom plugin contact form connecting to mailchimp API
- Posts structure named to blog, how to add month and year
- How to change post cpt with submit button?
- Filtering custom post types using category taxonomy
- Storing every individual update to the posts being updated over time?
- Rewrite nested urls for custom post type
- Custom Post Type featured option
- Change post structure
- WP Query + custom fields: How to query event posts from the current date backwards 6 months and organize it month by month?
- Custom post type Premalinks main page and details page
- Two custom post type relations
- Update Custom Field daily within 7days
- set_post_thumbnail or media_sideload_image adds image multiple times in media library
- How to use wp_set_object_terms depending on page ID?
- Change CPT Edit Target Link for Admin List
- How can I produce multiple webpages with a different output based on one entry/Page/custom Page?
- custom taxonomy not return in the code
- Rewrite rule taxonomy url with different values in one function
- How to display posts from IMPress for IDX Broker on home page? [closed]
- Permalinks for Custom Post Types and Taxonomies
- Group search results by post type, but having a unique heading for each section?
- selecting custom post types and taxonomies for hub page listing blocks
- Remote database access on another wordpress site’s custom post type
- How do I get parameters from the URL?