CyberAleks CyberAleks - 1 year ago 90
PHP Question

Widgeting with wordpress page editor

Is there some way to create a widget or placeholder for some content that should be only shown if i use some special tag in page editor?
For example: I have a special menu, that i want to define with page editor, but it should be shown outside of page content.

enter image description here

So if i write in editor something like this, it should put this in my optional menu:

<li><a>Menu Item 1</a></li>
<li><a>Menu Item 1</a></li>
Some content for my page

Is there some pugins or tricks or some filters etc. in wordpress for this?

Answer Source

If it's just like a menu then go to function.php file and register a menu with you specific name like this.

register_nav_menu( 'your-menu', __( 'Your Menu', 'theme-slug' ) );

and then show that menu conditionally on inside your div.

<?php if($var==1) : ?>
<?php endif; ?>

and if you have some different content then register custom fields for pages and show output those fields with conditional statement. hope it make sense to you. Cheers!