• Resolved Li-An

    (@li-an)


    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 the title, whatever I place 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');
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Li-An

    (@li-an)

    OK, I’ve tested with another FSE theme and the image is showing in the header. So it seems it’s a general problem. I will ask in a more general forum.

    Thread Starter Li-An

    (@li-an)

    OK, solved changing echo into return. Quite stunning.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘image through shortcode showing before title’ is closed to new replies.