Questions tagged [wp-delete-post]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1 vote
1 answer
1k views

Remove post if exist by title

I want to remove a post from PHP by title. I have a code for publish or update if the post exist by title, but I don't know how to insert the wp_delete_post() function. This is my actual code for ...
1 vote
0 answers
10 views

Frontend delete CPT post with custom role user

I am building a custom frontend where custom role members (created with User Role Editor) can add and edit spots. "Spots" are a custom post type registered like this: register_post_type('...
-1 votes
1 answer
76 views

Function to delete post from category older than 2 days

I was referring to What would be a PHP command to erase all posts from category X from the last month? from 2017 to delete old post from a category. When I implemented it, it is deleting newest 1 day ...
0 votes
0 answers
104 views

Delete data from the database on a table row on clicking delete button

So I have this custom table which displays data from database upon form submission on a custom plugin I'm building. I would like to add a functionality on the delete button to be able to delete each ...
0 votes
0 answers
170 views

Unable to delete related media attachments with deleted post

I want to delete the post attachments too from the 'Media" panel once a custom post is deleted. The post itself gets deleted well, but its media still remains in the wordpress "media" ...
-1 votes
2 answers
530 views

How to Delete Posts by title?

I have about 2000 titles. How can I automatically delete posts with these titles? For example
0 votes
1 answer
698 views

How to properly delete custom post type posts programmatically

I created a new custom post type that users can add new post from frontend and it works as desired. Now, I´m trying to add a button to delete. This is the code triggered by the button: if( ...
5 votes
1 answer
609 views

How to update the delete user confirmation form?

I want to update the confirmation form for delete user. If user has posts, it shows Attribute all content to - option to reassign other author for his posts. It takes lots-of time to load the page, if ...
0 votes
1 answer
336 views

`wp_delete_post` returns NULL

I am trying to delete a lot of WordPress posts programmatically using wp_delete_post, but not all posts are deleted successfully. In some cases I get NULL as a return value for wp_delete_post($row->...
0 votes
1 answer
347 views

Auto delete pages/posts without views

Hello please does anyone know a way to automatically delete posts that doesn't get views within a period of time. Lets say if a post on my site is made and within 30 days, there are no views on the ...
0 votes
1 answer
373 views

$wpdb->delete not working for me

I have a function (see in full below) that syncs data into WP from an external database. It's a list of scheduled items. When the schedule is updated, old data should be deleted. See this snippet: $...
2 votes
2 answers
3k views

Before Delete Post

I am trying to update the value of one custom post type's meta when another custom post type is deleted. When a space_rental is deleted, I need to update some meta value on a space. I don't think I ...
0 votes
1 answer
26 views

How to delete a post and keep its slug to refer to another post

I've 2 almost identical posts: https://webscraping.pro/reliable-open-proxies-for-business-directories-scrape/ https://webscraping.pro/reliable-rotating-proxies-for-business-directories-scrape/ I ...
0 votes
1 answer
294 views

Filter DELETE REST API calls

I have a custom post type, that can be editable by more than one user. Each post of that type has a field with the user ids who can edit it (kinda like co-authors). But since many users have ...
0 votes
2 answers
69 views

After creating Custom post type by user delete old one

I have created a form where users update their profile. When a profile is created or updated it creates a CPT called course. The url is the permalink + /course/ + the title of the course /* CREATING ...
0 votes
1 answer
91 views

Let any visitors delete a post if they know Id nr & password?

I've got only one function left that I need to solve (if it's solvable). I've got a frontend post system for unregistered users. But there are no way for the users to delete a post if they later want....
0 votes
0 answers
29 views

How to remove a page in its entirety

I'm having a problem with an unwanted page not disappearing, and continuing to be referenced even when replaced with another page. Here's the situation. I have 2 pages with different versions of the ...
0 votes
0 answers
762 views

How to optimize wp_delete_post() function, or why it is so slow

I have a code block to delete all the products from a store. This products have several custom fields and some images attached. The code is below: set_time_limit(0); define('WP_USE_THEMES', false); ...