[ad_1]
Hello, I meet a problem I cannot explain. I’ve created several shortcodes to insert content in single content and, if text through shortcodes shows at the good place, an image shows… before in the header, whatever I place the shortcode.
Tested on two different FSE themes.
Here is the code in the shortcode
// shortcode pour fse-alternative
function shortcode_fsealternative(){
global $post ;
$alternativeimage = get_post_meta($post->ID, 'alternative_image', true);
if (!empty($alternativeimage)) {
$urlcmm='https://xxx/blog/wp-content/uploads/alternative/'.$alternativeimage;
}
else {
$urlcmm='https:/xxx/blog/wp-content/uploads/images-site/click-x-640.png';
if ( !is_single() ) {
$urlcmm='https://xxx/blog/wp-content/uploads/images-site/click-x-home.png';}
}
echo '<figure class="wp-block-post-featured-image"><img src="' . $urlcmm . '" /></figure>';
}
add_shortcode('fsealternative', 'shortcode_fsealternative');
