CyberAleks CyberAleks - 2 years ago 116
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:

[menu]
<ul>
<li><a>Menu Item 1</a></li>
<li><a>Menu Item 1</a></li>
</ul>
[/menu]
<div>
Some content for my page
</div>


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) : ?>
<div>
wp_nav_menu(array());
</div>
<?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!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download