2014-10-10 5 views
0

페이스 북에서 공유 할 때 게시물의 발췌 부분을 표시하는 방법을 찾고 있습니다. 여기에 제 코드가 있지만 포스트의 the_exceprt를 보여줍니다. ..Wordpress - 페이스 북 공유에 게시물의 the_excerpt를 보여주세요

<a <a target="_blank" href="http://www.facebook.com/sharer.php?u=<?php the_permalink();?>&t= <?php the_excerpt(); ?><?php the_title(); ?>"<i class="fa fa-facebook"></i></a> 

가 도움이 될 수 있다면, 이것은 모든 코드가 (이 그리드 시스템은 "그리드"의 각 상자의이 다른 콘텐츠)와 섹션

<div data-ratio="1" class="grid__item grid__item_inline one-half cell tabbed" style="background-color: #ccffff" > 
        <a href="LINK_TO_PRESS_POST"><h1>Press room</h1></a> 
        <?php 
        $query = new WP_Query(array('post_type' => 'coverage', 'posts_per_page' => 1)); 
        if ($query->have_posts()) : while ($query->have_posts()) : $query->the_post(); 
        ?> 
        <time class="timestamp"><?php the_date(); ?></time> 
        <h2 class="h4"><?php the_title(); ?></h2> 
        <div class="palm--hidden"><?php the_excerpt(); ?><p></p></div> 
        <a href="<?php the_permalink(); ?>" class="palm--hidden">Read More</a> 
        <div class="social-icons-2"> 
         <ul class="hl"> 
          <li>Share:</li> 
          <li><a <a target="_blank" href="http://www.facebook.com/sharer.php?u=<?php the_permalink();?>&t= <?php the_excerpt(); ?><?php the_title(); ?>"<i class="fa fa-facebook"></i></a></li> 

          <li><a href="http://twitter.com/home?status=&nbsp;Take a look<?php the_title(); ?> <?php the_permalink(); ?>" class="icon"><i class="fa fa-twitter"></i></a></li> 
          <li><a href="" class="icon"><i class="fa fa-pinterest"></i></a></li> 
         </ul> 
        </div> 
        <?php 
        endwhile; endif; 
        ?> 
       </div> 
      </article> 
     </div> 

또 다른 질문 관련입니다 이 페이스 북은 현재 웹 사이트의 로고를 공유하고 있습니다. . 게시물의 그림 부착을 insterad 보여줄 수있는 모든 가능성?

사전에 당신에게

EDIT를 모든 시간을 너무 많이 감사 : 나는 heelps 경우 여기 페이지의 모든 코드를 넣습니다. ..

<?php get_header(); ?> 

    <div id="slider-header"> 
      <div class="container"> 
       <div class="row"> 
        <div class="col-sm-4 slider-header-left"> 
         WHAT WE DO 
        </div> 
        <div class="col-sm-8 slider-header-right"> 
         texttt 
        </div> 
       </div> 
      </div> 
     </div> 

<div id="main" class="site-main" role="main"> 

<div id="home-slider"> 
    <div class="container"> 
     <div class="row home-content-slider"> 
      <?php 
       $services = get_page_by_path('services'); 
       if($services) $parent = $services->ID; 
       $the_query = new WP_Query(array('post_type' => 'page', 'post_per_page' => 5, 'post_parent' => $parent, 'order' => 'ASC')); 
       $service_titles = array(); 
       $service_images = array(); 
       if ($the_query->have_posts()) { 
        $i = 1; 
        while ($the_query->have_posts()) { 
         $the_query->the_post(); 
         $service_titles[] = '<li id="nav-fragment-'. $i .'" class=""><a href="#fragment-'. $i .'" ><span>'. get_the_title() .'</span></a></li>'; 
         $post_thumbnail_id = get_post_thumbnail_id($post->ID); 
         $image = wp_get_attachment_image_src($post_thumbnail_id, 'full'); 
         $service_images[] = '<div id="fragment-'. $i .'" class="ui-tabs-panel ui-tabs-hide"><img src="'. $image[0] .'" title="" /><div class="overlay-description">'. get_field('slider_text') .'</div></div>'; 
         $i++; 
        } 
       } 
       wp_reset_postdata(); 
      ?> 
      <div class="col-sm-4 home-slider-left"> 
       <div class="row"> 
        <ul> 
         <?php echo implode("\n", $service_titles); ?> 
        </ul> 
       </div> 
      </div> 
      <div class="col-sm-8 home-slider-right"> 
       <div class="row"> 
        <?php echo implode("\n", $service_images); ?> 
       </div> 
      </div> 
     </div> 
    </div> 
</div> 
<div class="container"> 
<div id="grid_container"> 
    <div class="row"> 
     <div class="col-sm-6 news-post" style="background-color: #ccfff" data-key="newsItem"> 
      <article class="grid row"> 
       <div data-ratio="1" class="grid__item grid__item_inline one-half"> 
        <?php 
        echo '<div class="flexslider">'; 
        echo '<ul class="slides">'; 
        $query = new WP_Query(array('post_type' => 'coverage', 'posts_per_page' => 9)); 
        if ($query->have_posts()) : while ($query->have_posts()) : $query->the_post(); 
         $post_thumbnail_id = get_post_thumbnail_id($post->ID); 
         $image = wp_get_attachment_image_src($post_thumbnail_id, 'homepage-thumb'); 
         if($image) echo '<li><a href="'. get_permalink() .'"><img class="img-responsive" src="'. $image[0] .'" alt="" /></a></li>'; 
        endwhile; endif; 
        echo '</ul>'; 
        echo '</div>'; 
        ?> 
        <?php wp_reset_postdata(); ?> 
       </div> 
       <div data-ratio="1" class="grid__item grid__item_inline one-half cell tabbed" style="background-color: #ccffff" > 
        <a href="http://LINKK_TO.com/?post_type=coverage"><h1>Press room</h1></a> 
        <?php 
        $query = new WP_Query(array('post_type' => 'coverage', 'posts_per_page' => 1)); 
        if ($query->have_posts()) : while ($query->have_posts()) : $query->the_post(); 
        ?> 
        <time class="timestamp"><?php the_date(); ?></time> 
        <h2 class="h4"><?php the_title(); ?></h2> 
        <div class="palm--hidden"><?php the_excerpt(); ?><p></p></div> 
        <a href="<?php the_permalink(); ?>" class="palm--hidden">Read More</a> 
        <div class="social-icons-2"> 
         <ul class="hl"> 
          <li>Share:</li> 
          <li><a <a target="_blank" href="http://www.facebook.com/sharer.php?u=<?php the_permalink();?>&t= <?php the_excerpt(); ?><?php the_title(); ?>"<i class="fa fa-facebook"></i></a></li> 

          <li><a href="http://twitter.com/home?status=&nbsp;Take a look<?php the_title(); ?> <?php the_permalink(); ?>" class="icon"><i class="fa fa-twitter"></i></a></li> 
          <li><a href="" class="icon"><i class="fa fa-pinterest"></i></a></li> 
         </ul> 
        </div> 
        <?php 
        endwhile; endif; 
        ?> 
       </div> 
      </article> 
     </div> 
     <div class="col-sm-6 news-post" style="background-color: #ffcccc" data-key="newsItem"> 
      <article class="grid row"> 
       <?php 
       $query = new WP_Query(array('post_type' => 'news', 'posts_per_page' => 1)); 
       if ($query->have_posts()) : while ($query->have_posts()) : $query->the_post(); 
       ?> 
       <div data-ratio="1" class="grid__item grid__item_inline one-half"> 
        <figure data-ratio="1"> 
         <?php 
         $post_thumbnail_id = get_post_thumbnail_id($post->ID); 
         $image = wp_get_attachment_image_src($post_thumbnail_id, 'homepage-thumb'); 
         ?> 
         <a href="<?php echo get_permalink(); ?>"><img width="640" height="640" class="img-responsive" src="<?php echo $image[0]; ?>" alt="" /></a> 
        </figure> 
       </div> 
       <div data-ratio="1" class="grid__item grid__item_inline one-half cell tabbed" style="background-color: #ffcccc" > 
             <a href="<?php the_permalink(); ?>"><h1>NEWS</h1></a> 
        <time class="timestamp"><?php the_date(); ?></time> 
        <h2 class="h4"><?php the_title(); ?></h2> 
        <div class="palm--hidden"><p><?php the_excerpt(); ?></p></div> 
        <a href="<?php the_permalink(); ?>" class="palm--hidden">Read More</a> 
        <div class="social-icons-2"> 
         <ul class="hl"> 
          <li>Share:</li> 
          <li><a href="SM1" class="icon"><i class="fa fa-facebook"></i></a></li> 
          <li><a href="sm2" class="icon"><i class="fa fa-twitter"></i></a></li> 
          <li><a href="sm3" class="icon"><i class="fa fa-pinterest"></i></a></li> 
         </ul> 
        </div> 
       </div> 
       <?php 
       endwhile; endif; 
       ?> 
      </article> 
     </div> 
     <div class="col-sm-6 news-post" style="background-color: #ffffff" data-key="newsItem"> 
      <article class="grid row"> 
       <div data-ratio="1" class="grid__item one-half"> 
        <figure data-ratio="1"> 
        <!-- SnapWidget --> 
<!-- SnapWidget --> 
<!-- SnapWidget --> 
<iframe src="http://snapwidget.com/sc/?u=aW5fc3BhY2VzfGlufDI4MHwzfDN8fG5vfDV8bm9uZXx8eWVzfG5v&ve=020914" title="Instagram Widget" class="snapwidget-widget" allowTransparency="true" frameborder="0" scrolling="no" style="border:none; overflow:hidden; width:295px; height:295px"></iframe> 
        </figure> 
       </div> 
       <div data-ratio="1" class="grid__item grid__item_inline one-half cell tabbed twitter-widget" style="background-color: #ffffff" > 
        <a class="twitter-timeline" data-dnt="true" href="sm2" data-widget-id="501148708545638400">Tweets by @In__Spaces</a> 
        <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script> 
       </div> 
      </article> 
     </div> 
     <div class="post-1410 post type-post status-publish format-standard has-post-thumbnail hentry category-news col-sm-6 news-post" style="background-color: #ffffcc" data-key="newsItem"> 
      <article class="grid row"> 
       <?php 
       $query = new WP_Query(array('post_type' => 'event', 'posts_per_page' => 1)); 
       if ($query->have_posts()) : while ($query->have_posts()) : $query->the_post(); 
       ?> 
       <div data-ratio="1" class="grid__item grid__item_inline one-half"> 
        <figure data-ratio="1"> 
         <?php 
         $post_thumbnail_id = get_post_thumbnail_id($post->ID); 
         $image = wp_get_attachment_image_src($post_thumbnail_id, 'homepage-thumb'); 
         ?> 
         <a href="<?php echo get_permalink(); ?>"><img width="640" height="640" class="img-responsive" src="<?php echo $image[0]; ?>" alt="" /></a> 
        </figure> 
       </div> 
       <div data-ratio="1" class="grid__item grid__item_inline one-half cell tabbed" style="background-color: #ffffcc" > 
             <a href="<?php the_permalink(); ?>"><h1>EVENTS</h1></a> 
        <time class="timestamp">August 22, 2014</time> 
        <h2 class="h4"><?php the_title(); ?></h2> 
        <div class="palm--hidden"><p><?php the_excerpt(); ?></p></div> 
        <a href="<?php the_permalink(); ?>" class="palm--hidden">Read More</a> 
        <div class="social-icons-2"> 
         <ul class="hl"> 
          <li>Share:</li> 
          <li><a href="" class="icon"><i class="fa fa-facebook"></i></a></li> 
          <li><a href="" class="icon"><i class="fa fa-twitter"></i></a></li> 
          <li><a href="" class="icon"><i class="fa fa-pinterest"></i></a></li> 
         </ul> 
        </div> 
       </div> 
       <?php 
       endwhile; endif; 
       ?> 
      </article> 
     </div> 
     <div class="big-link"> 
     </div> 
    </div> 
</div> 
</div> 
</div><!-- #main --> 
<?php get_footer(); ?> 

답변

0

당신은 페이지의 <head> 섹션에 Open Graph Tags를 사용해야합니다. 내 header.php에서이 addd 경우

<meta property="og:title" content="<?=the_title();?>" /> 
<meta property="og:description" content="<?=the_excerpt();?>" /> 
<meta property="og:type" content="blog" /> 
<meta property="og:url" content="<?=the_permalink();?>" /> 
<meta property="og:site_name" content="YOUR_SITE_NAME" /> 
+0

흠, 모든 TEH 소셜 미디어 아이콘 나를 dsiplay, 여전히 발췌을 보여 나던 :

다음은 예입니다. .. 나는 공유를위한 personnal 아이콘을 사용할 필요가 있기 때문에 공식 아이콘이 필요 없다. 어떤 해결책이 있다면? 감사합니다 :) – tibewww

+0

도움이 될 경우를 대비하여 페이지의 모든 코드를 추가했습니다 – tibewww

+0

HTML 문서의 머리 부분을 'header.php' 파일에 넣지 않겠습니다. . 제 생각에 당신은 Wordpress Codex를 읽어야합니다. – adamdehaven