Account for page/post ID mismatch

This commit is contained in:
Tetrakern 2023-08-04 00:54:41 +02:00
parent 9525e27b82
commit 8bf1ab8a2d
2 changed files with 13 additions and 1 deletions

View File

@ -22,6 +22,13 @@
<?php
// IDs
$page_id = get_queried_object_id();
if ( $page_id != $args['post_id'] ) {
$args['post_id'] = $page_id;
}
// Null post ID for generated pages
if ( is_archive() || is_search() || is_404() ) {
$args['post_id'] = null;

View File

@ -23,9 +23,14 @@
global $post;
// Post ID
// IDs
$page_id = get_queried_object_id();
$post_id = $post ? $post->ID : null;
if ( $page_id != $post_id ) {
$post_id = $page_id;
}
if ( is_archive() || is_search() || is_404() ) {
$post_id = null;
}