Make WordPress Core

Opened 23 months ago

Last modified 23 months ago

#55920 new enhancement

Ability to query by post author in post_exists()

Reported by: mcqtia's profile mcqTia Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 6.0
Component: Posts, Post Types Keywords: changes-requested has-patch
Focuses: Cc:

Description

Needed the ability to determine if post exists by title && author when running wp_insert_post() in form submission.
I was using this to create a list of user saved favourite posts.

So this might be useful for others too

function post_exists( $title, $content = , $date = , $type = , $status = , $author = ) {...}

Pull Request #2783

Change History (3)

This ticket was mentioned in PR #2783 on WordPress/wordpress-develop by tiadotdev.


23 months ago
#1

  • Keywords has-patch added

Needed the ability to determine if post exists by title && author when running wp_insert_post() in form submission.
I was using this to create a list of user saved favourite posts.

So this might be useful for others too

function post_exists( $title, $content = , $date = , $type = , $status = , $author = ) {...}

Trac ticket: [](https://core.trac.wordpress.org/ticket/55920#ticket)

tiadotdev commented on PR #2783:


23 months ago
#2

All updates made, thanks for flagging!

What do I need to do for unit testing?

TimothyBJacobs commented on PR #2783:


23 months ago
#3

You'll want to add tests after this one. We'll want tests that check that the function returns true with a matching author ID and false with a non-matching author ID.

You can take a look at the Automated Tests Handbook for more guidance too.

Note: See TracTickets for help on using tickets.