Product check in Wordpress [Woocommerce]

0

Good morning community StackOverflow, I have some doubts because I want to make a check in PHP on the Wordpress platform, in the table wp_posts . I want to check if the title of a product exists. But how should I proceed to perform a check, for example:

My wp_posts table, the post_title column is equal to my String

Surely I should use the Wordpress API or should I do a simple mysqli_query ()?

Thanks in advance

    
asked by Fumatamax 07.02.2018 в 09:36
source

1 answer

0

There is a function post_exist () that checks if a post exists, given a title. Returns the id if it exists or 0 otherwise. An example of use would be this:

if ( post_exists( $title ) == 0 ) {
  //NO EXISTE EL POST
}
    
answered by 15.02.2018 в 15:21