Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter alexkwa

    (@alexkwa)

    I really could appreciate any help on this. I’ve tried a long while by myself…

    Thread Starter alexkwa

    (@alexkwa)

    Hello,

    First of all, thank you so much for your reply. I’ve actually tried these tutorials out before.
    The first tutorial does not work for me. This is the code for single pages.

    <?php if (is_singular() || is_single() || is_page()) { ?>
    <title>
    <?php single_post_title(''); ?>
    </title>
    <?php
    global $post;
    setup_postdata($post);
    ?>
    <meta name=”description” content=”<?php the_excerpt_rss(); ?>” />
    <meta property="og:type" content="article" />
    <meta property="og:title" content="<?php single_post_title(''); ?>" />
    <meta property="og:url" content="<?php the_permalink(); ?>"/>
    <meta property="og:image" content="<?php if ( $thumb[0] == null ) { echo $default_img; } else { echo $thumb; } ?>" />
    <?php }; ?>

    For Tutorial 2, the given code

    <span>function insert_image_src_rel_in_head() {
    	global $post;
    	if ( !is_singular()) //if it is not a post or a page
    		return;
    	if(!has_post_thumbnail( $post->ID )) { //the post does not have featured image, use a default image
    		$default_image="<a class="linkclass" href="http://example.com/image.jpg">http://example.com/image.jpg</a>"; //replace this with a default image on your server or an image in your media library
    		echo '';
    	}
    	else{
    		$thumbnail_src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'medium' );
    		echo '';
    	}
    	echo "n";
    }
    add_action( 'wp_head', 'insert_image_src_rel_in_head', 5 );
    
    </span>

    causes a parse error (Parse error: syntax error, unexpected ‘<‘ in /home/alexkwa/alexkwa.com/wp-content/themes/alexkwa/functions.php on line 4)

    Appreciate any help I can get. alexkwa.com is my site btw.

Viewing 2 replies - 1 through 2 (of 2 total)