Tag Info

New answers tagged


If you want to get the corresponding post ID's from a given menu id, try: $menu_id = 'mymenu'; $items = wp_get_nav_menu_items( $menu_id ); $ids = ( $items ) ? wp_list_pluck( $items , 'object_id' ) : array(); where you have to modify the $menu_id to your needs.


Soooo, I have tried the solution with javascript. It works without problems. For debug test: <script> $(function() { alert($('.menu-item').attr('id')); }); </script> It gives me the id from every element in the nav out as alert. I extract now the number at the end and have then the menu-item-id. thanks for all answers, ...


html mark up for navigation will look like this <ul id="menu-res" class="main-menu"><li id="menu-item-72" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-72"><a href="#home">Home</a></li> <li id="menu-item-238" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-238"><a ...


The post ID is available after the query has been fired. The first hook that is safe to get post id is 'template_redirect'. If you can modify your function to accept a post id as argument, like so: function em_change_form($id){ $reg_type = filter_input(INPUT_GET, 'reg_typ', FILTER_SANITIZE_STRING); if($reg_type === 'vln'){ ...

Top 50 recent answers are included