php – How to use Page link field with is_page()

Question

I want to let users select the pages on which a page title box will not appear by using a Page Link custom field that allows for multiple selections.
$excluded_pages_array returns ‘100’, ‘102’ etc. but not working inside is_page().
I tried to add $excluded_pages_array inside array() but that also doesn’t work.
The Page Title box shouldn’t show up on the pages selected by the user and on the home page (is_front page()). Could someone please try to help me solve this problem?

Code in header.php file:

$excluded_pages = get_field('hide_page_title', 'options', false);
$excluded_pages_array = "'" . implode("', '", $excluded_pages) . "'";
// echo $excluded_pages_array;

if (is_front_page()) {
  get_template_part('');
} 
elseif (is_singular(array('product'))) {
  get_template_part('template-parts/page-titles/page-title', 'product');
} 

// elseif ( is_page( array( $excluded_pages_array ) ) )
elseif ( is_page( $excluded_pages_array ) ) {
  get_template_part('');
} 
else {
  get_template_part('template-parts/page-titles/page-title', 'video');
}

0
Rafal 8 months 2021-12-28T13:27:44-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse