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


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()) {
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 ) ) {
else {
  get_template_part('template-parts/page-titles/page-title', 'video');

Rafal 2 years 2021-12-28T13:27:44-05:00 0 Answers 0 views 0

Leave an answer