• Huh… Documentation says it exists and I see the function in: post.php

    When I try to call and use the function, I get an error saying the function does not exist.

    I am trying to use this inside a plugin main file.

    Help is appreciated 🙂

Viewing 4 replies - 1 through 4 (of 4 total)
  • I believe your are looking for post_exists() not posts_exists() – That could certainly be the issue unless you just had a typo in the title of this thread.

    Thread Starter jemcbade

    (@jemcbade)

    Right. And even though I misspelled it here :), that is the function I called :post_exists()

    I copied it right out of the Developer documentation.

    Thanks!

    Can you show how you are trying to use it? Seeing the code and the error message will help.

    Thread Starter jemcbade

    (@jemcbade)

    I’m using it inside a function that is in the main file of a plugin I am building. Pretty simple “textbook” usage as gleaned from the docs:

    // Query for published listing
    function is_this_name_already_listed( $post_title, $content = ”, $date = ” ) {
    $result = post_exists( $post_title, $content = ”, $date = ”);
    return $result;
    }

    I pass in the post title in the form of a string stored inside the variable:

    $post_title = “Lastname, Firstname” which is the form it is stored inside the row of the CPT.

    Thanks again 🙂

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘posts_exists() casts error that the function does not exist’ is closed to new replies.