Skip to content

Instantly share code, notes, and snippets.

View iWebbers's full-sized avatar

Dennis Dallau iWebbers

View GitHub Profile
// Get WordPress site name via shortcode: [iw_site_name]
function iw_site_name_shortcode() {
return get_bloginfo('name');
}
add_shortcode('iw_site_name','iw_site_name_shortcode');
// Get WordPress site url via shortcode: [iw_site_url]
function iw_site_url_shortcode() {
return get_bloginfo('url');
}
add_shortcode('iw_site_url','iw_site_url_shortcode');
// Get WordPress site email via shortcode: [iw_site_email]
function iw_site_email_shortcode() {
return get_bloginfo('admin_email');
}
add_shortcode('iw_site_email','iw_site_email_shortcode');
// Get current page title via shortcode: [iw_page_title]
function iw_page_title_shortcode() {
return get_the_title();
}
add_shortcode('iw_page_title','iw_page_title_shortcode');
// Get social share icons via shortcode: [iw_social_share_icons]
function iw_social_share_icons_function( $atts ) {
$title = get_the_title();
$excerpt = implode(' ', array_slice(str_word_count(wp_strip_all_tags(get_the_excerpt()),1), 0, 17)) . '...';
$image = get_the_post_thumbnail_url();
$permalink = get_permalink();
$author = get_the_author();
$folder = site_url() . '/wp-content/uploads/iwebbers/social-share-icons';
$class = ' class="uk-border-rounded"';
// Get current year via shortcode: [iw_current_year]
function iw_current_year_shortcode() {
return date("Y");
}
add_shortcode('iw_current_year','iw_current_year_shortcode');
// Get WooCommerce product name by ID via shortcode: [iw_product_name id='']
function iw_product_name_shortcode( $atts ) {
$atts = shortcode_atts( array(
'id' => null,
), $atts, 'bartag' );
$html = '';
if( intval( $atts['id'] ) > 0 && function_exists( 'wc_get_product' ) ){
$_product = wc_get_product( $atts['id'] );
// Get WooCommerce product price by ID via shortcode: [iw_product_price id='']
function iw_product_price_shortcode( $atts ) {
$atts = shortcode_atts( array(
'id' => null,
), $atts, 'bartag' );
$html = '';
if( intval( $atts['id'] ) > 0 && function_exists( 'wc_get_product' ) ){
$_product = wc_get_product( $atts['id'] );
// Get WooCommerce product url by ID via shortcode: [iw_product_url id='']
function iw_product_url_shortcode( $atts ) {
$atts = shortcode_atts( array(
'id' => null,
), $atts, 'bartag' );
$html = '';
if( intval( $atts['id'] ) > 0 && function_exists( 'wc_get_product' ) ){
$_product = wc_get_product( $atts['id'] );
// Get WooCommerce product image by ID via shortcode: [iw_product_image id='']
function iw_product_image_shortcode( $atts ) {
$atts = shortcode_atts( array(
'id' => null,
), $atts, 'bartag' );
$html = '';
if( intval( $atts['id'] ) > 0 && function_exists( 'wc_get_product' ) ){
$_product = wc_get_product( $atts['id'] );