New Landing How can we help? Cardinal Featured Image/Facebook preview issue

Viewing 7 posts - 1 through 7 (of 7 total)
  • Posted in: Cardinal
  • #99890
    conorlumsden
    Member
    Post count: 37

    Hi there,

    I have set a featured image and have titled my homepage, but when I go to share the website, the facebook preview comes up as:

    “www.ensemble.ie is currently under construction

    If you’re seeing this page instead of your website, please replace or remove the default index.php from your public_html directory.”

    With no featured image.

    Could you please advise on how to fix this?

    Thank you,

    Conor

    Attachments:
    You must be logged in to view attached files.
    #99894
    Melanie – SUPPORT
    Member
    Post count: 11032

    Hi,

    so your website is not under maintenance? Can you deactivate all your plugins to see if any is disturbing it? If you have been in maintenance mode earlier, maybe your cache is troubling?

    Cheers

    #99904
    conorlumsden
    Member
    Post count: 37

    Thank you for the quick reply! I have deactivated all plugins and have tried on different computers. I don’t think I had ever put it into maintenance mode either.

    #99911
    conorlumsden
    Member
    Post count: 37

    Sorry, I should mention that the problem still persists.

    #100191
    Kyle – SUPPORT
    Moderator
    Post count: 35880

    Hi

    This is what is shows for me when sharing to facebook (see screenshot)

    – Kyle

    Attachments:
    You must be logged in to view attached files.
    #100245
    conorlumsden
    Member
    Post count: 37

    I added this to functions.php and it seemed to fix it. Thanks for the help Kyle and Melanie.

    // Facebook Open Graph
    add_action('wp_head', 'add_fb_open_graph_tags');
    function add_fb_open_graph_tags() {
    	if (is_single()) {
    		global $post;
    		if(get_the_post_thumbnail($post->ID, 'thumbnail')) {
    			$thumbnail_id = get_post_thumbnail_id($post->ID);
    			$thumbnail_object = get_post($thumbnail_id);
    			$image = $thumbnail_object->guid;
    		} else {	
    			$image = ''; // Change this to the URL of the logo you want beside your links shown on Facebook
    		}
    		//$description = get_bloginfo('description');
    		$description = my_excerpt( $post->post_content, $post->post_excerpt );
    		$description = strip_tags($description);
    		$description = str_replace("\"", "'", $description);
    ?>
    <meta property="og:title" content="<?php the_title(); ?>" />
    <meta property="og:type" content="article" />
    <meta property="og:image" content="<?php echo $image; ?>" />
    <meta property="og:url" content="<?php the_permalink(); ?>" />
    <meta property="og:description" content="<?php echo $description ?>" />
    <meta property="og:site_name" content="<?php echo get_bloginfo('name'); ?>" />
    
    <?php 	}
    }
    
    function my_excerpt($text, $excerpt){
    	
        if ($excerpt) return $excerpt;
    
        $text = strip_shortcodes( $text );
    
        $text = apply_filters('the_content', $text);
        $text = str_replace(']]>', ']]>', $text);
        $text = strip_tags($text);
        $excerpt_length = apply_filters('excerpt_length', 55);
        $excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
        $words = preg_split("/[\n
    	 ]+/", $text, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY);
        if ( count($words) > $excerpt_length ) {
                array_pop($words);
                $text = implode(' ', $words);
                $text = $text . $excerpt_more;
        } else {
                $text = implode(' ', $words);
        }
    
        return apply_filters('wp_trim_excerpt', $text, $excerpt);
    }
    #100247
    Kyle – SUPPORT
    Moderator
    Post count: 35880

    Ok great, no problem

    – Kyle

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in and have valid license to reply to this topic.

License required for one of the following items
Login and Registration Log in · Register