Get Custom Post Type by Slug

I recently had a case where I needed to get the post object for a custom post type in WordPress – I had to do this by a slug that the user passed in. There is a function (get_page_by_path) which I initially thought was to only find the post object for pages but it actually […]

Strict Standards: Only variables should be passed by reference

I recently came across an interesting warning on one of my WordPress sites. The warning was “Strict Standards: Only variables should be passed by reference” and was referring to line 14. As you can see below, I wasnt’ really sure what the issue was here. if ($post->post_parent != 0) { // On child page $postID […]

Remove Protected Posts from Search Results in WordPress

I recently came up with a scenario on a website I created using WordPress which needed me to prevent protected posts from displaying in search results or on the blog index page. Initially, I thought this would be a setting on a per post page but alas, WordPress does not have the feature built-in. After […]