Site icon Hip-Hop Website Design and Development

queried_object utilizing pre_get_posts gets notification and cautioning

My code is getting me the outcome I need on my page, I’m bringing another post and my subject is yielding the entirety of the applicable information I need on the page as expected.

function replaceQuery( $query ) { 

in the event that ( !is_admin() && $query->is_main_query() && $query->is_page ) { 

$childQuery = get_post(13); 

$query->queried_object->ID = $childQuery->ID; 

$query->queried_object->post_content = $childQuery->post_content; 

$query->queried_object->post_title = $childQuery->post_title; 

$query->queried_object->post_name = $childQuery->post_name; 

$query->queried_object->queried_object_id = $childQuery->post_name; 

$query->query_vars['page_id'] = $childQuery->ID; 

$query->query_vars['p'] = $childQuery->ID; 

} 

} 

/I've additionally utilized the "parse_query" snare 

add_action( 'pre_get_posts', 'replaceQuery'); 

The inconvenience is, I’m getting admonitions and notification for everything

Notice: Indirect alteration of over-burden property WP_Query::$queried_object has no impact in mycode.php on line 47 

Caution: Creating default object from void worth in mycode.php on line 47 

I tracked down a comparative issue here is_category in pre_get_posts results in php notices

It appears as though I’m attempting to roll out my improvements to the WP Query object either too soon or (for the situation above) past the point of no return. The properties I’ve taken a stab at utilizing as conditionals have killed numerous mistakes, however when I add whatever else, it appears to break the code.

Is there another restrictive I can utilize or maybe another snare to dispose of these notification & warnings?