Skip to content

Instantly share code, notes, and snippets.

@galengidman
galengidman / search.php
Last active September 26, 2021 16:45
WordPress search form & results for custom post type
<?php
// check to see if there is a post type in the URL
if ( isset( $_GET['post_type'] ) && $_GET['post_type'] ) {
// save it for later
$post_type = $_GET['post_type'];
// check to see if a search template exists
if ( locate_template( 'search-' . $post_type . '.php' ) ) {
@ms-studio
ms-studio / firstname-lastname.php
Last active November 24, 2020 10:30
Process "Lastname, Firstname" in post titles.
<?php
/**
* Processing "Last name, First name" pairs
*
* @param string $nom_prenom : The original post title ("Wilde, Oscar").
*
* @return string : The human-readable title ("Oscar Wilde").
*
* Usage in theme: