Snipt.net is closing on December 31st, 2016

For more information, please visit this blog post.

snipt

Ctrl+h for KB shortcuts

JavaScript

hashbang stylesheet change

1
2
3
4
5
// Swaps out the screen stylesheet for a print stylesheet
if (window.location.hash == '#print=true') {
	var printcssuri = $('link[media=print]:first').attr('href');
	$('link[media=screen]:first').attr('href', printcssuri);
}
https://snipt.net/embed/8316e7f10fd7cefa41accd90fe1f4036/
https://snipt.net/raw/8316e7f10fd7cefa41accd90fe1f4036/
8316e7f10fd7cefa41accd90fe1f4036
js
JavaScript
5
2016-12-10T05:40:54
True
False
False
Mar 18, 2014 at 03:12 AM
/api/public/snipt/122666/
hashbang-stylesheet-change
<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></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="c1">// Swaps out the screen stylesheet for a print stylesheet</span> </span><span id="L-2"><a name="L-2"></a><span class="k">if</span> <span class="p">(</span><span class="nb">window</span><span class="p">.</span><span class="nx">location</span><span class="p">.</span><span class="nx">hash</span> <span class="o">==</span> <span class="s1">&#39;#print=true&#39;</span><span class="p">)</span> <span class="p">{</span> </span><span id="L-3"><a name="L-3"></a> <span class="kd">var</span> <span class="nx">printcssuri</span> <span class="o">=</span> <span class="nx">$</span><span class="p">(</span><span class="s1">&#39;link[media=print]:first&#39;</span><span class="p">).</span><span class="nx">attr</span><span class="p">(</span><span class="s1">&#39;href&#39;</span><span class="p">);</span> </span><span id="L-4"><a name="L-4"></a> <span class="nx">$</span><span class="p">(</span><span class="s1">&#39;link[media=screen]:first&#39;</span><span class="p">).</span><span class="nx">attr</span><span class="p">(</span><span class="s1">&#39;href&#39;</span><span class="p">,</span> <span class="nx">printcssuri</span><span class="p">);</span> </span><span id="L-5"><a name="L-5"></a><span class="p">}</span> </span></pre></div> </td></tr></table>
CSS, jQuery, link, meta, theme

Text only

Output meta field

<?php echo get_post_meta($post->ID, 'meta-name', $single = true); ?>
https://snipt.net/embed/f2d2f40baf1d928f989c1a85f303e380/
https://snipt.net/raw/f2d2f40baf1d928f989c1a85f303e380/
f2d2f40baf1d928f989c1a85f303e380
text
Text only
1
2016-12-11T02:20:32
True
False
False
Aug 21, 2012 at 08:42 AM
/api/public/snipt/46032/
output-meta-field
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>&lt;?php echo get_post_meta($post-&gt;ID, &#39;meta-name&#39;, $single = true); ?&gt; </span></pre></div> </td></tr></table>
meta, wordpress
Copyrighted, illegal, or inappropriate content? Email [email protected].