WordPress.org

Ready to get started?Download WordPress

Forums

Custom Content Type Manager
[resolved] walker class (4 posts)

  1. MaestroBasssolo
    Member
    Posted 9 months ago #

    Hi,

    I want to get the content of a custom field inside a walker class for wp_nav_menu, but it seems that the setup_postdata () does not setup the meta values. Does someone know how to solve this?

    Thanks
    Maestro

    http://wordpress.org/plugins/custom-content-type-manager/

  2. fireproofsocks
    Member
    Plugin Author

    Posted 9 months ago #

    I haven't set up a walker class, but if you've got the post id, then you can retrieve the custom field values... it's sorta more fallout from WP relying on global variables (ouch), but you may be able to use the general get_custom_field() function, or if not that, then I typically do this by using the GetPostsQuery class -- I wrote that because I got so sick of WP's caveats and limitations and disjointed interfaces in retrieving post data.

    You could do something like this, give you have the $post_id:

    $post = get_post_complete($post_id);
    
    print $post['my_custom_field'];

    Hope that helps.

  3. MaestroBasssolo
    Member
    Posted 9 months ago #

    It took some time to get it going, but this fixed it. Somehow it was impossible to use the data inside a function inside the walker. So I copied everything in the walker itself and together with your code it's working now. Not the prettiest solution, but the best for now.
    Thanks

  4. fireproofsocks
    Member
    Plugin Author

    Posted 9 months ago #

    Glad you got it going. Sounds like it may have been a variable scoping problem.

Reply

You must log in to post.

About this Plugin

About this Topic