Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9221943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:41:50+00:00 2026-06-18T03:41:50+00:00

I’m currently building an object listing for a realtor and we are caching all

  • 0

I’m currently building an object listing for a realtor and we are caching all the objects locally in a custom post type called “objekt”, and it has the permalink rewrite “objekt”.

We have a file in the root of the server called wp-fetch-items.php which the realtors application pings at the time of a new object in the system. This causes all posts of the type “objekt” to be deleted, and then it goes through an XML-file and adds all the objects to the system again.

Everything works perfectly fine, but the posts keep getting -2 in the URL, even if it’s the first time the post is created, and there is nothing with a name even remotely similar.

For instance, an object which I insert using wp_insert_post with the name 152912 gets the post_name of 152912-2.

I create the objects with the following code:

$insertedPost = wp_insert_post(array(
    'post_author' => 1,
    'post_type' => 'objekt',
    'ping_status' => 'closed',
    'post_status' => 'publish',
    'post_name' => $objectData['title'],
    'post_title' => $objectData['title']
), false);

And before they are created, I loop through every post with the type “objekt” and remove them using this code:

wp_delete_post(get_the_ID(), true);

I specifically added true as a second parameter to permanently remove the object from the database and all searches I do prove that there is nothing left of it.

I also tried flushing the permalinks after deletion using this code, but it does nothing to help the situation:

global $wp_rewrite;
$wp_rewrite->flush_rules();

Have you experienced this issue, and do you know how to solve it? Please reply if you know what could be causing this!

Thanks in advance,
Jonathan

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T03:41:51+00:00Added an answer on June 18, 2026 at 3:41 am

    WordPress has a special handling of numerical post names. This is intentionally, because it assumes that a numerical ID in the URL is the actual ID of the post. Adding the -2 makes sure that it is interpreted as a string and as such as the name of the post. Otherwise it would try to show http://yoursite/?p=152912 and result into a 404 if this post id doesn’t exist.

    The only solution I found so far: avoid numerical names.

    (I wrote post because internally everything is a post, even pages and images)

    edit:

    I found the ticket that introduced this behaviour.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I'm outputting a post title and in our database, it's Hello Y’all
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have a text area in my form which accepts all possible characters from
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
i got an object with contents of html markup in it, for example: string
I'm trying to create an if statement in PHP that prevents a single post

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.