Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Facebook共享链接不正确_Php_Wordpress_Facebook - Fatal编程技术网

Php Facebook共享链接不正确

Php Facebook共享链接不正确,php,wordpress,facebook,Php,Wordpress,Facebook,我有一个WordPress网站,当你点击类似Facebook的按钮时,它会选择错误的url 如果我检查网页,无论你在什么帖子上,like小部件中的url总是相同的url。这就像是在某个地方设置了一个帖子的url 我已经检查过了,它只针对帖子,而不是页面 我觉得我已经找到了这个领域(可能是错误的),但我相信它在这里的循环 <?php if (have_posts()) : $post = $posts[0]; // Hack. Set $post

我有一个WordPress网站,当你点击类似Facebook的按钮时,它会选择错误的url

如果我检查网页,无论你在什么帖子上,like小部件中的url总是相同的url。这就像是在某个地方设置了一个帖子的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' );
                    ?>   

它将在某个地方的js文件中…@David如果不在上面,你知道要查找什么吗?我可能需要花钱请人帮我做这件事,但如果可以的话,我愿意去做。是的,如果你发布了链接,我会很快帮你看一看。谢谢@David,例如这个链接goo.gl/7SSy4f-浮动边栏上类似facebook的小部件链接到错误的URL。这是你需要更改的行-它在页脚-
,这样就可以添加它使用函数文件,使用
enqueue_脚本
或添加到页脚本身。请记住,它将使用php创建行,因此最好的做法是搜索文件,以查找class=“fb like”(大多数文本编辑器将允许您搜索某个位置的所有文件)
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;
}