WordPress.org

Ready to get started?Download WordPress

Forums

Genesis Featured Widget Amplified
Feature request: Enable custom shortcodes in post info & post meta (1 post)

  1. blogjunkie
    Member
    Posted 1 year ago #

    I wrote a custom shortcode handler to display the content of a custom field:

    add_shortcode( 'post_cf', 'click_cf_shortcode' );
    function click_cf_shortcode($atts, $content = null) {
    
    	global $post;
    
    	$defaults = array(
    			'key'    => ''
    	);
    	$atts = shortcode_atts( $defaults, $atts );
    
    	$custom_field = get_post_meta($post->ID, $atts[key], true);
    	if ( !$custom_field ) return;
    	$output = '<span class="post-cf post-cf-' . $atts[key] .'">' . $custom_field . '</span>';
    
    	return apply_filters( 'click_cf_shortcode', $output, $atts);
    };

    So I can do this to display the content of a custom field:
    [post_cf key="custom_field_name"]

    The shortcode works in the regular Genesis Featured Post widget, but not in GFWA. I'm guessing there's a filter or something that's blocking it. I would be much obliged if you made a change to enable custom shortcodes like this. Thanks Nick :)

    http://wordpress.org/extend/plugins/genesis-featured-widget-amplified/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic