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

<channel>
	<title>Wordpress API &#187; wordpress hacks</title>
	<atom:link href="http://wordpressapi.com/category/wordpress/wordpress-hacks/feed/" rel="self" type="application/rss+xml" />
	<link>http://wordpressapi.com</link>
	<description>Wordpress Tutorials, Tips, Code, Hacks, Themes, plugin, Developer Code book -Wordpress Code, Themes, Plugins, Tips, Tutorials, News, Releases, Designs, Hacks, Tricks, Blog</description>
	<lastBuildDate>Wed, 25 Jan 2012 18:48:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Show the comments from custom post type in wordpress</title>
		<link>http://wordpressapi.com/2012/01/25/show-the-comments-from-custom-post-type-in-wordpress/</link>
		<comments>http://wordpressapi.com/2012/01/25/show-the-comments-from-custom-post-type-in-wordpress/#comments</comments>
		<pubDate>Wed, 25 Jan 2012 18:48:14 +0000</pubDate>
		<dc:creator>Wordpress API</dc:creator>
				<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wordpress hacks]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[wp]]></category>

		<guid isPermaLink="false">http://wordpressapi.com/?p=7000</guid>
		<description><![CDATA[http://wordpressapi.com/2012/01/25/show-the-comments-from-custom-post-type-in-wordpress/Some time we shows the posts and there comments in sidebar. But what to do for show the comments for custom post type. It&#8217;s not well documented, but according to the codex, you can pass a &#8216;post_type&#8217; variable in the &#8230; Continue reading &#8594;]]></description>
			<content:encoded><![CDATA[http://wordpressapi.com/2012/01/25/show-the-comments-from-custom-post-type-in-wordpress/<p>Some time we shows the posts and there comments in sidebar. But what to do for show the comments for custom post type.</p>
<p>It&#8217;s not well documented, but according to the codex, you can pass a &#8216;post_type&#8217; variable in the get_comments function.</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
 $comments = get_comments('number=10&amp;status=approve&amp;post_type=YOUR_POST_TYPE');
foreach($comments as $comment) :

// comment loop code will go here

endforeach;
?&gt;
</pre>
<p>Note: This code only useful after wordpress 3.1 version.</p>
<div id="attachment_6862" class="wp-caption alignnone<a href="http://wordpressapi.com/2011/07/27/add-the-comment-preview-to-comment-box-without-wordpress-plugin/wordpress-comments-preview/" rel="attachment wp-att-6862"><img class="size-medium wp-image-6862" title="Show the comments from custom post type in wordpress" src="http://images.wordpressapi.com/wordpress-comments-preview-300x199.jpg" alt="Show the comments from custom post type in wordpress" width="300" height="199" /></a><p class="wp-caption-text">Show the comments from custom post type in wordpress</p></div>
<p>Follow us on Twitter <a href="http://twitter.com/wordpressapi">WordPress API</a></p>]]></content:encoded>
			<wfw:commentRss>http://wordpressapi.com/2012/01/25/show-the-comments-from-custom-post-type-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Change uploaded image name to post slug during upload using variables</title>
		<link>http://wordpressapi.com/2012/01/11/change-uploaded-image-name-to-post-slug-during-upload-using-variables/</link>
		<comments>http://wordpressapi.com/2012/01/11/change-uploaded-image-name-to-post-slug-during-upload-using-variables/#comments</comments>
		<pubDate>Wed, 11 Jan 2012 18:09:48 +0000</pubDate>
		<dc:creator>Wordpress API</dc:creator>
				<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wordpress hacks]]></category>
		<category><![CDATA[wordpress hack]]></category>
		<category><![CDATA[wp]]></category>

		<guid isPermaLink="false">http://wordpressapi.com/?p=6993</guid>
		<description><![CDATA[http://wordpressapi.com/2012/01/11/change-uploaded-image-name-to-post-slug-during-upload-using-variables/If you want to rename files during upload and set their names to the post slug the files are beeing attached to, plus some random characters (a simple incremental counter will de just fine) to make the filenames different. In &#8230; Continue reading &#8594;]]></description>
			<content:encoded><![CDATA[http://wordpressapi.com/2012/01/11/change-uploaded-image-name-to-post-slug-during-upload-using-variables/<p>If you want to  rename files during upload and set their names to the post slug the files are beeing attached to, plus some random characters (a simple incremental counter will de just fine) to make the filenames different.<br />
<div id="attachment_6994" class="wp-caption alignnone<a href="http://wordpressapi.com/?attachment_id=6994" rel="attachment wp-att-6994"><img src="http://images.wordpressapi.com/change-uploaded-image-name-to-post-slug-during-upload-using-variables-300x192.png" alt="Change uploaded image name to post slug during upload using variables" title="Change uploaded image name to post slug during upload using variables" width="300" height="192" class="size-medium wp-image-6994" /></a><p class="wp-caption-text">Change uploaded image name to post slug during upload using variables</p></div></p>
<p>In other words, if you are uploading/attaching images to the post whose page slug is &#8220;test-page-slug&#8221;, i&#8217;d like for the images to be renamed on the fly to test-page-slug-[C].[original_extension] — test-page-slug-1.jpg, test-page-slug-2.jpg etc (no matter what the original filenames were).</p>
<p>This is very easy. You just need to use following hook in functions.php file.</p>
<pre class="brush: php; title: ; notranslate">
function wp_modify_uploaded_file_names($image_name) {

    // Get the parent post ID, if there is one
    if( isset($_GET['post_id']) ) {
        $post_id = $_GET['post_id'];
    } elseif( isset($_POST['post_id']) ) {
        $post_id = $_POST['post_id'];
    }

    // Only do this if we got the post ID--otherwise they're probably in
    //  the media section rather than uploading an image from a post.
    if(is_numeric($post_id)) {

        // Get the post slug
        $post_obj = get_post($post_id);
        $post_slug = $post_obj-&gt;post_name;

        // If we found a slug
        if($post_slug) {

            $random_number = rand(10000,99999);
            $image_name['name'] = $post_slug . '-' . $random_number . '.jpg';

        }

    }

    return $image_name;

}
add_filter('wp_handle_upload_prefilter', 'wp_modify_uploaded_file_names', 1, 1);
</pre>
<p>This is very easy.<br />
if you have pretty permalinks enabled, so I&#8217;ve added a check to make sure there is a slug before renaming the file. You&#8217;ll also want to consider checking the file type, which I haven&#8217;t done here&#8211;I&#8217;ve just assumed it&#8217;s a jpg.</p>
<h4>Incoming search terms:</h4><ul><li><a href="http://wordpressapi.com/2012/01/11/change-uploaded-image-name-to-post-slug-during-upload-using-variables/" title="change wordpress image name">change wordpress image name</a></li><li><a href="http://wordpressapi.com/2012/01/11/change-uploaded-image-name-to-post-slug-during-upload-using-variables/" title="wordpress media-upload options page no post_id">wordpress media-upload options page no post_id</a></li></ul><p>Follow us on Twitter <a href="http://twitter.com/wordpressapi">WordPress API</a></p>]]></content:encoded>
			<wfw:commentRss>http://wordpressapi.com/2012/01/11/change-uploaded-image-name-to-post-slug-during-upload-using-variables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Solved: qTranslate slug with Widget not working with pages</title>
		<link>http://wordpressapi.com/2012/01/09/solved-qtranslate-slug-with-widget-not-working-with-pages/</link>
		<comments>http://wordpressapi.com/2012/01/09/solved-qtranslate-slug-with-widget-not-working-with-pages/#comments</comments>
		<pubDate>Mon, 09 Jan 2012 18:12:43 +0000</pubDate>
		<dc:creator>Wordpress API</dc:creator>
				<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wordpress hacks]]></category>
		<category><![CDATA[wp]]></category>
		<category><![CDATA[wp plugin]]></category>

		<guid isPermaLink="false">http://wordpressapi.com/?p=6990</guid>
		<description><![CDATA[http://wordpressapi.com/2012/01/09/solved-qtranslate-slug-with-widget-not-working-with-pages/We just saw the issue with qtranslate slug with widget is not working for 0.5 version. URL is showing but URL is not opening and 404 page is opening. The problem was exactly at the function qTranslateSlug_filter_request inside de file &#8230; Continue reading &#8594;]]></description>
			<content:encoded><![CDATA[http://wordpressapi.com/2012/01/09/solved-qtranslate-slug-with-widget-not-working-with-pages/<p>We just saw the issue with qtranslate slug with widget is not working for 0.5 version. URL is showing but URL is not opening and 404 page is opening.</p>
<div id="attachment_6991" class="wp-caption alignnone<a href="http://wordpressapi.com/?attachment_id=6991" rel="attachment wp-att-6991"><img class="size-medium wp-image-6991" title="Solved: qTranslate slug with Widget not working with pages" src="http://images.wordpressapi.com/wordpress-language-translation-300x225.jpg" alt="Solved: qTranslate slug with Widget not working with pages" width="300" height="225" /></a><p class="wp-caption-text">Solved: qTranslate slug with Widget not working with pages</p></div>
<p>The problem was exactly at the function qTranslateSlug_filter_request inside de file qtranslate-slug-with-widget.php, which is the only one of the plugin, so it’s easy to find.<br />
We must take a look at this part of the code:</p>
<pre class="brush: php; title: ; notranslate">
if (isset($q['name'])) {
    $type = QTS_POST;
    $slug = $q['name'];
    $param = 'p';
    $get_link = 'get_permalink';
    unset($new_q['name']);
} else if (isset($q['pagename'])) {
    //$type = QTS_PAGE;
    //$slug = $q['pagename'];
    //$param = 'page_id';
    $id = qTranslateSlug_get_page_by_path($q['pagename'], $lang);
    if ($id) {
        unset($new_q['pagename']);
        $q = $new_q;
        $q['page_id'] = $id;
        $get_link = 'get_page_link';
    }
} else if (isset($q['category_name'])) {
    $type = QTS_CAT;
    $slug = $q['category_name'];
    $param = 'cat';
    $get_link = 'get_category_link';
    unset($new_q['category_name']);
} else if (isset($q['tag'])) {
    $type = QTS_TAG;
    $slug = $q['tag'];
    $param = 'tag_id';
    $get_link = 'get_tag_link';
    unset($new_q['tag']);
}
</pre>
<p>That we hace to replace with the following:</p>
<pre class="brush: php; title: ; notranslate">
if (isset($q['name'])) {
        $id = qTranslateSlug_get_page_by_path($q['name'], $lang);
        if ($id) {
            unset($new_q['name']);
            $q = $new_q;
            $q['page_id'] = $id;
            $get_link = 'get_page_link';
        } else {
            $type = QTS_POST;
            $slug = $q['name'];
            $param = 'p';
            $get_link = 'get_permalink';
            unset($new_q['name']);
        }
    } else if (isset($q['pagename'])) {
        $id = qTranslateSlug_get_page_by_path($q['pagename'], $lang);
        if ($id) {
            unset($new_q['pagename']);
            $q = $new_q;
            $q['page_id'] = $id;
            $get_link = 'get_page_link';
        }
    } else if (isset($q['category_name'])) {
        $type = QTS_CAT;
        $slug = $q['category_name'];
        $param = 'cat';
        $get_link = 'get_category_link';
        unset($new_q['category_name']);
    } else if (isset($q['tag'])) {
        $type = QTS_TAG;
        $slug = $q['tag'];
        $param = 'tag_id';
        $get_link = 'get_tag_link';
        unset($new_q['tag']);
    } else {
        $path = trim(preg_replace('/\?(.*)/', '', $_SERVER['REQUEST_URI']), '/');
        $id = qTranslateSlug_get_page_by_path($path, $lang);
        if ($id) {
            if (isset ($q['attachment'])) {
                unset($q['attachment']);
                unset($new_q['attachment']);
            }
            $q = $new_q;
            $q['page_id'] = $id;
            $get_link = 'get_page_link';
        }
    }
</pre>
<p>With the last wordpress versions, mine is 3.3.1, has changed the way of passing the query to the request filter, changing the array slug position from ‘pagename’ to ‘name’, then the plugin didn’t have a way to find any page, since it expected to find in the array the position ‘pagename’, nonexistent for the current case.<br />
Ref is taken from &#8211; http://en.codatavern.com/qtranslate-slug-with-widget-wordpress-plugin-fix/</p>
<h4>Incoming search terms:</h4><ul><li><a href="http://wordpressapi.com/2012/01/09/solved-qtranslate-slug-with-widget-not-working-with-pages/" title="with the last wordpress versions mine is 3 3 1 has changed the way of passing the query">with the last wordpress versions mine is 3 3 1 has changed the way of passing the query</a></li><li><a href="http://wordpressapi.com/2012/01/09/solved-qtranslate-slug-with-widget-not-working-with-pages/" title="qtranslate not saving">qtranslate not saving</a></li><li><a href="http://wordpressapi.com/2012/01/09/solved-qtranslate-slug-with-widget-not-working-with-pages/" title="qtranslate tips and tricks">qtranslate tips and tricks</a></li><li><a href="http://wordpressapi.com/2012/01/09/solved-qtranslate-slug-with-widget-not-working-with-pages/" title="wordpress qtranslate api">wordpress qtranslate api</a></li><li><a href="http://wordpressapi.com/2012/01/09/solved-qtranslate-slug-with-widget-not-working-with-pages/" title="wordpress qtranslate detect language">wordpress qtranslate detect language</a></li></ul><p>Follow us on Twitter <a href="http://twitter.com/wordpressapi">WordPress API</a></p>]]></content:encoded>
			<wfw:commentRss>http://wordpressapi.com/2012/01/09/solved-qtranslate-slug-with-widget-not-working-with-pages/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Send email through wp_mail in html format with wordpress</title>
		<link>http://wordpressapi.com/2012/01/06/send-email-through-wp_mail-in-html-format-with-wordpress/</link>
		<comments>http://wordpressapi.com/2012/01/06/send-email-through-wp_mail-in-html-format-with-wordpress/#comments</comments>
		<pubDate>Fri, 06 Jan 2012 09:59:54 +0000</pubDate>
		<dc:creator>Wordpress API</dc:creator>
				<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wordpress api]]></category>
		<category><![CDATA[wordpress hacks]]></category>
		<category><![CDATA[wordpress tutorials]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[mail]]></category>
		<category><![CDATA[wp]]></category>

		<guid isPermaLink="false">http://wordpressapi.com/?p=6986</guid>
		<description><![CDATA[http://wordpressapi.com/2012/01/06/send-email-through-wp_mail-in-html-format-with-wordpress/In wordpress we use the wp_mail function for sending email. Following parameters we use for wp_mail Parameters Simple example: We can use this code for contact form or in functions.php file For html format email from wordpress. we just need &#8230; Continue reading &#8594;]]></description>
			<content:encoded><![CDATA[http://wordpressapi.com/2012/01/06/send-email-through-wp_mail-in-html-format-with-wordpress/<p>In wordpress we use the wp_mail function for sending email. Following parameters we use for wp_mail</p>
<p><!--?php wp_mail( $to, $subject, $message, $headers, $attachments ); ?--><br />
Parameters</p>
<pre class="brush: php; title: ; notranslate">
$to
    (string or array) (required) The intended recipient(s). Multiple recipients may be specified using an array or a comma-separated string.

$subject
    (string) (required) The subject of the message.

$message
    (string) (required) Message content.

$headers
    (string or array) (optional) Mail headers to send with the message. (advanced)

$attachments
    (string or array) (optional) Files to attach: a single filename, an array of filenames, or a newline-delimited string list of multiple filenames. (advanced)
</pre>
<p>Simple example:</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
   $attachments = array(WP_CONTENT_DIR . '/uploads/file_to_attach.zip');
   $headers = 'From: My Name &lt;myname@mydomain.com&gt;' . &quot;\r\n&quot;;
   wp_mail('test@test.com', 'subject', 'message', $headers, $attachments);
?&gt;
</pre>
<div id="attachment_6987" class="wp-caption alignnone<a href="http://wordpressapi.com/?attachment_id=6987" rel="attachment wp-att-6987"><img class="size-medium wp-image-6987" title="Send email through wp_mail in html format with wordpress" src="http://images.wordpressapi.com/wordpress-html-email-300x179.jpg" alt="Send email through wp_mail in html format with wordpress" width="300" height="179" /></a><p class="wp-caption-text">Send email through wp_mail in html format with wordpress</p></div>
<p>We can use this code for contact form or in functions.php file</p>
<p>For html format email from wordpress. we just need to add following line in functions.php file.</p>
<pre class="brush: php; title: ; notranslate">
add_filter('wp_mail_content_type',create_function('', 'return &quot;text/html&quot;;'));
</pre>
<p>Sending HTML email has risks. It could be caught in spam filters. The client may not support HTML formatting (although that&#8217;s rare). The client may disable email HTML from using javascript, CSS or grabbing remote assets like images.</p>
<h4>Incoming search terms:</h4><ul><li><a href="http://wordpressapi.com/2012/01/06/send-email-through-wp_mail-in-html-format-with-wordpress/" title="send html email via wordpress">send html email via wordpress</a></li><li><a href="http://wordpressapi.com/2012/01/06/send-email-through-wp_mail-in-html-format-with-wordpress/" title="wp_mail images">wp_mail images</a></li><li><a href="http://wordpressapi.com/2012/01/06/send-email-through-wp_mail-in-html-format-with-wordpress/" title="wp_mail not sending">wp_mail not sending</a></li></ul><p>Follow us on Twitter <a href="http://twitter.com/wordpressapi">WordPress API</a></p>]]></content:encoded>
			<wfw:commentRss>http://wordpressapi.com/2012/01/06/send-email-through-wp_mail-in-html-format-with-wordpress/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>how to integrate the wordpress with php or html</title>
		<link>http://wordpressapi.com/2011/12/06/how-to-integrate-the-wordpress-with-php-or-html/</link>
		<comments>http://wordpressapi.com/2011/12/06/how-to-integrate-the-wordpress-with-php-or-html/#comments</comments>
		<pubDate>Tue, 06 Dec 2011 17:10:50 +0000</pubDate>
		<dc:creator>Wordpress API</dc:creator>
				<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wordpress api]]></category>
		<category><![CDATA[wordpress hacks]]></category>
		<category><![CDATA[wordpress tutorials]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[wp]]></category>

		<guid isPermaLink="false">http://wordpressapi.com/?p=6974</guid>
		<description><![CDATA[http://wordpressapi.com/2011/12/06/how-to-integrate-the-wordpress-with-php-or-html/WordPress is very easy to work on. you can very easily integrate the wordpress with php or html site. There may be only a few features of WordPress you want to use when integrating it with your site, or you &#8230; Continue reading &#8594;]]></description>
			<content:encoded><![CDATA[http://wordpressapi.com/2011/12/06/how-to-integrate-the-wordpress-with-php-or-html/<p>WordPress is very easy to work on. you can very easily integrate the wordpress with php or html site. There may be only a few features of WordPress you want to use when integrating it with your site, or you may want your entire site run with WordPress. This tutorial will guide you through making your WordPress site look like your current design.</p>
<p>How to start?<br />
First you need to disable the wordpress theme. using following code.</p>
<p>open your header.php file from your wordpress theme and put following code in that file.</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
/* Short and sweet */
define('WP_USE_THEMES', false);
require('./wp-blog-header.php');
?&gt;
</pre>
<p>Create any php file and put following code in that file.</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
require('/the/path/to/your/wp-blog-header.php');
?&gt;
</pre>
<p>In the event you want to show ten posts sorted alphabetically in ascending order on your web page, you could do the following to grab the posted date, title and excerpt:</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
require('/the/path/to/your/wp-blog-header.php');
?&gt;

&lt;?php
$posts = get_posts('numberposts=10&amp;order=ASC&amp;orderby=post_title');
foreach ($posts as $post) : start_wp(); ?&gt;
&lt;?php the_date(); echo &quot;&lt;br /&gt;&quot;; ?&gt;
&lt;?php the_title(); ?&gt;
&lt;?php the_excerpt(); ?&gt;
&lt;?php
endforeach;
?&gt;
</pre>
<div id="attachment_6975" class="wp-caption alignnone<a href="http://wordpressapi.com/2011/12/06/how-to-integrate-the-wordpress-with-php-or-html/convert-html-to-wordpress/" rel="attachment wp-att-6975"><img class="size-medium wp-image-6975" title="how to integrate the wordpress with php or html" src="http://images.wordpressapi.com/Convert-HTML-to-Wordpress-300x214.jpg" alt="how to integrate the wordpress with php or html" width="300" height="214" /></a><p class="wp-caption-text">how to integrate the wordpress with php or html</p></div>
<p>For more information you can write to me.</p>
<h4>Incoming search terms:</h4><ul><li><a href="http://wordpressapi.com/2011/12/06/how-to-integrate-the-wordpress-with-php-or-html/" title="including wp-blog-header php wordpress 3 3">including wp-blog-header php wordpress 3 3</a></li><li><a href="http://wordpressapi.com/2011/12/06/how-to-integrate-the-wordpress-with-php-or-html/" title="how to integrate api for wordpress">how to integrate api for wordpress</a></li><li><a href="http://wordpressapi.com/2011/12/06/how-to-integrate-the-wordpress-with-php-or-html/" title="how to integrate wp in to phpbb design">how to integrate wp in to phpbb design</a></li><li><a href="http://wordpressapi.com/2011/12/06/how-to-integrate-the-wordpress-with-php-or-html/" title="html to php for wordpress">html to php for wordpress</a></li><li><a href="http://wordpressapi.com/2011/12/06/how-to-integrate-the-wordpress-with-php-or-html/" title="integrer wordpress i html">integrer wordpress i html</a></li><li><a href="http://wordpressapi.com/2011/12/06/how-to-integrate-the-wordpress-with-php-or-html/" title="wordpress the_date not working wordpress 3 3">wordpress the_date not working wordpress 3 3</a></li></ul><p>Follow us on Twitter <a href="http://twitter.com/wordpressapi">WordPress API</a></p>]]></content:encoded>
			<wfw:commentRss>http://wordpressapi.com/2011/12/06/how-to-integrate-the-wordpress-with-php-or-html/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to add the custom post type with associated tags and category</title>
		<link>http://wordpressapi.com/2011/11/28/how-to-add-the-custom-post-type-with-associated-tags-and-category/</link>
		<comments>http://wordpressapi.com/2011/11/28/how-to-add-the-custom-post-type-with-associated-tags-and-category/#comments</comments>
		<pubDate>Mon, 28 Nov 2011 18:03:09 +0000</pubDate>
		<dc:creator>Wordpress API</dc:creator>
				<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wordpress api]]></category>
		<category><![CDATA[wordpress hacks]]></category>
		<category><![CDATA[category]]></category>
		<category><![CDATA[custom post type]]></category>
		<category><![CDATA[tags]]></category>
		<category><![CDATA[wp]]></category>

		<guid isPermaLink="false">http://wordpressapi.com/?p=6948</guid>
		<description><![CDATA[http://wordpressapi.com/2011/11/28/how-to-add-the-custom-post-type-with-associated-tags-and-category/Many times we use the custom post type in wordpress. Some times we need to category and tags for custom post type which are only associated. you can use the following code in funcations.php file. Please consult with your developer. &#8230; Continue reading &#8594;]]></description>
			<content:encoded><![CDATA[http://wordpressapi.com/2011/11/28/how-to-add-the-custom-post-type-with-associated-tags-and-category/<p>Many times we use the custom post type in wordpress. Some times we need to category and tags for custom post type which are only associated.</p>
<p>you can use the following code in funcations.php file.</p>
<pre class="brush: php; title: ; notranslate">
// === CUSTOM POST TYPES === //
function create_my_post_types() {
	register_post_type( 'Services',
		array(
			'labels' =&gt; array(
				'name' =&gt; __( 'Services' ),
				'singular_name' =&gt; __( 'Services' ),
				'add_new_item' =&gt; 'Add New Services',
				'edit_item' =&gt; 'Edit Services',
				'new_item' =&gt; 'New Services',
				'search_items' =&gt; 'Search Services',
				'not_found' =&gt; 'No Services found',
				'not_found_in_trash' =&gt; 'No Services found in trash',
			),
			'_builtin' =&gt; false,
			'public' =&gt; true,
			'hierarchical' =&gt; false,
			'taxonomies' =&gt; array( 'website_type', 'service'),
			'supports' =&gt; array(
				'title',
				'editor',
				'excerpt',
                                'thumbnail'
			),
			'rewrite' =&gt; array( 'slug' =&gt; 'services', 'with_front' =&gt; false ),

		)
	);
}
add_action( 'init', 'create_my_post_types' );

// === CUSTOM TAXONOMIES === //
function my_custom_taxonomies() {
	register_taxonomy(
		'website_type',		// internal name = machine-readable taxonomy name
		'Services',		// object type = post, page, link, or custom post-type
		array(
			'hierarchical' =&gt; true,
			'label' =&gt; 'Website Types',	// the human-readable taxonomy name
			'query_var' =&gt; true,	// enable taxonomy-specific querying
			'rewrite' =&gt; array( 'slug' =&gt; 'website_type' ),	// pretty permalinks for your taxonomy?
		)
	);
	register_taxonomy(
		'service',
		'post',
		array(
			'hierarchical' =&gt; false,
			'label' =&gt; 'Service',
			'query_var' =&gt; true,
			'rewrite' =&gt; array( 'slug' =&gt; 'service' ),
		)
	);

}
add_action('init', 'my_custom_taxonomies', 0);
</pre>
<p>Please consult with your developer.</p>
<div id="attachment_6968" class="wp-caption alignnone<a href="http://wordpressapi.com/2011/11/28/how-to-add-the-custom-post-type-with-associated-tags-and-category/custom-post-type-wordpress1-2/" rel="attachment wp-att-6968"><img class="size-full wp-image-6968" title="How to add the custom post type with associated tags and category" src="http://images.wordpressapi.com/custom-post-type-wordpress11.gif" alt="How to add the custom post type with associated tags and category" width="300" height="250" /></a><p class="wp-caption-text">How to add the custom post type with associated tags and category</p></div>
<p>&nbsp;</p>
<p>&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;..</p>
<h4>Incoming search terms:</h4><ul><li><a href="http://wordpressapi.com/2011/11/28/how-to-add-the-custom-post-type-with-associated-tags-and-category/" title="wordpress custom post type tags">wordpress custom post type tags</a></li><li><a href="http://wordpressapi.com/2011/11/28/how-to-add-the-custom-post-type-with-associated-tags-and-category/" title="wordpress custom post types query_var">wordpress custom post types query_var</a></li><li><a href="http://wordpressapi.com/2011/11/28/how-to-add-the-custom-post-type-with-associated-tags-and-category/" title="wordpres add taxonomy slug permalink %">wordpres add taxonomy slug permalink %</a></li><li><a href="http://wordpressapi.com/2011/11/28/how-to-add-the-custom-post-type-with-associated-tags-and-category/" title="add tag to wordpress bookmarker">add tag to wordpress bookmarker</a></li><li><a href="http://wordpressapi.com/2011/11/28/how-to-add-the-custom-post-type-with-associated-tags-and-category/" title="how to add post type to main menu wordpress">how to add post type to main menu wordpress</a></li><li><a href="http://wordpressapi.com/2011/11/28/how-to-add-the-custom-post-type-with-associated-tags-and-category/" title="proudly powered by wordpress tags posted categories">proudly powered by wordpress tags posted categories</a></li><li><a href="http://wordpressapi.com/2011/11/28/how-to-add-the-custom-post-type-with-associated-tags-and-category/" title="qtranslate slug custom taxonomy">qtranslate slug custom taxonomy</a></li><li><a href="http://wordpressapi.com/2011/11/28/how-to-add-the-custom-post-type-with-associated-tags-and-category/" title="wordpress 3 3 custom post type rewrite taxonomy">wordpress 3 3 custom post type rewrite taxonomy</a></li><li><a href="http://wordpressapi.com/2011/11/28/how-to-add-the-custom-post-type-with-associated-tags-and-category/" title="wordpress custom post types category tags">wordpress custom post types category tags</a></li><li><a href="http://wordpressapi.com/2011/11/28/how-to-add-the-custom-post-type-with-associated-tags-and-category/" title="wordpress custom rewrite slug for taxonomy without plugin">wordpress custom rewrite slug for taxonomy without plugin</a></li><li><a href="http://wordpressapi.com/2011/11/28/how-to-add-the-custom-post-type-with-associated-tags-and-category/" title="custom post types category">custom post types category</a></li><li><a href="http://wordpressapi.com/2011/11/28/how-to-add-the-custom-post-type-with-associated-tags-and-category/" title="custom post type tag">custom post type tag</a></li><li><a href="http://wordpressapi.com/2011/11/28/how-to-add-the-custom-post-type-with-associated-tags-and-category/" title="add tags to custom post">add tags to custom post</a></li><li><a href="http://wordpressapi.com/2011/11/28/how-to-add-the-custom-post-type-with-associated-tags-and-category/" title="add tags to custom post type">add tags to custom post type</a></li><li><a href="http://wordpressapi.com/2011/11/28/how-to-add-the-custom-post-type-with-associated-tags-and-category/" title="add tags to custom post types">add tags to custom post types</a></li><li><a href="http://wordpressapi.com/2011/11/28/how-to-add-the-custom-post-type-with-associated-tags-and-category/" title="add tags to custom post wordpress">add tags to custom post wordpress</a></li><li><a href="http://wordpressapi.com/2011/11/28/how-to-add-the-custom-post-type-with-associated-tags-and-category/" title="adding tags to custom post types">adding tags to custom post types</a></li><li><a href="http://wordpressapi.com/2011/11/28/how-to-add-the-custom-post-type-with-associated-tags-and-category/" title="assciated tag for amazon de">assciated tag for amazon de</a></li><li><a href="http://wordpressapi.com/2011/11/28/how-to-add-the-custom-post-type-with-associated-tags-and-category/" title="category name custom post type">category name custom post type</a></li><li><a href="http://wordpressapi.com/2011/11/28/how-to-add-the-custom-post-type-with-associated-tags-and-category/" title="category php custom post type">category php custom post type</a></li></ul><p>Follow us on Twitter <a href="http://twitter.com/wordpressapi">WordPress API</a></p>]]></content:encoded>
			<wfw:commentRss>http://wordpressapi.com/2011/11/28/how-to-add-the-custom-post-type-with-associated-tags-and-category/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>change permalinks as per your choice in wordpress using post_link filter</title>
		<link>http://wordpressapi.com/2011/11/22/change-permalinks-choice-wordpress-post_link-filter/</link>
		<comments>http://wordpressapi.com/2011/11/22/change-permalinks-choice-wordpress-post_link-filter/#comments</comments>
		<pubDate>Tue, 22 Nov 2011 17:12:54 +0000</pubDate>
		<dc:creator>Wordpress API</dc:creator>
				<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wordpress api]]></category>
		<category><![CDATA[wordpress hacks]]></category>
		<category><![CDATA[permalink]]></category>
		<category><![CDATA[wp]]></category>

		<guid isPermaLink="false">http://wordpressapi.com/?p=6951</guid>
		<description><![CDATA[http://wordpressapi.com/2011/11/22/change-permalinks-choice-wordpress-post_link-filter/WordPress publishing URL you can change to anything using following function. Following wordpress hook is very important. You can publish article with different URL or domain also. Using your blog you can publish your article to another URL also. You &#8230; Continue reading &#8594;]]></description>
			<content:encoded><![CDATA[http://wordpressapi.com/2011/11/22/change-permalinks-choice-wordpress-post_link-filter/<p>WordPress publishing URL you can change to anything using following function. Following wordpress hook is very important. You can publish article with different URL or domain also. Using your blog you can publish your article to another URL also.</p>
<p>You just need to open your functions.php file and put following function in that file.</p>
<p><span class="Apple-style-span" style="font-family: Consolas, Monaco, monospace; font-size: 12px; line-height: 18px; white-space: pre;">
<pre class="brush: php; title: ; notranslate">&lt;/span&gt;
&lt;pre&gt;&lt;pre&gt;
add_filter('post_link', 'fitsmi_post_link');
function fitsmi_post_link($permalink) {
	global $post;
        $permalink = str_replace(&quot;wordpress/&quot;, &quot;&quot;, $permalink);
        return $permalink;
	if (!isset($post))
		return $permalink;
	else
		return 'http://hack.by.wordpressapi/';
}
</pre>
<div id="attachment_6964" class="wp-caption alignnone<a href="http://wordpressapi.com/2011/11/22/change-permalinks-choice-wordpress-post_link-filter/wordpress-custom-url/" rel="attachment wp-att-6964"><img class="size-medium wp-image-6964" title="change permalinks as per your choice in wordpress using post_link filter" src="http://images.wordpressapi.com/wordpress-custom-url-300x199.jpg" alt="change permalinks as per your choice in wordpress using post_link filter" width="300" height="199" /></a><p class="wp-caption-text">change permalinks as per your choice in wordpress using post_link filter</p></div>
<p>&nbsp;</p>
<pre>With following function you need to be very careful.</pre>
<h4>Incoming search terms:</h4><ul><li><a href="http://wordpressapi.com/2011/11/22/change-permalinks-choice-wordpress-post_link-filter/" title="post_link filter arguments wordpress">post_link filter arguments wordpress</a></li><li><a href="http://wordpressapi.com/2011/11/22/change-permalinks-choice-wordpress-post_link-filter/" title="change permalink post_link">change permalink post_link</a></li><li><a href="http://wordpressapi.com/2011/11/22/change-permalinks-choice-wordpress-post_link-filter/" title="post_link">post_link</a></li><li><a href="http://wordpressapi.com/2011/11/22/change-permalinks-choice-wordpress-post_link-filter/" title="cars themes filter wordpress">cars themes filter wordpress</a></li><li><a href="http://wordpressapi.com/2011/11/22/change-permalinks-choice-wordpress-post_link-filter/" title="wordpress filter post_link">wordpress filter post_link</a></li><li><a href="http://wordpressapi.com/2011/11/22/change-permalinks-choice-wordpress-post_link-filter/" title="wordpress filter permalink">wordpress filter permalink</a></li><li><a href="http://wordpressapi.com/2011/11/22/change-permalinks-choice-wordpress-post_link-filter/" title="permalink hook">permalink hook</a></li><li><a href="http://wordpressapi.com/2011/11/22/change-permalinks-choice-wordpress-post_link-filter/" title="function post_link wordpress">function post_link wordpress</a></li><li><a href="http://wordpressapi.com/2011/11/22/change-permalinks-choice-wordpress-post_link-filter/" title="filter wordpress permalink">filter wordpress permalink</a></li><li><a href="http://wordpressapi.com/2011/11/22/change-permalinks-choice-wordpress-post_link-filter/" title="filter permalink wordpress">filter permalink wordpress</a></li><li><a href="http://wordpressapi.com/2011/11/22/change-permalinks-choice-wordpress-post_link-filter/" title="wordpress::api replace image">wordpress::api replace image</a></li></ul><p>Follow us on Twitter <a href="http://twitter.com/wordpressapi">WordPress API</a></p>]]></content:encoded>
			<wfw:commentRss>http://wordpressapi.com/2011/11/22/change-permalinks-choice-wordpress-post_link-filter/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Solved for WordPress old and new versions &#8211; PHP Fatal error:  Allowed memory size of 33554432 bytes exhausted</title>
		<link>http://wordpressapi.com/2011/11/21/solved-for-wordpress-old-and-new-versions-php-fatal-error-allowed-memory-size-33554432-bytes-exhausted/</link>
		<comments>http://wordpressapi.com/2011/11/21/solved-for-wordpress-old-and-new-versions-php-fatal-error-allowed-memory-size-33554432-bytes-exhausted/#comments</comments>
		<pubDate>Mon, 21 Nov 2011 18:16:01 +0000</pubDate>
		<dc:creator>Wordpress API</dc:creator>
				<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wordpress hacks]]></category>
		<category><![CDATA[wordpress tutorials]]></category>
		<category><![CDATA[wp]]></category>

		<guid isPermaLink="false">http://wordpressapi.com/?p=6944</guid>
		<description><![CDATA[http://wordpressapi.com/2011/11/21/solved-for-wordpress-old-and-new-versions-php-fatal-error-allowed-memory-size-33554432-bytes-exhausted/We got always following ERROR PHP Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 10485761 bytes) in This issue with old and new wordpress versions both. First you need to increase memory limit for your php &#8230; Continue reading &#8594;]]></description>
			<content:encoded><![CDATA[http://wordpressapi.com/2011/11/21/solved-for-wordpress-old-and-new-versions-php-fatal-error-allowed-memory-size-33554432-bytes-exhausted/<pre>We got always following ERROR

PHP Fatal error:  Allowed memory size of 33554432 bytes exhausted (tried to allocate 10485761 bytes) in

This issue with old and new wordpress versions both. First you need to increase memory limit for your php package.

Use following method for increase the memory for php.

Open php configuration file.

# vim /etc/php.ini
Change following sections:
<pre class="brush: php; title: ; notranslate">
max_execution_time = 300     ; Maximum execution time of each script, in seconds
max_input_time = 300    ; Maximum amount of time each script may spend parsing request data
memory_limit = 128M      ; Maximum amount of memory a script may consume (16MB)
</pre>
<p>I know on 2.5.1 i needed to increase the memdory, but i don't know how in 2.6. in the wp-config.php there no define to increase memory.</p>
<p>If you are using old wordpress version less then wordpress 2.6 version or you are using the wordpress MU then use following code.</p>
<p>open your wp-settings.php file from root folder and change following line</p>
<pre class="brush: php; title: ; notranslate">
if ( !defined('WP_MEMORY_LIMIT') )
        define('WP_MEMORY_LIMIT', '32M');
</pre>
<p>to</p>
<pre class="brush: php; title: ; notranslate">
if ( !defined('WP_MEMORY_LIMIT') )
        define('WP_MEMORY_LIMIT', '128M');
</pre>
<p>If you are using the newer wordpress version greater then 2.7 then use following method.<br />
Following URL is also helpful<br />
http://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP</p>
<p>Edit wp-config.php and enter the following line<br />
define('WP_MEMORY_LIMIT', '64M');</p>
<p>If you are using the shared hosting then use following method.</p>
<p>   1. Create a file called php.ini in the root of your site (if you are using a hosted addon domain, this must be in the subdirectory of that site)<br />
   2. In php.ini, enter a line that says<br />
      memory_limit = 64MB<br />
   3. In your site's .htaccess (being a WordPress blog, I'm assuming there is one), enter the following line<br />
      SetEnv PHPRC /&lt;unix path to the directory where php.ini is&gt;/<br />
      (keep the slashes)<br />
   4. Edit wp-config.php and enter the following line<br />
      define('WP_MEMORY_LIMIT', '64M');<br />
   5. Upload the new files to the server</p>
<p>Oh, and don't tell your hosting provider you've done this... </p>
<p>This will solve your issue.</pre>
<div id="attachment_6945" class="wp-caption alignnone<a href="http://wordpressapi.com/2011/11/21/solved-for-wordpress-old-and-new-versions-php-fatal-error-allowed-memory-size-33554432-bytes-exhausted/fatal_error/" rel="attachment wp-att-6945"><img class="size-medium wp-image-6945" title="Solved for WordPress old and new versions - PHP Fatal error:  Allowed memory size of 33554432 bytes exhausted" src="http://images.wordpressapi.com/fatal_error-264x300.jpg" alt="Solved for WordPress old and new versions - PHP Fatal error:  Allowed memory size of 33554432 bytes exhausted" width="264" height="300" /></a><p class="wp-caption-text">Solved for WordPress old and new versions - PHP Fatal error: Allowed memory size of 33554432 bytes exhausted</p></div>
<h4>Incoming search terms:</h4><ul><li><a href="http://wordpressapi.com/2011/11/21/solved-for-wordpress-old-and-new-versions-php-fatal-error-allowed-memory-size-33554432-bytes-exhausted/" title="wordpress 3 3 1 fatal error when uploading pictures">wordpress 3 3 1 fatal error when uploading pictures</a></li><li><a href="http://wordpressapi.com/2011/11/21/solved-for-wordpress-old-and-new-versions-php-fatal-error-allowed-memory-size-33554432-bytes-exhausted/" title="qtranslate allowed memory exhausted">qtranslate allowed memory exhausted</a></li><li><a href="http://wordpressapi.com/2011/11/21/solved-for-wordpress-old-and-new-versions-php-fatal-error-allowed-memory-size-33554432-bytes-exhausted/" title="wordpress 3 3 Allowed memory size bytes exhausted">wordpress 3 3 Allowed memory size bytes exhausted</a></li><li><a href="http://wordpressapi.com/2011/11/21/solved-for-wordpress-old-and-new-versions-php-fatal-error-allowed-memory-size-33554432-bytes-exhausted/" title="qtranslate allow memory php">qtranslate allow memory php</a></li><li><a href="http://wordpressapi.com/2011/11/21/solved-for-wordpress-old-and-new-versions-php-fatal-error-allowed-memory-size-33554432-bytes-exhausted/" title="qtranslate allowed memory size exhausted">qtranslate allowed memory size exhausted</a></li><li><a href="http://wordpressapi.com/2011/11/21/solved-for-wordpress-old-and-new-versions-php-fatal-error-allowed-memory-size-33554432-bytes-exhausted/" title="qtranslate fatal error: allowed memory size">qtranslate fatal error: allowed memory size</a></li><li><a href="http://wordpressapi.com/2011/11/21/solved-for-wordpress-old-and-new-versions-php-fatal-error-allowed-memory-size-33554432-bytes-exhausted/" title="upload video php xhr php fatal error: allowed memory size">upload video php xhr php fatal error: allowed memory size</a></li><li><a href="http://wordpressapi.com/2011/11/21/solved-for-wordpress-old-and-new-versions-php-fatal-error-allowed-memory-size-33554432-bytes-exhausted/" title="3 3 1 out of memory cache php wordpress">3 3 1 out of memory cache php wordpress</a></li><li><a href="http://wordpressapi.com/2011/11/21/solved-for-wordpress-old-and-new-versions-php-fatal-error-allowed-memory-size-33554432-bytes-exhausted/" title="wordpress 3 3 allowed memory size of 33554432 bytes exhausted">wordpress 3 3 allowed memory size of 33554432 bytes exhausted</a></li><li><a href="http://wordpressapi.com/2011/11/21/solved-for-wordpress-old-and-new-versions-php-fatal-error-allowed-memory-size-33554432-bytes-exhausted/" title="wordpress 3 3 fatal error: allowed memory size of 33554432 bytes exhausted">wordpress 3 3 fatal error: allowed memory size of 33554432 bytes exhausted</a></li><li><a href="http://wordpressapi.com/2011/11/21/solved-for-wordpress-old-and-new-versions-php-fatal-error-allowed-memory-size-33554432-bytes-exhausted/" title="wordpress comment image allowed memory size">wordpress comment image allowed memory size</a></li><li><a href="http://wordpressapi.com/2011/11/21/solved-for-wordpress-old-and-new-versions-php-fatal-error-allowed-memory-size-33554432-bytes-exhausted/" title="wordpress fatal error when uploading custom background">wordpress fatal error when uploading custom background</a></li><li><a href="http://wordpressapi.com/2011/11/21/solved-for-wordpress-old-and-new-versions-php-fatal-error-allowed-memory-size-33554432-bytes-exhausted/" title="PHP Fatal error: Allowed memory size of wp 3 3">PHP Fatal error: Allowed memory size of wp 3 3</a></li><li><a href="http://wordpressapi.com/2011/11/21/solved-for-wordpress-old-and-new-versions-php-fatal-error-allowed-memory-size-33554432-bytes-exhausted/" title="nginx Fatal error: Allowed memory exhausted">nginx Fatal error: Allowed memory exhausted</a></li><li><a href="http://wordpressapi.com/2011/11/21/solved-for-wordpress-old-and-new-versions-php-fatal-error-allowed-memory-size-33554432-bytes-exhausted/" title="fatal error: allowed memory size of bytes exhausted /var/www/html/wordpress/wp-includes/media php on line">fatal error: allowed memory size of bytes exhausted /var/www/html/wordpress/wp-includes/media php on line</a></li><li><a href="http://wordpressapi.com/2011/11/21/solved-for-wordpress-old-and-new-versions-php-fatal-error-allowed-memory-size-33554432-bytes-exhausted/" title="allowed memory size bytes exhausted wordpress 3 3 1">allowed memory size bytes exhausted wordpress 3 3 1</a></li><li><a href="http://wordpressapi.com/2011/11/21/solved-for-wordpress-old-and-new-versions-php-fatal-error-allowed-memory-size-33554432-bytes-exhausted/" title="delicious magazine memory allowed">delicious magazine memory allowed</a></li><li><a href="http://wordpressapi.com/2011/11/21/solved-for-wordpress-old-and-new-versions-php-fatal-error-allowed-memory-size-33554432-bytes-exhausted/" title="fatal error allowed memory size of wordpress">fatal error allowed memory size of wordpress</a></li><li><a href="http://wordpressapi.com/2011/11/21/solved-for-wordpress-old-and-new-versions-php-fatal-error-allowed-memory-size-33554432-bytes-exhausted/" title="fatal error allowed memory size of wordpress 3 3">fatal error allowed memory size of wordpress 3 3</a></li><li><a href="http://wordpressapi.com/2011/11/21/solved-for-wordpress-old-and-new-versions-php-fatal-error-allowed-memory-size-33554432-bytes-exhausted/" title="fatal error allowed memory size of wordpress 3 3 1">fatal error allowed memory size of wordpress 3 3 1</a></li></ul><p>Follow us on Twitter <a href="http://twitter.com/wordpressapi">WordPress API</a></p>]]></content:encoded>
			<wfw:commentRss>http://wordpressapi.com/2011/11/21/solved-for-wordpress-old-and-new-versions-php-fatal-error-allowed-memory-size-33554432-bytes-exhausted/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to remove first image from wordpress post with caption if caption is present</title>
		<link>http://wordpressapi.com/2011/11/16/how-to-remove-first-image-from-wordpress-post-with-caption-if-caption-is-present/</link>
		<comments>http://wordpressapi.com/2011/11/16/how-to-remove-first-image-from-wordpress-post-with-caption-if-caption-is-present/#comments</comments>
		<pubDate>Wed, 16 Nov 2011 17:59:03 +0000</pubDate>
		<dc:creator>Wordpress API</dc:creator>
				<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wordpress hacks]]></category>
		<category><![CDATA[wordpress tutorials]]></category>
		<category><![CDATA[wp]]></category>

		<guid isPermaLink="false">http://wordpressapi.com/?p=6933</guid>
		<description><![CDATA[http://wordpressapi.com/2011/11/16/how-to-remove-first-image-from-wordpress-post-with-caption-if-caption-is-present/I struggled lot for this issue. Some times I only removed the first image. some times I removed first caption. I used the following code for first image removing. But I faced the some issues with that code. When first &#8230; Continue reading &#8594;]]></description>
			<content:encoded><![CDATA[http://wordpressapi.com/2011/11/16/how-to-remove-first-image-from-wordpress-post-with-caption-if-caption-is-present/<pre>I struggled lot for this issue. Some times I only removed the first image. some times I removed first caption.</pre>
<p>I used the following code for first image removing.</p>
<pre class="brush: php; title: ; notranslate">
/*
 * Removing the first image from post
 */
function remove_first_image ($content) {
 if (!is_page() &amp;&amp; !is_feed() &amp;&amp; !is_feed() &amp;&amp; !is_home()) {
    if (preg_match(&quot;/&lt;img[^&gt;]+\&gt;/i&quot;,$content)) {
		 $content = preg_replace(&quot;/&lt;img[^&gt;]+\&gt;/i&quot;, &quot;&quot;, $content, 1);
 	}
	return $content;
   }
}
</pre>
<p>But I faced the some issues with that code. When first image has caption then only image get removed and caption will remain there.</p>
<p>After that I used the following code for caption remove.</p>
<pre class="brush: php; title: ; notranslate">
/*
 * Removing the first caption from post with image
 */
function remove_first_image_caption ($content) {
 if (!is_page() &amp;&amp; !is_feed() &amp;&amp; !is_feed() &amp;&amp; !is_home()) {
 $content = preg_replace(&quot;(\)&quot;, &quot;&quot;, $content, 1);
 } return $content;
}
add_filter('the_content', 'remove_first_image_caption');
</pre>
<p>But if first image has no caption and second image image has caption then both the images will be get removed from post.</p>
<p>After some struggle I written following code. Following is the solution:</p>
<p>Final Code.</p>
<pre class="brush: php; title: ; notranslate">
/*
 * Removing the first image from post
 * functionality added to delete caption is present to first image.
 */
function remove_first_image ($content) {
 if (!is_page() &amp;&amp; !is_feed() &amp;&amp; !is_feed() &amp;&amp; !is_home()) {
    if (preg_match(&quot;/&lt;img[^&gt;]+\&gt;/i&quot;,$content)) {
    //find first image URL
     $first_img = '';
     $output = preg_match_all('/&lt; *img[^&gt;]*src *= *[&quot;\']?([^&quot;\']*)/', $content, $matches);
     $first_img = $matches[1][0];

    //find first image caption inner text
     $output = preg_match_all(&quot;/caption=['&quot;](.*)/&quot;, $content, $matches);

     //find first image present in first caption text or not
        $pos = strpos($matches[0][0], $first_img);

    // if image URL found in caption array then delete the caption and image
        if ($pos !== false) {
           $content = preg_replace(&quot;(\)&quot;, &quot;&quot;, $content, 1);
        } else {
           $content = preg_replace(&quot;/&lt;img[^&gt;]+\&gt;/i&quot;, &quot;&quot;, $content, 1);
        }
    }

 } return $content;
}
add_filter('the_content', 'remove_first_image');
</pre>
<p>solved: pagination for Custom post type not working</p>
<p>Some people asked me about pagination of custom post type. That is very easy.</p>
<p>For showing the custom post type we always use the query_post method.</p>
<p>Just use the following code in your template or theme file.</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php get_header(); ?&gt;

            &lt;?php  query_posts( 'post_type=custom-post-type&amp;paged='.$paged );
                                    if (have_posts()) : while (have_posts()) : the_post(); ?&gt;

loop here

              			&lt;?php endwhile; ?&gt;
				  &lt;div id=&quot;nav-below&quot; class=&quot;navigation&quot;&gt;
					&lt;div class=&quot;nav-previous&quot;&gt;&lt;?php next_posts_link( __( '&lt;span class=&quot;meta-nav&quot;&gt;&amp;larr;&lt;/span&gt; Older posts', 'twentyten' ) ); ?&gt;&lt;/div&gt;
					&lt;div class=&quot;nav-next&quot;&gt;&lt;?php previous_posts_link( __( 'Newer posts &lt;span class=&quot;meta-nav&quot;&gt;&amp;rarr;&lt;/span&gt;', 'twentyten' ) ); ?&gt;&lt;/div&gt;
				  &lt;/div&gt;&lt;!-- #nav-below --&gt;
				  &lt;?php endif; wp_reset_query(); ?&gt;

&lt;?php get_footer(); ?&gt;
</pre>
[caption id="attachment_6934" align="alignnone" width="300" caption="How to remove first image from wordpress post with caption if caption is present"]<a href="http://wordpressapi.com/2011/11/16/how-to-remove-first-image-from-wordpress-post-with-caption-if-caption-is-present/wordpress-caption-image/" rel="attachment wp-att-6934"><img class="size-medium wp-image-6934" title="How to remove first image from wordpress post with caption if caption is present" src="http://images.wordpressapi.com/wordpress-caption-image-300x300.jpg" alt="How to remove first image from wordpress post with caption if caption is present" width="300" height="300" /></a>
<h4>Incoming search terms:</h4><ul><li><a href="http://wordpressapi.com/2011/11/16/how-to-remove-first-image-from-wordpress-post-with-caption-if-caption-is-present/" title="preg_match_all first image">preg_match_all first image</a></li><li><a href="http://wordpressapi.com/2011/11/16/how-to-remove-first-image-from-wordpress-post-with-caption-if-caption-is-present/" title="wordpress remove first">wordpress remove first</a></li><li><a href="http://wordpressapi.com/2011/11/16/how-to-remove-first-image-from-wordpress-post-with-caption-if-caption-is-present/" title="if (preg_match first image">if (preg_match first image</a></li><li><a href="http://wordpressapi.com/2011/11/16/how-to-remove-first-image-from-wordpress-post-with-caption-if-caption-is-present/" title="strip caption tag from wordpress content using mysql">strip caption tag from wordpress content using mysql</a></li><li><a href="http://wordpressapi.com/2011/11/16/how-to-remove-first-image-from-wordpress-post-with-caption-if-caption-is-present/" title="remove captions by add_filter">remove captions by add_filter</a></li><li><a href="http://wordpressapi.com/2011/11/16/how-to-remove-first-image-from-wordpress-post-with-caption-if-caption-is-present/" title="remove caption php">remove caption php</a></li><li><a href="http://wordpressapi.com/2011/11/16/how-to-remove-first-image-from-wordpress-post-with-caption-if-caption-is-present/" title="preg_replace delete first image from text">preg_replace delete first image from text</a></li><li><a href="http://wordpressapi.com/2011/11/16/how-to-remove-first-image-from-wordpress-post-with-caption-if-caption-is-present/" title="preg_match_all(/&lt;img[^&gt;] &gt;/i $content $images);">preg_match_all(/&lt;img[^&gt;] &gt;/i $content $images);</a></li><li><a href="http://wordpressapi.com/2011/11/16/how-to-remove-first-image-from-wordpress-post-with-caption-if-caption-is-present/" title="preg_match wordpress post content">preg_match wordpress post content</a></li><li><a href="http://wordpressapi.com/2011/11/16/how-to-remove-first-image-from-wordpress-post-with-caption-if-caption-is-present/" title="is_home directive">is_home directive</a></li><li><a href="http://wordpressapi.com/2011/11/16/how-to-remove-first-image-from-wordpress-post-with-caption-if-caption-is-present/" title="if(preg_match fluxbb extract first image">if(preg_match fluxbb extract first image</a></li><li><a href="http://wordpressapi.com/2011/11/16/how-to-remove-first-image-from-wordpress-post-with-caption-if-caption-is-present/" title="how to remove the 1st image in a post in a category in wordpress">how to remove the 1st image in a post in a category in wordpress</a></li><li><a href="http://wordpressapi.com/2011/11/16/how-to-remove-first-image-from-wordpress-post-with-caption-if-caption-is-present/" title="function remove_first_image ($content) { if (!is_page() &amp;&amp; !is_feed() &amp;&amp; !is_feed() &amp;&amp; !is_home()) { $content = preg_replace(/&lt;img[^&gt;] \&gt;/i $content 1); } return $content; } add_filter(\the_content\ \remove_first_image\);">function remove_first_image ($content) { if (!is_page() &amp;&amp; !is_feed() &amp;&amp; !is_feed() &amp;&amp; !is_home()) { $content = preg_replace(/&lt;img[^&gt;] \&gt;/i $content 1); } return $content; } add_filter(\the_content\ \remove_first_image\);</a></li><li><a href="http://wordpressapi.com/2011/11/16/how-to-remove-first-image-from-wordpress-post-with-caption-if-caption-is-present/" title="first image wordpress post">first image wordpress post</a></li><li><a href="http://wordpressapi.com/2011/11/16/how-to-remove-first-image-from-wordpress-post-with-caption-if-caption-is-present/" title="exclude caption id from html post wordpress">exclude caption id from html post wordpress</a></li><li><a href="http://wordpressapi.com/2011/11/16/how-to-remove-first-image-from-wordpress-post-with-caption-if-caption-is-present/" title="amazon api preg_match">amazon api preg_match</a></li></ul><p>Follow us on Twitter <a href="http://twitter.com/wordpressapi">WordPress API</a></p>]]></content:encoded>
			<wfw:commentRss>http://wordpressapi.com/2011/11/16/how-to-remove-first-image-from-wordpress-post-with-caption-if-caption-is-present/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to show some posts to only registered users in wordpress</title>
		<link>http://wordpressapi.com/2011/11/10/how-to-show-some-posts-to-only-registered-users-in-wordpress/</link>
		<comments>http://wordpressapi.com/2011/11/10/how-to-show-some-posts-to-only-registered-users-in-wordpress/#comments</comments>
		<pubDate>Thu, 10 Nov 2011 15:12:14 +0000</pubDate>
		<dc:creator>Wordpress API</dc:creator>
				<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wordpress hacks]]></category>
		<category><![CDATA[wordpress tutorials]]></category>
		<category><![CDATA[private category]]></category>
		<category><![CDATA[wordpress api]]></category>
		<category><![CDATA[wp]]></category>

		<guid isPermaLink="false">http://wordpressapi.com/?p=6921</guid>
		<description><![CDATA[http://wordpressapi.com/2011/11/10/how-to-show-some-posts-to-only-registered-users-in-wordpress/Some people want to show selected posts to only registered users in site. You can easily achieve this. You just need to create public and private category and publish your selected posts in private category. Use the following code in index.php &#8230; Continue reading &#8594;]]></description>
			<content:encoded><![CDATA[http://wordpressapi.com/2011/11/10/how-to-show-some-posts-to-only-registered-users-in-wordpress/<p>Some people want to show selected posts to only registered users in site. You can easily achieve this. You just need to create public and private category and publish your selected posts in private category. Use the following code in index.php and single.php and page.php file.</p>
<pre class="brush: php; title: ; notranslate">

$cat_id = get_cat_ID('private');
$args=array(
  'category__not_in' =&gt; $cat_id,
  'post_type' =&gt; 'post',
  'post_status' =&gt; 'publish',
  'posts_per_page' =&gt; 5
);

if(!is_user_logged_in()){
    $cat_id = get_cat_ID('private');
   $args=array(
  'category__not_in' =&gt; $cat_id,
  'post_type' =&gt; 'post',
  'post_status' =&gt; 'publish',
  'posts_per_page' =&gt; 5
);

} else {
    $cat_id = get_cat_ID('public');
$args=array(
  'category__not_in' =&gt; $cat_id,
  'post_type' =&gt; 'post',
  'post_status' =&gt; 'publish',
  'posts_per_page' =&gt; 5
);

}
// The Query
query_posts( $args );

// The Loop
while ( have_posts() ) : the_post();
	echo '&lt;li&gt;';
	the_title();
	echo '&lt;/li&gt;';
endwhile;

// Reset Query
wp_reset_query();
</pre>
<div id="attachment_6922" class="wp-caption alignnone<a href="http://wordpressapi.com/2011/11/10/how-to-show-some-posts-to-only-registered-users-in-wordpress/private-wordpress-posts/" rel="attachment wp-att-6922"><img class="size-full wp-image-6922" title="How to show some posts to only registered users in wordpress" src="http://images.wordpressapi.com/private-wordpress-posts.jpg" alt="How to show some posts to only registered users in wordpress" width="200" height="148" /></a><p class="wp-caption-text">How to show some posts to only registered users in wordpress</p></div>
<h4>Incoming search terms:</h4><ul><li><a href="http://wordpressapi.com/2011/11/10/how-to-show-some-posts-to-only-registered-users-in-wordpress/" title="wordpress menu post_status == \register\">wordpress menu post_status == \register\</a></li><li><a href="http://wordpressapi.com/2011/11/10/how-to-show-some-posts-to-only-registered-users-in-wordpress/" title="$args = array( \post_type\ =&gt; array(\post\ \post_type\) \cat_id\ =&gt; 24">$args = array( \post_type\ =&gt; array(\post\ \post_type\) \cat_id\ =&gt; 24</a></li><li><a href="http://wordpressapi.com/2011/11/10/how-to-show-some-posts-to-only-registered-users-in-wordpress/" title="wordpress query on registered users">wordpress query on registered users</a></li><li><a href="http://wordpressapi.com/2011/11/10/how-to-show-some-posts-to-only-registered-users-in-wordpress/" title="wordpress category__not_in=&gt; slug">wordpress category__not_in=&gt; slug</a></li><li><a href="http://wordpressapi.com/2011/11/10/how-to-show-some-posts-to-only-registered-users-in-wordpress/" title="word press only show category to registered">word press only show category to registered</a></li><li><a href="http://wordpressapi.com/2011/11/10/how-to-show-some-posts-to-only-registered-users-in-wordpress/" title="show only some posts rails">show only some posts rails</a></li><li><a href="http://wordpressapi.com/2011/11/10/how-to-show-some-posts-to-only-registered-users-in-wordpress/" title="how to display posts in wordpress for registered user">how to display posts in wordpress for registered user</a></li><li><a href="http://wordpressapi.com/2011/11/10/how-to-show-some-posts-to-only-registered-users-in-wordpress/" title="category__not_in working queery">category__not_in working queery</a></li><li><a href="http://wordpressapi.com/2011/11/10/how-to-show-some-posts-to-only-registered-users-in-wordpress/" title="category__not_in wordpress query">category__not_in wordpress query</a></li><li><a href="http://wordpressapi.com/2011/11/10/how-to-show-some-posts-to-only-registered-users-in-wordpress/" title="wordpress registered only category">wordpress registered only category</a></li></ul><p>Follow us on Twitter <a href="http://twitter.com/wordpressapi">WordPress API</a></p>]]></content:encoded>
			<wfw:commentRss>http://wordpressapi.com/2011/11/10/how-to-show-some-posts-to-only-registered-users-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Served from: wordpressapi.com @ 2012-02-05 14:17:50 by W3 Total Cache -->
