PHP webdeveloper and frontend developer



Use a custom template for all subapges of a parent page in WordPress

Category : PHP, Wordpress · No Comments · by Oct 27th, 2012

Add this code to your functions.php file from your template and replace the $page_id variable with the ID from your parent page ID and replace page-template.php with the template file you want to use for your subpages.

 

Get the current page’s parent page ID in WordPress

Category : PHP, Wordpress · (2) Comments · by Oct 27th, 2012

Add this function to your theme’s functions.php file in WordPress. This function will return the page id from the parent page.

How to get the youtube ID from a youtube URL using PHP

Category : PHP · No Comments · by Oct 21st, 2012

Just use this function:

 

Filter posts with a certain custom field value in wordpress

Category : PHP, Wordpress · No Comments · by Oct 12th, 2012

Add the meta_key and meta_value parameters to your wp_query where the meta_key is the name of the custom field and the meta_value is it’s value.

 

Fetch all tweets with a certain hashtag and store them in the database

Category : PHP · (1) Comment · by Jul 13th, 2012

I wrote a small script that gets all tweets with a certain hashag and stores them in a database. When the tweets exists in the database, it won’t be added again.

This is the table structure I used:

   

Ipad detection with PHP and htaccess

Category : PHP, Apache · No Comments · by Aug 19th, 2010

This wil return a 1 value if it’s an iPad:

 You also set a redirect with htaccess:

 

Removing the index.php from your codeigniter URL

Category : PHP, Apache · No Comments · by Jul 1st, 2010
Removing the index.php from your codeigniter URL

When you create a standard new codeigniter application, there’s always a index.php in your url. It’s kind of ugly in your url so I prefer to remove this. To remove this you need to do a couple of things: change the $config[‘index_page’] to $config[‘index_page’]=”“ instead of $config[‘index_page’]=“index.php” This will only work is mod_rewrite is enabled on your webserver! Next create a .htaccess file in…

Multi-language support with Smarty Gettext

Category : PHP · No Comments · by Mar 1st, 2010

With smarty you can make language files containing all the words that need to be translated and smarty will replace the language variables with the correct language. This is based on Gettext. Smarty is also able to automatically check the browser language. I found this language class on the http://smarty.incutio.com/ website.  usage: Make a file in your libs folder with the following:…

Extract the source from an img tag with PHP

Category : PHP · No Comments · by Feb 11th, 2010

You can extract the source from an img tag with this PHP function:

 Comes in handy with wordpress sometimes.

How to resize youtube or vimeo movies with PHP

Category : PHP · No Comments · by May 27th, 2009
How to resize youtube or vimeo movies with PHP

You have to use the preg_replace php function here. The $video variable holds the embed code fromyoutube, vimeo or other similar website that use these parameters in their embed codes in the example. You can change the width and height in the second parameter. This will replace the width and height parameters in you embed code with you desired width….


s