<?php get_cat_name( $cat_id ) ?> Get the category name if you have the id of it <?php get_category_link( $category_id ); ?> Get the category permalink
Category Archives: PHP
WordPress: produce new templates that can be used for new pages
Put them on your Themes directory, any php file that is there and includes the following header will be included in the drop-down menu for templates to choose from while creating a page: <?php/*Template Name: Custom Feed*/
WordPress: Adding the version of jquery that comes with the installation
wp_enqueue_script(‘jquery’);
Where is my php.ini?
So you setup a page with phpinfo() on it, and the php.ini path indicated by it does not actually contain a php.ini file? Kind of a weird bug I run across. After searching for all my php.ini files in my linux box (find / -name php.ini) and not being able to find the appropiate one […]
Setting the user agent on a php based bot
The source says it all: http://forums.digitalpoint.com/showthread.php?s=54a41b4d013e9c78bbb65201b35f70c7&t=13408
Files not being uploaded on a PHP server
The solution may be something really simple you overlooked: make sure your form contains the enctype=”multipart/form-data” part.
Extension not found error when trying to run the DB package for php Pear
This only means you did not configure that specific database to be compiled with php. For example, if you get that error when trying to connect to a mysql database, make sure that when you run ./configure (when installing php) you included the -with–mysql option.
Example on how to use php smarty foreach control structure
<p><!–StartFragment –> {foreach from=$advertiser_categories item=category}<br /> </p> <li><input id=”category_id_{$category}” type=”checkbox” name=”category_id[]” value=”{$category}” />{$category}</li> <p> <br /> {/foreach} Keywords: notes, code</p> Keywords: notes, code
PHP: To turn off only warnings and still show errors
Use the following line on your code: error_reporting(E_ERROR); You can also turn it off on your php.ini file (not recommended): error_reporting = E_ERROR
PHP: Do not use fopen() to read XML files into xml_parse(
was using the following function to get a xml url from the web, create a handle, read the content, and then feed it to xml_parse(): if (!($fp = fopen($xml_file, ‘r’))) { die(’Cannot open XML data file: ‘.$xml_file); return false; } $bytes_to_parse = 1024; while ($data = fread($fp, $bytes_to_parse)) { $parse = xml_parse($this->xml, $data, feof($fp)); if […]