Category Archives: Snippets

Extend WP_Query with custom parameters

The snippets story Some weeks ago I wanted to pass a custom parameter to the WP_Query object to change the where-query if the param was true. The problem was, that to extend WP_Query with a parameter, you have to circumvent the filtering of the query options. I solved this by hooking into the pre_get_posts action. […]

Read more »

Get class hierarchy in PHP

Get class hierarchy in PHP: The snippets story Yesterday I tried to call a function for every parent class of an object and get the results in an array. I didn’t found the solution instantly, so I thought that’s something for the snippets section. The function above takes an instance of a class and a […]

Read more »

Current wp_nav_menu item in WordPress

Current wp_nav_menu item: The snippets story I needed to retrieve the current wp_nav_menu item connected to the currently requested page/post in WordPress. I found some solutions going through the hole menu-tree, comparing each items object-id with the current post-id. But, since menu items are post-types, you are able to use all the WP-Query-params with wp_get_nav_menu_items, […]

Read more »