Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use both id and page-template in show_on array #421

Open
sambulance opened this issue Mar 15, 2017 · 1 comment
Open

Cannot use both id and page-template in show_on array #421

sambulance opened this issue Mar 15, 2017 · 1 comment

Comments

@sambulance
Copy link
Member

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.

@mikeselander
Copy link
Contributor

@sambulance they are exclusionary because each filters the previous value so one or the other will always fail. This opens up a much larger can of worms but I'm glad you brought it up because this doesn't behave as I would expect it to if I were just walking into the project.

I might have a look at how CMB2 handles this - we might want some of the checks to accept the previous value if true and skip and other to override it like the permissions checks one; downside being that then we have disparate behavior and expectations between the checks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants