I am trying to automate a whole bulk of my pages and one of the shortcodes I have created is to output the NextGen Gallery Tags by using the page custom fields that each page has a unique id. This id is actually tagged into certain galleries which I want to output on the page.
For those unfamiliar with NextGen Gallery tags shortcode. Please visit this link.
Each page has a custom field "gallery_id" which I input a unique tagged id everytime I create a page. I want every page to have the same template but pull different information depending on the custom fields.
This is my current shortcode, but at this stage, it is only outputting as text, but not as a shortcode. Does anyone know how to output this as a shortcode?
// Grab ID Custom Field [gallery_display]
function lilap_gid( ){
$gid = get_post_meta(get_the_ID(), 'gallery_id', TRUE);
return do_shortcode( '[ngg_images tag_ids="'. $gid .'"]');
}
add_shortcode( 'gallery_display', 'lilap_gid' );
I am trying to automate a whole bulk of my pages and one of the shortcodes I have created is to output the NextGen Gallery Tags by using the page custom fields that each page has a unique id. This id is actually tagged into certain galleries which I want to output on the page.
For those unfamiliar with NextGen Gallery tags shortcode. Please visit this link.
Each page has a custom field "gallery_id" which I input a unique tagged id everytime I create a page. I want every page to have the same template but pull different information depending on the custom fields.
This is my current shortcode, but at this stage, it is only outputting as text, but not as a shortcode. Does anyone know how to output this as a shortcode?
// Grab ID Custom Field [gallery_display]
function lilap_gid( ){
$gid = get_post_meta(get_the_ID(), 'gallery_id', TRUE);
return do_shortcode( '[ngg_images tag_ids="'. $gid .'"]');
}
add_shortcode( 'gallery_display', 'lilap_gid' );
Depending on the ngg_images
shortcode, you maybe need to echo the do_shortcode
function.
You can try
function lilap_gid($atts, $content = ""){
$gid = get_post_meta(get_the_ID(), 'gallery_id', TRUE);
ob_start();
echo do_shortcode( '[ngg_images tag_ids="'. $gid .'"]');
$content = ob_get_clean();
return $content;
}
add_shortcode( 'gallery_display', 'lilap_gid' );