Site logo

Archived topic

Dashboard Meta Box

4 replies · Started by Ashley on August 27, 2019

Viewing posts 1–5 of 5

Hi Guys,

I'm looking to create a simple text field on the WordPress dash that then populates an element.

The scenario is basically a news bar which I'm using an element to place underneath the nav. I'd like the client to be able to simply populate this from the WordPress dashboard to stop them going into Elements.

Can this be done?

Hi there,

What kind of Element?

If it's a Hook Element, you would need to use get_post_meta() to get your custom field.

Actually creating a custom metabox is a bit advanced for this forum, but you can use the core Custom Fields metabox to add your meta data if you don't need a fully custom metabox.

Let me know :)

Ok - I think I've managed to do it just using a custom widget-area for now.

This is how my GP Element looks at the moment:

<div id="ticker-wrapper">
	<div id="ticker-bar">
		<?php if ( is_active_sidebar( 'nsb_ticker_bar' ) ) : ?>
	<div id="primary-sidebar" class="primary-sidebar widget-area" role="complementary">
		<?php dynamic_sidebar( 'nsb_ticker_bar' ); ?>
	</div><!-- #primary-sidebar -->
<?php endif; ?>
	</div>
</div>

Is there a way to hide the #ticker-wrapper div when there's no widget present in the sidebar? Could I do that with a bit of PHP?

Ignore me - I've managed that by moving it within the if statement.

Finished code is as follows:

<?php if ( is_active_sidebar( 'nsb_ticker_bar' ) ) : ?>
	<div id="ticker-wrapper">
			<div id="ticker-bar">
				<?php dynamic_sidebar( 'nsb_ticker_bar' ); ?>
			</div>
	</div>
<?php endif; ?>

Thanks Tom :-)

Glad you got it working. Thanks for sharing your code :)

This archived topic is closed to new replies.