Showing posts with label Wordpress. Show all posts
Showing posts with label Wordpress. Show all posts

To change the admin side font and any style include the following code in function.php of your theme

<style type="text/css">

body {

font-family: verdana !important;

 font-size: 13px !important;

}

</style>

So you want to add a custom Role to your WordPress site to add more flexibility when assigning users their role, what do you do? Simply add a role, with a few lines of code in your theme’s functions.php file, using WordPress’ add_role() function, as defined below.

add_role( $role_name, $display_name, $capabilities );

The example below adds a role of Video Manager with a custom cabability of ‘manage videos’.

add_role( 'video_manager, 'Video Manager', array( 'manage_videos' ) );

NOTE: Once you add this code to your functions.php file and view any page on your site to make the role addition, you can and should comment it out so that it doesn’t run on every page view.

Now, how do we use this new role with the new capability you ask? Simply use the WordPress current_user_can() function to check the user’s capability.

if ( current_user_can( 'manage_videos' ) ) {
// let them manage those videos!
}

Regards:http://camwebdesign.com
WordPress Plugin: A WordPress Plugin is a program, or a set of one or more functions, written in the PHP scripting language, that adds a specific set of features or services to the WordPress weblog, which can be seamlessly integrated with the weblog using access points and methods provided by the WordPress Plugin Application Program Interface (API).

Creating a Plugin

This section of the article goes through the steps you need to follow, and things to consider when creating a well-structured WordPress Plugin.
Names, Files, and Locations
Plugin Name

The first task in creating a WordPress Plugin is to think about what the Plugin will do, and make a (hopefully unique) name for your Plugin. Check out Plugins and the other repositories it refers to, to verify that your name is unique; you might also do a Google search on your proposed name. Most Plugin developers choose to use names that somewhat describe what the Plugin does; for instance, a weather-related Plugin would probably have the word "weather" in the name. The name can be multiple words.
Plugin Files

The next step is to create a PHP file with a name derived from your chosen Plugin name. For instance, if your Plugin will be called "Fabulous Functionality", you might call your PHP file fabfunc.php. Again, try to choose a unique name. People who install your Plugin will be putting this PHP file into the WordPress Plugin directory in their installation, wp-content/plugins/, so no two Plugins they are using can have the same PHP file name.

Another option is to split your Plugin into multiple files. Your WordPress Plugin must have at least one PHP file; it could also contain JavaScript files, CSS files, image files, language files, etc. If there are multiple files, pick a unique name for a file directory and for the main PHP file, such as fabfunc and fabfunc.php in this example, put all your Plugin's files into that directory, and tell your Plugin users to install the whole directory under wp-content/plugins/. However, an installation can be configured for wp-content/plugins to be moved, so you must use plugin_dir_path() and plugins_url() for absolute paths and URLs. See: http://codex.wordpress.org/Determining_Plugin_and_Content_Directories for more details.

In the rest of this article, "the Plugin PHP file" refers to the main Plugin PHP file, whether in wp-content/plugins/ or a sub-directory.
Readme File

If you want to host your Plugin on http://wordpress.org/extend/plugins/, you also need to create a readme.txt file in a standard format, and include it with your Plugin. See http://wordpress.org/extend/plugins/about/readme.txt for a description of the format.

Note that the WordPress plugin repository takes the "Requires" and "Tested up to" versions from the readme.txt in the stable tag.
Home Page

It is also very useful to create a web page to act as the home page for your WordPress Plugin. This page should describe how to install the Plugin, what it does, what versions of WordPress it is compatible with, what has changed from version to version of your Plugin, and how to use the Plugin.
File Headers

Now it's time to put some information into your main Plugin PHP file.
Standard Plugin Information

The top of your Plugin's main PHP file must contain a standard Plugin information header. This header lets WordPress recognize that your Plugin exists, add it to the Plugin management screen so it can be activated, load it, and run its functions; without the header, your Plugin will never be activated and will never run. Here is the header format:



The minimum information WordPress needs to recognize your Plugin is the Plugin Name line. The rest of the information (if present) will be used to create the table of Plugins on the Plugin management screen. The order of the lines is not important.

The License slug should be a short common identifier for the license the plugin is under and is meant to be a simple way of being explicit about the license of the code.

Important: file must be in UTF-8 encoding.
License

It is customary to follow the standard header with information about licensing for the Plugin. Most Plugins use the GPL2 license used by WordPress or a license compatible with the GPL2. To indicate a GPL2 license, include the following lines in your Plugin:



Programming Your Plugin

Now, it's time to make your Plugin actually do something. This section contains some general ideas about Plugin development, and describes how to accomplish several tasks your Plugin will need to do.
WordPress Plugin Hooks

Many WordPress Plugins accomplish their goals by connecting to one or more WordPress Plugin "hooks". The way Plugin hooks work is that at various times while WordPress is running, WordPress checks to see if any Plugins have registered functions to run at that time, and if so, the functions are run. These functions modify the default behavior of WordPress.

For instance, before WordPress adds the title of a post to browser output, it first checks to see if any Plugin has registered a function for the "filter" hook called "the_title". If so, the title text is passed in turn through each registered function, and the final result is what is printed. So, if your Plugin needs to add some information to the printed title, it can register a "the_title" filter function.

Another example is the "action" hook called "wp_footer". Just before the end of the HTML page WordPress is generating, it checks to see whether any Plugins have registered functions for the "wp_footer" action hook, and runs them in turn.

You can learn more about how to register functions for both filter and action hooks, and what Plugin hooks are available in WordPress, in the Plugin API. If you find a spot in the WordPress code where you'd like to have an action or filter, but WordPress doesn't have one, you can also suggest new hooks (suggestions will generally be taken); see Reporting Bugs to find out how.
Template Tags

Another way for a WordPress Plugin to add functionality to WordPress is by creating custom Template Tags. Someone who wants to use your Plugin can add these "tags" to their theme, in the sidebar, post content section, or wherever it is appropriate. For instance, a Plugin that adds geographical tags to posts might define a template tag function called geotag_list_states() for the sidebar, which lists all the states posts are tagged with, with links to the state-based archive pages the Plugin enables.

To define a custom template tag, simply write a PHP function and document it for Plugin users on your Plugin's home page and/or in the Plugin's main PHP file. It's a good idea when documenting the function to give an example of exactly what needs to be added to the theme file to use the function, including the .
Saving Plugin Data to the Database

Most WordPress Plugins will need to get some input from the site owner or blog users and save it between sessions, for use in its filter functions, action functions, and template functions. This information has to be saved in the WordPress database, in order to be persistent between sessions. There are three methods for saving Plugin data in the database:

Use the WordPress "option" mechanism (described below). This method is appropriate for storing relatively small amounts of relatively static, named pieces of data -- the type of data you'd expect the site owner to enter when first setting up the Plugin, and rarely change thereafter.
Post Meta (a.k.a. Custom Fields). Appropriate for data associated with individual posts, pages, or attachments. See post_meta Function Examples, add_post_meta(), and related functions.
Create a new, custom database table. This method is appropriate for data not associated with individual posts, pages, attachments, or comments -- the type of data that will grow as time goes on, and that doesn't have individual names. See Creating Tables with Plugins for information on how to do this.

WordPress Options Mechanism

See Creating Options Pages for info on how to create a page that will automatically save your options for you.

WordPress has a mechanism for saving, updating, and retrieving individual, named pieces of data ("options") in the WordPress database. Option values can be strings, arrays, or PHP objects (they will be "serialized", or converted to a string, before storage, and unserialized when retrieved). Option names are strings, and they must be unique, so that they do not conflict with either WordPress or other Plugins.

Here are the main functions your Plugin can use to access WordPress options.

add_option($name, $value, $deprecated, $autoload);

Creates a new option; does nothing if option already exists.
$name
Required (string). Name of the option to be added.
$value
Optional (mixed), defaults to empty string. The option value to be stored.
$deprecated
Optional (string), no longer used by WordPress, You may pass an empty string or null to this argument if you wish to use the following $autoload parameter.
$autoload
Optional, defaults to 'yes' (enum: 'yes' or 'no'). If set to 'yes' the setting is automatically retrieved by the wp_load_alloptions function.

get_option($option);

Retrieves an option value from the database.
$option
Required (string). Name of the option whose value you want returned. You can find a list of the default options that are installed with WordPress at the Option Reference.

update_option($option_name, $newvalue);

Updates or creates an option value in the database (note that add_option does not have to be called if you do not want to use the $deprecated or $autoload parameters).
$option_name
Required (string). Name of the option to update.
$newvalue
Required. (string|array|object) The new value for the option.

Administration Panels

Assuming that your Plugin has some options stored in the WordPress database (see section above), you will probably want it to have an administration panel that will enable your Plugin users to view and edit option values. The methods for doing this are described in Adding Administration Menus.
Internationalizing Your Plugin

Once you have the programming for your Plugin done, another consideration (assuming you are planning on distributing your Plugin) is internationalization. Internationalization is the process of setting up software so that it can be localized; localization is the process of translating text displayed by the software into different languages. WordPress is used all around the world, so it has internationalization and localization built into its structure, including localization of Plugins.

Please note that language files for Plugins ARE NOT automatically loaded. Add this to the Plugin code to make sure the language file(s) are loaded:

load_plugin_textdomain('your-unique-name', false, basename( dirname( __FILE__ ) ) . '/languages' );

To fetch a string simply use __('String name','your-unique-name'); to return the translation or _e('String name','your-unique-name'); to echo the translation. Translations will then go into your plugin's /languages folder.

It is highly recommended that you internationalize your Plugin, so that users from different countries can localize it. There is a comprehensive reference on internationalization, including a section describing how to internationalize your plugin, at I18n for WordPress Developers.
Plugin Development Suggestions

This last section contains some random suggestions regarding Plugin development.

The code of a WordPress Plugin should follow the WordPress Coding Standards. Please consider the Inline Documentation Standards as well.
All the functions in your Plugin need to have unique names that are different from functions in the WordPress core, other Plugins, and themes. For that reason, it is a good idea to use a unique function name prefix on all of your Plugin's functions. A far superior possibility is to define your Plugin functions inside a class (which also needs to have a unique name).
Do not hardcode the WordPress database table prefix (usually "wp_") into your Plugins. Be sure to use the $wpdb->prefix variable instead.
Database reading is cheap, but writing is expensive. Databases are exceptionally good at fetching data and giving it to you, and these operations are (usually) lightning quick. Making changes to the database, though, is a more complex process, and computationally more expensive. As a result, try to minimize the amount of writing you do to the database. Get everything prepared in your code first, so that you can make only those write operations that you need.
SELECT only what you need. Even though databases fetch data blindingly fast, you should still try to reduce the load on the database by only selecting that data which you need to use. If you need to count the number of rows in a table don't SELECT * FROM, because all the data in all the rows will be pulled, wasting memory. Likewise, if you only need the post_id and the post_author in your Plugin, then just SELECT those specific fields, to minimize database load. Remember: hundreds of other processes may be hitting the database at the same time. The database and server each have only so many resources to spread around amongst all those processes. Learning how to minimize your Plugin's hit against the database will ensure that your Plugin isn't the one that is blamed for abuse of resources.
Eliminate PHP errors in your plugin. Add define('WP_DEBUG', true); to your wp-config.php file, try all of your plugin functionality, and check to see if there are any errors or warnings. Fix any that occur, and continue in debug mode until they have all been eliminated.
Try not to echo

<script> and <style> tags directly - instead use the recommended wp_enqueue_style() and wp_enqueue_script() functions. They help eliminate including duplicate scripts and styles as well as introduce dependency support. See posts by the following people for more info: Ozh Richard, Artem Russakovskii, and Vladimir Prelovac.

Reference : <a href="http://codex.wordpress.org">http://codex.wordpress.org</a>

By default, every wordpress powered site’s login page is located @ http://yoursite/wp-login.php url. Registration and reset pages are called by adding an action query in login ( wp-login.php ) page url. Reset page comes with a lostpassword query attribute for action, like http://yoursite/wp-login.php?action=lostpassword will display the reset page and action=register displays the registration page. Remember, this is the default rules if you are not using any login or registration management plugin, buddypress or any theme with custom login page option.
It comes with a wordpress.org logo image on wordpress default login page, and i think most of the people don’t want to show wordpress.org logo rather than their own site logo or defined image. Moreover, the wordpress.org logo is linked to the wordpress.org site with anchor title attribute “powered by wordpress”. Now, I will show you how to change this without affecting the core files.

Customizations

The wordpress.org logo file has 67px height and 326px width, so crop your image to this dimension first ( size actually doesn’t matter, for using bigger image, u need some css adjustment ). First, grab the new image url to replace wordpress.org pic, and place it on below code -
add_action( 'login_enqueue_scripts', 'w4_login_enqueue_scripts' );
function w4_login_enqueue_scripts(){
echo '';
}
If the image url is perfect and everything is fine, you will see your new login page image.
The login_enqueue_scripts is called just before the login_head action on wp-login.php file line 82 on wordpress version 3.1.1, and calling our function with this action will place our Css inside login header tag.
#login h1 a is used to identify the image anchor with CSS. Image Css Customization can be done with #login h1 a.
To change the wordpress login page image url address to your site home page url
add_filter( 'login_headerurl', 'w4_login_headerurl');
function w4_login_headerurl(){
 return home_url('/');
}
To use any other url replace home_url('/') to the url.
To change the wordpress login page image title to your sitename
add_filter( 'login_headertitle', 'w4_login_headertitle');
function w4_login_headertitle(){
 return get_bloginfo('title', 'display' );
}
To use any other title replace get_bloginfo('title', 'display' ) to your title.
Example: As example, view our login page and registration page.

Get familiar with some related functions and hooks for WordPress Login Page

As WordPress login process uses variety of functions and hooks, we can use them for customizing a bit more.
wp_login_url
– is a function to generate the login url address. To change the url of the function we can simply hook to ‘login_url’.
Example:
add_filter( 'login_url', 'mysite_login_url', 10, 2);
function mysite_login_url( $force_reauth, $redirect ){
 $login_url = 'yoursite_login_url';
 if ( !empty($redirect) )
  $login_url = add_query_arg( 'redirect_to', urlencode( $redirect ), $login_url );
 if ( $force_reauth )
  $login_url = add_query_arg( 'reauth', '1', $login_url ) ;
 return $login_url ;
}
This will change the login url to your desire one when the wp_login_url function is called.
login_redirect
– is used to redirect the user after they have logged in successfully.
Example:
add_action( 'login_redirect', 'mysite_login_redirect');
function mysite_login_redirect(){
 return 'your_url';
}
So, this will take your user to your defined url address. You can change it based on yours capability or choice.

Regards:http://w4dev.com
f you want to change default wordpress logo on the wp-login.php page then you can change wordpress logo by your logo by just adding following lines in your theme’s function php files.
function my_custom_login_logo() {
    echo '';
}
add_action('login_head', 'my_custom_login_logo');
 Reference: http://www.snilesh.com
TimThumb PHP Script is a custom image-sizing script, that allows you to produce a cropped and sized version of an image. These are great to use along with a WordPress Magazine Theme. TimThumb has recently been released as open source, and here I will walk you through adding TimThumb to your WordPress theme.
Using TimThumb will require the use of WP Custom Fields.

01. Setting Up The Script

Lets grab the TimThumb.php source code, and save it to our theme directory.
To keep things organized, lets save it in a scripts directory in our theme.
yourdomain.com/wp-content/themes/your-theme/scripts/timthumb.php
Now create a new directory inside of scripts, and name it “cache”
yourdomain.com/wp-content/themes/your-theme/scripts/cache/
Make sure that both directories /scripts/ and /cache/ are set to 755 so they’re writable by the server.

02. Adding The Call To Our Theme Template

Depending on whether you use home.php or index.php, open the appropriate template file up, and lets find The Loop. Look for the calll to the post title, and lets insert the call somewhere below the title, or meta information.
I’m presenting you with 3 options for the call. You can pick which one might suit you best.
Option 01 – Show Image Only

<?php 
 // This will show only the image. 
 //Alter the width and height (in both places) to your needs.
?>     
<?php
  if ( get_post_meta($post->ID, 'thumb', true) ) { ?>
    <div class="postthumb">
            <img src="<?php bloginfo('template_directory'); ?>/scripts/timthumb.php?
            src=<?php echo get_post_meta($post->ID, "thumb", $single = true); ?>&h=150&w=150&zc=1" 
            alt="<?php the_title(); ?>" width="100" height="57" />
    </div>  
<?php } ?>

 
Option 03 – Show image and link image to URL of your choice. Requires
 additional custom field of “imglink”. Could be used for outgoing links,
 or linking a thumb to a full version of the image. This option would 
work best inside of your single.php template.
 
  // This will show the image and link it to anything you place into another 
custom field of "imglink".
  // Alter the width and height (in both places) to your needs.
  ?>
 
 if ( get_post_meta($post->ID, 'imglink', true) ) { ?>
 
echo get_post_meta($post->ID, "imglink", $single = true);   ?>" rel="bookmark" title="Permanent Link to the_title(); ?>"> }   ?> bloginfo('template_directory'); ?>/scripts/timthumb.php?src=   echo get_post_meta($post->ID, "thumb", $single = true); ?>&h=150&w=150&zc=1" alt=" the_title(); ?>" /> if ( get_post_meta($post->ID, 'imglink', true) ) { ?> } ?>
} ?>
 

03. Making Use of Custom Fields

 For creation and use of custom  field refer the post

How to get the custom feild value of post or page in wordpress?

Reference:http://vonlind.com/2008/06/adding-timthumb-to-your-wordpress-theme/

Anyone who’s worked with WordPress before will recognise the structure here. We’re adding an action when the WP Admin initialises to call the function portfolio_register(). In that function we create two arrays, $labels and $args, and then use register_post_type to pull it all together. In doing so we name the new custom post type ‘portfolio’ and tell it to use the arguments from $args.

Step 1

add_action('init', 'portfolio_register');

function portfolio_register() {

$labels = array(
'name' => _x('My Portfolio', 'post type general name'),
'singular_name' => _x('Portfolio Item', 'post type singular name'),
'add_new' => _x('Add New', 'portfolio item'),
'add_new_item' => __('Add New Portfolio Item'),
'edit_item' => __('Edit Portfolio Item'),
'new_item' => __('New Portfolio Item'),
'view_item' => __('View Portfolio Item'),
'search_items' => __('Search Portfolio'),
'not_found' => __('Nothing found'),
'not_found_in_trash' => __('Nothing found in Trash'),
'parent_item_colon' => ''
);

$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'query_var' => true,
'menu_icon' => get_stylesheet_directory_uri() . '/article16.png',
'rewrite' => true,
'capability_type' => 'post',
'hierarchical' => false,
'menu_position' => null,
'supports' => array('title','editor','thumbnail')
);

register_post_type( 'portfolio' , $args );
}

Descriptions
name – this is the (probably plural) name for our new post type
singular_name – how you’d refer to this in the singular (such as ‘Add new ****’)

You can probably work out the rest of $labels for yourself, as they simply refer to different circumstances in which the name of your custom post type would be used.

And now $args:

1 public – should they be shown in the admin UI
2 show_ui – should we display an admin panel for this custom post type
3 menu_icon – a custom icon for the admin panel
4 capability_type - WordPress will treat this as a ‘post’ for read, edit, and delete capabilities
5 hierarchical – is it hierarchical, like pages
6 rewrite – rewrites permalinks using the slug ‘portfolio’
7 supports – which items do we want to display on the add/edit post page

That’s the first simple step, and it should be enough to see your new custom post time in the WordPress admin. Save functions.php and take a look!

Step 2

The next thing we need to do is register a taxonomy. Or, in English, create categories for this new content type.

For example, in our portfolio we want to include the names of technologies and software used to create our work. I’m going to call this taxonomy ‘Skills’, and populate it with things like HTML, CSS and jQuery.

It’s just one line of code:

register_taxonomy("Skills", array("portfolio"), array("hierarchical" => true, "label" => "Skills", "singular_label" => "Skill", "rewrite" => true));

The first item here is the taxonomy name, ‘Skills’. The second is the name of the object type we’re applying it to, in our case the custom post type ‘portfolio’ (which is an array). Finally our arguments; you can find a full list at http://codex.wordpress.org/Function_Reference/register_taxonomy, and here we’re using just three which have the same meaning as described in Step 1.

Add that line of code in and you should now see:
Mobile phones being smarter than ever before, ever wondered how some websites redirect you to the mobile version to make it easier to navigate. I use my Nokia E61i a lot for web browsing, while I am traveling. So it was obvious that I had to try this interesting feature 
Now back to the topic. I did a lot of Google search and found some very interesting websites which list down the process. Basically there are two methods.
1) If using WordPress, redirect to mobile friendly theme
2) Redirect to a mobile version of your website

) If using WordPress, redirect to mobile friendly theme
This is one of the easiest method I found out yesterday.
There is a great plugin (WTap) which you need to install in your base website (e.g. here I did on www.abhizworld.com).
Then install a mobile theme as per your preference. You can find the themes here. I am using the Carrington theme.
After you have installed the plugin, you will get a “Mobile Detector” option in your WordPress Dashboard.


This plug-in is so awesome that it gives you the flexibility to define what you want to do for every device type. (a) You can select a theme which you want to present for a mobile OR (b) redirect the user to your mobile URL (e.g m.abhizworld.com).
As shown in the example above, I have redirected iPhone/iPad devices to the Carrington mobile theme and for “Palm” devices, I redirect them to my mobile website (m.abhizworld.com). Please note as soon as you put/select any entry for a device, you have to click the update button individually or else you will lose your changes you did until now
Once done, you are good to go!!!!
Another useful piece of information. I found out that my Nokia mobile browser was not redirecting properly, even if I had the settings for Nokia. Not to worry (did I tell you this plugin was awesome !). When you click the “Mobile Detector”, there is an option to add custom devices.
Here you can mention the device name (just a description) and the “Mobile Device Agent” (this is important). Look at the example below.
2) Redirect to a mobile version of your website
Another method is to redirect your base website to your mobile website URL by detecting which device is accessing your website. Download this file here . Update the variable $mobile="m.abhizworld.com"; to something like
$mobile="yourmobilesite.com";
If you are using wordpress, in your wordpress base directory, there is index.php. Edit the file and add the above entry (i.e from 0)
{
header("location: $mobile");
exit;
}


}
?>

Save the file and you are done!! You can call the php redirection script as well, it depends on you.
Now whenever someone accesses your website from a mobile device, they will be redirect to the mobile URL of your website!
For this method credit goes to Stepforth for providing the easy to use script.



The default image sizes of WordPress are "thumbnail", "medium", "large" and "full" (the size of the image you uploaded). These image sizes can be configured in the WordPress Administration Media panel under Settings > Media. This is how you can use these default sizes with get_the_post_thumbnail():


get_the_post_thumbnail($id); 
// without parameter -> Thumbnail
get_the_post_thumbnail($id, 'thumbnail'); 
// Thumbnail
get_the_post_thumbnail($id, 'medium');
// Medium resolution
get_the_post_thumbnail($id, 'large');
// Large resolution
get_the_post_thumbnail($id, array(100,100) );
// Other resolutions
function the_content_limit($max_char, $more_link_text = '(more...)'
$stripteaser = 0, $more_file = '') {
$content = get_the_content($more_link_text, 
$stripteaser, $more_file);
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
$content = strip_tags($content);

if (strlen($_GET['p']) > 0) {
echo "";
echo $content;
echo "<a href=""the_permalink();</p> <p> 
     echo "">"."Read More</a>";
echo "";
}

elseif ((strlen($content)>$max_char) &&
 ($espacio = strpos($content, " ", $max_char ))) {
$content = substr($content, 0, $espacio);
$content = $content;
echo "
";
echo $content;
echo "...";
echo <a href="";echo the_permalink(); 
echo "">".$more_link_text."</a>";
echo "
";
}

else {
echo "
";
echo $content;
echo "<a href="";echo the_permalink();echo "">"."Read More</a>";
echo "";
}
}
Hi Friends, In this post I am going to write about getting images from wordpress post content, I want this because I want to show post content without images on home page for one of my client, So below is code by which we can get all images one by one from content of post.

// Start the Loop
<?php if (have_posts()) : ?><?php while (have_posts()) : the_post(); ?>
<?php
// Set the post content to a variable
$temppostcontent = $post->post_content;

// Define the pattern to search
$temppattern = '~<img alt="" />]*\ />~';

// Run preg_match_all to grab all the images and save the results in $resultpics
preg_match_all( $temppattern, $temppostcontent, $resultpics );

// Count the results
 $iNumberOfPics = count($resultpics[0]);

// Check to see if we have at least 1 image
if ( $iNumberOfPics > 0 )
{

     // Now here you would do whatever you need to do with the images
     // For this example I'm just going to echo them
     for ( $i=0; $i < $iNumberOfPics ; $i++ )
     {
          echo $resultpics[0][$i];
     };

};

// ...finish the loop,
?>

to get the custom feild value of post or page try with this code
get_post_meta($post_id, 'customfeildname', true);

to set custom field value...

For getting the current page or post id in wordpress try with this
<?php
$post_id = $wp_query->post->ID;
echo  $post_id;
?>
  will displays the current page or post id