o/ (FEB13/19:12)

Permalink ShortCode

Ein einfaches Plugin, um Permalinks im Editor verwenden zu können, wie es bestimmt schon tausend mal existiert:

Source

<?php
/*
Plugin Name: Permalink Shortcode
Plugin URI: https://sezz.at/projects/wordpress/permalink-shortcode
Description: Adds 2 new shortcodes:  creates a link,  only gets the permalink.
Version: 1.0
Author: Martin Karer
Author URI: https://sezz.at/
*/

function permalink_shortcode($atts) {
	extract(shortcode_atts(array('id' => 1), $atts));
	
	$url = get_permalink($id);
	if ($url)
		return '<a href="' . get_permalink($id) . '">' . get_the_title($id) . '</a>';
	else
		return false;
}

function permalinkurl_shortcode($atts) {
	extract(shortcode_atts(array('id' => 1), $atts));
	return get_permalink($id);
}

add_shortcode('permalink', 'permalink_shortcode');
add_shortcode('permalinkurl', 'permalinkurl_shortcode');

?>

Kommentare


Bisher keine Kommentare...
Sei der Erste und leg los indem Du die Felder unten ausfüllst!


Schreibe einen Kommentar

OCT1/20:46 - iTunes plays:
The Prodigy - Wild Frontier

Kontakt Impressum Martin Karer 2008-2024