WordPressSharp icon indicating copy to clipboard operation
WordPressSharp copied to clipboard

How to Find Out if Published Post Already Exists ?

Open GlennIM opened this issue 6 years ago • 1 comments

Before I publish a post I need to know if the post already exists. I know what the title of the post is but I need a way to search the blog for an existing post using the title I already know.

I tried calling the method GetPosts() as shown below but it throws an exception. What can I do to get a list of published posts so that I can search the list. If the list contains the post I need to get the post URL. In the code below, I changed PostStatus to "draft" and the code worked but only returned 10 draft posts and the blog has over 600.

var posts = client.GetPosts(new PostFilter { PostType = "post", PostStatus = "publish" }).OrderByDescending(a => a.Id).ToList();

I changed my code to pass null to the PostFilter as shown below but get the following unhandled exception.

var posts = client.GetPosts(null);

Both lines of code above return the same exception below...

CookComputing.XmlRpc.XmlRpcInvalidXmlRpcException

"response contains invalid dateTime value [response : array mapped to type Post[] : element 2 : struct mapped to type Post : member FeaturedImage mapped to type Object : struct mapped to XmlRpcStruct : member date_created_gmt : dateTime]"

Please Help! Thanks, Glenn

GlennIM avatar Aug 10 '18 15:08 GlennIM

You can write a spider and search it directly on Web pages.

Blackcat156 avatar Oct 29 '18 02:10 Blackcat156