<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>WordPress &#8211; REONTOSANTA</title>
	<atom:link href="https://knowledge.reontosanta.com/archives/category/wordpress/feed" rel="self" type="application/rss+xml" />
	<link>https://knowledge.reontosanta.com</link>
	<description>Collection of personal knowledge</description>
	<lastBuildDate>Wed, 17 Jun 2020 00:16:40 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	
	<atom:link rel='hub' href='https://knowledge.reontosanta.com/?pushpress=hub'/>
<site xmlns="com-wordpress:feed-additions:1">83369280</site>	<item>
		<title>WordPressでウィジェットを追加する</title>
		<link>https://knowledge.reontosanta.com/archives/1334</link>
					<comments>https://knowledge.reontosanta.com/archives/1334#respond</comments>
		
		<dc:creator><![CDATA[mogice]]></dc:creator>
		<pubDate>Sun, 19 Nov 2017 20:57:04 +0000</pubDate>
				<category><![CDATA[WordPress]]></category>
		<guid isPermaLink="false">https://knowledge.reontosanta.com/?p=1334</guid>

					<description><![CDATA[WordPressでウィジェットを任意の位置に挿入するには、func&#46;&#46;&#46;]]></description>
										<content:encoded><![CDATA[<p>WordPressでウィジェットを任意の位置に挿入するには、function.phpとstyle.cssに記述を追加する。</p>
<p>以下は表示位置ごとのサンプルになる。</p>
<h2>投稿本文中(最初のH2見出し手前)ウィジェットの追加</h2>
<p></p><pre class="urvanov-syntax-highlighter-plain-tag">///////////////////////////////////////
// 投稿本文中ウィジェットの追加
///////////////////////////////////////
register_sidebars(1,
  array(
  'name'=&gt;'投稿本文中',
  'id' =&gt; 'widget-in-article',
  'description' =&gt; '投稿本文中に表示されるウイジェット。文中最初のH2タグの手前に表示されます。',
  'before_widget' =&gt; '&lt;div id="%1$s" class="widget-in-article %2$s"&gt;',
  'after_widget' =&gt; '&lt;/div&gt;',
  'before_title' =&gt; '&lt;div class="widget-in-article-title"&gt;',
  'after_title' =&gt; '&lt;/div&gt;',
));

///////////////////////////////////////
//H2見出しを判別する正規表現を定数にする
///////////////////////////////////////
define('H2_REG', '/&lt;h2.*?&gt;/i');//H2見出しのパターン

///////////////////////////////////////
//本文中にH2見出しが最初に含まれている箇所を返す（含まれない場合はnullを返す）
//H3-H6しか使っていない場合は、h2部分を変更してください
///////////////////////////////////////
function get_h2_included_in_body( $the_content ){
  if ( preg_match( H2_REG, $the_content, $h2results )) {//H2見出しが本文中にあるかどうか
    return $h2results[0];
  }
}

///////////////////////////////////////
// 投稿本文中の最初のH2見出し手前にウィジェットを追加する処理
///////////////////////////////////////
add_filter( 'the_content', function ($the_content) {
  if ( is_single() &amp;&amp; //投稿ページのとき、固定ページも表示する場合はis_singular()にする
       is_active_sidebar( 'widget-in-article' ) //ウィジェットが設定されているとき
  ) {
    //広告（AdSense）タグを記入
    ob_start();//バッファリング
    dynamic_sidebar( 'widget-in-article' );//本文中ウィジェットの表示
    $ad_template = ob_get_clean();
    $h2result = get_h2_included_in_body( $the_content );//本文にH2タグが含まれていれば取得
    if ( $h2result ) {//H2見出しが本文中にある場合のみ
      //最初のH2の手前に広告を挿入（最初のH2を置換）
      $count = 1;
      $the_content = preg_replace(H2_REG, $ad_template.$h2result, $the_content, $count);
    }
  }
  return $the_content;
});</pre><p></p><pre class="urvanov-syntax-highlighter-plain-tag">/* 投稿本文中ウィジェットのスタイル */
.widget-in-article {
  text-align: center;
}</pre><p></p>
<div class="knowl-content" style="margin-top: 40px;" id="knowl-644456253"><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-8913642688016174" crossorigin="anonymous"></script><ins class="adsbygoogle" style="display:block;" data-ad-client="ca-pub-8913642688016174" 
data-ad-slot="4196732648" 
data-ad-format="auto"></ins>
<script> 
(adsbygoogle = window.adsbygoogle || []).push({}); 
</script>
</div><h2>投稿本文下ウィジェットの追加</h2>
<p></p><pre class="urvanov-syntax-highlighter-plain-tag">///////////////////////////////////////
// 投稿本文下ウィジェットの追加
///////////////////////////////////////
register_sidebars(1,
  array(
  'name'=&gt;'投稿本文下',
  'id' =&gt; 'widget-bottom-article',
  'description' =&gt; '投稿本文下に表示されるウイジェット。投稿本文の後に表示されます。',
  'before_widget' =&gt; '&lt;div id="%1$s" class="widget-bottom-article %2$s"&gt;',
  'after_widget' =&gt; '&lt;/div&gt;',
  'before_title' =&gt; '&lt;div class="widget-bottom-article-title"&gt;',
  'after_title' =&gt; '&lt;/div&gt;',
));

///////////////////////////////////////
// 投稿本文下にウィジェットを追加する処理
///////////////////////////////////////
add_filter( 'the_content', function ($the_content) {
  if ( is_single() &amp;&amp; //投稿ページのとき、固定ページも表示する場合はis_singular()にする
       is_active_sidebar( 'widget-bottom-article' ) //ウィジェットが設定されているとき
  ) {
    //広告（AdSense）タグを記入
    ob_start();//バッファリング
    dynamic_sidebar( 'widget-bottom-article' );//本文下ウィジェットの表示
    $ad_template = ob_get_clean();
    $the_content .= $ad_template;
  }
  return $the_content;
});</pre><p></p><pre class="urvanov-syntax-highlighter-plain-tag">/* 投稿本文下ウィジェットのスタイル */
.widget-bottom-article {
  text-align: center;
}</pre><p></p>
<h2>フッター上ウィジェットの追加</h2>
<p></p><pre class="urvanov-syntax-highlighter-plain-tag">///////////////////////////////////////
// フッター上ウィジェットの追加
///////////////////////////////////////
register_sidebars(1,
  array(
  'name'=&gt;'フッター上',
  'id' =&gt; 'widget-top-footer',
  'description' =&gt; 'フッター上に表示されるウイジェット。',
  'before_widget' =&gt; '&lt;div id="%1$s" class="widget-top-footer %2$s"&gt;',
  'after_widget' =&gt; '&lt;/div&gt;',
  'before_title' =&gt; '&lt;div class="widget-top-footer-title"&gt;',
  'after_title' =&gt; '&lt;/div&gt;',
));

///////////////////////////////////////
// フッター上にウィジェットを追加する処理
///////////////////////////////////////
add_action( 'get_footer', function () {
  if ( is_active_sidebar( 'widget-top-footer' ) //ウィジェットが設定されているとき
  ) {
    //広告（AdSense）タグを記入
    ob_start();//バッファリング
    dynamic_sidebar( 'widget-top-footer' );//フッター上ウィジェットの表示
    echo ob_get_clean();
  }
});</pre><p></p><pre class="urvanov-syntax-highlighter-plain-tag">/* フッター上ウィジェットのスタイル */
.widget-top-footer {
  text-align: center;
}</pre><p></p>
<h2>ヘッダー下ウィジェットの追加</h2>
<p></p><pre class="urvanov-syntax-highlighter-plain-tag">&lt;?php
  include(TEMPLATEPATH . '/header.php');
  dynamic_sidebar('widget-bottom-header');
?&gt;</pre><p></p><pre class="urvanov-syntax-highlighter-plain-tag">/* ヘッダー下ウィジェットのスタイル */
.widget-bottom-header {
  text-align: center;
}</pre><p>&nbsp;</p>
<div class="knowl-after-content-ad" style="margin-top: 40px;" id="knowl-42002409"><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-8913642688016174" crossorigin="anonymous"></script><ins class="adsbygoogle" style="display:block;" data-ad-client="ca-pub-8913642688016174" 
data-ad-slot="2719999442" 
data-ad-format="auto"></ins>
<script> 
(adsbygoogle = window.adsbygoogle || []).push({}); 
</script>
</div><div class="knowl-after-content-relation" id="knowl-1396586736"><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-8913642688016174" crossorigin="anonymous"></script><ins class="adsbygoogle" style="display:block;" data-ad-client="ca-pub-8913642688016174" 
data-ad-slot="7848218644" 
data-ad-format="autorelaxed"></ins>
<script> 
(adsbygoogle = window.adsbygoogle || []).push({}); 
</script>
</div>]]></content:encoded>
					
					<wfw:commentRss>https://knowledge.reontosanta.com/archives/1334/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1334</post-id>	</item>
		<item>
		<title>WordPressでコメントに入力されたurlを制御する</title>
		<link>https://knowledge.reontosanta.com/archives/1327</link>
					<comments>https://knowledge.reontosanta.com/archives/1327#respond</comments>
		
		<dc:creator><![CDATA[mogice]]></dc:creator>
		<pubDate>Sat, 14 Oct 2017 20:56:20 +0000</pubDate>
				<category><![CDATA[WordPress]]></category>
		<guid isPermaLink="false">https://knowledge.reontosanta.com/?p=1327</guid>

					<description><![CDATA[WordPressでコメントに書かれたurlがリンクにならないように&#46;&#46;&#46;]]></description>
										<content:encoded><![CDATA[<p>WordPressでコメントに書かれたurlがリンクにならないようにするには、functions.phpに以下の記述を追加する。</p><pre class="urvanov-syntax-highlighter-plain-tag">///////////////////////////////////////
// コメントに書かれたurlがリンクにならないようにする
///////////////////////////////////////
remove_filter( 'comment_text', 'make_clickable', 9);</pre><p>&nbsp;</p>
<div class="knowl-after-content-ad" style="margin-top: 40px;" id="knowl-222092224"><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-8913642688016174" crossorigin="anonymous"></script><ins class="adsbygoogle" style="display:block;" data-ad-client="ca-pub-8913642688016174" 
data-ad-slot="2719999442" 
data-ad-format="auto"></ins>
<script> 
(adsbygoogle = window.adsbygoogle || []).push({}); 
</script>
</div><div class="knowl-after-content-relation" id="knowl-2058794426"><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-8913642688016174" crossorigin="anonymous"></script><ins class="adsbygoogle" style="display:block;" data-ad-client="ca-pub-8913642688016174" 
data-ad-slot="7848218644" 
data-ad-format="autorelaxed"></ins>
<script> 
(adsbygoogle = window.adsbygoogle || []).push({}); 
</script>
</div>]]></content:encoded>
					
					<wfw:commentRss>https://knowledge.reontosanta.com/archives/1327/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1327</post-id>	</item>
		<item>
		<title>WordPressで子テーマを作成する</title>
		<link>https://knowledge.reontosanta.com/archives/1325</link>
					<comments>https://knowledge.reontosanta.com/archives/1325#respond</comments>
		
		<dc:creator><![CDATA[mogice]]></dc:creator>
		<pubDate>Mon, 04 Sep 2017 20:55:13 +0000</pubDate>
				<category><![CDATA[WordPress]]></category>
		<guid isPermaLink="false">https://knowledge.reontosanta.com/?p=1325</guid>

					<description><![CDATA[WordPressで子テーマは、子テーマディレクトリと2つのファイル&#46;&#46;&#46;]]></description>
										<content:encoded><![CDATA[<p>WordPressで子テーマは、子テーマディレクトリと2つのファイル(style.css と functions.php) から構成される。</p>
<h2>子テーマディレクトリの作成</h2>
<p>wp-content/themes ディレクトリ下に子テーマディレクトリを作成する。</p>
<p>子テーマディレクトリの名前には最後に &#8216;(親テーマ名)_child&#8217; を付けるとわかりやすい。</p>
<div class="knowl-content" style="margin-top: 40px;" id="knowl-362868217"><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-8913642688016174" crossorigin="anonymous"></script><ins class="adsbygoogle" style="display:block;" data-ad-client="ca-pub-8913642688016174" 
data-ad-slot="4196732648" 
data-ad-format="auto"></ins>
<script> 
(adsbygoogle = window.adsbygoogle || []).push({}); 
</script>
</div><h2>style.cssの作成</h2>
<p>子テーマディレクトリ下にstyle.cssを作成する。</p>
<p>最低限、Theme NameとTemplateのみの記述でOK。</p><pre class="urvanov-syntax-highlighter-plain-tag">/*
 Theme Name:   Twenty Fifteen Child
 Theme URI:    http://example.com/twenty-fifteen-child/
 Description:  Twenty Fifteen Child Theme
 Author:       John Doe
 Author URI:   http://example.com
 Template:     twentyfifteen
 Version:      1.0.0
 License:      GNU General Public License v2 or later
 License URI:  http://www.gnu.org/licenses/gpl-2.0.html
 Tags:         light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready
 Text Domain:  twenty-fifteen-child
*/</pre><p></p>
<h2>functions.phpの作成</h2>
<p>子テーマディレクトリ下にfunctions.phpを作成する。</p>
<p>親テーマのスタイルシートをキューに入れる処理を記述する。</p><pre class="urvanov-syntax-highlighter-plain-tag">&lt;?php
///////////////////////////////////////
// 親テーマのスタイルシートをキューに入れる
///////////////////////////////////////
add_action( 'wp_enqueue_scripts', function () {
  wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
});
?&gt;</pre><p>&nbsp;</p>
<div class="knowl-after-content-ad" style="margin-top: 40px;" id="knowl-3300736649"><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-8913642688016174" crossorigin="anonymous"></script><ins class="adsbygoogle" style="display:block;" data-ad-client="ca-pub-8913642688016174" 
data-ad-slot="2719999442" 
data-ad-format="auto"></ins>
<script> 
(adsbygoogle = window.adsbygoogle || []).push({}); 
</script>
</div><div class="knowl-after-content-relation" id="knowl-121328431"><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-8913642688016174" crossorigin="anonymous"></script><ins class="adsbygoogle" style="display:block;" data-ad-client="ca-pub-8913642688016174" 
data-ad-slot="7848218644" 
data-ad-format="autorelaxed"></ins>
<script> 
(adsbygoogle = window.adsbygoogle || []).push({}); 
</script>
</div>]]></content:encoded>
					
					<wfw:commentRss>https://knowledge.reontosanta.com/archives/1325/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1325</post-id>	</item>
	</channel>
</rss>
