Facebook分享链接不正确

时间:2014-11-09 19:04:51

标签: php wordpress facebook

我有一个WordPress网站,当你点击Facebook喜欢按钮时,它就像错误的网址一样。

如果我检查网页,那么无论您发布什么帖子,相似小部件内的网址始终都是相同的网址。这就像其中一个帖子url被设置在某个地方。

我已经检查过,它只适用于帖子,而不是页面。

我觉得我找到了这个区域(可能是错的),但我相信它在循环中

<?php if (have_posts()) : 

                    $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
                    <?php /* If this is a category archive */ if (is_category()) { ?>
                  <h3><?php printf(__('Archive for the &#8216;%s&#8217; Category', TEXTDOMAIN), single_cat_title('', false)); ?></h3>
                    <?php /* If this is a tag archive */ } elseif( is_tag() ) { ?>
                  <h3><?php printf(__('Posts Tagged &#8216;%s&#8217;', TEXTDOMAIN), single_tag_title('', false) ); ?></h3>
                    <?php /* If this is a daily archive */ } elseif (is_day()) { ?>
                  <h3><?php printf(__('Archive for %s | Daily archive page', TEXTDOMAIN), get_the_time(__('F jS, Y', TEXTDOMAIN))); ?></h3>
                    <?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
                  <h3><?php printf(__('Archive for %s | Monthly archive page', TEXTDOMAIN), get_the_time(__('F Y', TEXTDOMAIN))); ?></h3>
                    <?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
                  <h3><?php printf(__('Archive for %s | Yearly archive page', TEXTDOMAIN), get_the_time(__('Y', TEXTDOMAIN))); ?></h3>
                    <?php /* If this is a yearly archive */ } elseif (is_search()) { ?>
                  <h3><?php printf( __( 'Search Results for: %s', TEXTDOMAIN ), '<span>' . get_search_query() . '</span>' ); ?></h3>
                   <?php /* If this is an author archive */ } elseif (is_author()) { ?>               
                  <h3><?php _e('Author Archive', TEXTDOMAIN); ?></h3>
                    <?php /* If this is a paged archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?>
                  <h3><?php _e('Blog Archives', TEXTDOMAIN); ?></h3>        
                    <?php } 

                      while (have_posts()) : the_post(); 

                        global $more;

                        if(!is_single()) $more = 0;

                        $type_blog = ( $GLOBALS['yiw_custom_blog_type'] != false ) ? $GLOBALS['yiw_custom_blog_type'] : get_option( $GLOBALS['shortname'] . '_blog_type', 'classic' );
                    ?>   

它正在设置$ post但我不确定如何解决它或检查这实际上是它。如果我删除它,该页面不起作用。

这里的任何帮助都会有很大帮助,如果我不正确我还应该寻找什么?

以下也是functions.php中包含$ post的区域

function catch_that_image() {
    global $post, $posts;
    $first_img = '';
    ob_start();
    ob_end_clean();
    $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
    $first_img = $matches [1] [0];

    if(empty($first_img)){ //Defines a default image
      $first_img = get_stylesheet_directory_uri()."/images/default.gif";
    }
    return $first_img;
}             

    function get_current_ID()
{
    global $post;
    return $post->ID;
}

function get_current_pagename()
{
    global $post;
    return $post->post_name;
}

0 个答案:

没有答案
相关问题