1

Well, here is my problem suppose i have a menu like this generated by wp_nav_menu()

home
test- test1, test2
contact
about

test is my custom post type

so what i want to do is if a user/admin publish posts a test post type i want it to automatically add in under test as test3.Forget about the publish_test hook i have done some research and i am ready to go with the code as follows in my functions.php

function auto_add_service_as_menu() {
    echo 'ok';exit;

}
function auto_remove_service_from_menu() {
    echo 'ok';exit;
}
add_action( 'publish_test', 'auto_add_service_as_menu' );
add_action( 'trash_test', 'auto_remove_service_from_menu' );

now what i want to do is add test3 which will be new test(cpt) post and its title and link should be automatically added to test menu. Note: I don't want anything to add or remove in admin dashboard or admin menu only to the user(wp_nav_menu). So any help would be helpful.Thanks in advance

0
0

My suggestion would be to create a custom walker for the navigation. You can check the post_type of every item and if it's your custom post type get the parent items.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.