Category: Code

WordPress Menu Functions

Returns an array of menu items. $menu parameter is slug or id of Menu created in WordPress. $args is from here: get_posts, which isn’t very helpful for filtering what menu items you want to display.  This function returns an array that you can display manually, but does not include any data about which menu item […]

Category Template Tags

The following functions can be used on the category.php template to display information about the current category. Display Current Category Title on category.php: Display Current Category Description: Get Current Category Object: Use Category Object returned above to get ACF fields on category: Display Category Link – works for custom taxonomies and post categories.

Handy WordPress Functions

A collection of WordPress functions I use often. Link to Home: Include another php file: *File name separated on ‘-‘ between two inputs to function. So if named include-content-blocks.php call is: Custom field images (not featured): Get image values in array instead of outputting image: Retrieving featured images is a different function: Get Image Caption […]

WP_Query – Order by multiple custom fields

The Code Always call wp_reset_postdata() afterwards to reset the global $post value. Otherwise, any attempt to retrieve data from the page will return null.

Modifying WordPress excerpts

When displaying links to your posts, it’s helpful to display a short excerpt so your readers can quickly get an overall idea of the article. The built in function to display the excerpt defaults to a certain number of words and displays a “Continue Reading” link at the end. Both defaults can be modified to […]