snipt

Ctrl+h for KB shortcuts

PHP

Read more at the end of the_excerpt in Wordpress

1
2
3
4
5
6
7
8
<?php
	//Read more at the end of the_excerpt
	function new_excerpt_more($more) {
        global $post;
		return '... <a class="more-link" href="'. get_permalink($post->ID) . '">Далее...</a>';
	}
	add_filter('excerpt_more', 'new_excerpt_more');
?>
https://snipt.net/embed/fa8ceb8f33bbc418ac90806b57dfd665/
/raw/fa8ceb8f33bbc418ac90806b57dfd665/
fa8ceb8f33bbc418ac90806b57dfd665
php
PHP
8
2016-11-26T03:03:20
True
False
True
Jul 27, 2013 at 01:50 PM
/api/public/snipt/69895/
read-more-at-the-end-of-the_excerpt-in-wordpress
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a> <a href="#L-8">8</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="cp">&lt;?php</span> </span><span id="L-2"><a name="L-2"></a> <span class="c1">//Read more at the end of the_excerpt</span> </span><span id="L-3"><a name="L-3"></a> <span class="k">function</span> <span class="nf">new_excerpt_more</span><span class="p">(</span><span class="nv">$more</span><span class="p">)</span> <span class="p">{</span> </span><span id="L-4"><a name="L-4"></a> <span class="k">global</span> <span class="nv">$post</span><span class="p">;</span> </span><span id="L-5"><a name="L-5"></a> <span class="k">return</span> <span class="s1">&#39;... &lt;a class=&quot;more-link&quot; href=&quot;&#39;</span><span class="o">.</span> <span class="nx">get_permalink</span><span class="p">(</span><span class="nv">$post</span><span class="o">-&gt;</span><span class="na">ID</span><span class="p">)</span> <span class="o">.</span> <span class="s1">&#39;&quot;&gt;Далее...&lt;/a&gt;&#39;</span><span class="p">;</span> </span><span id="L-6"><a name="L-6"></a> <span class="p">}</span> </span><span id="L-7"><a name="L-7"></a> <span class="nx">add_filter</span><span class="p">(</span><span class="s1">&#39;excerpt_more&#39;</span><span class="p">,</span> <span class="s1">&#39;new_excerpt_more&#39;</span><span class="p">);</span> </span><span id="L-8"><a name="L-8"></a><span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
functions.php, wordpress