humanmade / humanmade/Custom-Meta-Boxes
Cannot use both id and page-template in show_on array
- Vorherrschende Sprache
- PHP
- Sterne
- 516
- Forks
- 118
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
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.
Beitragsleitfaden
Rechercherichtung
Start at the show_on configuration handling for the combined id and page-template conditions, then reproduce the homepage case with a matching template. Trace why the id condition is ignored, add coverage for both conditions together, and confirm the meta boxes appear in each matching context.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- php, wordpress
- Bereich
- backend
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100