Have a read through the Shortcode API page. It will tell you everything that you need to know.
Thank you catacaustic! I appreciate the reply and link. I have already looked at it, and know how to make a very basic shortcode. I just don’t know how I would re-write the above code because the embedded php tag keeps causing errors. I know it’s probably something simple for an actual programmer or web developer. I just kinda got stuck with this project. 🙁
The last one I tried was putting this in my functions file:
function prodpic_sc_handler() {
$content = get_post_meta($post->ID,'productcms_wp_image_url_0', true);
return $content;
}
add_shortcode( 'productmainpic', 'prodpic_sc_handler' );
Then I tried putting the shortcode inside an image link on my page. It didn’t work, and every other way I try gives me an error. Can you help me format it properly? Or do you know how I can pull an image (that is not “featured”) from a custom post type?
Something like this?
function prodpic_sc_handler ($atts = array ()) {
global $post;
$args = shortcode_atts (array (
'postid' => $post->ID
), $atts);
$img = get_post_meta ($atts ['postid'], 'productcms_wp_image_url_0', true);
$content = '<img src="' . $img . '" />';
return $content;
}
Thank you much. You are the only one that has even attempted to help me. 🙂 When I implemented the above code, I get the following error:
Warning: Illegal string offset ‘postid’
It’s so close. I can feel it! 🙂
That’s my fault… 🙂 I left the wrong variable name in there.
Change this bit:
$atts = shortcode_atts (array (
'postid' => $post->ID
), $atts);
YOU ARE MY HERO! That worked perfectly! Thank you so much. You really are very awesome, and it was very kind of you to help me out! 🙂