Skip to main content

Posts

Inserting post image programmatically to worpress

We have discussed how posts can be added programmatically before. This comes very much handy when you have to make custom scripts to import content from some cms especially custom ones. But the thing often missed is how to add post image for a particular post programmatically. This is something that is always missed. There very less resources online explaining this. But this is a very straight forward thing and very easy to do. There is this wonderful function that does this beautifully. media_sideload_image($url,$post_id,$description); The first argument is the remote url of the image you want to download. The second argument is the post id of the post to which you want to attach the image. The third argument is optional, but will be a description if included. I'd suggest finding a way to throttle the downloads so that you don't keep timing out, such as limiting the number of images it pulls in per load and setting the importer to refresh itself between dow
Recent posts

Effective Comment Management in Wordpress

Each people have their on reasons to ask for more control over the comment system, some people want to allow commenting on some posts while some want to close it on some. Some need extra features in comments like subscription or rich text. For some the problem is spam. Here is a random list of plugins that solve these issues. Plugins to combat Fight Spam: Akismet – Anti-spam is a plugin from the creators of WordPress that uses a central database of spam comments to flag spam. Requires a free API key from WordPress.com Spam Karma – Analyzes comments for spam based on a karma system in place. Bad Behavior – Prevents the spambots from even accessing your site by analyzing their HTTP requests. Did You Pass Math? – Asks the commentators a simple math question before their comments are posted. Comment Timeout – Closes comments on all old posts. Encourage Commenting BlogFollow – Shows a snippet of the commenter’s blog at the bottom of the comment. DoFollow – Removes “n

Highlight your Codes in WordPress Post with Google Syntax Highlighter

One of the problem most of the WordPress newbies face is highlighting their codes in the post. Some even go to the extend of writing their own extension for this purpose. When there are better solutions. Google Syntax Highlighter Plugin is one of the best plugin out there which does this task wonderfully. Its based on this work by Alex Gorbatchev . Here is a screen shot of what it can achieve

Allow contributor to Upload in Wordpress

In WordPress one of the most irritating thing that webmasters with multiple author feel is the lack of permission for the contributor to upload or insert images. When your blog is using post image its really hard as some one with a higher permission has to do the job. But there is a really simple trick to allow this. You just have to add this small piece of code to your functions.php file within your theme. if ( current_user_can('contributor') && !current_user_can('upload_files') ) add_action('admin_init', 'allow_contributor_uploads'); function allow_contributor_uploads() { $contributor = get_role('contributor'); $contributor->add_cap('upload_files'); } Wasn't that easy? For any doubts or suggestion use the comment form.

Insert Ads, Images or anything in RSS Feeds in WordPress

Monetizing RSS feeds has becomw a common practice, and many blogs do it to maximize their income. FeedBurner can insert AdSense ads into your feed items, but you need at least 500 subscribers to qualify, and you can’t use any ads other than the AdSense ads provided by FeedBurner. So what is the workaround? What if you want to show images in the feeds? Well thats quite easy! Follow these simple steps to perform this hack: Edit the functions.php file of your theme. If your theme doesn’t have a functions.php file, simply create one. Paste the following code into your functions.php file: <?php function insertAds($content) { $content = $content.'<hr /><a href="http://www.wprecipes.com">Have you visited WpRecipes today?</a><hr />'; return $content; } add_filter('the_excerpt_rss', 'insertAds'); add_filter('the_content_rss', 'insertAds'); ?> Save the file. You’re now displaying your ads in your RSS feed!

Using WordPress Comment Meta

Comment meta is such a wonderful addition to WordPress that allow us to extend the native comment form with additional fields. This comes very handy for the one's who is trying to create review sites etc. Unfortunately there’s no documentation added on the WP codex. For the purpose of demonstration we will be doing: add a check box to the comments form. show in the WordPress comments admin whether or not the checkbox was selected. indicate in the comment notification email whether or not the checkbox was selected. Adding the checkbox to the comments form is easy. To add the checkbox to the comments form open up your themes comments.php file and paste this into the area where you need it: <label><input id="publishc" name="publishc" tabindex="90" type="checkbox" value="this is the value I want to capture" /> Whatever sentence that you want commenters to use the checkbox for</label> Now that the checkbox

Using Multiple Permalink in WordPress

There time when you feel that the basic permalink settings of wordpress simply isn't enough when you want to make your url more meaningful and seo friendly. But how do we do this? There no much information on this out there as this is not something that all needs. Well, there is a very cool plugin out there that does exactly what you want. It's called   Advanced Permalinks The plugin provides advanced permalink options that allow you to: Have multiple permalink structures. Permalinks can be assigned to posts or ranges of posts 301 redirect old permalink structures (many structures are allowed) Category-specific permalinks. Posts in certain categories can be assigned a permalink structure No need to have a base to the category permalink! Change author permalinks Enable periods in permalinks - perfect for migrating old websit es.