Skip to content

Instantly share code, notes, and snippets.

@aldolat
Last active June 10, 2017 06:08
Show Gist options
  • Save aldolat/cacb790da0c8f01454c5d0aa2848a1ea to your computer and use it in GitHub Desktop.
Save aldolat/cacb790da0c8f01454c5d0aa2848a1ea to your computer and use it in GitHub Desktop.
Adds a list of posts in a 404 page using Posts in Sidebar
<?php
$request_uri = $_SERVER['REQUEST_URI']; // Returns for example /blog/loremipsum
// Remove trailing slash and take only the word after the last slash
preg_match( '/[^\/]+$/', rtrim( $request_uri, '/' ), $search );
$search = implode( '', $search ); // Returns for example loremipsum
echo do_shortcode('[pissc search="' . $search . '" orderby=title number=5 debug_query="true"]');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment