<?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>WP Engineer &#187; Plugin</title>
	<atom:link href="http://wpengineer.com/tag/plugin/feed/" rel="self" type="application/rss+xml" />
	<link>http://wpengineer.com</link>
	<description>WordPress News, Hacks, Tips, Tutorials, Plugins and Themes</description>
	<lastBuildDate>Sun, 22 Jan 2012 13:32:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Stop SOPA!</title>
		<link>http://wpengineer.com/2401/stop-sopa/</link>
		<comments>http://wpengineer.com/2401/stop-sopa/#comments</comments>
		<pubDate>Tue, 17 Jan 2012 07:34:50 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[WPengineer Misc]]></category>
		<category><![CDATA[Plugin]]></category>
		<category><![CDATA[sopa]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WP]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=2401</guid>
		<description><![CDATA[What is this all about: Help Stop SOPA/PIPA Turn off your website on January 18th for 12 hours. Simple and fast solution for turn the website off; use the Plugin WP Maintenance Mode, original for the activation of the maintenance mode; but its easy for this requirement. As useful; the plugin send an 503 Service [...]]]></description>
			<content:encoded><![CDATA[<p>What is this all about: <a href="http://wordpress.org/news/2012/01/help-stop-sopa-pipa/" title="Stop SOPA" target="_blank">Help Stop SOPA/PIPA</a><br />
Turn off your website on January 18th for 12 hours.</p>
<p>Simple and fast solution for turn the website off; use the Plugin <a href="http://wordpress.org/extend/plugins/wp-maintenance-mode/">WP Maintenance Mode</a>, original for the activation of the maintenance mode; but its easy for this requirement. As useful; the plugin send an 503 Service Unavailable header.</p>
<p>Set the following settings in the plugin<br />
<a href="http://wpengineer.com/wp-content/uploads/wp-maintenance-mode-sopa.png"><img src="http://wpengineer.com/wp-content/uploads/wp-maintenance-mode-sopa-300x274.png" alt="" title="wp-maintenance-mode-sopa" width="300" height="274" class="aligncenter size-medium wp-image-2403" /></a></p>
<p>Code for the field text, the video markup:</p>
<pre>
&lt;iframe src=&quot;http://player.vimeo.com/video/31100268?byline=0&amp;portrait=0&quot; width=&quot;400&quot; height=&quot;225&quot; frameborder=&quot;0&quot; webkitAllowFullScreen mozallowfullscreen allowFullScreen&gt;&lt;/iframe&gt;
&lt;p&gt;&lt;a href=&quot;http://vimeo.com/31100268&quot;&gt;PROTECT IP / SOPA Breaks The Internet&lt;/a&gt; from &lt;a href=&quot;http://vimeo.com/fightforthefuture&quot;&gt;Fight for the Future&lt;/a&gt;.&lt;/p&gt;
</pre>
<p>Here is the result for not signed in visitors:<br />
<a href="http://wpengineer.com/wp-content/uploads/stop-sopa.png"><img src="http://wpengineer.com/wp-content/uploads/stop-sopa-300x210.png" alt="" title="stop-sopa" width="300" height="210" class="aligncenter size-medium wp-image-2402" /></a><br />
<hr /><a href="http://wpplugins.com/plugin/281/snippets" title="More informations about this plugin for WordPress"><img src="http://wpengineer.com/wp-content/themes/wpe-3/images/snippets-125-125.png" height="90" alt="WordPress Snippet Plugin" /></a> <a href="http://xtreme-theme.com"><img src="http://wpengineer.com/wp-content/uploads/feed-banner-2.jpg" alt="Xtreme One WordPress Framework"/></a><br />
&copy; <a href="http://wpengineer.com/">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p>
]]></content:encoded>
			<wfw:commentRss>http://wpengineer.com/2401/stop-sopa/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Best Practice for Multilanguage WordPress Content? New Plugin!</title>
		<link>http://wpengineer.com/2389/best-practice-for-multilanguage-wordpress-content-new-plugin/</link>
		<comments>http://wpengineer.com/2389/best-practice-for-multilanguage-wordpress-content-new-plugin/#comments</comments>
		<pubDate>Sat, 24 Dec 2011 07:00:20 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[WordPress Tutorials]]></category>
		<category><![CDATA[Advent Calendar]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[language]]></category>
		<category><![CDATA[language plugin]]></category>
		<category><![CDATA[Multilanguage]]></category>
		<category><![CDATA[multilnual]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Plugin]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Plugins]]></category>
		<category><![CDATA[WP]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=2389</guid>
		<description><![CDATA[Since the beginning of WordPress the desire to publish the content in different languages is huge. But the topic can quickly become complex, because not only the rendering of content in the form of text in different languages ​​is an issue, we also have to take care of the meta data for content, for images [...]]]></description>
			<content:encoded><![CDATA[<p>Since the beginning of WordPress the desire to publish the content in different languages is huge. But the topic can quickly become complex, because not only the rendering of content in the form of text in different languages ​​is an issue, we also have to take care of the meta data for content, for images that can be different depending on the language and the use of the admin interface in the preferred language. Thus, only a part would be covered depending on the requirements (<a href="http://wordpress.stackexchange.com/questions/1552/best-practices-for-localizing-wordpress-content">a example on StackExchange</a>) it would quickly become an project and WordPress would be just a "small" framework behind it. There are already many <a href="http://codex.wordpress.org/Multilingual_WordPress">Plugins available</a>, the different approaches - new tables in the system or separation of content for each language in a table entry to post, or other solutions.</p>
<p>All these solutions have their limitations, are inflexible and you go into a dependency that will be hard to get out and with each update of WordPress you have to check if the Plugin is still working or has any bugs with the new version. Therefore, I would suggest a solution that we use in our <a title="Inpsyde photo" href="http://inpsyde.com">Inpsyde Team</a> frequently for customers and maintained their strength in the flexibility, in extensibility and in its capacity to use the WordPress standard without changing the core or anything else. You can deactivate the Plugin at any time, you won't lose anything, your website remains the same.</p>
<p><span id="more-2389"></span><br />
<img class="aligncenter size-medium wp-image-2390" title="banner-772x250" src="http://wpengineer.com/wp-content/uploads/banner-772x250-300x97.png" alt="" width="300" height="97" /></p>
<h3>Why multilanuage?</h3>
<ul>
<li>2/3, if not even more, of the worldwide population speak another language</li>
<li>Globale Aufstellung von Unternehmen</li>
<li>Better distribution of content</li>
<li>Service for the client</li>
<li>Search Engine Optimization</li>
</ul>
<h3>The solution</h3>
<p>WordPress Multi-site provides the solution already.<br />
This makes the management of different instances, with similarities and differences, with the help of an installation possible. The exchange of data is possible via core functions, which get united and simplified via Plugin.</p>
<h3>Advantages</h3>
<ul>
<li>WordPress Core Functions</li>
<li>No dependency to Plugins</li>
<li>Independent to WordPress development*</li>
<li>Control Themes, Plugins at a central place, use them decentralized</li>
<li>Low maintenance</li>
<li>Seperating languages in Backend/Frontend (user dependent)</li>
<li>Complete mirrored or in every content form seperated</li>
<li>Subdomains or Subdirectories</li>
<li>de.example.com, example.com/de</li>
<li>Seperate Domains via Domainmapping</li>
<li>example.de, example.com</li>
<li>Free in development in design and usability</li>
<li>Optimization not only on frontend, also lang-attributes, SEO</li>
</ul>
<h3>Plugin</h3>
<p>With all these requirements and benefits, we use a base that is available as a Plugin in the official repository of WordPress: <a href="http://wordpress.org/extend/plugins/multilingual-press/"> Multilingual Press </a>. The plugin provides several convenient tools to use Multisite for the implementation of multilingualism.</p>
<p>
<a href='http://wpengineer.com/2389/best-practice-for-multilanguage-wordpress-content-new-plugin/banner-772x250/' title='banner-772x250'><img width="150" height="150" src="http://wpengineer.com/wp-content/uploads/banner-772x250-150x150.png" class="attachment-thumbnail" alt="banner-772x250" title="banner-772x250" /></a>
<a href='http://wpengineer.com/2389/best-practice-for-multilanguage-wordpress-content-new-plugin/screenshot-1-3/' title='screenshot-1'><img width="150" height="150" src="http://wpengineer.com/wp-content/uploads/screenshot-12-150x150.png" class="attachment-thumbnail" alt="screenshot-1" title="screenshot-1" /></a>
<a href='http://wpengineer.com/2389/best-practice-for-multilanguage-wordpress-content-new-plugin/screenshot-2-3/' title='screenshot-2'><img width="150" height="150" src="http://wpengineer.com/wp-content/uploads/screenshot-22-150x150.png" class="attachment-thumbnail" alt="screenshot-2" title="screenshot-2" /></a>
<a href='http://wpengineer.com/2389/best-practice-for-multilanguage-wordpress-content-new-plugin/screenshot-3/' title='screenshot-3'><img width="150" height="150" src="http://wpengineer.com/wp-content/uploads/screenshot-3-150x150.png" class="attachment-thumbnail" alt="screenshot-3" title="screenshot-3" /></a>
<a href='http://wpengineer.com/2389/best-practice-for-multilanguage-wordpress-content-new-plugin/screenshot-4/' title='screenshot-4'><img width="150" height="150" src="http://wpengineer.com/wp-content/uploads/screenshot-4-150x150.png" class="attachment-thumbnail" alt="screenshot-4" title="screenshot-4" /></a>
<a href='http://wpengineer.com/2389/best-practice-for-multilanguage-wordpress-content-new-plugin/wordpress-christmas-2010-24-2/' title='WordPress-Christmas-2010-24'><img width="150" height="150" src="http://wpengineer.com/wp-content/uploads/WordPress-Christmas-2010-241-150x150.jpg" class="attachment-thumbnail" alt="WordPress-Christmas-2010-24" title="WordPress-Christmas-2010-24" /></a>
</p>
<p>This plugin simplifies the identification of different blogs in the network to a language and linking to other blogs, so that when you publish the content in blog A, it will create a post as draft in blog B. Thus, the articles are in relation, the system knows this and with the help of some functions, it may be used in the frontend and backend.<br />
The Plugin provides in the article or page the ability to see a meta box with the content of the linked data, in the simplest case as a translation aid. Similarly, there is a widget that simplifies the frontend to change. In each blog you can be make ​​some adjustments, assigning a flag and language.</p>
<h3>An outlook</h3>
<p>We are in the midst of the development, which adds the extra help. For example a dashboard widget with the overview of article and all links, an extension of the mediathek to seperate global content across all blogs and independent content per blog. Similarly, there are helpers for updating existing installations. In addition there is the possibility to directly load the language in the backend, without the need of FTP/SSH and assign the languages accordingly​​. We will also add the function to copy existing blogs with all the content and options if you want to.</p>
<h3>Summary</h3>
<p>WordPress Multisite provides the basis and with some adjustments, a clean, controlled solution exists for the use of WordPress in a multilingual environment. Now it's up to you - use Multisite, Test the Plugin and give us a feedback, preferable on <a href="https://github.com/inpsyde/multilingual-press">our repo on Github</a>.</h3>
<p>.</p>
<p>This was our last door of our Advent Calendar. We hope you enjoyed it! </p>
<p>We wish you a Merry Christmas and thanks a lot for reading our posts!<br />
<hr /><a href="http://wpplugins.com/plugin/281/snippets" title="More informations about this plugin for WordPress"><img src="http://wpengineer.com/wp-content/themes/wpe-3/images/snippets-125-125.png" height="90" alt="WordPress Snippet Plugin" /></a> <a href="http://xtreme-theme.com"><img src="http://wpengineer.com/wp-content/uploads/feed-banner-2.jpg" alt="Xtreme One WordPress Framework"/></a><br />
&copy; <a href="http://wpengineer.com/">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p>
]]></content:encoded>
			<wfw:commentRss>http://wpengineer.com/2389/best-practice-for-multilanguage-wordpress-content-new-plugin/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
		<item>
		<title>Register Settings on WordPress Multisite</title>
		<link>http://wpengineer.com/2324/register-settings-on-wordpress-multisite/</link>
		<comments>http://wpengineer.com/2324/register-settings-on-wordpress-multisite/#comments</comments>
		<pubDate>Wed, 21 Dec 2011 07:08:59 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[WordPress Plugins]]></category>
		<category><![CDATA[Advent Calendar]]></category>
		<category><![CDATA[backend]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Plugin]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WP]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=2324</guid>
		<description><![CDATA[The use of WordPress for several blogs in the network can be useful to simplify several steps and is becoming increasingly popular. Whether you want the classical scenarios of blog hosting service or like to create multilingual websites or other ideas. Therefore, it is also important for plugin developers to use the functions and to [...]]]></description>
			<content:encoded><![CDATA[<p>The use of WordPress for several blogs in the network can be useful to simplify several steps and is becoming increasingly popular. Whether you want the classical scenarios of blog hosting service or like to create multilingual websites or other ideas. Therefore, it is also important for plugin developers to use the functions and to expand or develop their own Plugins for it specifically.</p>
<p>Much is the same, but not all, and in this small article I would like to briefly explain how you set settings in the database when you activate a Plugin. <span id="more-2324"></span> </p>
<p>The best case for this is a Function of WordPress, which is triggered when activating a plugin <code>register_activation_hook()</code>. This Function will be called in init or constructor of the Plugin. In the called Function are the functions to store the settings of WordPress in the table options - <code>add_option()</code>. In Multisite there is also a function for it - <code>add_site_option()</code>.</p>
<p>Now you have to separate, if the Plugin is activated within the Network, in the management of Multisite installation, or if it is only used in one of the blogs in the network or a single installation. There are currently no functions, but a value that is passed. The following example illustrates it:</p>
<pre>
register_activation_hook( __FILE__, &#039;fb_add_config&#039; );
function fb_add_config() {

	$data = array(
		&#039;active&#039; =&gt; 0,
		&#039;radio&#039;  =&gt; 0,
		&#039;link&#039;   =&gt; 1,
		&#039;theme&#039;  =&gt; 1,
		&#039;role&#039;   =&gt; &#039;administrator&#039;,
		&#039;unit&#039;   =&gt; 1,
	);
	// if is active in network of multisite
	if ( is_multisite() &amp;&amp; isset($_GET&#091;&#039;networkwide&#039;&#093;) &amp;&amp; 1 == $_GET&#091;&#039;networkwide&#039;&#093; ) {
		add_site_option( &#039;my_settings_id&#039;, $data );
	} else {
		add_option( &#039;my_settings_id&#039;, $data );
	}
}
</pre>
<p>The query of the value in the global <code>GET</code> can be integrated in the long time ago <a href="http://wpengineer.com/2221/wordpress-multisite-plugins-and-activation/">mentioned solution for Multisite</a> and settings.</p>
<p>To solve other queries in a Multisite environment and to remove the setup or integrate menus in the admin area, the function <code>is_plugin_active_for_network()</code> is useful.</p>
<pre>
if ( is_multisite() &amp;&amp; is_plugin_active_for_network( plugin_basename( __FILE__ ) ) )
	$values = get_site_option( &#039;my_settings_id&#039; );
else
	$values = get_option( &#039;my_settings_id&#039; );
</pre>
<hr /><a href="http://wpplugins.com/plugin/281/snippets" title="More informations about this plugin for WordPress"><img src="http://wpengineer.com/wp-content/themes/wpe-3/images/snippets-125-125.png" height="90" alt="WordPress Snippet Plugin" /></a> <a href="http://xtreme-theme.com"><img src="http://wpengineer.com/wp-content/uploads/feed-banner-2.jpg" alt="Xtreme One WordPress Framework"/></a><br />
&copy; <a href="http://wpengineer.com/">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p>
]]></content:encoded>
			<wfw:commentRss>http://wpengineer.com/2324/register-settings-on-wordpress-multisite/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Easier Plugin Development by Moving Plugin Directory</title>
		<link>http://wpengineer.com/2374/easier-plugin-development-by-moving-plugin-directory/</link>
		<comments>http://wpengineer.com/2374/easier-plugin-development-by-moving-plugin-directory/#comments</comments>
		<pubDate>Mon, 19 Dec 2011 07:07:50 +0000</pubDate>
		<dc:creator>Latz</dc:creator>
				<category><![CDATA[WordPress Hacks]]></category>
		<category><![CDATA[WordPress Plugins]]></category>
		<category><![CDATA[Advent Calendar]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[Plugin]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Tutorials]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=2374</guid>
		<description><![CDATA[If you're a experienced programmer you're testing your programs not only with the latest version of WordPress but also with some older versions since there are many dated installations. So you have several versions installed on your development server and want to test your newly created code with every single version. You could copy your [...]]]></description>
			<content:encoded><![CDATA[<p>If you're a experienced programmer you're testing your programs not only with the latest version of WordPress but also with some older versions since there are <a title="WordPress Infographic" href="http://hackertarget.com/wordpress-infographic/">many dated installations</a>. So you have several versions installed on your development server and want to test your newly created code with every single version.<br />
<span id="more-2374"></span><br />
You could copy your plugin files to all installed version's plugin directory manually every time you change the code... but you're a programmer, so this is no option, is it?<br />
If your dev server works under a *nix system you probably have tried to use symbolic links but it didn't work. This is not a bug of WordPress but <a href="https://bugs.php.net/bug.php?id=46260">of PHP</a>. So this does not work either.</p>
<p>Fortunately WordPress defines two constants which can help you to simplify things nonetheless: <code>WP_PLUGIN_DIR</code> and <code>WP_PLUGIN_URL</code>. These constants point to the plugin directory of the respective WordPress installation. They are defined since WordPress 2.6 and supporting older versions is most likely unnecessary<br />
.<br />
To make your plugins accessible to all your installed WordPress versions you simply move them to a central directory and define the constants accordingly:</p>
<pre lang="php">
define( &#039;WP_PLUGIN_DIR&#039;, &#039;/var/www/plugins&#039; ); // or with XAMPP C:/xampp/htdocs/plugins
define( &#039;WP_PLUGIN_URL&#039;, &#039;http://localhost/plugins&#039; );
</pre>
<p>In this example the plugins reside in the directory 'plugins' in the root directory of the webserver. If you now define the above constants in every WordPress installation you have easy access to them to test your code with every version. </p>
<p>(Thanks to <a href="http://profiles.wordpress.org/users/johnbillion">John Blackbourn</a> on the <a href="http://lists.automattic.com/mailman/listinfo/wp-hackers">wp-hackers</a> list for having the idea.)</p>
<h4>Hint for Multisite-Users</h4>
<p>Also usable for WordPress Multisite</p>
<pre lang="php">
define( &#039;WPMU_PLUGIN_DIR&#039;, &#039;/var/www/multisite-plugins&#039; );
define( &#039;WPMU_PLUGIN_URL&#039;, &#039;http://localhost/multisite-plugins&#039; );
</pre>
<hr /><a href="http://wpplugins.com/plugin/281/snippets" title="More informations about this plugin for WordPress"><img src="http://wpengineer.com/wp-content/themes/wpe-3/images/snippets-125-125.png" height="90" alt="WordPress Snippet Plugin" /></a> <a href="http://xtreme-theme.com"><img src="http://wpengineer.com/wp-content/uploads/feed-banner-2.jpg" alt="Xtreme One WordPress Framework"/></a><br />
&copy; <a href="http://wpengineer.com/">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p>
]]></content:encoded>
			<wfw:commentRss>http://wpengineer.com/2374/easier-plugin-development-by-moving-plugin-directory/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Restrict Mime Types on WordPress Media Upload</title>
		<link>http://wpengineer.com/2369/restrict-mime-types-on-wordpress-media-upload/</link>
		<comments>http://wpengineer.com/2369/restrict-mime-types-on-wordpress-media-upload/#comments</comments>
		<pubDate>Sat, 17 Dec 2011 07:05:00 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[WordPress Plugins]]></category>
		<category><![CDATA[Advent Calendar]]></category>
		<category><![CDATA[backend]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[mediathek]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Plugin]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WP]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=2369</guid>
		<description><![CDATA[WordPress has changed the library in version 3.3 - which I think is an improvement. The restrictions in terms of file types remains and you can control them via hook. So you can limit or extend the file-types. Via two hooks, this is done quickly and there is a notification displayed in your backend which [...]]]></description>
			<content:encoded><![CDATA[<p>WordPress has changed the library in version 3.3  - which I think is an improvement. The restrictions in terms of file types remains and you can control them via hook. So you can limit or extend the file-types. Via two hooks, this is done quickly and there is a notification displayed in your backend which lists the allowed file types.</p>
<p><span id="more-2369"></span><br />
<a href="http://wpengineer.com/wp-content/uploads/restrict-mime-type.png"><img src="http://wpengineer.com/wp-content/uploads/restrict-mime-type-300x187.png" alt="Screenshot Example for restrive the mime type" title="restrict-mime-type" width="300" height="187" class="aligncenter size-medium wp-image-2370" /></a></p>
<p>The following small Plugin may extend to different roles or authorization objects, so that you can upload, depending on the role, different types of files in the system - <a href="http://wpengineer.com/?s=current_user_can"><code>current_user_can()</code></a>.</p>
<p>Anyone interested in the currently allowed types, you can return the array of the first function or look into the function <code>get_allowed_mime_types()</code> in <code>wp-includes/functions.php</code>.</p>
<p><a href="http://wpengineer.com/wp-content/uploads/restrict-mime-type-hint.png"><img src="http://wpengineer.com/wp-content/uploads/restrict-mime-type-hint-300x65.png" alt="Screenshot for Hint about allowed Mime Types" title="restrict-mime-type-hint" width="300" height="65" class="aligncenter size-medium wp-image-2371" /></a></p>
<pre>
&lt;?php
/**
 * Plugin Name: Restrict mime types
 * Plugin URI:  http://wpengineer.com/?p=2369
 * Description: Restrict list of allowed mime types and file extensions.
 * Version:     1.0.0
 * License:     GPLv3
 * Author:      Frank B&uuml;ltge
 * Author URI:  http://bueltge.de/
 */

 // This file is not called from WordPress. We don&#039;t like that.
! defined( &#039;ABSPATH&#039; ) and exit;

// If the function exists this file is called as upload_mimes.
// We don&#039;t do anything then.
if ( ! function_exists( &#039;fb_restrict_mime_types&#039; ) ) {

	add_filter( &#039;upload_mimes&#039;, &#039;fb_restrict_mime_types&#039; );
	/**
	 * Retrun allowed mime types
	 *
	 * @see     function get_allowed_mime_types in wp-includes/functions.php
	 * @param   array Array of mime types
	 * @return  array Array of mime types keyed by the file extension regex corresponding to those types.
	 */
	function fb_restrict_mime_types( $mime_types ) {

		$mime_types = array(
			&#039;pdf&#039; =&gt; &#039;application/pdf&#039;,
			&#039;doc|docx&#039; =&gt; &#039;application/msword&#039;,
		);

		return $mime_types;
	}
}

// If the function exists this file is called as post-upload-ui.
// We don&#039;t do anything then.
if ( ! function_exists( &#039;fb_restrict_mime_types_hint&#039; ) ) {
	// add to wp
	add_action( &#039;post-upload-ui&#039;, &#039;fb_restrict_mime_types_hint&#039; );
	/**
	 * Get an Hint about the allowed mime types
	 *
	 * @return  void
	 */
	function fb_restrict_mime_types_hint() {

		echo &#039;&lt;br /&gt;&#039;;
		_e( &#039;Accepted MIME types: PDF, DOC/DOCX&#039; );
	}
}
</pre>
<hr /><a href="http://wpplugins.com/plugin/281/snippets" title="More informations about this plugin for WordPress"><img src="http://wpengineer.com/wp-content/themes/wpe-3/images/snippets-125-125.png" height="90" alt="WordPress Snippet Plugin" /></a> <a href="http://xtreme-theme.com"><img src="http://wpengineer.com/wp-content/uploads/feed-banner-2.jpg" alt="Xtreme One WordPress Framework"/></a><br />
&copy; <a href="http://wpengineer.com/">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p>
]]></content:encoded>
			<wfw:commentRss>http://wpengineer.com/2369/restrict-mime-types-on-wordpress-media-upload/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Add Icon to Site Link in the WordPress Admin Bar</title>
		<link>http://wpengineer.com/2366/add-icon-to-site-link-in-the-wordpress-admin-bar/</link>
		<comments>http://wpengineer.com/2366/add-icon-to-site-link-in-the-wordpress-admin-bar/#comments</comments>
		<pubDate>Fri, 16 Dec 2011 07:00:14 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[WordPress Tutorials]]></category>
		<category><![CDATA[Advent Calendar]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Plugin]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WP]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=2366</guid>
		<description><![CDATA[Each button in the Admin bar has a self-defining and space-saving icon. But the link to the blog frontend (which is represented as a blog title), has no icon. If you want, you can change it quickly - here is a small solution. The following code belongs in the functions.php of the Theme, or better, [...]]]></description>
			<content:encoded><![CDATA[<p>Each button in the Admin bar has a self-defining and space-saving icon. But the link to the blog frontend (which is represented as a blog title), has no icon. If you want, you can change it quickly - here is a small solution.</p>
<p><span id="more-2366"></span><br />
<img src="http://wpengineer.com/wp-content/uploads/wordpress-adminbar-icon.png" alt="Screenshot Admin Bar Icon Example" title="wordpress-adminbar-icon" width="278" height="168" class="aligncenter size-full wp-image-2367" /></p>
<p>The following code belongs in the <code>functions.php</code> of the Theme, or better, in a Plugin. It adds the current favicon before the blog title. And to fit the image into the overall picture of the admin bar, we darkened it and and gave it a round shape.</p>
<pre>
&lt;?php
/**
 * Plugin Name: Icon for Admin Bar Site Link
 * Plugin URI:  http://wpengineer.com/?p=2366
 * Description: Add Icon to Site Link in the WordPress Admin Bar
 * Version:	1.0.0
 * Author:      Sergej Müller
 * Author URI:  http://ebiene.de
 * License:     GPLv3
 */

// This file is not called from WordPress. We don&#039;t like that.
! defined( &#039;ABSPATH&#039; ) and exit;
// If the function exists this file is called as comments template.
// We don&#039;t do anything then.
if ( ! function_exists( &#039;sm_add_adminbar_site_icon&#039; ) ) {

	// add to admin area, inside head
	add_action( &#039;admin_head&#039;, &#039;sm_add_adminbar_site_icon&#039; );
	// add to frontend, inside head
	add_action( &#039;wp_head&#039;, &#039;sm_add_adminbar_site_icon&#039; );

	function sm_add_adminbar_site_icon() {

		if ( ! is_admin_bar_showing() ) {
			return;
		}

		echo &#039;&lt;style&gt;
			#wp-admin-bar-site-name &gt; a.ab-item:before {
				float: left;
				width: 16px;
				height: 16px;
				margin: 5px 5px 0 -1px;
				display: block;
				content: &quot;&quot;;
				opacity: 0.4;
				background: #000 url(&quot;http://www.google.com/s2/u/0/favicons?domain=&#039; . parse_url( home_url(), PHP_URL_HOST ). &#039;&quot;);
				border-radius: 16px;
			}
			#wp-admin-bar-site-name:hover &gt; a.ab-item:before {
				opacity: 1;
			}
		&lt;/style&gt;&#039;;
	}

}
</pre>
<div class="incontent">
<h4>Guest Post</h4>
<p><img src="http://wpengineer.com/wp-content/uploads/sergej_mueller.jpg" alt="Sergej Müller Avatar" title="sergej_mueller" width="64" height="64" class="alignleft size-full wp-image-2005" />This post is written by Sergej Müller <a href="http://wpseo.org">wpseo.de</a>, who created the popular WordPress Plugin to optimize your SEO.</p>
<p>Thank you very much from our part to Sergej.</p>
<p>If you also like to have your interesting post published on our website, please let us know on our contact page. Of course we will appreciate your contribution!
</p></div>
<hr /><a href="http://wpplugins.com/plugin/281/snippets" title="More informations about this plugin for WordPress"><img src="http://wpengineer.com/wp-content/themes/wpe-3/images/snippets-125-125.png" height="90" alt="WordPress Snippet Plugin" /></a> <a href="http://xtreme-theme.com"><img src="http://wpengineer.com/wp-content/uploads/feed-banner-2.jpg" alt="Xtreme One WordPress Framework"/></a><br />
&copy; <a href="http://wpengineer.com/">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p>
]]></content:encoded>
			<wfw:commentRss>http://wpengineer.com/2366/add-icon-to-site-link-in-the-wordpress-admin-bar/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Activate WordPress Plugins Automatically via a Function</title>
		<link>http://wpengineer.com/2300/activate-wordpress-plugins-automatically-via-a-function/</link>
		<comments>http://wpengineer.com/2300/activate-wordpress-plugins-automatically-via-a-function/#comments</comments>
		<pubDate>Tue, 13 Dec 2011 07:11:17 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[WordPress Hacks]]></category>
		<category><![CDATA[Advent Calendar]]></category>
		<category><![CDATA[backend]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Plugin]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WP]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=2300</guid>
		<description><![CDATA[WordPress stores the active Plugins in the database table options, field activate_plugins, so it is easy to change this value to activate various Plugins by WordPress; either as a Plugin solution after setting up a new installation or because some Plugins need some other Plugins. I show you as an example a solution. It is [...]]]></description>
			<content:encoded><![CDATA[<p>WordPress stores the active Plugins in the database table <code>options</code>, field <code>activate_plugins</code>, so it is easy to change this value to activate various Plugins by WordPress; either as a Plugin solution after setting up a new installation or because some Plugins need some other Plugins.<br />
<span id="more-2300"></span><br />
I show you as an example a solution. It is important that you don't use the Plugin names, but the string of the file, which is also required in various hooks. Below you will also find a simple solution to get to this string in your backend.</p>
<pre>
// example on admin init, control about register_activation_hook()
add_action( &#039;admin_init&#039;, &#039;fb_activate_plugins&#039; );
// the exmple function
function fb_activate_plugins() {

	if ( ! current_user_can(&#039;activate_plugins&#039;) )
		wp_die(__(&#039;You do not have sufficient permissions to activate plugins for this site.&#039;));
	$plugins = FALSE;
	$plugins = get_option(&#039;active_plugins&#039;); // get active plugins

	if ( $plugins ) {
		// plugins to active
		$pugins_to_active = array(
			&#039;hello.php&#039;, // Hello Dolly
			&#039;adminimize/adminimize.php&#039;, // Adminimize
			&#039;akismet/akismet.php&#039; // Akismet
		);

		foreach ( $pugins_to_active as $plugin ) {
			if ( ! in_array( $plugin, $plugins ) ) {
				array_push( $plugins, $plugin );
				update_option( &#039;active_plugins&#039;, $plugins );
			}
		}

	} // end if $plugins

}
</pre>
<p>The following function and its hook provides a direct output of the string of the Plugin file on the Plugin page in your backend, so please use it only for a quick finding.</p>
<pre>
add_filter( &#039;plugin_row_meta&#039;, &#039;fb_get_plugin_string&#039;, 10, 4 );
function fb_get_plugin_string( $plugin_meta, $plugin_file, $plugin_data, $status ) {
	// echo plugin file string
	echo &#039;&lt;code&gt;&#039; . $plugin_file . &#039;&lt;/code&gt;&lt;br&gt;&#039;;
	return $plugin_meta;
}
</pre>
<hr /><a href="http://wpplugins.com/plugin/281/snippets" title="More informations about this plugin for WordPress"><img src="http://wpengineer.com/wp-content/themes/wpe-3/images/snippets-125-125.png" height="90" alt="WordPress Snippet Plugin" /></a> <a href="http://xtreme-theme.com"><img src="http://wpengineer.com/wp-content/uploads/feed-banner-2.jpg" alt="Xtreme One WordPress Framework"/></a><br />
&copy; <a href="http://wpengineer.com/">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p>
]]></content:encoded>
			<wfw:commentRss>http://wpengineer.com/2300/activate-wordpress-plugins-automatically-via-a-function/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Advent Calendar- How to disable comments for WordPress pages in any theme</title>
		<link>http://wpengineer.com/2302/how-to-disable-comments-for-wordpress-pages-in-any-theme/</link>
		<comments>http://wpengineer.com/2302/how-to-disable-comments-for-wordpress-pages-in-any-theme/#comments</comments>
		<pubDate>Fri, 02 Dec 2011 07:10:30 +0000</pubDate>
		<dc:creator>Thomas</dc:creator>
				<category><![CDATA[WordPress Plugins]]></category>
		<category><![CDATA[Advent Calendar]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[comments]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Plugin]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=2302</guid>
		<description><![CDATA[Usually you don’t need comments on pages. Unfortunately, WordPress doesn’t offer a separate option to leave comments on posts on and turn them off for pages. If your theme calls comments_template(); in its page.php and you don’t want to break automatic updates, you cannot just remove the function call, because it will be overwritten with [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://wpengineer.com/wp-content/uploads/WordPress-Christmas-2010-021-300x200.jpg" alt="" width="300" height="200" class="alignleft size-medium wp-image-2305" />Usually you don’t need comments on pages. Unfortunately, WordPress doesn’t offer a <em>separate</em> option to leave comments on posts on and turn them off for pages. If your theme calls <code>comments_template();</code> in its <code>page.php</code> and you don’t want to break automatic updates, you cannot just remove the function call, because it will be overwritten with the next update.</p>
<p>No problem. There’s an hook for that. It’s a filter called … wait for it … <code>comments_template</code>. We can change the path to the comments template here – if haven’t figured that out already. Let’s build a small plugin.</p>
<p>So, what do we do? We hook into <code>comments_template();</code> and change the path. Our new path should point to an existing file without any HTML output. In this case, we use just our plugin file, because we <em>know</em> it exists and we control the output.</p>
<p>As you may have noticed our plugin file is included two times: First as a plugin, later as a replacement for <code>comments.php</code>. The <code>function_exists()</code> check prevents any <em>You cannot redeclare …</em> errors.</p>
<p>Putting this all together …</p>
<pre>
&lt;?php # -*- coding: utf-8 -*-
/**
Plugin Name: Disable Comments On Pages
Version:     1.0
Author:      Thomas Scholz
Author URI:  http://toscho.de
License:     GPL
*/
// This file is not called from WordPress. We don&#039;t like that.
! defined( &#039;ABSPATH&#039; ) and exit;

// If the function exists this file is called as comments template.
// We don&#039;t do anything then.
if ( ! function_exists( &#039;t5_disable_comments_on_pages&#039; ) ) {
	/**
	 * Replaces the path of the original comments template with this
	 * file&#039;s path on pages.
	 *
	 * @param  string $file Original comments template file path.
	 * @return string
	 */
	function t5_disable_comments_on_pages( $file ) {
		return is_page() ? __FILE__ : $file;
	}

	add_filter( &#039;comments_template&#039;, &#039;t5_disable_comments_on_pages&#039;, 11 );
}
</pre>
<hr /><a href="http://wpplugins.com/plugin/281/snippets" title="More informations about this plugin for WordPress"><img src="http://wpengineer.com/wp-content/themes/wpe-3/images/snippets-125-125.png" height="90" alt="WordPress Snippet Plugin" /></a> <a href="http://xtreme-theme.com"><img src="http://wpengineer.com/wp-content/uploads/feed-banner-2.jpg" alt="Xtreme One WordPress Framework"/></a><br />
&copy; <a href="http://wpengineer.com/">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p>
]]></content:encoded>
			<wfw:commentRss>http://wpengineer.com/2302/how-to-disable-comments-for-wordpress-pages-in-any-theme/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Force Reload of Scripts and Stylesheets in your Plugin or Theme</title>
		<link>http://wpengineer.com/2292/force-reload-of-scripts-and-stylesheets-in-your-plugin-or-theme/</link>
		<comments>http://wpengineer.com/2292/force-reload-of-scripts-and-stylesheets-in-your-plugin-or-theme/#comments</comments>
		<pubDate>Fri, 21 Oct 2011 06:13:38 +0000</pubDate>
		<dc:creator>Latz</dc:creator>
				<category><![CDATA[WordPress Tutorials]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Plugin]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=2292</guid>
		<description><![CDATA[If you're developing a WordPress theme or plugin you may have had the problem that scripts or stylesheets are not reloaded from the source when you refresh the page because they are cached somewhere on the way from the server to the browser. There are various methods to suppress this behaviour like disabling the browser [...]]]></description>
			<content:encoded><![CDATA[<p>If you're developing a WordPress theme or plugin you may have had the problem that scripts or stylesheets are not reloaded from the source when you refresh the page because they are cached somewhere on the way from the server to the browser. There are various methods to suppress this behaviour like disabling the browser cache in the options or by using a web development add-on. Sometimes this simply does not work because it's not always apparent where the content is cached since there are so many possibilities and you may have missed to disable all of them.</p>
<p>WordPress provides a simple method to ensure that all stylesheets and scripts are reloaded from the source when they have changed by providing a version parameter:</p>
<pre lang="php">
wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer );
wp_enqueue_style( $handle, $src, $deps, $ver, $media);
</pre>
<p>You can increase the <code>$ver</code> parameter every time you've changed the files:</p>
<pre lang="php">
wp_enqueue_script( &#039;my_script&#039;, &#039;my_script.js&#039;, &#039;&#039;, &#039;0.11&#039; );
wp_enqueue_style( &#039;my_style&#039;, &#039;my_style.css&#039;, &#039;&#039;, &#039;0.11&#039; );
</pre>
<p>The URL of the stylesheet/script will be changed to '<code>.../my_script.js?ver=0.11</code>' so that every caching system detects the changed file and reloads it from its source and the user always gets the recent version.</p>
<p>But to change the version number manually every time in the development stage would be a bit tedious and you're a programmer, right? So let's automate this:</p>
<pre lang="php">
wp_enqueue_script( &#039;my_script&#039;, &#039;my_script.js&#039;, &#039;&#039;, time() );
wp_enqueue_style( &#039;my_style&#039;, &#039;my_style.css&#039;, &#039;&#039;, time() );
</pre>
<p>The value of <a href="http://php.net/manual/de/function.time.php">time()</a> changes every second so the version ID of the file changes constantly and it's reloaded from the source and not from some cache.</p>
<p>It's a bit disadvantageous that you have to substitute the time based version parameter by a "real" version number every time you deploy your code since the actual user still should have the benefits of cached scripts and stylesheets. Let's extend the idea:</p>
<pre lang="php">
define (&#039;VERSION&#039;, &#039;1.1&#039;);

function version_id() {
  if ( WP_DEBUG )
    return time();
  return VERSION;
}

wp_enqueue_script( &#039;my_script&#039;, &#039;my_script.js&#039;, &#039;&#039;, version_id() );
wp_enqueue_style( &#039;my_style&#039;, &#039;my_style.css&#039;, &#039;&#039;, version_id() );
</pre>
<p>This way you can make sure that in your development environment everything is reloaded from source all the time but a productive server takes advantage of caches.</p>
<hr /><a href="http://wpplugins.com/plugin/281/snippets" title="More informations about this plugin for WordPress"><img src="http://wpengineer.com/wp-content/themes/wpe-3/images/snippets-125-125.png" height="90" alt="WordPress Snippet Plugin" /></a> <a href="http://xtreme-theme.com"><img src="http://wpengineer.com/wp-content/uploads/feed-banner-2.jpg" alt="Xtreme One WordPress Framework"/></a><br />
&copy; <a href="http://wpengineer.com/">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p>
]]></content:encoded>
			<wfw:commentRss>http://wpengineer.com/2292/force-reload-of-scripts-and-stylesheets-in-your-plugin-or-theme/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>WordPress Custom Post Types Get Into The Loop</title>
		<link>http://wpengineer.com/2249/wordpress-custom-post-types-get-into-the-loop/</link>
		<comments>http://wpengineer.com/2249/wordpress-custom-post-types-get-into-the-loop/#comments</comments>
		<pubDate>Wed, 03 Aug 2011 09:23:25 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[WordPress Tutorials]]></category>
		<category><![CDATA[custom post type]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Plugin]]></category>
		<category><![CDATA[Theme]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WP]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=2249</guid>
		<description><![CDATA[WordPress started a new era with the Custom Post Types for developers in the WordPress environment. The possibilities are numerous and primarily from the knowledge of the developer dependent. Nevertheless, there are so many tutorials how to use Custom Post Types in WordPress, but that is not enough - at least not in most cases [...]]]></description>
			<content:encoded><![CDATA[<p>WordPress started a new era with the Custom Post Types for developers in the WordPress environment. The possibilities are numerous and primarily from the knowledge of the developer dependent. Nevertheless, there are so many tutorials how to use Custom Post Types in WordPress, but that is not enough - at least not in most cases and therefore are various other steps necessary to make the use of CPT more efficient and smooth.</p>
<p>In this article I would like to briefly explain how to get content of Custom Post Types in the loop of WordPress. This is not a complete guide, but please feel free to add tips, critics, hints in our comment area.</p>
<p><span id="more-2249"></span><br />
<img src="http://wpengineer.com/wp-content/uploads/cpt-example.png" alt="" title="cpt-example" width="328" height="226" class="aligncenter size-full wp-image-2250" /><br />
The screenshot is an example of the use of CPT, hereby were the Plugins <a href="http://wordpress.org/extend/plugins/archive/" title="WordPress Plugin Archive">Archive</a> und <a href="http://wpplugins.com/plugin/281/snippets" title="WordPress Plugin Snippet">Snippet</a> created, they have different tasks and via CPT tailored to the requirements you need.</p>
<p>In the first case, the syntax is shown how to use the query and passes through the type of the CPT via parameters. In a template of the theme it ensures that only the CPT will be read. All other parameters of the query remain untouched.</p>
<pre>
query_posts( &#039;post_type=my_post_type&#039; )
</pre>
<p>Another solution differs essentially only in style and that several CPTs are passed, wich are in an array.</p>
<pre>
global $query_string;
parse_str( $query_string, $args );
$args&#091;&#039;post_type&#039;&#093; = array( &#039;my_post_type&#039;, &#039;my_second_post_type&#039; );
query_posts( $args );
</pre>
<p>To complete the loop of WP and not to limit, the array is added to the parameter of the <code>post_type</code>. So only via the array  <a href="http://php.net/manual/de/function.array-merge.php"><code>array_merge</code></a> the array is added to another array.</p>
<pre>
global $wp_query;
$args = array_merge( $wp_query-&gt;query, array( &#039;post_type&#039; =&gt; &#039;my_post_type&#039; ) );
query_posts( $args );
</pre>
<p>Furthermore you can define your own queries, especially if you want to use them in your own variables, either in your Themes or Plugins.</p>
<pre>
$args = array(
	&#039;post_type&#039; =&gt; &#039;my_post_type&#039;,
	&#039;post_status&#039; =&gt; &#039;publish&#039;,
	&#039;posts_per_page&#039; =&gt; -1
);

$posts = new WP_Query( $args );
if ( $posts -&gt; have_posts() ) {
	while ( $posts -&gt; have_posts() ) {
...
	}
}

wp_reset_query();
</pre>
<p>At the end a solution that has a particular charm that you control it via Plugin and turn it off easily while testing. Also, to implement the application in a Plugin is simple or as an extension of an existing Themes via Childtheme or Plugin. About the Hook <code>pre_get_posts</code> you can adjust various things of the query, including the CPT.<br />
In the example I have via conditional tags diverse conditions implemented, so that you can see, how it responds to the output in the frontend.</p>
<pre>
// $this? - example was used in class-structures
// add custom post type to wp loop
add_filter( &#039;pre_get_posts&#039;, array( $this, &#039;add_to_query&#039;) );

// ads to query
function add_to_query( $query ) {

	if ( is_admin() || is_preview() )
		return;

	if ( ! isset( $query -&gt; query_vars&#091;&#039;suppress_filters&#039;&#093; ) )
		$query -&gt; query_vars&#091;&#039;suppress_filters&#039;&#093; = FALSE;

	// conditional tags for restrictions
	if ( is_home() || is_front_page() &amp;&amp; ( FALSE == $query -&gt; query_vars&#091;&#039;suppress_filters&#039;&#093; ) ) {
		$query -&gt; set( $this -&gt; my_post_type, array( &#039;post&#039;, $this -&gt; get_textdomain() ) );

	return $query;
}
</pre>
<hr /><a href="http://wpplugins.com/plugin/281/snippets" title="More informations about this plugin for WordPress"><img src="http://wpengineer.com/wp-content/themes/wpe-3/images/snippets-125-125.png" height="90" alt="WordPress Snippet Plugin" /></a> <a href="http://xtreme-theme.com"><img src="http://wpengineer.com/wp-content/uploads/feed-banner-2.jpg" alt="Xtreme One WordPress Framework"/></a><br />
&copy; <a href="http://wpengineer.com/">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p>
]]></content:encoded>
			<wfw:commentRss>http://wpengineer.com/2249/wordpress-custom-post-types-get-into-the-loop/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

