Example #1
0
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" />
<?php 
        if (strlen($image) > 3) {
            ?>
<meta property="og:image" content="<?php 
            echo $image;
            ?>
" /><?php 
        }
        ?>
<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 
    }
}
Example #2
0
?>
</span> <?php 
echo esc_attr(get_search_query());
?>
</h1><br>

						<?php 
if (have_posts()) {
    while (have_posts()) {
        the_post();
        $category = get_the_category($post->ID);
        foreach ($category as $cat) {
            echo '<div class="entry-content post ' . $cat->slug . ' row">';
            echo '<div class="post-icon large-2 hide-for-medium hide-for-small columns"><i title="' . $cat->name . '"></i><span class="icon-text">' . $cat->name . '</span><div class="hack-num">#' . $post->ID . '</div></div>';
            echo '<div class="post-text large-10 medium-12 small-12 columns">';
            echo '<a href="' . get_permalink($post->ID) . '">' . my_excerpt(35) . '</a>';
            if (get_field('submitted_by', $post->ID)) {
                echo '<div class="submitted-wrap"><div class="submitted-by">Submitted By ' . get_field('submitted_by', $post->ID) . '</div></div>';
            }
            echo do_shortcode('[simple-social-share]');
            echo '<a class="tweet" href="https://twitter.com/intent/tweet?text=' . substr(strip_tags(get_the_content()), 0, 75) . '...&hashtags=babylifehacks,parenting,parentingtips&url=' . wp_get_shortlink() . '" target="_blank">Tweet</a>';
            echo '<a class="mail" href="mailto:?subject=' . substr(strip_tags(get_the_content()), 0, 75) . '...&amp;body=' . substr(strip_tags(get_the_content()), 0, 75) . '...Read the rest of this tip on BabyLifeHacks.com here: ' . wp_get_shortlink() . '">Mail</a>';
            echo '<div class="url"><a href="' . wp_get_shortlink() . '" target="_blank"><span title="' . wp_get_shortlink() . '"></span></a></div>';
            echo '<div class="comments">Comments: <fb:comments-count href="' . get_permalink($post->ID) . '"></fb:comments-count></div>';
            $image = get_field('hack_image', $post->ID);
            if (!empty($image)) {
                ?>
													<a class="hack-image-link" href="<?php 
                echo get_permalink($post->ID);
                ?>
"><img class="hack-image" src="<?php 
function opengraph()
{
    global $post;
    global $wp;
    $current_url = home_url(add_query_arg(array(), $wp->request));
    if (is_single() || is_page() && !is_front_page()) {
        if (has_post_thumbnail($post->ID)) {
            $img_src = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'large');
        } else {
            $img_src[0] = get_template_directory_uri() . '/build/img/main-og-img.png';
        }
        $description = my_excerpt($post->post_content, $post->post_excerpt);
        $description = strip_tags($description);
        $description = str_replace('"', "'", $description);
        ?>
    <meta name="twitter:card" content="summary_large_image" />
    <meta name="twitter:site" value="@MKNMSynergia" />
    <meta name="twitter:title" property="og:title" content="<?php 
        echo the_title();
        ?>
"/>
    <meta name="twitter:description" property="og:description" content="<?php 
        echo $description;
        ?>
"/>
    <meta property="og:type" content="article"/>
    <meta name="twitter:url" property="og:url" content="<?php 
        echo the_permalink();
        ?>
"/>
    <meta property="og:site_name" content="<?php 
        echo get_bloginfo('name');
        ?>
"/>
    <meta name="twitter:image" property="og:image" content="<?php 
        echo $img_src[0];
        ?>
"/>

<?php 
    } else {
        if (is_front_page()) {
            ?>
      <meta name="twitter:card" content="summary_large_image" />
      <meta name="twitter:site" value="@MKNMSynergia" />
      <meta name="twitter:title" property="og:title" content="<?php 
            echo get_bloginfo('name');
            ?>
"/>
      <meta name="twitter:description" property="og:description" content="<?php 
            echo get_bloginfo('description');
            ?>
"/>
      <meta property="og:type" content="website"/>
      <meta name="twitter:url" property="og:url" content="<?php 
            echo get_bloginfo('url');
            ?>
"/>
      <meta property="og:site_name" content="<?php 
            echo get_bloginfo('name');
            ?>
"/>
      <meta name="twitter:image" property="og:image" content="<?php 
            echo get_template_directory_uri() . '/build/img/main-og-img.png';
            ?>
"/>
<?php 
        } elseif (is_author()) {
            global $wp_query;
            $current_member = $wp_query->get_queried_object();
            ?>
      <meta name="twitter:card" content="summary" />
      <meta name="twitter:site" value="@MKNMSynergia" />
      <meta name="twitter:title" property="og:title" content="<?php 
            echo $current_member->display_name;
            ?>
"/>
      <meta name="twitter:description" property="og:description" content="<?php 
            echo show_membership_status($current_member);
            ?>
"/>
      <meta property="og:type" content="website"/>
      <meta name="twitter:url" property="og:url" content="<?php 
            echo $current_url;
            ?>
"/>
      <meta property="og:site_name" content="<?php 
            echo get_bloginfo('name');
            ?>
"/>
      <meta name="twitter:image" property="og:image" content="<?php 
            echo get_member_avatar_url($current_member);
            ?>
"/>
      <?php 
            if ($current_member->twitter_profile) {
                echo '<meta name="twitter:creator" content="' . $current_member->twitter_profile . '" />';
            }
        }
    }
}
$event_loop = new WP_Query(array('order' => 'DESC', 'post_type' => 'event', 'posts_per_page' => 2, 'post_status' => 'publish'));
while ($event_loop->have_posts()) {
    $event_loop->the_post();
    ?>
					<h3><a href="<?php 
    the_permalink();
    ?>
"><?php 
    the_title();
    ?>
</a></h3>
					<h4><?php 
    the_time('F j, Y');
    ?>
</h4>
					<?php 
    my_excerpt('my_excerpt_index', 'my_excerpt_more');
    ?>
					<?php 
}
?>
				</div>
				<?php 
include 'module-find-funding.php';
?>
				<?php 
include 'module-tour-our-labs.php';
?>
			</div>
<?php 
get_footer();
							<div class="post-category">
								<?php 
    the_category();
    ?>
							</div>
							
							<div class="post-content">
								<h1><a href="<?php 
    the_permalink();
    ?>
"><?php 
    the_title();
    ?>
</a></h1>
								<?php 
    my_excerpt(12);
    ?>
								<a class="read-more" href="<?php 
    the_permalink();
    ?>
">read more</a>
							</div>
						</div>
					</article>
				<?php 
}
?>
			</div>
		</div>
	</div>
</article><!-- #post-## -->
Example #6
0
function get_my_excerpt($excerpt_length = 55, $id = false, $echo = false)
{
    return my_excerpt($excerpt_length, $id, $echo);
}
Example #7
0
    echo " | {$site_description}";
}
// Add a page number if necessary:
if ($paged >= 2 || $page >= 2) {
    echo ' | ' . sprintf(__('Page %s', 'fairpixels'), max($paged, $page));
}
?>
</title>
<meta property="og:title" content="<?php 
wp_title('|', true, 'right');
/*bloginfo( 'name' );*/
?>
">

<?php 
$description = my_excerpt($post->post_content, $post->post_excerpt);
$description = strip_tags($description);
$description = str_replace("\"", "'", $description);
?>
<meta property="og:url" content="<?php 
echo get_permalink();
?>
">
<meta property="og:description" content="<?php 
echo $description;
?>
">
<meta property="og:image" content="<?php 
$src = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), array(800, 800), false, '');
echo $src[0];
?>
Example #8
0
					<?php 
        } else {
            ?>

						<img src="<?php 
            echo get_template_directory_uri();
            ?>
/images/default.jpg" alt="" />

					<?php 
        }
        ?>

					<div class="excerpt">
						<?php 
        echo my_excerpt(60);
        /** Green 独自関数 - 半角60文字抜粋を表示する */
        ?>
					</div>

					<p class="rigft-align link">
						<a href="<?php 
        the_permalink();
        ?>
">詳しく見る</a>
					</p>

				</div>
				<div class="box-s-bottom"></div>

			</article>
Example #9
0
function add_fb_open_graph_tags()
{
    global $post;
    global $wp;
    $current_url = home_url(add_query_arg(array(), $wp->request));
    $blogtemplate = get_bloginfo('template_url');
    $blogurl = get_bloginfo('url') . "/";
    $blogname = get_bloginfo('name');
    $blogdescription = get_bloginfo('description');
    $blogkeywords = "";
    $post_url = $current_url . "/";
    if (is_single() || is_page()) {
        if (get_field('social_title_post')) {
            $post_title = get_field('social_title_post');
        } else {
            $post_title = get_the_title();
        }
    } else {
        $post_title = $blogname;
    }
    if (is_single() || is_page()) {
        if (get_field('social_text_post')) {
            $description = get_field('social_text_post');
        } else {
            $description = my_excerpt($post->post_content, $post->post_excerpt);
            $description = strip_tags($description);
            $description = str_replace("\"", "\\'", $description);
        }
    } else {
        $description = $blogdescription;
    }
    $result = "<!-- og -->\n";
    $result .= "<meta property=\"og:site_name\" content=\"{$blogname}\" />\n";
    $result .= "<meta property=\"fb:app_id\" content=\"527744890712825\" />\n";
    $result .= "<meta property=\"og:locale\" content=\"es_ES\" />\n";
    $result .= "<meta property=\"article:author\" content=\"{$blogurl}\" />\n";
    $result .= "<meta property=\"article:publisher\" content=\"{$blogurl}\" />\n";
    $result .= "<meta property=\"og:description\" content=\"{$description}\" />\n";
    $result .= "<meta property=\"og:title\" content=\"{$post_title}\" />\n";
    $result .= "<meta name=\"twitter:card\" content=\"summary_large_image\"/>\n";
    $result .= "<meta name=\"twitter:title\" content=\"{$post_title}\"/>\n";
    $result .= "<meta name=\"twitter:description\" content=\"{$description}\">\n";
    $result .= "<meta name=\"twitter:site\" content=\"@NarcoData\">\n";
    $result .= "<meta name=\"twitter:creator\" content=\"@NarcoData\">\n";
    if (is_single() || is_page()) {
        $result .= "<meta property=\"og:type\" content=\"article\" />\n";
        $result .= "<meta property=\"og:url\" content=\"{$post_url}\" />\n";
    } elseif (is_home()) {
        $result .= "<meta property=\"og:type\" content=\"website\" />\n";
        $result .= "<meta property=\"og:url\" content=\"{$blogurl}\" />\n";
    } else {
        $result .= "<meta property=\"og:type\" content=\"website\" />\n";
        $result .= "<meta property=\"og:url\" content=\"{$post_url}\" />\n";
    }
    echo $result;
    if (is_single() || is_page()) {
        if (get_field('social_photo_post')) {
            $social_photo_post = get_field('social_photo_post');
            $image = $social_photo_post['url'];
            $resultImage = "<meta property=\"og:image\" content=\"{$image}\" />\n";
            $resultImage .= "<meta name=\"twitter:image\" content=\"{$image}\" />\n";
            echo $resultImage;
        } elseif (get_the_post_thumbnail($post->ID, 'thumbnail')) {
            $post_thumbnail_id = get_post_thumbnail_id($post->ID);
            $image = wp_get_attachment_url($post_thumbnail_id);
            $resultImage = "<meta property=\"og:image\" content=\"{$image}\" />\n";
            $resultImage .= "<meta name=\"twitter:image\" content=\"{$image}\" />\n";
            echo $resultImage;
        }
    }
    echo "<!--/ og end -->";
}
Example #10
0
<tr>
<th class="last">Mail</th><td class="last"><?php 
            echo $mail[0];
            ?>
</td>
</tr>
<?php 
        }
        ?>
</table>
</div>
<div class="commentArea">
<h3>一言コメント</h3>
<div class="commentBox">
<p><?php 
        echo my_excerpt(200);
        ?>
</p>
</div>

<?php 
        if (isset($company_profile[0]) || isset($delegate_image[0]) || isset($delegate_main[0]) || isset($delegate[0]) || isset($map[0]) || isset($execution_sum[0])) {
            ?>
<div class="detailTableArea">
<table class="detailTable">
  <?php 
            if (isset($company_profile[0])) {
                ?>
<tr>
<th>会社案内</th><td >
<ul>
Example #11
0
function add_meta_tags()
{
    global $post;
    setup_postdata($post);
    //all tags
    //echo '<meta property="og:site_name" content="'.bloginfo('name').'" />';
    //echo '<meta property="og:site_name" content="MetLife Defender - Understanding Your Risks" />';
    echo '<meta property="og:site_name" content="MetLife Defender - Tools and Tips" />';
    echo '<meta property="og:type" content="website" />';
    //$title = empty(trim(wp_title('', '', '')))? 'MetLife Defender' : wp_title('', '', '');
    //echo '<meta property="og:title" content="'.$title.'" />';
    //echo '<meta property="og:url" content="'.get_site_url().'" />';
    //echo '<meta property="og:url" content="http://'.$_SERVER['PHP_SELF'] .'" />';
    echo '<meta name="twitter:card" content="summary"/>';
    //echo '<meta property="og:url" content="http://'.$_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"].'" />';
    //wp_title('', '', '');
    //page specific tags
    //check if on article page
    if (is_single()) {
        $image_id = get_post_thumbnail_id($post->ID);
        $image_attributes = wp_get_attachment_image_src($image_id, 'facebook-share');
        $articleDesc = my_excerpt($post->post_content, get_the_excerpt());
        $fb_image = empty($image_attributes[0]) ? get_site_url() . '/wp-content/themes/rfi_blank/images/facebook.png' : $image_attributes[0];
        $twitter_image = empty($image_attributes[0]) ? get_site_url() . '/wp-content/themes/rfi_blank/images/twitter.png' : $image_attributes[0];
        //echo $articleDesc;
        echo '<meta property="og:url" content="' . get_permalink($post->ID) . '" />';
        echo '<meta property="og:image" content="' . $fb_image . '" />';
        echo '<meta property="og:description" content="' . $articleDesc . '" />';
        echo '<meta property="og:title" content="' . wp_title('', '', '') . '" />';
        echo '<meta name="twitter:title" content="' . wp_title('', '', '') . '"/>';
        echo '<meta name="twitter:image" content="' . $twitter_image . '" />';
        echo '<meta name="twitter:image:src" content="' . $twitter_image . '">';
        echo '<meta name="twitter:description" content="' . $articleDesc . '" />';
    } else {
        //if its not article page, pick general share image
        echo '<meta property="og:url" content="' . get_site_url() . '" />';
        echo '<meta property="og:image" content="' . get_site_url() . '/wp-content/themes/rfi_blank/images/facebook.png" />';
        echo '<meta property="og:description" content="MetLife Defender will protect you and your family from identify theft, data and credit fraud. Start to protect your personal information here." />';
        echo '<meta property="og:title" content="MetLife Defender"/>';
        echo '<meta name="twitter:title" content="MetLife Defender"/>';
        echo '<meta name="twitter:image" content="' . get_site_url() . '/wp-content/themes/rfi_blank/images/twitter.png" />';
        echo '<meta name="twitter:image:src" content="' . get_site_url() . '/wp-content/themes/rfi_blank/images/twitter.png" />';
        echo '<meta name="twitter:description" content="MetLife Defender will protect you and your family from identify theft, data and credit fraud. Start to protect your personal information here." />';
    }
}