Skip to content

Instantly share code, notes, and snippets.

@alanef
Last active May 3, 2019 14:29
Show Gist options
  • Select an option

  • Save alanef/15a470e89ccbee09f2bc21b82c50ec29 to your computer and use it in GitHub Desktop.

Select an option

Save alanef/15a470e89ccbee09f2bc21b82c50ec29 to your computer and use it in GitHub Desktop.

Custom Plugin to show blog info in a shortcode

create a folder in your plugins directory , e.g. blog-info-shortcode add the index.php to the folder activate the plugin

use the shortcode

[bloginfo] displays the name [bloginfo show='url'] shows the url

other possible 'show' values are here https://developer.wordpress.org/reference/functions/get_bloginfo/

<?php
/*
Plugin Name: Blog Info Shortcode
Plugin URI: https://fullworks.net/
Description: Blog Info Shortcode
Version: 1.0
Author: Alan
Author URI: https://fullworks.net/
License: GPL2
*
* No warranty or liability accepted as per GPL
*
* Shortcode to display blog info
*
* Usage:
* [bloginfo show="name"]
*
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
add_shortcode( 'bloginfo', function ( $atts ) {
$a = shortcode_atts( array(
'show' => 'name',
), $atts );
return get_bloginfo( $a['show']);
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment