RSS

Category Archives: wordpress

common errors and tips while coding in wordpress

Playing with WordPress Interface

Being priceless and free at the same time, wordpress is web based application software (content management system CMS), one can use to create flexible, interactive and dynamic website or blogs. More than 60 million user and developers are sharing wordpress home and enjoining being a part of wordpress family. Over thousands of templates and themes are volunteered by wordpress developers for transforming your themes into reality. Hundreds of well equipped developers contributed in developing the core of the CMS and are still there to facilities error fixing.
Want to skin your wordpress blog (weblog)? WordPress theme system is there. Skinning the theme? Yes it’s like look and feel. Only design is changed in wordpress theme that refers to skinning wordpress blog. WordPress theme is flexible enough in the way to not only providing the design and presentation of the website but also the database control over the theme. It’s just a collection of files connected together to build a graphical interface. Template files are the files showing this presentation. Without changing the core files, these template files are there working separately on the basis of hook architecture – the supporting architecture of wordpress. There are number of file types included in the new customized template like php (with naming like *.php), cascading style sheets (named as *.css) and supporting images (*.png, *.gif, *.jpg etc).
One way of learning theme coding in wordpress is to modify the built-in theme Twenty Ten, Twenty Eleven or Twenty Twelve by changing the div placements and adding content there in the theme files. But before digging deep into it some basics like the theme files structure is required. WordPress theme, at least, consists two files index.php (having the template i.e. html) and a style.css (basic theme styles are defined here). If the theme is child type then one style file is sufficient in the theme directory, no template files is then required as the template is inherited from the parent file. Maximum number of files varies as per the requirement. Conventional wordpress site with four main blocks i.e. header, footer, sidebar and main content will have an optimal 6 number of files.
All the built in wordpress themes are contained in wp-content/themes directory. Same directory will be used for placing the custom themes. For creating a theme from scratch, just create your directory, for instance named first_theme, in wp-content/themes/ directory and place the following blank files in the directory: index.php (main file to control display), header.php (top information like menu of the web page that is to be repeated in all web pages), sidebar.php (left or right block content need to be there throughout site), footer.php (bottom content with navigations or copy write related information), functions.php (repeated functionality i.e. php custom functions are defined here), and style.css (as name sound it – all of the site style is residing in this file). And now start tracing the code from any of Twenty Ten, Twenty Eleven or Twenty Twelve and record your experiment.
Let’s move on and play with your theme but don’t forget to mention how you find playing with wordpress interface?
 
Leave a comment

Posted by on October 14, 2012 in wordpress

 

Tags: , , ,

Express Your Theme in WordPress

WordPress is an open source content management system (CMS) providing with blogging services like posts, comments, image galleries, video uploaders, zipping database or extracting files etc. Developed in open source programming language PHP, it offers with number of built in functionalities. Free hosting services are also offered by the host by simply registering the blog and accessing it through wordpress specific unique reference link. Free blog offers with limited set of functionalities like categorizing the posts and managing comments. In order to modify the blog in terms of fulfilling the cause, one has to buy a domain for customization services.
Wordpress can be extended by two ways; either by customizing the functionalities or by modifying the interface or design. Hook architecture is followed in wordpress for customization purpose in order to keeping the code clean, maintained and reusable. Thus it offers a way to modify the functionalities without messing up with the core code of wordpress. For wordpress customization, plugins (modifying the functionality) and theme or template (modifying the interface) is used.
How to display the WordPress site to the users and to the web world, templates are there to meet the purpose. HTML code is generated in the template files by fetching the information from the MySQL Database of the WordPress package and then displaying it in web browser. In single theme, wordpress facilitate the definition of number of templates. Calling pattern and usage of the template is defined in the configuration file.
Wordpress community has contributed a lot by providing the free themes of variable layout with classic color schemes. Click here to download number of unique wordpress themes like Pinboard, Responsive, Esquire, Buttercream, Toolbox, Montezuma, Patchwork, News, Annotum Base, Easel, PageLines etc. Any of the freely available themes can be used by simply downloading and installing the theme and then to explore it with the help of number of articles available.
Varity of learner articles are available at wordpress official site demonstrating the basics like Theme Usage (providing the basic guidelines for installing and using template and themes), Themes Migration (Whenever there is an up gradation by the theme developer or an up gradation in theme version due to the change in wordpress new version, there comes compatibility issues addressed by the theme up gradration tutorials), Developing your own theme (If the available freeware themes are not meeting your need, then you can design and develop your own theme from scratch), Theme Frameworks (Theme inheritance is also supported by wordpress in a way to create a parent theme with overlapping functionalities and then to specify differentiating functionalities in child theme files), Admin theme creation (Admin section i.e. dashboard can be managed by separate theme structure), Theme Compatibility list (Some of the themes are generalize enough to work with all wordpress versions, remaining themes having compatibility issues can be checked by the compatibility list provided) and finally the Theme Review (Submission to the directory handling themes and public release preparation can be learned by the theme review tutorials).
How you find expressing your theme in wordpress?
 
Leave a comment

Posted by on October 14, 2012 in wordpress

 

Tags: , ,

[wordpress][tutorial km tip] How to Call plugin function at front end? How to display record listing at front end?

To hook any plugin function at back end, following code is there

add_action('admin_menu', 'action_here');
function action_here() {
add_users_page('Customized Functionality', 'Customized Functionality', 'administrator',
'action_here', 'action_here_function_call');
}
function  action_here_function_call()
{
// functionality definition here.
}

But how to hook  action_here_function_call() at front end without modifying theme.
As in drupal we have ‘Pages’ which execute php code when ‘PHP Filter’ module is enabled, i need the same in wordpress, but wordpress didn’t filter php code by default.
Then I get Exec-PHP plugin, when it get activated any php code in post, pages etc get executed.

Simply create new wordpress page ({base_url}wp-admin/post-new.php?post_type=page) and paste following code in html view:

<?php

action_here_function_call()

?>

Through Custom Menu ({base_url}wp-admin/nav-menus.php) customized tab for the page can be created.
Following are few considerations while executing php code through Exec-PHP plugin:
1) Try to avoid php tags <?php ?> within the function as much as you can, because i observed that tags, within the particular function called at front end, break the code.
2) Avoid extra spaces in javascripting. If there is any js in your function then to execute it remove extra spaces.

Have a nice learning with opensource cms 🙂

 
Leave a comment

Posted by on November 4, 2011 in wordpress

 

Tags: , , , , , ,

[wordpress][error][solution] filemtime or filectime gives 1293858000 (i.e. 01-01-1970 05:00:00)

It takes hours to debug the issue i faced while listing all the files (residing in nested set of directories) with file’s last modified date and file size. It displays 01-01-1970 05:00:00 as a last modified date for all the files and empty file size. I was coding wordpress plugin and the issue arises there. When i paste the code in custom php file it works fine and get correct last modified date and size.
File path was correct as i could see the file content and filename correctly, then whats the magic behind that static date and empty size.

It was all about relative and absolute path.

I was getting file last modified date by filemtime($filename) and file size by filesize($file).
I just make the file path absolute by concatenating complete physical path before $filename as file last modified date by filemtime($physical_path.$filename) and file size by filesize($physical_path.$file).
And alhamdullilah it gets functional 🙂

Note: In most of the cases when built-in function is not correctly displaying the result then ist of all print $_SERVER[‘SCRIPT_FILENAME’]; to check out the path of the executed code (as in wordpress, code in plugin binded by admin related hooks is get called by specific file within wp-admin directory, so specially in wordpress every hook is called by its own file so for relative path one should need to know that particular file or have to use absolute path)

 
Leave a comment

Posted by on November 1, 2011 in wordpress

 

Tags: , , , , , ,

 
%d bloggers like this: