Hi,
I’m using a custom function to reorder posts on my category pages based on a custom field. However, this causes elements – both hooks and headers – to not show up on these pages. The green banner on the site is a header element set to be displayed on the entire site but does not show up on my category pages. I realize this isn’t exactly a GP issue but I’m wondering if there is any way for me to continue using the function and display elements on these pages:
function order_by_custom_field( $query ) {
if ( is_category()) {
$query->set('meta_query', array(
array(
'meta_key' => 'custom_key',
'orderby' => 'meta_value_num',
'order' => 'DESC'
)
));
$query->set('meta_key', 'custom_key');
$query->set('orderby', 'meta_value_num');
}
}
add_action( 'pre_get_posts', 'order_by_custom_field' );