humanmade / humanmade/Custom-Meta-Boxes

Cannot use both id and page-template in show_on array

Open
#421 1 comment 0 reactions 0 assignees View on GitHub
Bug Discussion
Dominant language
PHP
Stars
516
Forks
118
PR merge metrics
No merged PRs in 30d

Description

I have some meta boxes that need to only appear on the homepage and when a certain page template is selected.

I tried using the following setup:
```
$meta_boxes[] = array(
'title' => 'Feature Settings',
'pages' => array( 'page' ),
'show_on' => array(
'id' => array( get_option( 'page_on_front' ) ),
'page-template' => array(
'page-templates/feature.php',
),
),
'context' => 'normal',
'priority' => 'core',
'fields' => $this->fields(),
);
```
But the boxes do not appear on the front page. Any value passed to `id` is ignored while `page-template` exists in the same `show_on` array.

I've got around this by having two `$meta_boxes[]` arrays, one with using `id` and the other using `page_template`, which works fine.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.