Well, you’re getting error, because your code is not correct… There is syntax error in this line (You combine string and PHP code in there…):
$items .= '<li class="menu-item">echo do_shortcode( '[contact-form-7 id="1323" title="Newsletter"]' );</li>';
It should look like this:
add_filter( 'wp_nav_menu_items', 'your_custom_menu_item', 8, 2 );
function your_custom_menu_item ( $items, $args ) {
if( $args->theme_location == 'primary') {
$items .= '<li class="menu-item">'. do_shortcode( '[contact-form-7 id="1323" title="Newsletter"]' ) .'</li>';
}
return $items;
}
Related Posts:
- WordPress menu deletes when trying to add a hook
- How to manually fix the WordPress gallery code using PHP in functions.php?
- Adding first / last CSS classes to menus
- Return HTML Template Page with PHP Function
- Mega Menu Walker
- start_lvl Ignored in Custom walker_nav_menu
- Encode text string being appended as query to URL [closed]
- Displaying Logged-In User Name in WordPress Menu
- Hide main div if wp_nav_menu is empty
- Menu Items Disappearing
- How do I use Shortcodes inside of HTML tags?
- Is there a way to parse shortcodes in PHP?
- wp_delete_auto_drafts() deletes links in menus
- Shortcode to insert
- Check if a menu is empty?
- Shortcode putting html such as
- how to put the logo in the center of other items in the navigation bar
- Display sorting options dropdown when using WooCommerce product category shortcode
- renaming an admin menu item with decimal array index number
- Retrieve multiple values passed to a single attribute in a shortcode
- How can I hook into and edit the text of a wp_nav_menu tag?
- How to remove a metabox from menu editor page?
- WordPress Shortcode and Dynamic CSS
- ob_get_clean returns empty string, ob_get_flush outputs string
- Display a text message if the shortcode is not found?
- Walker class: Problems with understanding how walk() method can be called without error
- Export User Info to CSV from Front End
- How to Use the Function is_user_logged_in To Display Different Menus?
- Counting number of posts in a category and its sub categories and displaying result using shortcode
- Shortcode created to check language not works
- Replacing a specific menu item
- How to show only parents subpages of current page item in vertical menu?
- Hide a menu-item and its submenus and display a ‘Log in’ link if the user is logged out
- The best way to customize “nav-menu-template.php” to add if the ‘link_before’ is “checkbox”
- How to create different menu’s for not logged in visitors and for logged in members?
- Can we have a php “page” without a WordPress “page”?
- How to add active class to custom menu using while loop and wp_list_pages
- How to return a string that has a variable inside in a shortcode?
- Run shortcode at certain resolution
- How can I access the “description” of a menu item?
- Using Echo in ShortCode – Stuck
- Passing a shortcode attribute to a sub-function
- removing tags from wp_list_pages() using PHP
- How to create shortcodes that pull custom field data from general settings
- post meta value as shortcode parameter
- How to place login logout link on menu that redirects users back to current page?
- How to protect own PHP code from WordPress updates
- Add/echo div with Analytics-Code to function in functions.php
- wp_delete_auto_drafts() deletes links in menus
- Creating a WordPress shortcode
- How can I add a class to a single menu item?
- Multiple do_shortcode($content) within one shortcode
- Adding Image Count to Multigallery
- the_title() & the_content() are retrieving Post details inside a Page, after calling a shortcode
- Replacing the NavWalker dropdown element
- Get list of shortcodes from content
- Audio tags around Mp3 URL in content
- How do I hardcode a WordPress shortcode into my theme?
- Loading page template into shortcode
- How to add specific menu on a specific page or pages
- My shortcode is showing up twice
- How to add Shortcode (font awesome) in widget title?
- Unusable menus and “Illegal widget setting ID: nav_menu_item[]” error
- has_shortcode() – how to detect nested shortcode
- How to return multiples lines in a shortcode?
- Custom plugin issue when trying to use the shortcode twice on a page [closed]
- How can I default to all WordPress roles when parameter is not included in shortcode?
- PHP contact form returns warning in text widget [closed]
- Logout and redirect using the WP Menu
- Remove all nav menu classes ( but keep useful ones… )
- How to find the output of contact form 7 shortcode? [closed]
- Second Navigation inside header
- Wrap each shortcode in array to div
- Creating new menu item
- How do i get (unique) page name?
- Programmatically create menu with custom link
- Listing and displaying WooCommerce Shipping Zones in the frontend? [closed]
- Can A Shortcode Get HTML/Text From Content And Return It Twice With Added HTML?
- Custom Loop through category menu to include sub categories
- Recent post display using shortcode
- selected menu item
- Browser title script ignoring is_page /else conditional [closed]
- How do I turn a shortcode into PHP code?
- Nested shortCode functions in the functions.php file
- Placing the_content inside shortcode not working
- Put php variable in shortcode
- How can I add a custom class to only nav sub-menu > li > a items in WordPress?
- get_page_by_title with an apostrophe in variable
- Need to turn this php into WP shortcode
- Making Quote Plugin more efficient
- items_wrap not working
- Autogenerate shortcodes from an array of strings
- How to limit the content coming from wordpress shortcodes?
- How to return a foreach inside a shortcode
- Style wp_page_menu() items
- Placing raw HTML inside a WordPress shortcode
- How do I add text in a shortcode?
- wp nav menu: add attributes to menu items [duplicate]
- How to Insert Shortcodes into Theme?
- How can I get content inside one shortcode to another shortcode?