Skip to content

Instantly share code, notes, and snippets.

View Ceekay0's full-sized avatar

CeeKay Ceekay0

View GitHub Profile
@Ceekay0
Ceekay0 / single.php
Last active July 21, 2021 04:36
Wordpress: Show related posts by tag. The tag the snippet is looking for needs to be setup in the WP admin interface using the custom value keyword = your_tag Output is as unordered list with links. Snippet is fully i8n compatible You can use this in any Wordpress Template, not just single.php
<?php
/** SHOW RELATED POSTS BY TAG, TAG IS INDICATED BY CUSTOM PROPERTY keyword => tag **/
/** check for custom property **/
$key = 'keyword';
$keyword = get_post_meta($post->ID, $key, true);
if ($keyword != '') {
/** set max number of posts **/
$num_posts = '4';
/** setup the query array **/
<?php
add_action( 'after_setup_theme', 'bootstrap_setup' );
if ( ! function_exists( 'bootstrap_setup' ) ):
function bootstrap_setup(){
add_action( 'init', 'register_menu' );