Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

Twansparant on "Automatically add anchor links as children elements in custom nav walker"

$
0
0

Hi there,

I'm struggling with a problem I can't seem to figure out myself...
What I want is to automatically add anchor links from a loop in the parent page as a dropdown submenu with a custom navigation walker.

I use Advanced Custom Fields to add extra content blocks in a page, in each block there is a named anchor that should be added to the parent page as a submenu.

What I got so far: pastebin.com/YbY1wxSa

The normal output of the $children_elements would be like this:

Array (
    [7] => Array (
            [0] => WP_Post Object (
                [ID] => 124
                etc ...
                [current_item_parent] =>
            )
            [1] => WP_Post Object (
                [ID] => 125
                etc ...
                [current_item_parent] =>
            )
            [2] => WP_Post Object (
                [ID] => 126
                etc ...
                [current_item_parent] =>
            )
        )
)

But my output of the $children_elements is like this:

Array (
    [7] => Array (
            [0] => Array (
                [ID] => 124
                etc ...
                [current_item_parent] =>
            )
            [1] => Array (
                [ID] => 125
                etc ...
                [current_item_parent] =>
            )
            [2] => Array (
                [ID] => 126
                etc ...
                [current_item_parent] =>
            )
        )
)

So the children elements are in an Array and not in a WP_Post Object.
What do I need to change in order to add the anchors correctly without needing to create new nav_menu_item in the database?

Any help is welcome!
Thanks


Viewing all articles
Browse latest Browse all 8245

Trending Articles