Add new field in WordPress Menu to output in theme - php

Is there a simple class or function to extend the WordPress default menu items with new custom fields?
For example, when you go to Appearance - Menus, add a new menu and drag/drop an item to your menu, that actual item has few hidden fields that can be enabled from Screen Options:
Title Attribute
Description
My question is: how to add another custom field there? Like a background field to write the text there and output it in my custom theme like we output the title and description:
<?php echo $navItem->description; ?>
Changed the html code live on the admin page, so you can catch my idea on what I want to do.
Thanks!

ACF is the plugin just what you looking for. Create as many fields as your want, assign it to manu form and you are done.
For more information follow this URL,
https://www.advancedcustomfields.com/resources/adding-fields-menu-items/
Hope this helps.

follow this URL may help you
Adding custom Fields to WordPress Navigation Menu Items
http://jafty.com/blog/how-to-add-custom-fields-to-wordpress-navigation-menu-items/

Related

Adding custom post title to wordpress menu

Excuse my rookieness – this might be a very simple thing to solve for someone with more experience. I tried searching the forum but did not find a fitting solution.
I am trying to make my Wordpress menu add the custom title to a current menu item on a specific post type when that page is active, what would be the best way to do so?
Menu <--- Original menu item<br>
Menu: Addition <--- When on the custom post type titled "Addition"
Any ideas?
I would start with finding the code in the template ( theme ) where menu is being rendered. You need to look for function that renders navigation menu wp_nav_menu():https://developer.wordpress.org/reference/functions/wp_nav_menu/
Depending on how complicated solution you want to choose to pick for checking the post type - I would suggest simple if() statement.
To check post type you can use get_post_type():https://developer.wordpress.org/reference/functions/get_post_type/
If post type is "Addition" pass argument to wp_nav_menu() to use custom menu prepare for that post type.

Unique fields added to Wordpress Pages editor

I need to customise the page editor in Wordpress so I have 5 text fields which I can pull out in the front end page. This is because the Wordpress manager is a bit hopeless with no HTML skills and the content of these boxes will populate buttons and a drop-down select. These fields will be completely unique to the page being edited. How do I go about this? Do I need to build my own plugin or customise an existing one or other?
Advanced Custom Fields is a great plugin for this. You can target a particular page to display fields on and then output your fields in the front end templates using:
the_field('field_name');
See here: http://www.advancedcustomfields.com/

Wordpress custom page attribute

I'm working on a custom WP theme that displays all "pages" as sections in a one page layout.
What I would like to do is add a color chooser to the page designer, so that the user can choose a color to be the background color of that section.
I'm totally new to wordpress so I don't even know what files or functions to look at to add this behavior.
Is there perhaps a prebuilt plugin to do something like this?
Four options:
use a plugin like Advanced Custom Fields or Custom Content Type Manager
ACF has a Lite version to add the meta box programmatically
a helper script like Custom Metaboxes and Fields for WordPress
do it yourself, using this Q&A as example: Add a checkbox to post screen that adds a class to the title
Probably, you'd want to change the visibility of the meta box according to the chosen page template, refer to this Q&A: Custom meta box shown when template is chosen

Append custom class to wordpress headway theme

I would like to hack headway theme by adding an option to pages to append custom "classes" for that particular page. It's similar to your regular page where you have an option to select page template. but instead of selecting page template user would just have to select the class he/she wanted to append on the page. that class will have a CSS overide.
Example:
HTML
<body class=" red ...other headway css classes..." ">
CSS
body.red #container { background: red }
body.green #container { background: green }
I want to add a custom dropdown that list some classes option for theme to choose. example item on the dropdown. "red theme", "blue theme". This can also be done using Custom field but prefred to use dropdown so user won't get it wrong.
Append the class that was selected on the page to the tag of that page. I tried using "body_class" on my functions.php But It totally erased all the classes causing my page to break appart. What I wanted to do is just append the custom class instead of erasing the entire classes of the body.
Please advice. thanks!
Headway already has a custom meta box for custom classes on a page, so maybe you could either:
hack that to display a drop down
create some sort of meta box that will save a selection from a drop down to the same field that Headway writes to, if that's possible, and just remove/hide the Headway meta box from the admin
add an informational box on the page screen that displays the available classes and just use the Headway meta box instead (upgrade safe, best approach to keep things clean)

wordpress - add new category based admin panel menu tab

i want to show a new admin menu tab which will pull information from a certain category, i.e products.
I do not want to use custom Post types because i want to be able to change themes with out any modification to theme files, so please do not recommend that.
using wordpress function add_menu_page() i can add a new tab, but how to show new post page and existing posts of that category, exactly like custom post type.
thanks
Did you try the Menus?
If I'm not mistaken, what you want to do is to create a menu tab that can fetch the posts from a certain category
Create a post with your category
In your dashboard go to the Appearance > Menus
Name your Menu, after creating your New Menu
You can select what you want to add on that Menu
by checking it and clicking Add Menu, the Categories
are on the bottom part.
You should try to create your custom post types as part of a plugin anyway, as that's what WordPress recommends:
https://codex.wordpress.org/Post_Types#A_word_about_custom_post_types_as_a_plugin
That way you can them with any theme.

Categories