<?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>目次広告 &#8211; ケケンタの独学ITブログ</title>
	<atom:link href="https://kekenta-it-blog.com/tag/%E7%9B%AE%E6%AC%A1%E5%BA%83%E5%91%8A/feed/" rel="self" type="application/rss+xml" />
	<link>https://kekenta-it-blog.com</link>
	<description>プログラミングやWeb制作の情報を発信</description>
	<lastBuildDate>Tue, 18 Mar 2025 02:19:00 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://kekenta-it-blog.com/wp-content/uploads/2023/07/cropped-KEKENTA-BLOG-32x32.png</url>
	<title>目次広告 &#8211; ケケンタの独学ITブログ</title>
	<link>https://kekenta-it-blog.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>【SWELL】「目次広告」の内容をカテゴリーごとに変更する方法</title>
		<link>https://kekenta-it-blog.com/swell-tocad-cat-branch/</link>
					<comments>https://kekenta-it-blog.com/swell-tocad-cat-branch/#respond</comments>
		
		<dc:creator><![CDATA[ケケンタ]]></dc:creator>
		<pubDate>Tue, 11 Jun 2024 06:08:14 +0000</pubDate>
				<category><![CDATA[SWELL]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[カテゴリー別]]></category>
		<category><![CDATA[目次広告]]></category>
		<guid isPermaLink="false">https://kekenta-it-blog.com/?p=8093</guid>

					<description><![CDATA[<p><img src="https://kekenta-it-blog.com/wp-content/uploads/2024/06/eye-catch__swell-tocad-cat-branch__8093-1024x576.jpg" class="webfeedsFeaturedVisual" /></p>この記事では SWELLで「目次広告」の内容をカテゴリーごとに変更する方法 をご紹介します。 SWELLの「目次広告」を使用すると簡単に目次の前後に任意の広告を表示できて便利なのですが、 ということがあります。 今回ご紹 [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><img src="https://kekenta-it-blog.com/wp-content/uploads/2024/06/eye-catch__swell-tocad-cat-branch__8093-1024x576.jpg" class="webfeedsFeaturedVisual" /></p>
<p>この記事では</p>



<p class="has-text-align-center is-style-big_kakko_box"><strong>SWELLで「目次広告」の内容を<br>カテゴリーごとに変更する方法</strong></p>



<p>をご紹介します。</p>



<p>SWELLの「目次広告」を使用すると簡単に目次の前後に任意の広告を表示できて便利なのですが、</p>


<div class="swell-block-balloon"><div class="c-balloon -bln-left" data-col="gray"><div class="c-balloon__icon -circle"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://kekenta-it-blog.com/wp-content/uploads/2023/07/困った顔-150x150.jpg" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://kekenta-it-blog.com/wp-content/uploads/2023/07/困った顔-150x150.jpg" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript><span class="c-balloon__iconName">ケケンタ</span></div><div class="c-balloon__body -speaking -border-on"><div class="c-balloon__text">
<p>このカテゴリーでは<strong>別の広告を表示した</strong>いんだよな……</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>


<p>ということがあります。</p>



<p>今回ご紹介するのはそのようなお悩みを解決できる方法です。</p>



<div class="swell-block-capbox cap_box is-style-shadow"><div class="cap_box_ttl"><span><span data-icon="LsLightbulb" data-id="0" style="--the-icon-svg: url(data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjFlbSIgd2lkdGg9IjFlbSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiBhcmlhLWhpZGRlbj0idHJ1ZSIgdmlld0JveD0iMCAwIDQ4IDQ4Ij48cGF0aCBkPSJNMzIgNDYuNUgxNmMtMS4xIDAtMi0uOS0yLTJzLjktMiAyLTJoMTZjMS4xIDAgMiAuOSAyIDJzLS45IDItMiAyek00MS43IDE1LjlDNDEuMyAxMyA0MCAxMC4zIDM4LjIgOCAzNC41IDMuMiAyOSAuOCAyMy4xIDEgMTQgMS40IDYuNSA4LjkgNiAxOGMtLjMgNiAyLjQgMTEuNyA3LjIgMTUuNC41LjQuOC45LjggMS41djEuNmMwIDIuMiAxLjggNCA0IDRoMTJjMi4yIDAgNC0xLjggNC00VjM1YzAtLjYuMy0xLjIuOS0xLjcgNS4zLTQgOC0xMC42IDYuOC0xNy40em0tNy4xIDEuN2gtLjNjLS43IDAtMS4zLS41LTEuNS0xLjItLjctMy4yLTMuMi01LjctNi40LTYuMy0uOC0uMS0xLjQtLjktMS4yLTEuN3MuOS0xLjQgMS43LTEuMmM0LjQuOCA4IDQuMiA4LjkgOC42LjEuOC0uNCAxLjYtMS4yIDEuOHoiPjwvcGF0aD48L3N2Zz4=)" aria-hidden="true" class="swl-inline-icon"> </span><strong> この記事でわかること</strong></span></div><div class="cap_box_content">
<ul class="wp-block-list is-style-check_list -list-under-dashed">
<li>SWELLの目次広告をカテゴリーごとに変更する方法</li>



<li>親カテゴリーを基準に目次広告を変更する方法</li>



<li>祖先カテゴリーを基準に目次広告を変更する方法</li>
</ul>
</div></div>


<div class="swell-block-postLink">			<a href="https://kekenta-it-blog.com/wp-edit-functions/" class="c-blogLink -internal" data-style="text">
				<!-- <i class="c-blogLink__icon icon-link" role="presentation"></i> -->
				<span class="c-blogLink__icon">
					<svg xmlns="http://www.w3.org/2000/svg" class="swl-svg-link __svg" width="1em" height="1em" viewBox="0 0 48 48" role="img" aria-hidden="true" focusable="false"><path d="M21.2 30.2c-.5 0-1-.2-1.4-.6l-.7-.7c-2.3-2.3-3.5-5.3-3.5-8.5s1.2-6.2 3.5-8.5l7.1-7.1c2.3-2.3 5.3-3.5 8.5-3.5s6.2 1.2 8.5 3.5c4.7 4.7 4.7 12.3 0 17l-3.5 3.5c-.8.8-2 .8-2.8 0-.8-.8-.8-2 0-2.8l3.5-3.5c3.1-3.1 3.1-8.2 0-11.3-1.5-1.5-3.5-2.3-5.7-2.3-2.1 0-4.2.8-5.7 2.3l-7.1 7.1c-1.5 1.5-2.3 3.5-2.3 5.7s.8 4.2 2.3 5.7l.7.7c.8.8.8 2 0 2.8-.4.3-.9.5-1.4.5z" /><path d="M13.4 46.6c-3.1 0-6.1-1.2-8.5-3.5-2.3-2.3-3.5-5.3-3.5-8.5s1.2-6.2 3.5-8.5l3.5-3.5c.8-.8 2-.8 2.8 0 .8.8.8 2 0 2.8l-3.5 3.5c-1.5 1.5-2.3 3.5-2.3 5.7 0 2.1.8 4.2 2.3 5.7 3.1 3.1 8.2 3.1 11.3 0l7.1-7.1c1.5-1.5 2.3-3.5 2.3-5.7 0-2.1-.8-4.2-2.3-5.7l-.7-.7c-.8-.8-.8-2 0-2.8.8-.8 2-.8 2.8 0l.7.7c2.3 2.3 3.5 5.3 3.5 8.5s-1.2 6.2-3.5 8.5l-7.1 7.1c-2.3 2.3-5.3 3.5-8.4 3.5z" /></svg>				</span>
				<span class="c-blogLink__text">【WordPress】functions.phpを編集する「３つ」の方法と編集時の注意点</span>
			</a>
		</div>

<div class="swell-block-postLink">			<a href="https://kekenta-it-blog.com/swell-title-eyecatch-re/" class="c-blogLink -internal" data-style="text">
				<!-- <i class="c-blogLink__icon icon-link" role="presentation"></i> -->
				<span class="c-blogLink__icon">
					<svg xmlns="http://www.w3.org/2000/svg" class="swl-svg-link __svg" width="1em" height="1em" viewBox="0 0 48 48" role="img" aria-hidden="true" focusable="false"><path d="M21.2 30.2c-.5 0-1-.2-1.4-.6l-.7-.7c-2.3-2.3-3.5-5.3-3.5-8.5s1.2-6.2 3.5-8.5l7.1-7.1c2.3-2.3 5.3-3.5 8.5-3.5s6.2 1.2 8.5 3.5c4.7 4.7 4.7 12.3 0 17l-3.5 3.5c-.8.8-2 .8-2.8 0-.8-.8-.8-2 0-2.8l3.5-3.5c3.1-3.1 3.1-8.2 0-11.3-1.5-1.5-3.5-2.3-5.7-2.3-2.1 0-4.2.8-5.7 2.3l-7.1 7.1c-1.5 1.5-2.3 3.5-2.3 5.7s.8 4.2 2.3 5.7l.7.7c.8.8.8 2 0 2.8-.4.3-.9.5-1.4.5z" /><path d="M13.4 46.6c-3.1 0-6.1-1.2-8.5-3.5-2.3-2.3-3.5-5.3-3.5-8.5s1.2-6.2 3.5-8.5l3.5-3.5c.8-.8 2-.8 2.8 0 .8.8.8 2 0 2.8l-3.5 3.5c-1.5 1.5-2.3 3.5-2.3 5.7 0 2.1.8 4.2 2.3 5.7 3.1 3.1 8.2 3.1 11.3 0l7.1-7.1c1.5-1.5 2.3-3.5 2.3-5.7 0-2.1-.8-4.2-2.3-5.7l-.7-.7c-.8-.8-.8-2 0-2.8.8-.8 2-.8 2.8 0l.7.7c2.3 2.3 3.5 5.3 3.5 8.5s-1.2 6.2-3.5 8.5l-7.1 7.1c-2.3 2.3-5.3 3.5-8.4 3.5z" /></svg>				</span>
				<span class="c-blogLink__text">【SWELL】タイトルとアイキャッチ画像の表示を上下逆にする方法</span>
			</a>
		</div>

<div class="swell-block-postLink">			<a href="https://kekenta-it-blog.com/swell-f-cr-link/" class="c-blogLink -internal" data-style="text">
				<!-- <i class="c-blogLink__icon icon-link" role="presentation"></i> -->
				<span class="c-blogLink__icon">
					<svg xmlns="http://www.w3.org/2000/svg" class="swl-svg-link __svg" width="1em" height="1em" viewBox="0 0 48 48" role="img" aria-hidden="true" focusable="false"><path d="M21.2 30.2c-.5 0-1-.2-1.4-.6l-.7-.7c-2.3-2.3-3.5-5.3-3.5-8.5s1.2-6.2 3.5-8.5l7.1-7.1c2.3-2.3 5.3-3.5 8.5-3.5s6.2 1.2 8.5 3.5c4.7 4.7 4.7 12.3 0 17l-3.5 3.5c-.8.8-2 .8-2.8 0-.8-.8-.8-2 0-2.8l3.5-3.5c3.1-3.1 3.1-8.2 0-11.3-1.5-1.5-3.5-2.3-5.7-2.3-2.1 0-4.2.8-5.7 2.3l-7.1 7.1c-1.5 1.5-2.3 3.5-2.3 5.7s.8 4.2 2.3 5.7l.7.7c.8.8.8 2 0 2.8-.4.3-.9.5-1.4.5z" /><path d="M13.4 46.6c-3.1 0-6.1-1.2-8.5-3.5-2.3-2.3-3.5-5.3-3.5-8.5s1.2-6.2 3.5-8.5l3.5-3.5c.8-.8 2-.8 2.8 0 .8.8.8 2 0 2.8l-3.5 3.5c-1.5 1.5-2.3 3.5-2.3 5.7 0 2.1.8 4.2 2.3 5.7 3.1 3.1 8.2 3.1 11.3 0l7.1-7.1c1.5-1.5 2.3-3.5 2.3-5.7 0-2.1-.8-4.2-2.3-5.7l-.7-.7c-.8-.8-.8-2 0-2.8.8-.8 2-.8 2.8 0l.7.7c2.3 2.3 3.5 5.3 3.5 8.5s-1.2 6.2-3.5 8.5l-7.1 7.1c-2.3 2.3-5.3 3.5-8.4 3.5z" /></svg>				</span>
				<span class="c-blogLink__text">【SWELL】誰でも簡単！フッターのコピーライトをリンクにする方法</span>
			</a>
		</div>

<div class="swell-block-postLink">			<a href="https://kekenta-it-blog.com/change-to-swell/" class="c-blogLink -internal" data-style="text">
				<!-- <i class="c-blogLink__icon icon-link" role="presentation"></i> -->
				<span class="c-blogLink__icon">
					<svg xmlns="http://www.w3.org/2000/svg" class="swl-svg-link __svg" width="1em" height="1em" viewBox="0 0 48 48" role="img" aria-hidden="true" focusable="false"><path d="M21.2 30.2c-.5 0-1-.2-1.4-.6l-.7-.7c-2.3-2.3-3.5-5.3-3.5-8.5s1.2-6.2 3.5-8.5l7.1-7.1c2.3-2.3 5.3-3.5 8.5-3.5s6.2 1.2 8.5 3.5c4.7 4.7 4.7 12.3 0 17l-3.5 3.5c-.8.8-2 .8-2.8 0-.8-.8-.8-2 0-2.8l3.5-3.5c3.1-3.1 3.1-8.2 0-11.3-1.5-1.5-3.5-2.3-5.7-2.3-2.1 0-4.2.8-5.7 2.3l-7.1 7.1c-1.5 1.5-2.3 3.5-2.3 5.7s.8 4.2 2.3 5.7l.7.7c.8.8.8 2 0 2.8-.4.3-.9.5-1.4.5z" /><path d="M13.4 46.6c-3.1 0-6.1-1.2-8.5-3.5-2.3-2.3-3.5-5.3-3.5-8.5s1.2-6.2 3.5-8.5l3.5-3.5c.8-.8 2-.8 2.8 0 .8.8.8 2 0 2.8l-3.5 3.5c-1.5 1.5-2.3 3.5-2.3 5.7 0 2.1.8 4.2 2.3 5.7 3.1 3.1 8.2 3.1 11.3 0l7.1-7.1c1.5-1.5 2.3-3.5 2.3-5.7 0-2.1-.8-4.2-2.3-5.7l-.7-.7c-.8-.8-.8-2 0-2.8.8-.8 2-.8 2.8 0l.7.7c2.3 2.3 3.5 5.3 3.5 8.5s-1.2 6.2-3.5 8.5l-7.1 7.1c-2.3 2.3-5.3 3.5-8.4 3.5z" /></svg>				</span>
				<span class="c-blogLink__text">無料テーマCocoonからSWELLに乗り換えた７つの理由【WordPress】</span>
			</a>
		</div>

<div class="swell-block-postLink">			<div class="p-blogCard -internal" data-type="type2" data-onclick="clickLink">
				<div class="p-blogCard__inner">
					<span class="p-blogCard__caption">あわせて読みたい</span>
					<div class="p-blogCard__thumb c-postThumb"><figure class="c-postThumb__figure"><img decoding="async" src="https://kekenta-it-blog.com/wp-content/uploads/2025/03/eye-catch__school-php-and-wp__14099-300x169.jpg" alt="" class="c-postThumb__img u-obf-cover" width="320" height="180"></figure></div>					<div class="p-blogCard__body">
						<a class="p-blogCard__title" href="https://kekenta-it-blog.com/school-php-and-wp/">PHPやWordPressを学ぶのにおすすめのプログラミングスクール【７選】</a>
						<span class="p-blogCard__excerpt">僕はこれまで独学でPHPを学習してきました。結論から言えば、それでもPHPを習得することはできました。 しかし、それに費やした累計学習期間は1年ほど。モチベーション&#8230;</span>					</div>
				</div>
			</div>
		</div>


<h2 class="wp-block-heading">【作業の流れ】カテゴリーごとに目次広告を変更する方法</h2>



<p class="is-style-bg_stripe">実は「目次広告」を設定する項目欄ではHTMLタグを使用することが可能です。</p>


<div class="swell-block-balloon"><div class="c-balloon -bln-left" data-col="gray"><div class="c-balloon__icon -circle"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://kekenta-it-blog.com/wp-content/uploads/2023/07/キリッ-150x150.jpg" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://kekenta-it-blog.com/wp-content/uploads/2023/07/キリッ-150x150.jpg" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript><span class="c-balloon__iconName">ケケンタ</span></div><div class="c-balloon__body -speaking -border-on"><div class="c-balloon__text">
<p>そちらを踏まえた上で、まずは簡単に<strong>今回使用する方法の作業の流れ</strong>をご説明します。</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>


<div class="swell-block-capbox cap_box"><div class="cap_box_ttl"><span><strong>カテゴリーごとに目次広告を変更する作業の流れ</strong></span></div><div class="cap_box_content">
<ul class="wp-block-list is-style-num_circle -list-under-dashed">
<li>使用したい広告を<strong>「広告タグ」もしくは「ブログパーツ」</strong>に登録しておく</li>



<li>「SWELL設定」→「広告コード」→「目次広告」に<strong>使用したい広告のショートコード</strong>をすべて入力する</li>



<li>②で入力したショートコードそれぞれを、<strong>任意のCSSクラス名を付けたdiv要素</strong>で囲う</li>



<li>「カスタマイズ」→「追加CSS」に<strong>③で設定した各div要素を非表示にするCSS</strong>を記述する</li>



<li>functinos.phpに<strong>カテゴリー別制御用の処理</strong>を記述する</li>
</ul>
</div></div>


<div class="swell-block-balloon"><div class="c-balloon -bln-left" data-col="gray"><div class="c-balloon__icon -circle"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://kekenta-it-blog.com/wp-content/uploads/2023/07/キリッ-150x150.jpg" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://kekenta-it-blog.com/wp-content/uploads/2023/07/キリッ-150x150.jpg" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript><span class="c-balloon__iconName">ケケンタ</span></div><div class="c-balloon__body -speaking -border-on"><div class="c-balloon__text">
<p>手順が少々複雑になる箇所もありますが、以降より画像も使用してできるだけ丁寧に解説していきます！</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>


<h3 class="wp-block-heading">① 使用したい広告を<strong>「広告タグ」もしくは「ブログパーツ」</strong>に登録しておく</h3>



<p>まずは使用したい広告（コンテンツ）を「広告タグ」もしくは「ブログパーツ」に登録します。</p>



<p class="has-text-align-center is-style-balloon_box2">以下はブログパーツ登録後の画面</p>


<div class="wp-block-image is-style-shadow size_s">
<figure class="alignleft size-full"><img decoding="async" width="916" height="79" src="https://kekenta-it-blog.com/wp-content/uploads/2024/06/image-27.png" alt="ブログパーツにコンテンツを登録した後の一覧画面の様子" class="wp-image-8201" srcset="https://kekenta-it-blog.com/wp-content/uploads/2024/06/image-27.png 916w, https://kekenta-it-blog.com/wp-content/uploads/2024/06/image-27-300x26.png 300w, https://kekenta-it-blog.com/wp-content/uploads/2024/06/image-27-768x66.png 768w" sizes="(max-width: 916px) 100vw, 916px" /><figcaption class="wp-element-caption">コンテンツを登録した後のブログパーツ一覧画面（一部抜粋）</figcaption></figure>
</div>

<div class="swell-block-balloon"><div class="c-balloon -bln-left" data-col="gray"><div class="c-balloon__icon -circle"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://kekenta-it-blog.com/wp-content/uploads/2023/07/キリッ-150x150.jpg" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://kekenta-it-blog.com/wp-content/uploads/2023/07/キリッ-150x150.jpg" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript><span class="c-balloon__iconName">ケケンタ</span></div><div class="c-balloon__body -speaking -border-on"><div class="c-balloon__text">
<p>画像の右側に写っている<div class="p-blogParts post_content" data-partsID="○○○◯"></div>の部分がショートコードです。</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>


<h3 class="wp-block-heading">② 「目次広告」に<strong>使用したい広告のショートコード</strong>をすべて入力する</h3>



<p class="is-style-icon_info"><strong>手順③を完了するまでの間はすべての「目次広告」が表示されてしまう</strong>ため、この手順②を行う前に手順③の作業内容もご確認いただくことを推奨します。</p>



<p>①で用意したショートコードを</p>



<p class="is-style-bg_stripe">「SWELL設定」→「広告コード」→「目次広告」</p>



<p>にすべて入力します。</p>


<div class="wp-block-image is-style-shadow size_s">
<figure class="aligncenter size-full"><img decoding="async" width="633" height="223" src="https://kekenta-it-blog.com/wp-content/uploads/2024/06/image-28.png" alt="目次広告にショートコードを設定" class="wp-image-8206" srcset="https://kekenta-it-blog.com/wp-content/uploads/2024/06/image-28.png 633w, https://kekenta-it-blog.com/wp-content/uploads/2024/06/image-28-300x106.png 300w" sizes="(max-width: 633px) 100vw, 633px" /><figcaption class="wp-element-caption">目次広告にショートコードを設定</figcaption></figure>
</div>


<h3 class="wp-block-heading">③ ②で入力したショートコードを任意のCSSクラス名を付けたdiv要素で囲う</h3>



<p class="is-style-icon_info"><strong>この作業が「目次広告をカテゴリーごとに制御する」上で最も重要です。</strong></p>



<p>②で入力したショートコードを任意のCSSクラス名を付与したdiv要素で囲います。</p>



<p>例えば、以下の画像では次のような形でクラス名を付与しています。</p>



<div class="wp-block-group has-border -border01"><div class="wp-block-group__inner-container">
<ul class="wp-block-list is-style-check_list -list-under-dashed">
<li>デフォルトで全体に表示したい目次広告……<strong>display-general-cat</strong></li>



<li>特定のカテゴリー（例では「WordPress」カテゴリー）で表示したい目次広告……<strong>display-only-wp-cat</strong></li>
</ul>
</div></div>


<div class="wp-block-image is-style-shadow size_s">
<figure class="aligncenter size-full"><img decoding="async" width="617" height="215" src="https://kekenta-it-blog.com/wp-content/uploads/2024/06/image-29.png" alt="目次広告に設定したショートコードをdiv要素で囲う" class="wp-image-8207" srcset="https://kekenta-it-blog.com/wp-content/uploads/2024/06/image-29.png 617w, https://kekenta-it-blog.com/wp-content/uploads/2024/06/image-29-300x105.png 300w" sizes="(max-width: 617px) 100vw, 617px" /><figcaption class="wp-element-caption">目次広告に設定したショートコードをdiv要素で囲う</figcaption></figure>
</div>

<div class="swell-block-balloon"><div class="c-balloon -bln-left" data-col="gray"><div class="c-balloon__icon -circle"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://kekenta-it-blog.com/wp-content/uploads/2023/07/キリッ-150x150.jpg" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://kekenta-it-blog.com/wp-content/uploads/2023/07/キリッ-150x150.jpg" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript><span class="c-balloon__iconName">ケケンタ</span></div><div class="c-balloon__body -speaking -border-on"><div class="c-balloon__text">
<p>１行目には<strong>特定のカテゴリーに依存せず表示</strong>したい目次広告のショートコード<br>２行目には<strong>「WordPress」カテゴリーにだけ表示</strong>したい目次広告のショートコードを入力した状態です。</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>

<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-4374558503914683"
     crossorigin="anonymous"></script>
<!-- ディスプレイ【横長】 -->
<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="ca-pub-4374558503914683"
     data-ad-slot="9744298852"
     data-ad-format="auto"
     data-full-width-responsive="true"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



<h3 class="wp-block-heading">④ 「追加CSS」に<strong>③で設定した各div要素を非表示にするCSS</strong>を記述する</h3>



<p>次に、<strong>③でショートコードに設定した各div要素</strong>を非表示にするためのCSSを</p>



<p class="is-style-bg_stripe">「外観」→「カスタマイズ」→「追加CSS」</p>



<p>に記述していきます。</p>



<p class="is-style-icon_info">すべてのdiv要素を非表示にするのではなく、<strong><span class="swl-marker mark_yellow">特定のカテゴリーでだけ表示したい目次広告のdiv要素だけ</span></strong>を非表示にします。</p>



<div class="swell-block-columns"><div class="swell-block-columns__inner">
<div class="swell-block-column swl-has-mb--s is-breadk-all" style="--clmn-w--mobile:100%;--clmn-w--tab:50%;--clmn-w--pc:50%"><div class="wp-block-image is-style-shadow size_s">
<figure class="aligncenter size-full"><img decoding="async" width="323" height="199" src="https://kekenta-it-blog.com/wp-content/uploads/2024/06/image-30.png" alt="「カスタマイズ」の位置" class="wp-image-8214" srcset="https://kekenta-it-blog.com/wp-content/uploads/2024/06/image-30.png 323w, https://kekenta-it-blog.com/wp-content/uploads/2024/06/image-30-300x185.png 300w" sizes="(max-width: 323px) 100vw, 323px" /><figcaption class="wp-element-caption">「カスタマイズ」の位置</figcaption></figure>
</div></div>



<div class="swell-block-column swl-has-mb--s" style="--clmn-w--mobile:100%;--clmn-w--tab:50%;--clmn-w--pc:50%"><div class="wp-block-image is-style-shadow size_xs">
<figure class="aligncenter size-full"><img decoding="async" width="381" height="690" src="https://kekenta-it-blog.com/wp-content/uploads/2024/06/image-31.png" alt="「追加CSS」の位置" class="wp-image-8216" srcset="https://kekenta-it-blog.com/wp-content/uploads/2024/06/image-31.png 381w, https://kekenta-it-blog.com/wp-content/uploads/2024/06/image-31-166x300.png 166w" sizes="(max-width: 381px) 100vw, 381px" /><figcaption class="wp-element-caption">「追加CSS」の位置</figcaption></figure>
</div></div>
</div></div>


<div class="swell-block-balloon"><div class="c-balloon -bln-left" data-col="gray"><div class="c-balloon__icon -circle"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://kekenta-it-blog.com/wp-content/uploads/2023/07/キリッ-150x150.jpg" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://kekenta-it-blog.com/wp-content/uploads/2023/07/キリッ-150x150.jpg" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript><span class="c-balloon__iconName">ケケンタ</span></div><div class="c-balloon__body -speaking -border-on"><div class="c-balloon__text">
<p>「追加CSS」を開いたら以下のように、<strong><span class="swl-marker mark_yellow">「特定のカテゴリーでだけ表示したい目次広告」に設定したCSSクラス名に対してCSSを記述</span></strong>します。</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>


<p class="has-text-align-center is-style-balloon_box2">（例）「WordPress」カテゴリーでだけ表示したい目次広告の<br>CSSクラス（display-only-wp-cat）にCSSを記述</p>



<figure class="wp-block-image size-full is-style-shadow"><img decoding="async" width="373" height="233" src="https://kekenta-it-blog.com/wp-content/uploads/2024/06/image-32.png" alt="「追加CSS」への記述内容" class="wp-image-8217" srcset="https://kekenta-it-blog.com/wp-content/uploads/2024/06/image-32.png 373w, https://kekenta-it-blog.com/wp-content/uploads/2024/06/image-32-300x187.png 300w" sizes="(max-width: 373px) 100vw, 373px" /><figcaption class="wp-element-caption">「追加CSS」への記述内容</figcaption></figure>



<div class="hcb_wrap"><pre class="prism line-numbers lang-css" data-lang="CSS"><code>.display-only-wp-cat {
  display: none;
}</code></pre></div>



<p class="has-text-align-center is-style-balloon_box2"><strong><span class="swl-marker mark_yellow">対象のショートコードが複数ある場合</span></strong>は以下のように行を追加<br>※最後の行以外は「,」で区切ってあることに注意</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-css" data-lang="CSS"><code>.display-only-wp-cat,
.display-only-sample01-cat,
.display-only-sample02-cat {
  display: none;
}</code></pre></div>



<p class="is-style-big_icon_check">ここまでの作業で、いったん<strong>すべての目次に「デフォルトで全体に表示したい目次広告」だけが表示されている状態</strong>になりました。</p>


<div class="swell-block-balloon"><div class="c-balloon -bln-left" data-col="gray"><div class="c-balloon__icon -circle"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://kekenta-it-blog.com/wp-content/uploads/2023/07/キリッ-150x150.jpg" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://kekenta-it-blog.com/wp-content/uploads/2023/07/キリッ-150x150.jpg" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript><span class="c-balloon__iconName">ケケンタ</span></div><div class="c-balloon__body -speaking -border-on"><div class="c-balloon__text">
<p>このあとご紹介するソースコードをfunctions.phpに追加することで、カテゴリーごとに表示する目次広告を変更することが可能です。</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>


<h3 class="wp-block-heading">⑤ functinos.phpにカテゴリー別制御用の処理を記述する</h3>



<p class="is-style-icon_info">functions.phpを編集する際には必ずバックアップをお取りいただき、自己責任のもとで作業を行ってください。</p>



<p>functions.phpの最後に以下の<strong>ソースコードを追加</strong>します。</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-php" data-lang="PHP" data-line="11,19"><code>/**
 * 現在のカテゴリーごとに目次広告を切り替える
 */
function my_headinput_toc_ctrl_css() {
	$cats = get_the_category(); 
	$cat = $cats[0];

	/**
     * カテゴリー「サンプル」を判定
     */ 
	if( $cat-&gt;slug == &#39;sample&#39; ){
		$headinputtag = &lt;&lt;&lt;EOM

		&lt;style&gt;
		.display-general-cat {
			display: none !important;
		}

		.display-only-sample-cat {
			display: block !important;
		}
		&lt;/style&gt;

		EOM;
		echo $headinputtag;
	}
}
add_action( &#39;wp_head&#39;, &#39;my_headinput_toc_ctrl_css&#39;, 99);</code></pre></div>



<p class="is-style-icon_pen">ハイライトされている11行目と19行目の「sample」、「.display-only-sample-cat」がご自身の設定内容に合わせて変更していただく箇所です。</p>



<p>例えば<strong>以下のような内容で設定</strong>をしていた場合には、次のようなソースコードになります。</p>



<ul class="wp-block-list is-style-check_list -list-under-dashed">
<li>「WordPress」カテゴリーでのみ表示したい</li>



<li>「WordPress」カテゴリーでのみ表示した目次広告のショートコードのCSSクラス名は「display-only-wp-cat」に設定してある。</li>
</ul>



<p class="is-style-balloon_box2">（例）<strong>「WordPress」カテゴリー</strong>でのみ表示したい目次広告を有効にする</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-php" data-lang="PHP" data-line="11,19"><code>/**
 * 現在のカテゴリーごとに目次広告を切り替える
 */
function my_headinput_toc_ctrl_css() {
	$cats = get_the_category(); 
	$cat = $cats[0];

	/**
     * カテゴリー「WordPress」を判定
     */ 
	if( $cat-&gt;slug == &#39;wordpress&#39; ){
		$headinputtag = &lt;&lt;&lt;EOM

		&lt;style&gt;
		.display-general-cat {
			display: none !important;
		}

		.display-only-wp-cat {
			display: block !important;
		}
		&lt;/style&gt;

		EOM;
		echo $headinputtag;
	}
}
add_action( &#39;wp_head&#39;, &#39;my_headinput_toc_ctrl_css&#39;, 99);</code></pre></div>


<div class="swell-block-balloon"><div class="c-balloon -bln-left" data-col="gray"><div class="c-balloon__icon -circle"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://kekenta-it-blog.com/wp-content/uploads/2023/11/kekenta-icon-150x150.jpg" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://kekenta-it-blog.com/wp-content/uploads/2023/11/kekenta-icon-150x150.jpg" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript><span class="c-balloon__iconName">ケケンタ</span></div><div class="c-balloon__body -speaking -border-on"><div class="c-balloon__text">
<p>以上でカテゴリーごとに表示する目次広告を変更することが可能です！</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>

<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-4374558503914683"
     crossorigin="anonymous"></script>
<!-- ディスプレイ【横長】 -->
<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="ca-pub-4374558503914683"
     data-ad-slot="9744298852"
     data-ad-format="auto"
     data-full-width-responsive="true"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



<h2 class="wp-block-heading">複数のカテゴリーを制御したい場合のソースコード</h2>



<p>ここまでのご説明では「WordPress」カテゴリーひとつに限った内容になっていましたが、実際には複数のカテゴリーで目次広告を出しわけたいという方も多いかと思います。</p>



<p class="is-style-bg_stripe">その場合は<strong>else if文</strong>を使用してソースコードを記述します。</p>



<p class="is-style-balloon_box2">複数のカテゴリーを制御したい場合のソースコード</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-php" data-lang="PHP"><code>/**
 * 現在のカテゴリーごとに目次広告を切り替える
 */
function my_headinput_toc_ctrl_css() {
	$cats = get_the_category(); 
	$cat = $cats[0];

	/**
     * カテゴリー「サンプル０１」を判定
     */ 
	if( $cat-&gt;slug == &#39;sample01&#39; ){
		$headinputtag = &lt;&lt;&lt;EOM

		&lt;style&gt;
		.display-general-cat {
			display: none !important;
		}

		.display-only-sample01-cat {
			display: block !important;
		}
		&lt;/style&gt;

		EOM;
		echo $headinputtag;
	
    /**
     * カテゴリー「サンプル０２」を判定
     */ 
	} else if( $cat-&gt;slug == &#39;sample02&#39; ) {

		$headinputtag = &lt;&lt;&lt;EOM

		&lt;style&gt;
		.display-general-cat {
			display: none !important;
		}

		.display-only-sample02-cat {
			display: block !important;
		}
		&lt;/style&gt;

		EOM;
		echo $headinputtag;
    /**
     * カテゴリー「サンプル０３」を判定
     */ 
	} else if( $cat-&gt;slug == &#39;sample03&#39; ) {
               
                 ～　省略　～
    }
}
add_action( &#39;wp_head&#39;, &#39;my_headinput_toc_ctrl_css&#39;, 99);</code></pre></div>



<h2 class="wp-block-heading">「親カテゴリー」を基準に目次広告を出しわけたい場合</h2>



<p>人によってはカテゴリーに階層を設定しており、「子カテゴリーではなく親カテゴリー」で目次広告を出しわけしたいという場合も多いのではないかと思います。</p>



<p>その場合は以下のソースコードをお使いください。</p>



<p class="is-style-balloon_box2"><strong>親カテゴリー</strong>で目次広告を出しわけたい場合</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-php" data-lang="PHP" data-line="12-20"><code>/**
 * 親カテゴリーごとに目次広告を切り替える
 */
function my_headinput_toc_ctrl_css() {

	/**
	 * 現在のカテゴリー情報を取得
	 */
	$cats = get_the_category(); 
	$cat = $cats[0];

	/**
	 * 親カテゴリーがあれば親カテゴリーを取得する
	 */
	if( $cat-&gt;parent ){ //親カテゴリの場合
		$parent = get_category( $cat-&gt;parent );
		$cat_slug = $parent-&gt;slug;
	} else { //子カテゴリの場合
		$cat_slug =  $cat-&gt;slug;
	}

	/**
     * カテゴリー「WordPress」を判定
     */ 
	if( $cat_slug == &#39;wordpress&#39; ){
		$headinputtag = &lt;&lt;&lt;EOM

		&lt;style&gt;
		.display-general-cat {
			display: none !important;
		}

		.display-only-wp-cat {
			display: block !important;
		}
		&lt;/style&gt;

		EOM;
		echo $headinputtag;
	}
}
add_action( &#39;wp_head&#39;, &#39;my_headinput_toc_ctrl_css&#39;, 99);</code></pre></div>



<p class="is-style-bg_stripe">ハイライト行（12～20行目）が増え、ここで親カテゴリーかどうかの判定を行っています。</p>



<h2 class="wp-block-heading">「祖先カテゴリー」を基準に目次広告を出しわけたい場合</h2>



<p>もしかしたらカテゴリー階層を<strong>３階層</strong>にしている方もいらっしゃるかもしれません。</p>



<p>そのようなとき、親カテゴリーではなく「祖先カテゴリー」で目次広告を出しわけしたいという方は以下のソースコードをお使いください。</p>



<p class="is-style-balloon_box2"><strong>祖先カテゴリー</strong>で目次広告を出しわけたい場合</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-php" data-lang="PHP" data-line="12-20"><code>/**
 * 祖先カテゴリーごとに目次広告を切り替える
 */
function my_headinput_toc_ctrl_css() {

  /**
   * 現在のカテゴリーを取得
   */
  $cats = get_the_category(); 
  $cat = $cats[0];

  /**
   * 祖先カテゴリーがあれば祖先カテゴリーを取得する
   */
  if( !$cat-&gt;parent ){ //現在のページが最上位のカテゴリーなら
    $cat_slug = $cat-&gt;slug; // 現在のカテゴリーのスラッグ
  } else { //祖先カテゴリーを表示するなら
    $ancestor = array_pop(get_ancestors( $cat-&gt;cat_ID, &#39;category&#39; )); //一番上のカテゴリーIDを取得
    $cat_slug = get_category($ancestor)-&gt;slug; // 祖先カテゴリーのスラッグ
  }

  // カテゴリー「sosen」を判定
  if( $cat_slug == &#39;sosen&#39; ){
    $headinputtag = &lt;&lt;&lt;EOM

    &lt;style&gt;
    .display-general-cat {
      display: none !important;
    }

    .display-only-wp-cat {
      display: block !important;
    }
    &lt;/style&gt;

    EOM;
    echo $headinputtag;
  }
}
add_action( &#39;wp_head&#39;, &#39;my_headinput_toc_ctrl_css&#39;, 99);</code></pre></div>



<p class="is-style-bg_stripe">ハイライト行（12～20行目）が増え、ここで親カテゴリーかどうかの判定を行っています。</p>


<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-4374558503914683"
     crossorigin="anonymous"></script>
<!-- ディスプレイ【横長】 -->
<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="ca-pub-4374558503914683"
     data-ad-slot="9744298852"
     data-ad-format="auto"
     data-full-width-responsive="true"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



<h2 class="wp-block-heading">まとめ</h2>


<div class="swell-block-balloon"><div class="c-balloon -bln-left" data-col="gray"><div class="c-balloon__icon -circle"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://kekenta-it-blog.com/wp-content/uploads/2023/07/キリッ-150x150.jpg" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://kekenta-it-blog.com/wp-content/uploads/2023/07/キリッ-150x150.jpg" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript><span class="c-balloon__iconName">ケケンタ</span></div><div class="c-balloon__body -speaking -border-on"><div class="c-balloon__text">
<p>以上が目次広告をカテゴリー別に出しわける方法でした！</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>


<p>いかがだったでしょうか。</p>



<p>SWELLの目次広告は非常に便利なのですが、カテゴリー別に目次広告を出しわけるためにはひと手間必要になります。</p>



<p>今回ご紹介した方法で各カテゴリーに適した目次広告を表示すれば、お財布の中身もうるおう……かもしれません。</p>


<div class="swell-block-balloon"><div class="c-balloon -bln-left" data-col="gray"><div class="c-balloon__icon -circle"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://kekenta-it-blog.com/wp-content/uploads/2023/07/キリッ-150x150.jpg" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://kekenta-it-blog.com/wp-content/uploads/2023/07/キリッ-150x150.jpg" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript><span class="c-balloon__iconName">ケケンタ</span></div><div class="c-balloon__body -speaking -border-on"><div class="c-balloon__text">
<p>この記事が少しでもお役に立ったなら何よりです！</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>


<p>この記事ではWordPressやWeb制作に関する情報を発信していますので、ご興味のある方は他の記事もご覧いただけると嬉しいです。</p>



<p>それでは、最後までご覧いただきありがとうございました！</p>
<div class="p-blogParts post_content" data-partsID="7607">
<p class="has-text-align-center is-style-balloon_box">SWELLのその他の記事はこちら</p>



<p class="has-text-align-center"><span data-icon="LsSwellLogo" data-id="0" style="--the-icon-svg: url(data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjFlbSIgd2lkdGg9IjFlbSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiBhcmlhLWhpZGRlbj0idHJ1ZSIgdmlld0JveD0iMCAwIDQwIDQwIj48Y2lyY2xlIGN4PSI0LjIiIGN5PSIxNS42IiByPSIyLjEiPjwvY2lyY2xlPjxwYXRoIGQ9Ik0zNi43IDExLjZjLTEtMi4yLTMuNy0zLjktNi45LTMuMy0zLjYuNy01LjQgMi45LTcuOCA1LjktMi43IDMuNC01LjUgNy05LjQgOC41LTEuNC42LTIuOC44LTQuMy44LTEuMSAwLTIuMy0uMi0zLjUtLjUtLjctLjItMS41LS41LTIuMy0uOCAyIDcuOSA5LjIgMTMuOCAxNy44IDEzLjYgOS44LS4yIDE3LjctOC4zIDE3LjctMTgtLjEtMi4xLS40LTQuMy0xLjMtNi4yeiI+PC9wYXRoPjwvc3ZnPg==)" aria-hidden="true" class="swl-inline-icon"> </span><a href="https://kekenta-it-blog.com/category/wordpress/swell/">SWELL記事一覧</a></p>



<div class="swell-block-fullWide pc-py-60 sp-py-40 alignfull" style="background-color:#f7f7f7"><div class="swell-block-fullWide__inner l-article">
<h2 class="wp-block-heading is-style-section_ttl my-is-style-section_ttl--none"></h2>



<p class="has-text-align-center"><span class="swl-marker mark_green"><strong><span class="swl-fz u-fz-l">今回ご紹介した内容のテーマ</span></strong></span><span style="--the-icon-svg: url(data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjFlbSIgd2lkdGg9IjFlbSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiBhcmlhLWhpZGRlbj0idHJ1ZSIgdmlld0JveD0iMCAwIDQwIDQwIj48Y2lyY2xlIGN4PSI0LjIiIGN5PSIxNS42IiByPSIyLjEiPjwvY2lyY2xlPjxwYXRoIGQ9Ik0zNi43IDExLjZjLTEtMi4yLTMuNy0zLjktNi45LTMuMy0zLjYuNy01LjQgMi45LTcuOCA1LjktMi43IDMuNC01LjUgNy05LjQgOC41LTEuNC42LTIuOC44LTQuMy44LTEuMSAwLTIuMy0uMi0zLjUtLjUtLjctLjItMS41LS41LTIuMy0uOCAyIDcuOSA5LjIgMTMuOCAxNy44IDEzLjYgOS44LS4yIDE3LjctOC4zIDE3LjctMTgtLjEtMi4xLS40LTQuMy0xLjMtNi4yeiI+PC9wYXRoPjwvc3ZnPg==)" data-icon="LsSwellLogo" data-id="13" aria-hidden="true" class="swl-inline-icon"><span class="swl-fz u-fz-l"> </span></span></p>


<p><div class="p-blogParts post_content" data-partsID="7603">
<div style="text-align: center;">



<a href="//af.moshimo.com/af/c/click?a_id=4500848&p_id=3885&pc_id=9646&pl_id=53838" rel="nofollow" referrerpolicy="no-referrer-when-downgrade"><img decoding="async" src="//image.moshimo.com/af-img/3130/000000053838.jpg" width="420" height="350" style="border:none;"></a><img decoding="async" src="//i.moshimo.com/af/i/impression?a_id=4500848&p_id=3885&pc_id=9646&pl_id=53838" width="1" height="1" style="border:none;">



</div>
</div></p>



<p class="has-text-align-center u-mb-ctrl u-mb-0"><span class="swl-fz u-fz-s"><strong>＼　19,800円・買い切り　／</strong></span></p>



<div class="swell-block-button -html green_ -size-l is-style-btn_shiny"><a href="//af.moshimo.com/af/c/click?a_id=4500848&amp;p_id=3885&amp;pc_id=9646&amp;pl_id=53798&amp;url=https%3A%2F%2Fswell-theme.com%2F" rel="nofollow" referrerpolicy="no-referrer-when-downgrade" attributionsrc="">今すぐSWELLを購入する　&gt;&gt;</a><img decoding="async" src="//i.moshimo.com/af/i/impression?a_id=4500848&amp;p_id=3885&amp;pc_id=9646&amp;pl_id=53798" width="1" height="1" style="border:none;" alt="" loading="lazy"></div>
</div></div>
</div>]]></content:encoded>
					
					<wfw:commentRss>https://kekenta-it-blog.com/swell-tocad-cat-branch/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>【SWELL】特定のページで目次広告を非表示にする方法</title>
		<link>https://kekenta-it-blog.com/swell-tocad-hidden/</link>
					<comments>https://kekenta-it-blog.com/swell-tocad-hidden/#respond</comments>
		
		<dc:creator><![CDATA[ケケンタ]]></dc:creator>
		<pubDate>Mon, 10 Jun 2024 07:22:20 +0000</pubDate>
				<category><![CDATA[SWELL]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[目次広告]]></category>
		<guid isPermaLink="false">https://kekenta-it-blog.com/?p=7953</guid>

					<description><![CDATA[<p><img src="https://kekenta-it-blog.com/wp-content/uploads/2024/06/eye-catch__swell-tocad-hidden__7953-1024x576.jpg" class="webfeedsFeaturedVisual" /></p>SWELLの目次広告、便利なのですが収益化メインのページでは表示したくないなあというのが正直なところです。 と色々調べていたところ、その方法を見つけることができたため、今回はそちらをご紹介します。 この記事でご紹介する方 [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><img src="https://kekenta-it-blog.com/wp-content/uploads/2024/06/eye-catch__swell-tocad-hidden__7953-1024x576.jpg" class="webfeedsFeaturedVisual" /></p>
<p>SWELLの目次広告、便利なのですが収益化メインのページでは表示したくないなあというのが正直なところです。</p>


<div class="swell-block-balloon"><div class="c-balloon -bln-left" data-col="gray"><div class="c-balloon__icon -circle"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://kekenta-it-blog.com/wp-content/uploads/2023/07/困った顔-150x150.jpg" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://kekenta-it-blog.com/wp-content/uploads/2023/07/困った顔-150x150.jpg" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript><span class="c-balloon__iconName">ケケンタ</span></div><div class="c-balloon__body -speaking -border-on"><div class="c-balloon__text">
<p>特定のページでは目次広告を非表示にする方法って無いのかな……</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>


<p>と色々調べていたところ、その方法を見つけることができたため、今回はそちらをご紹介します。</p>



<div class="swell-block-capbox cap_box is-style-shadow"><div class="cap_box_ttl"><span><span data-icon="LsLightbulb" data-id="0" style="--the-icon-svg: url(data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjFlbSIgd2lkdGg9IjFlbSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiBhcmlhLWhpZGRlbj0idHJ1ZSIgdmlld0JveD0iMCAwIDQ4IDQ4Ij48cGF0aCBkPSJNMzIgNDYuNUgxNmMtMS4xIDAtMi0uOS0yLTJzLjktMiAyLTJoMTZjMS4xIDAgMiAuOSAyIDJzLS45IDItMiAyek00MS43IDE1LjlDNDEuMyAxMyA0MCAxMC4zIDM4LjIgOCAzNC41IDMuMiAyOSAuOCAyMy4xIDEgMTQgMS40IDYuNSA4LjkgNiAxOGMtLjMgNiAyLjQgMTEuNyA3LjIgMTUuNC41LjQuOC45LjggMS41djEuNmMwIDIuMiAxLjggNCA0IDRoMTJjMi4yIDAgNC0xLjggNC00VjM1YzAtLjYuMy0xLjIuOS0xLjcgNS4zLTQgOC0xMC42IDYuOC0xNy40em0tNy4xIDEuN2gtLjNjLS43IDAtMS4zLS41LTEuNS0xLjItLjctMy4yLTMuMi01LjctNi40LTYuMy0uOC0uMS0xLjQtLjktMS4yLTEuN3MuOS0xLjQgMS43LTEuMmM0LjQuOCA4IDQuMiA4LjkgOC42LjEuOC0uNCAxLjYtMS4yIDEuOHoiPjwvcGF0aD48L3N2Zz4=)" aria-hidden="true" class="swl-inline-icon"> </span><strong> この記事を読むと分かること</strong></span></div><div class="cap_box_content">
<ul class="wp-block-list is-style-check_list">
<li>SWELLの目次広告を特定のページで非表示にする方法</li>
</ul>
</div></div>



<p class="is-style-icon_info">この記事でご紹介する方法ではfunctions.phpを編集します。<br>作業をする際には必ずバックアップをお取りいただき、自己責任のもとで作業を行ってください。</p>


<div class="swell-block-postLink">			<a href="https://kekenta-it-blog.com/wp-edit-functions/" class="c-blogLink -internal" data-style="text">
				<!-- <i class="c-blogLink__icon icon-link" role="presentation"></i> -->
				<span class="c-blogLink__icon">
					<svg xmlns="http://www.w3.org/2000/svg" class="swl-svg-link __svg" width="1em" height="1em" viewBox="0 0 48 48" role="img" aria-hidden="true" focusable="false"><path d="M21.2 30.2c-.5 0-1-.2-1.4-.6l-.7-.7c-2.3-2.3-3.5-5.3-3.5-8.5s1.2-6.2 3.5-8.5l7.1-7.1c2.3-2.3 5.3-3.5 8.5-3.5s6.2 1.2 8.5 3.5c4.7 4.7 4.7 12.3 0 17l-3.5 3.5c-.8.8-2 .8-2.8 0-.8-.8-.8-2 0-2.8l3.5-3.5c3.1-3.1 3.1-8.2 0-11.3-1.5-1.5-3.5-2.3-5.7-2.3-2.1 0-4.2.8-5.7 2.3l-7.1 7.1c-1.5 1.5-2.3 3.5-2.3 5.7s.8 4.2 2.3 5.7l.7.7c.8.8.8 2 0 2.8-.4.3-.9.5-1.4.5z" /><path d="M13.4 46.6c-3.1 0-6.1-1.2-8.5-3.5-2.3-2.3-3.5-5.3-3.5-8.5s1.2-6.2 3.5-8.5l3.5-3.5c.8-.8 2-.8 2.8 0 .8.8.8 2 0 2.8l-3.5 3.5c-1.5 1.5-2.3 3.5-2.3 5.7 0 2.1.8 4.2 2.3 5.7 3.1 3.1 8.2 3.1 11.3 0l7.1-7.1c1.5-1.5 2.3-3.5 2.3-5.7 0-2.1-.8-4.2-2.3-5.7l-.7-.7c-.8-.8-.8-2 0-2.8.8-.8 2-.8 2.8 0l.7.7c2.3 2.3 3.5 5.3 3.5 8.5s-1.2 6.2-3.5 8.5l-7.1 7.1c-2.3 2.3-5.3 3.5-8.4 3.5z" /></svg>				</span>
				<span class="c-blogLink__text">【WordPress】functions.phpを編集する「３つ」の方法と編集時の注意点</span>
			</a>
		</div>

<div class="swell-block-postLink">			<a href="https://kekenta-it-blog.com/swell-title-eyecatch-re/" class="c-blogLink -internal" data-style="text">
				<!-- <i class="c-blogLink__icon icon-link" role="presentation"></i> -->
				<span class="c-blogLink__icon">
					<svg xmlns="http://www.w3.org/2000/svg" class="swl-svg-link __svg" width="1em" height="1em" viewBox="0 0 48 48" role="img" aria-hidden="true" focusable="false"><path d="M21.2 30.2c-.5 0-1-.2-1.4-.6l-.7-.7c-2.3-2.3-3.5-5.3-3.5-8.5s1.2-6.2 3.5-8.5l7.1-7.1c2.3-2.3 5.3-3.5 8.5-3.5s6.2 1.2 8.5 3.5c4.7 4.7 4.7 12.3 0 17l-3.5 3.5c-.8.8-2 .8-2.8 0-.8-.8-.8-2 0-2.8l3.5-3.5c3.1-3.1 3.1-8.2 0-11.3-1.5-1.5-3.5-2.3-5.7-2.3-2.1 0-4.2.8-5.7 2.3l-7.1 7.1c-1.5 1.5-2.3 3.5-2.3 5.7s.8 4.2 2.3 5.7l.7.7c.8.8.8 2 0 2.8-.4.3-.9.5-1.4.5z" /><path d="M13.4 46.6c-3.1 0-6.1-1.2-8.5-3.5-2.3-2.3-3.5-5.3-3.5-8.5s1.2-6.2 3.5-8.5l3.5-3.5c.8-.8 2-.8 2.8 0 .8.8.8 2 0 2.8l-3.5 3.5c-1.5 1.5-2.3 3.5-2.3 5.7 0 2.1.8 4.2 2.3 5.7 3.1 3.1 8.2 3.1 11.3 0l7.1-7.1c1.5-1.5 2.3-3.5 2.3-5.7 0-2.1-.8-4.2-2.3-5.7l-.7-.7c-.8-.8-.8-2 0-2.8.8-.8 2-.8 2.8 0l.7.7c2.3 2.3 3.5 5.3 3.5 8.5s-1.2 6.2-3.5 8.5l-7.1 7.1c-2.3 2.3-5.3 3.5-8.4 3.5z" /></svg>				</span>
				<span class="c-blogLink__text">【SWELL】タイトルとアイキャッチ画像の表示を上下逆にする方法</span>
			</a>
		</div>

<div class="swell-block-postLink">			<a href="https://kekenta-it-blog.com/swell-f-cr-link/" class="c-blogLink -internal" data-style="text">
				<!-- <i class="c-blogLink__icon icon-link" role="presentation"></i> -->
				<span class="c-blogLink__icon">
					<svg xmlns="http://www.w3.org/2000/svg" class="swl-svg-link __svg" width="1em" height="1em" viewBox="0 0 48 48" role="img" aria-hidden="true" focusable="false"><path d="M21.2 30.2c-.5 0-1-.2-1.4-.6l-.7-.7c-2.3-2.3-3.5-5.3-3.5-8.5s1.2-6.2 3.5-8.5l7.1-7.1c2.3-2.3 5.3-3.5 8.5-3.5s6.2 1.2 8.5 3.5c4.7 4.7 4.7 12.3 0 17l-3.5 3.5c-.8.8-2 .8-2.8 0-.8-.8-.8-2 0-2.8l3.5-3.5c3.1-3.1 3.1-8.2 0-11.3-1.5-1.5-3.5-2.3-5.7-2.3-2.1 0-4.2.8-5.7 2.3l-7.1 7.1c-1.5 1.5-2.3 3.5-2.3 5.7s.8 4.2 2.3 5.7l.7.7c.8.8.8 2 0 2.8-.4.3-.9.5-1.4.5z" /><path d="M13.4 46.6c-3.1 0-6.1-1.2-8.5-3.5-2.3-2.3-3.5-5.3-3.5-8.5s1.2-6.2 3.5-8.5l3.5-3.5c.8-.8 2-.8 2.8 0 .8.8.8 2 0 2.8l-3.5 3.5c-1.5 1.5-2.3 3.5-2.3 5.7 0 2.1.8 4.2 2.3 5.7 3.1 3.1 8.2 3.1 11.3 0l7.1-7.1c1.5-1.5 2.3-3.5 2.3-5.7 0-2.1-.8-4.2-2.3-5.7l-.7-.7c-.8-.8-.8-2 0-2.8.8-.8 2-.8 2.8 0l.7.7c2.3 2.3 3.5 5.3 3.5 8.5s-1.2 6.2-3.5 8.5l-7.1 7.1c-2.3 2.3-5.3 3.5-8.4 3.5z" /></svg>				</span>
				<span class="c-blogLink__text">【SWELL】誰でも簡単！フッターのコピーライトをリンクにする方法</span>
			</a>
		</div>

<div class="swell-block-postLink">			<a href="https://kekenta-it-blog.com/change-to-swell/" class="c-blogLink -internal" data-style="text">
				<!-- <i class="c-blogLink__icon icon-link" role="presentation"></i> -->
				<span class="c-blogLink__icon">
					<svg xmlns="http://www.w3.org/2000/svg" class="swl-svg-link __svg" width="1em" height="1em" viewBox="0 0 48 48" role="img" aria-hidden="true" focusable="false"><path d="M21.2 30.2c-.5 0-1-.2-1.4-.6l-.7-.7c-2.3-2.3-3.5-5.3-3.5-8.5s1.2-6.2 3.5-8.5l7.1-7.1c2.3-2.3 5.3-3.5 8.5-3.5s6.2 1.2 8.5 3.5c4.7 4.7 4.7 12.3 0 17l-3.5 3.5c-.8.8-2 .8-2.8 0-.8-.8-.8-2 0-2.8l3.5-3.5c3.1-3.1 3.1-8.2 0-11.3-1.5-1.5-3.5-2.3-5.7-2.3-2.1 0-4.2.8-5.7 2.3l-7.1 7.1c-1.5 1.5-2.3 3.5-2.3 5.7s.8 4.2 2.3 5.7l.7.7c.8.8.8 2 0 2.8-.4.3-.9.5-1.4.5z" /><path d="M13.4 46.6c-3.1 0-6.1-1.2-8.5-3.5-2.3-2.3-3.5-5.3-3.5-8.5s1.2-6.2 3.5-8.5l3.5-3.5c.8-.8 2-.8 2.8 0 .8.8.8 2 0 2.8l-3.5 3.5c-1.5 1.5-2.3 3.5-2.3 5.7 0 2.1.8 4.2 2.3 5.7 3.1 3.1 8.2 3.1 11.3 0l7.1-7.1c1.5-1.5 2.3-3.5 2.3-5.7 0-2.1-.8-4.2-2.3-5.7l-.7-.7c-.8-.8-.8-2 0-2.8.8-.8 2-.8 2.8 0l.7.7c2.3 2.3 3.5 5.3 3.5 8.5s-1.2 6.2-3.5 8.5l-7.1 7.1c-2.3 2.3-5.3 3.5-8.4 3.5z" /></svg>				</span>
				<span class="c-blogLink__text">無料テーマCocoonからSWELLに乗り換えた７つの理由【WordPress】</span>
			</a>
		</div>

<div class="swell-block-postLink">			<div class="p-blogCard -internal" data-type="type2" data-onclick="clickLink">
				<div class="p-blogCard__inner">
					<span class="p-blogCard__caption">あわせて読みたい</span>
					<div class="p-blogCard__thumb c-postThumb"><figure class="c-postThumb__figure"><img decoding="async" src="https://kekenta-it-blog.com/wp-content/uploads/2025/03/eye-catch__school-php-and-wp__14099-300x169.jpg" alt="" class="c-postThumb__img u-obf-cover" width="320" height="180"></figure></div>					<div class="p-blogCard__body">
						<a class="p-blogCard__title" href="https://kekenta-it-blog.com/school-php-and-wp/">PHPやWordPressを学ぶのにおすすめのプログラミングスクール【７選】</a>
						<span class="p-blogCard__excerpt">僕はこれまで独学でPHPを学習してきました。結論から言えば、それでもPHPを習得することはできました。 しかし、それに費やした累計学習期間は1年ほど。モチベーション&#8230;</span>					</div>
				</div>
			</div>
		</div>


<h2 class="wp-block-heading">目次広告を特定のページで非表示にするソースコード</h2>


<div class="swell-block-balloon"><div class="c-balloon -bln-left" data-col="gray"><div class="c-balloon__icon -circle"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://kekenta-it-blog.com/wp-content/uploads/2023/07/キリッ-150x150.jpg" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://kekenta-it-blog.com/wp-content/uploads/2023/07/キリッ-150x150.jpg" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript><span class="c-balloon__iconName">ケケンタ</span></div><div class="c-balloon__body -speaking -border-on"><div class="c-balloon__text">
<p>早速ですが、以下が<strong>ベースとなるソースコード</strong>です。<br>ご状況に合わせて、以下のソースコードの<strong>一部を修正</strong>してご利用いただく形になります。</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>


<p class="is-style-balloon_box2">ベースとなるソースコード</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-php" data-lang="PHP" data-line="2"><code>add_filter( &#39;swell_is_show_toc_ad&#39;, function( $is_show ) {
    if ( ページ判定の条件分岐 ) {
        return false; // 目次広告を非表示
    }
    return $is_show; // それ以外のページはデフォルトの設定に従う
} );</code></pre></div>



<p class="is-style-bg_stripe">ハイライト行（２行目）の「ページ判定の条件分岐」の部分にはご状況に応じた条件をご入力下さい。</p>



<p class="is-style-big_icon_check">以下より<strong><span class="swl-marker mark_yellow">利用頻度が高そうな条件の具体例</span></strong>をご紹介します。<br>ご自身の状況に合わせて、適当なソースコードを<strong>functions.phpの最後</strong>に追加して下さい。<br><br>※SWELLで子テーマのfunctoins.phpにソースコードを追加する手順は<a href="#add_functinons">こちら</a></p>



<h3 class="wp-block-heading">特定の「投稿ページ」で目次広告を非表示にする</h3>



<div class="hcb_wrap"><pre class="prism line-numbers lang-php" data-lang="PHP" data-line="2"><code>add_filter( &#39;swell_is_show_toc_ad&#39;, function( $is_show ) {
    if ( is_single(&#39;投稿ページのスラッグ&#39;) ) { // 投稿ページ「スラッグ」では目次広告を非表示
        return false; 
    }
    return $is_show; // それ以外のページはデフォルトの設定に従う
} );</code></pre></div>



<p class="is-style-balloon_box2">具体例</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-php" data-lang="PHP" data-line="2"><code>add_filter( &#39;swell_is_show_toc_ad&#39;, function( $is_show ) {
    if ( is_single(&#39;sample_slug&#39;) ) { // 投稿ページ「sample_slug」では目次広告を非表示
        return false; 
    }
    return $is_show; // それ以外のページはデフォルトの設定に従う
} );</code></pre></div>



<h3 class="wp-block-heading">特定の「個別ページ」で目次広告を非表示にする</h3>



<div class="hcb_wrap"><pre class="prism line-numbers lang-php" data-lang="PHP" data-line="2"><code>add_filter( &#39;swell_is_show_toc_ad&#39;, function( $is_show ) {
    if ( is_page(&#39;固定ページのスラッグ&#39;) ) { // 固定ページ「スラッグ」では目次広告を非表示
        return false; 
    }
    return $is_show; // それ以外のページはデフォルトの設定に従う
} );</code></pre></div>



<p class="is-style-balloon_box2">具体例</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-php" data-lang="PHP" data-line="2"><code>add_filter( &#39;swell_is_show_toc_ad&#39;, function( $is_show ) {
    if ( is_page(&#39;sample_slug&#39;) ) { // 固定ページ「sample_slug」では目次広告を非表示
        return false; 
    }
    return $is_show; // それ以外のページはデフォルトの設定に従う
} );</code></pre></div>



<h3 class="wp-block-heading">特定の「カスタム投稿ページ」で目次広告を非表示にする</h3>


<div class="swell-block-balloon"><div class="c-balloon -bln-left" data-col="gray"><div class="c-balloon__icon -circle"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://kekenta-it-blog.com/wp-content/uploads/2023/07/キリッ-150x150.jpg" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://kekenta-it-blog.com/wp-content/uploads/2023/07/キリッ-150x150.jpg" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript><span class="c-balloon__iconName">ケケンタ</span></div><div class="c-balloon__body -speaking -border-on"><div class="c-balloon__text">
<p>カスタム投稿ページだけ少し条件の指定までの流れが異なります。</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>


<div class="hcb_wrap"><pre class="prism line-numbers lang-php" data-lang="PHP" data-line="2"><code>add_filter( &#39;swell_is_show_toc_ad&#39;, function( $is_show ) {
    // カスタム投稿タイプのスラッグを取得
    global $post;
    $slug = $post-&gt;post_name;

    if ( $slug === &#39;カスタム投稿タイプのスラッグ&#39; ) { // カスタム投稿タイプ「スラッグ」では目次広告を非表示
        return false; 
    }
    return $is_show; // それ以外のページはデフォルトの設定に従う
} );</code></pre></div>



<p class="is-style-balloon_box2">具体例</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-php" data-lang="PHP" data-line="2"><code>add_filter( &#39;swell_is_show_toc_ad&#39;, function( $is_show ) {
    // カスタム投稿タイプのスラッグを取得
    global $post;
    $slug = $post-&gt;post_name;

    if ( $slug === &#39;sample_slug&#39; ) { // カスタム投稿タイプ「sample_slug」では目次広告を非表示
        return false; 
    }
    return $is_show; // それ以外のページはデフォルトの設定に従う
} );</code></pre></div>


<div class="swell-block-postLink">			<a href="https://kekenta-it-blog.com/wp-cpt-page-condition/" class="c-blogLink -internal" data-style="text">
				<!-- <i class="c-blogLink__icon icon-link" role="presentation"></i> -->
				<span class="c-blogLink__icon">
					<svg xmlns="http://www.w3.org/2000/svg" class="swl-svg-link __svg" width="1em" height="1em" viewBox="0 0 48 48" role="img" aria-hidden="true" focusable="false"><path d="M21.2 30.2c-.5 0-1-.2-1.4-.6l-.7-.7c-2.3-2.3-3.5-5.3-3.5-8.5s1.2-6.2 3.5-8.5l7.1-7.1c2.3-2.3 5.3-3.5 8.5-3.5s6.2 1.2 8.5 3.5c4.7 4.7 4.7 12.3 0 17l-3.5 3.5c-.8.8-2 .8-2.8 0-.8-.8-.8-2 0-2.8l3.5-3.5c3.1-3.1 3.1-8.2 0-11.3-1.5-1.5-3.5-2.3-5.7-2.3-2.1 0-4.2.8-5.7 2.3l-7.1 7.1c-1.5 1.5-2.3 3.5-2.3 5.7s.8 4.2 2.3 5.7l.7.7c.8.8.8 2 0 2.8-.4.3-.9.5-1.4.5z" /><path d="M13.4 46.6c-3.1 0-6.1-1.2-8.5-3.5-2.3-2.3-3.5-5.3-3.5-8.5s1.2-6.2 3.5-8.5l3.5-3.5c.8-.8 2-.8 2.8 0 .8.8.8 2 0 2.8l-3.5 3.5c-1.5 1.5-2.3 3.5-2.3 5.7 0 2.1.8 4.2 2.3 5.7 3.1 3.1 8.2 3.1 11.3 0l7.1-7.1c1.5-1.5 2.3-3.5 2.3-5.7 0-2.1-.8-4.2-2.3-5.7l-.7-.7c-.8-.8-.8-2 0-2.8.8-.8 2-.8 2.8 0l.7.7c2.3 2.3 3.5 5.3 3.5 8.5s-1.2 6.2-3.5 8.5l-7.1 7.1c-2.3 2.3-5.3 3.5-8.4 3.5z" /></svg>				</span>
				<span class="c-blogLink__text">【WordPress】カスタム投稿タイプの特定ページを判定する方法</span>
			</a>
		</div>


<h2 class="wp-block-heading" id="add_functinons">SWELLの子テーマのfunctions.phpにソースコードを追加する方法</h2>



<p>まずは管理画面の「外観」→「テーマファイルエディタ」をクリックします。</p>



<figure class="wp-block-image size-full is-style-shadow"><img decoding="async" width="403" height="249" src="https://kekenta-it-blog.com/wp-content/uploads/2024/06/image-8.png" alt="外観→テーマファイルエディタ" class="wp-image-7694" srcset="https://kekenta-it-blog.com/wp-content/uploads/2024/06/image-8.png 403w, https://kekenta-it-blog.com/wp-content/uploads/2024/06/image-8-300x185.png 300w" sizes="(max-width: 403px) 100vw, 403px" /><figcaption class="wp-element-caption">「テーマファイルエディタ」の場所</figcaption></figure>



<p>すると以下のような画面が表示されるので、右側にある「<strong>Theme Functions（functions.php）</strong>」をクリックします。</p>



<figure class="wp-block-image size-large size_s is-style-shadow"><img decoding="async" width="1024" height="565" src="https://kekenta-it-blog.com/wp-content/uploads/2024/06/image-9-1024x565.png" alt="SWELLで外観→テーマファイルエディタをクリックした直後の様子" class="wp-image-7695" srcset="https://kekenta-it-blog.com/wp-content/uploads/2024/06/image-9-1024x565.png 1024w, https://kekenta-it-blog.com/wp-content/uploads/2024/06/image-9-300x166.png 300w, https://kekenta-it-blog.com/wp-content/uploads/2024/06/image-9-768x424.png 768w, https://kekenta-it-blog.com/wp-content/uploads/2024/06/image-9.png 1159w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption class="wp-element-caption">functions.phpの場所</figcaption></figure>



<p class="is-style-icon_info">このとき、念のため右上の「編集するテーマを選択」が「SWELL CHILD」になっていることをご確認下さい。<br>※もしなっていなければ、「SWELL CHILD」を選び、「選択」ボタンをクリックして下さい。</p>



<p>続いて、<strong>エディタの末尾にソースコードを追加</strong>します。</p>



<figure class="wp-block-image size-full size_s is-style-shadow"><img decoding="async" width="957" height="802" src="https://kekenta-it-blog.com/wp-content/uploads/2024/06/image-11.png" alt="SWELLでのfunctions.phpの編集個所" class="wp-image-7697" srcset="https://kekenta-it-blog.com/wp-content/uploads/2024/06/image-11.png 957w, https://kekenta-it-blog.com/wp-content/uploads/2024/06/image-11-300x251.png 300w, https://kekenta-it-blog.com/wp-content/uploads/2024/06/image-11-768x644.png 768w" sizes="(max-width: 957px) 100vw, 957px" /><figcaption class="wp-element-caption">functions.phpの編集内容</figcaption></figure>


<div class="swell-block-balloon"><div class="c-balloon -bln-left" data-col="gray"><div class="c-balloon__icon -circle"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://kekenta-it-blog.com/wp-content/uploads/2023/07/キリッ-150x150.jpg" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://kekenta-it-blog.com/wp-content/uploads/2023/07/キリッ-150x150.jpg" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript><span class="c-balloon__iconName">ケケンタ</span></div><div class="c-balloon__body -speaking -border-on"><div class="c-balloon__text">
<p>ソースコードを追加したら、最後に画面左下の「ファイルを更新」をクリックして完了です。</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>


<h2 class="wp-block-heading">目次広告は適切なページにだけ表示しよう</h2>


<div class="swell-block-balloon"><div class="c-balloon -bln-left" data-col="gray"><div class="c-balloon__icon -circle"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://kekenta-it-blog.com/wp-content/uploads/2023/07/キリッ-150x150.jpg" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://kekenta-it-blog.com/wp-content/uploads/2023/07/キリッ-150x150.jpg" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript><span class="c-balloon__iconName">ケケンタ</span></div><div class="c-balloon__body -speaking -border-on"><div class="c-balloon__text">
<p>以上が<strong>目次広告を特定のページで非表示にする方法</strong>でした！</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>


<p>目次広告は一度設定すればすべてのページに自動反映されて便利なのですが、収益化ページではかえって邪魔になってしまうケースもあります。</p>



<p>そのようなときに今回ご紹介した方法がお役に立てば幸いです。</p>



<p>それでは、最後までご覧いただきありがとうございました！</p>
<div class="p-blogParts post_content" data-partsID="7607">
<p class="has-text-align-center is-style-balloon_box">SWELLのその他の記事はこちら</p>



<p class="has-text-align-center"><span data-icon="LsSwellLogo" data-id="0" style="--the-icon-svg: url(data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjFlbSIgd2lkdGg9IjFlbSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiBhcmlhLWhpZGRlbj0idHJ1ZSIgdmlld0JveD0iMCAwIDQwIDQwIj48Y2lyY2xlIGN4PSI0LjIiIGN5PSIxNS42IiByPSIyLjEiPjwvY2lyY2xlPjxwYXRoIGQ9Ik0zNi43IDExLjZjLTEtMi4yLTMuNy0zLjktNi45LTMuMy0zLjYuNy01LjQgMi45LTcuOCA1LjktMi43IDMuNC01LjUgNy05LjQgOC41LTEuNC42LTIuOC44LTQuMy44LTEuMSAwLTIuMy0uMi0zLjUtLjUtLjctLjItMS41LS41LTIuMy0uOCAyIDcuOSA5LjIgMTMuOCAxNy44IDEzLjYgOS44LS4yIDE3LjctOC4zIDE3LjctMTgtLjEtMi4xLS40LTQuMy0xLjMtNi4yeiI+PC9wYXRoPjwvc3ZnPg==)" aria-hidden="true" class="swl-inline-icon"> </span><a href="https://kekenta-it-blog.com/category/wordpress/swell/">SWELL記事一覧</a></p>



<div class="swell-block-fullWide pc-py-60 sp-py-40 alignfull" style="background-color:#f7f7f7"><div class="swell-block-fullWide__inner l-article">
<h2 class="wp-block-heading is-style-section_ttl my-is-style-section_ttl--none"></h2>



<p class="has-text-align-center"><span class="swl-marker mark_green"><strong><span class="swl-fz u-fz-l">今回ご紹介した内容のテーマ</span></strong></span><span style="--the-icon-svg: url(data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjFlbSIgd2lkdGg9IjFlbSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiBhcmlhLWhpZGRlbj0idHJ1ZSIgdmlld0JveD0iMCAwIDQwIDQwIj48Y2lyY2xlIGN4PSI0LjIiIGN5PSIxNS42IiByPSIyLjEiPjwvY2lyY2xlPjxwYXRoIGQ9Ik0zNi43IDExLjZjLTEtMi4yLTMuNy0zLjktNi45LTMuMy0zLjYuNy01LjQgMi45LTcuOCA1LjktMi43IDMuNC01LjUgNy05LjQgOC41LTEuNC42LTIuOC44LTQuMy44LTEuMSAwLTIuMy0uMi0zLjUtLjUtLjctLjItMS41LS41LTIuMy0uOCAyIDcuOSA5LjIgMTMuOCAxNy44IDEzLjYgOS44LS4yIDE3LjctOC4zIDE3LjctMTgtLjEtMi4xLS40LTQuMy0xLjMtNi4yeiI+PC9wYXRoPjwvc3ZnPg==)" data-icon="LsSwellLogo" data-id="13" aria-hidden="true" class="swl-inline-icon"><span class="swl-fz u-fz-l"> </span></span></p>


<p><div class="p-blogParts post_content" data-partsID="7603">
<div style="text-align: center;">



<a href="//af.moshimo.com/af/c/click?a_id=4500848&p_id=3885&pc_id=9646&pl_id=53838" rel="nofollow" referrerpolicy="no-referrer-when-downgrade"><img decoding="async" src="//image.moshimo.com/af-img/3130/000000053838.jpg" width="420" height="350" style="border:none;"></a><img decoding="async" src="//i.moshimo.com/af/i/impression?a_id=4500848&p_id=3885&pc_id=9646&pl_id=53838" width="1" height="1" style="border:none;">



</div>
</div></p>



<p class="has-text-align-center u-mb-ctrl u-mb-0"><span class="swl-fz u-fz-s"><strong>＼　19,800円・買い切り　／</strong></span></p>



<div class="swell-block-button -html green_ -size-l is-style-btn_shiny"><a href="//af.moshimo.com/af/c/click?a_id=4500848&amp;p_id=3885&amp;pc_id=9646&amp;pl_id=53798&amp;url=https%3A%2F%2Fswell-theme.com%2F" rel="nofollow" referrerpolicy="no-referrer-when-downgrade" attributionsrc="">今すぐSWELLを購入する　&gt;&gt;</a><img decoding="async" src="//i.moshimo.com/af/i/impression?a_id=4500848&amp;p_id=3885&amp;pc_id=9646&amp;pl_id=53798" width="1" height="1" style="border:none;" alt="" loading="lazy"></div>
</div></div>
</div>]]></content:encoded>
					
					<wfw:commentRss>https://kekenta-it-blog.com/swell-tocad-hidden/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
