WordPress.org

Ready to get started?Download WordPress

Forums

Page ID changed (7 posts)

  1. razoredger
    Member
    Posted 11 months ago #

    I have an issue with the way WP creates a new page id for each page revision.
    Specifically, I use plugins that filter display and functionality based on page ids.
    When a page is revised WP gives it a new ID and although it display correctly, the plugins retain the original page ID and therefore continue to display the old page version on the website, although the view page link on the page edit displays the updated page.

    Is there a way to prevent WP from changing pages IDs after an update?

  2. When a page is revised WP gives it a new ID and although it display correctly

    Huh? That should not happen. IDs are unique and unchanging. Can you provide an example by way of a link?

    Edit: Here's the codex link I meant to refer to

    http://codex.wordpress.org/Function_Reference/get_page

  3. esmi
    Forum Moderator
    Posted 11 months ago #

    Nope. MySql ids are fundamental to the way in which WordPress stores revisions. The only way around it without changing your plugins would be to turn off all revisions via your wp_config.php file. If it was me, I'd be looking at plugins/solutions that filter based on page slug or title.

  4. razoredger
    Member
    Posted 11 months ago #

    I did a "brute force" fix, by deleting all revisions of page except the current version in PhpMyAdmin. I then updated the page id based on the database info to the new version page id in the code.

    I agree, about finding plugins solutions that use the title or slug. Especially since the latest versions of WP no longer displays page IDs natively.

  5. razoredger
    Member
    Posted 11 months ago #

    Jan The issue became acute when I revised the page that sticks above the rest on the front page.

    I am using the following code:

    /** inserts specific page content */
    $post_id = xx;
    $queried_post = get_post($post_id);
    
    echo '<h1>'; echo $queried_post->post_title; echo '</h1>';
    echo $queried_post->post_content;
    
    echo '<p><p/>';
    /** above rests on top of main loop content */

    I feel that instead of re IDing the latest revision of the page, WP should re-ID or rename the older versions so that the current page conserves it's ID constant.

  6. esmi
    Forum Moderator
    Posted 11 months ago #

    Page and Post IDs are constant. They never change. Only the db table id changes.

  7. razoredger
    Member
    Posted 11 months ago #

    esmi, ah thanks for the precision.

Reply

You must log in to post.

About this Topic

Tags