Tag Archives: snippets

How to add custom nodes to WordPress RSS feed

Recently I was working on a WordPress site and wanted to add a custom node to the WordPress RSS Feeds. In my previous post How to add featured image to WordPress RSS feed we saw how to add a featured image to the post content in RSS Feed. In this post we will see how we can add any node to the RSS Feed. To add a custom node in the RSS feed we just need to add some code to the theme’s functions.php file.
Read more »

How to create a zip file using PHP

Recently I had to write a script to create a zip file containing different files and folders. PHP has a ZipArchive class which can be used easily to create zip files. In this article we will see how to create zip files in PHP. We will create different zip files from different files and folders.

Read more »

How to create CSV file using PHP

CSV (comma-separated values) is one of the most popular methods for transferring tabular data between applications. Lot of applications want to export data in a CSV file. In this article we will see how we can create CSV file using PHP. We will also see how to automatically download the file instead of just showing it in the browser or giving the user a link to download it.
Read more »

How to sort a multi-dimension array by value in PHP

In this article we will see how to sort a multi-dimension array by value of one of the keys of the array. We can use a few different methods to do this. One way to to use usort() function. Another way is to just identify the values and create another array with the values and then use it in the array_multisort() function. Using the multisort method we can easily sort a multi-dimension array based on its one or more values. Lets see how we can use both these methods.
Read more »

How to add featured image to WordPress RSS feed

Recently I came across a situation when I wanted to add the featured image of the posts to my RSS Feed. By default WordPress does not shows the Featured Image in the RSS Feed. This can be easily achieved by adding a few lines of code in the functions.php file of the theme.

Important: Make sure to add the code to the functions.php file of your theme. Do not add it to the functions.php file in the wp-includes directory.
Read more »