xampp 5.6.8のセッティング

Filed under: xampp — kdcs @ 2017年2月9日 木曜日

php5.6でのwordpress動作チェックが必要なためxampp5.6系を導入

このあたりのxamppはバージョンによってかなりの変更が加えられており
特に5.6.11からは管理画面などに大幅に変更あり、
さらに5.6.14からMySQLではなくMariaDBに変更になっている

wordpress公式サイトを見ると動作環境には、
「MySQL バージョン 5.6 以上 または MariaDB バージョン 10.0 以上」と、MariaDBが含まれている

今回は変更前のxamppでphp5.6が使用できる5.6.8を選択
しかし、ステータスやセキュリティのページが文字化けするため以下の対応が必要となる
(続きを読む…)

WP-DBManager 2.78.1

Filed under: wordpressプラグイン — kdcs @ 2017年1月26日 木曜日

WP-DBManager 2.78.1 に更新すると以前の日本語化ファイルが対応していないため英語表示になる

以下のサイトから「wp-dbmanager-ja.mo」をダウンロードしてプラグインのフォルダに入れる
WP-DBManager日本語化ファイル

wordpress 公開記事にnewマークを付ける

Filed under: php,wordpress — kdcs @ 2016年11月26日 土曜日

公開日時を基準とした場合
「date_i18n」はwordpressで日本時間を取得する関数

(続きを読む…)

カスタム投稿タイプの記事掲載と改行させず、コンテンツの文字制限

Filed under: wordpress — kdcs @ 2016年10月20日 木曜日

カスタム投稿タイプを固定ページに表示させる方法
例:カスタム投稿タイプ「event」 表示件数3件

<?php
    $args=array(
        'post_type' => 'event', //カスタム投稿名
        'posts_per_page'=> 3 //表示件数(-1で全ての記事を表示)
    );
 ?>
<?php query_posts( $args ); ?>
<?php if(have_posts()): ?>
<?php while(have_posts()):the_post(); ?>
<?php the_content(); ?>
<?php endwhile; else: //記事が無い場合 ?>
記事が無い場合の処理
<?php endif; wp_reset_query(); //クエリのリセット ?>

単に改行させないだけなら以下

<?php remove_filter('the_content', 'wpautop'); ?>
<?php the_content(); ?>

コンテンツに文字制限を行う
例:200文字で制限し、それを超えると「…」を文末に付ける

<?php the_content(); ?>

この部分を以下に書き換える

<?php
if(mb_strlen($post->post_content,'UTF-8')>200){
	$content= str_replace('\n', '', mb_substr(strip_tags($post-> post_content), 0, 200,'UTF-8'));
	echo $content.'...';
}else{
	echo str_replace('\n', '', strip_tags($post->post_content));
}
?>

instagram-feed wordpressでインスタグラムを表示させるプラグイン

Filed under: wordpressプラグイン — kdcs @ 2016年10月16日 日曜日

Instagramにアップしている画像をwebページで表示するためのプラグイン

Instagram APIの仕様変更があり、2016年6月1日より登録制が申告制になった影響で
———————————————————————————————
【注意!】2016年6月1日からInstagram APIの仕様が変わったため、既にインストールしている方は
バージョン1.4.6以上にアップデートした後、アクセストークンを取得し直す必要があります。
———————————————————————————————
とのこと。

【重要】
wordpressのテーマをカスタマイズする場合、footer.phpへ

<script src="<?php bloginfo('url'); ?>/wp-content/plugins/instagram-feed/js/sb-instagram.min.js"></script>

common.jsへAccess Tokenを記述

// instagram ----------------------------------------------
var sb_instagram_js_options = {"sb_instagram_at":"user-Access Token"};

header.phpへcssを記述

<link rel="stylesheet" href="<?php bloginfo('url'); ?>/wp-content/plugins/instagram-feed/css/sb-instagram.css">

【重要】
バージョン1.6まではwp_footer()への出力は無かったがバージョン1.8.3では以下が出力される

<script type="text/javascript">
var sbiajaxurl = "http://xxx.com/wp-admin/admin-ajax.php";
</script>

「type=”text/javascript”」が書き込まれるのでバリデーションチェックにひっかかる
※1.8.3の場合
プラグインのフォルダ内にあるinstagram-feed.php 698行目に出力の記述があるので修正する

固定ページに表示させる場合、テンプレートにループタグが必要

<div id="instagramArea" class="inner">
<?php  if(have_posts()):while(have_posts()):the_post(); ?>
<div class="pc_block"><?php the_content(); ?></div>
<?php endwhile; endif; ?>
</div><!--/instagramArea-->

固定ページ編集画面のエディタ内に以下記述 ※ビジュアルエディタではなくテキストエディタを使う!
idはインスタグラムから取得

[instagram-feed id=”xxxxxxxx”]

(続きを読む…)

サイト内検索

カテゴリー

最近の投稿

↑上に戻る