LoginSignup
0
0

More than 5 years have passed since last update.

WP Social Bookmark LightでTwitterシェアの文面をなおす

Posted at

※2017年10月現在の方法です

WP Social Bookmark Lightとは

日本人の方がつくられている、WordPressで記事をシェアしてもらうための非常にシンプルなプラグイン。

WP Social Bookmarking Light — WordPress プラグイン
https://ja.wordpress.org/plugins/wp-social-bookmarking-light/

導入方法はこのあたりを参照。

WP Social Bookmarking Light の設定方法
https://bazubu.com/wp-social-bookmarking-light-23861.html

Twitterシェアの文面で記事タイトルしか出ない

スクリーンショット 2017-10-15 21.43.30.png
記事タイトル だけじゃなく、 記事タイトル | サイト名 にしたい。

対策

WP Social Bookmarking Lightで記事タイトルとブログ名の表示方法
http://gucciz03.com/twitibl-1311
こちらを参照したが、どんどん内容が修正されていくのでこの通りやってもうまくいかない。

src/WpSocialBookmarkLight/Service.php

プラグインのフォルダ内、 src/WpSocialBookmarkLight/Service.phpを開く。この中に各ボタンの挙動が記されている。
180行めあたりに下記のような部分がある。

Service.php
    /**
     * Twitter button
     *
     * @return string
     */
    public function twitter()
    {
        $options = $this->option->getAll();;
        $twitter = $options['twitter'];
        $data_url = $this->url;
        $data_text = $this->title;
//以下略

これの$data_textの行がブログタイトル出してくるやつなので、下記のように変える。

Service.php
    /**
     * Twitter button
     *
     * @return string
     */
    public function twitter()
    {
        $options = $this->option->getAll();;
        $twitter = $options['twitter'];
        $data_url = $this->url;
        $data_text = $this->title . ' | ' . $this->blogname;
//以下略

以上おっけー

スクリーンショット_2017-10-15_21_51_26.png
シェアし放題です

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0