Sunday, May 11, 2008

Wordpress PHP functions

Today I would like to mention about some php commands required for making a wordpress site. Creating a Wordpress template is not that much hard unless you know some basic php. I initially thought of making a step by step video tutorial on this. But due to the lack of time and some other limitation I decided to make it short. I will teach you some basic php, but before that I am giving the complete list of files

  • style.css

  • index.php

  • home.php

  • single.php

  • page.php

  • archive.php

  • category.php

  • search.php

  • 404.php

  • comments.php

  • comments-popup.php

  • author.php

  • date.php



Don't worry. you just need to make a blank file with that name

PHP Basics


PHP - Hypertext Preprocessor


File Extensions The usual web server configuration is that somefile.php will be interpreted by PHP,
whereas somefile.html will be passed straight through to the web
browser, without PHP getting involved.

The <?php tag tells PHP that everything that
follows is program code rather than HTML, until the closing ?> tag


Understanding Variables


Variables containers in which values can be stored and later retrieved are a fundamental building block of any programming language.

For instance, you could have a variable called number
that holds the value 5 or a variable called name that holds
the value Chris. The following PHP code declares variables with those
names and values:

$number = 5;

Arguments and Return Values

Every function call consists of the function name followed by a list of arguments in parentheses. If there is more than one argument, the list items are separated with commas. Some functions do not require any arguments at all, but a pair of parentheses is still requiredeven if there are no arguments contained in them.

The built-in function phpinfo generates a web page that contains a lot of information about the PHP module. This function does not require any arguments, so it can be called from a script that is as simple as

<?php phpinfo();?>

If you create this script and point a web browser at it, you will see a web page that contains system information and configuration settings.

Now its time for wordpress

Wordpress has a set of built-in functions and arguments. All we have to do is use these. This is a short tutorial and I will keep everything short.



<?php bloginfo('name'); ?>

Display the name (title) of the blog. This command calls for the argument name in the function bloginfo. The blog name is nothing but what you have as Weblog title from the wordpress. This can be inserted between <title><title/> tags.



<?php bloginfo('url'); ?>

This one displays the url of the blog. Here also "bloginfo" is the function. This command calls the argument "url" in the function "bloginfo".



<?php bloginfo('description') ?>

This displays the caption of the blog. In default, its result will be "Just another wordpress blog".



<?php have_posts() ?>

It checks to see if you have any post.

<?php the_post() ?>

Calls for the posts.

<?php the_title(); ?>

This function calls the title of the current blog post.

<?php the_permalink(); ?>

This function that calls for the address or location of each post.

<?php the_content(); ?>

It displays the post



<?php _e('Filed under:'); ?>

It is the code to call for a colon ":"



<?php the_category(', ‘); ?>

the_category() is the PHP function that calls for all the categories that you tagged your post with. If you put Filed under: and the_category() together. You'd get Filed under: Name of category 1, Name of category 2. The comma within the_category() is a way of separating the category names.



<?php _e('by'); ?>
same as Filed under:. If you're creating the theme for personal use, wrapping _e() around the word by isn't necessary.



<?php the_author(); ?>

self explanatory. It simply prints your name or whoever published the post.



<?php comments_popup_link('No Comments »', ‘1 Comment »', ‘% Comments »'); ?>

comments_popup_link() calls for a pop up window of your comments, when popup comment is activated. If popup comment isn't activated, comments_popup_link() simply send you to the list of comments. No Comments » is what will be displayed when you have no comments. 1 Comment » is when you have exactly one comment. % Comments &187; is for when you have more than one comment. For example: 8 Comments ». The percent sign % means number. » is a code to display a double arrow.



<?php edit_post_link('Edit', ‘ | ‘, "); ?>

This is only visible when you are logged in as an administrator. edit_post_link() simply displays an edit link for you to select which post to edit, instead of having to browse through all the posts from the administration panel to search for the one you want to edit. edit_post_link() has three sets of single quotes. The first set is for what word you will use for the link title of the edit link. If you use Edit post, then it'll say Edit post instead of Edit. The second set of single quotes is for whatever that comes before the link. In this case, a vertical line |; that's what the &124; code is for. The third set of single quotes is for whatever that you want to come after the edit link. In this case, nothing comes after it.

<?php posts_nav_link(); ?>

At the bottom of most WordPress blogs, there's a Next Page or Previous Page link. You call for those links by using the posts_nav_link() function of the WordPress template system.



<?php wp_list_cats('sort_column=name&optioncount=1&hierarchical=0′); ?>

This function calls for the list of categories to be displayed. You can further customize them using the following arguments.

  • sort_column=name - list category links alphabetically

  • optioncount=1 - display the number of posts made under each category

  • hierarchial=0 - don't turn sub-categories into sub-list-items, which explains why my Sub Category link is listed in the first level of the list.

  • & - each time you add on another attribute, you have to type & before it to separate it from the existing attributes. For example & sits in between sort_column and optioncount.




<?php wp_list_pages(); ?>

This function generates the full list of links for all pages.


<?php wp_get_archives('type=monthly'); ?>


This function call for archive links by month, nest each. Here, "month" is the argument.



<?php get_links_list(); ?>

Add your blogroll links to the your blog.

Thats all for now folks.

13 comments:

Anonymous said...

useful list

Anonymous said...

how to buy cialis without a prescription cialis vs viagra buy viagra generic,
cialis sin receta cialis free trial discount sale viagra,
cialis viagra levitra samples buy cialis in the uk cheap extra strength viagra from canada,
buy generic cialis order prescription cialis cheap generic viagra overnight delivery,
cialis generico sicuro generic cialis overnight buy viagra on line
snu smu mrik

Anonymous said...

cialis generico online buy cialis professional online viagra 6 free samples,
unicure cialis soft tabs buy cialis online canada viagra online without prescription,
cialis bestellen online non prescription generic cialis viagra generic name,
generic cialis overnight unicem cialis soft tabs cheapest viagra in uk,
discount cialis levitra viagra buy cheap cialis viagra discount europe
snu smu mrik

Anonymous said...

does cialis always work the first time lowest price generic cialis no perscription purchasing viagra in the united kingdom,
canadian drug cialis order prescription cialis buy viagra online without prescription,
cialis attorney ohio cialis generika best herbal viagra,
generic for cialis order cialis buy viagra online canada,
cialis bestellen schweiz cialis bestellen cheapest prices on generic viagra
snu smu mrik

Anonymous said...

cialis message board buy daily cialis are there any side effects with the drug viagra,
free cialis samples cialis free shipping viagra generique france,
itc exclusion order cialis cialis professional canadian canada viagra supply uk,
order cialis cialis generic cheapest free viagra samples before buying,
free cialis samples how long does cialis last generic no prescription viagra
snu smu mrik

Anonymous said...

cialis forum cialis online bestellen buy viagra in london england,
buy generic cialis comprar cialis online generic viagra sale,
acheter cialis original comprar cialis internet comprar viagra sin receta,
buying generic cialis cialis reviews viagra generico acquisto,
cialis prices in canada and usa cialis kaufen ohne rezept get viagra online
snu smu mrik

Anonymous said...

cialis 5 mg online cialis one a day cost viagra benefits side effects,
does cialis always work the first time achat cialis viagra cheap viagra for men,
buy cialis usa buy cialis with discover card generic cheap viagra licensed pharmacies,
cialis super inthe uk unicem cialis soft tabs buy viagra online inu,
legally buy cialis on line buy cialis online best price for viagra
snu smu mrik

Anonymous said...

cialis generica free cialis compare cialis levitra viagra,
buy cialis uk cialis non generic natural viagra alternatives,
cialis online no prescription cialis for women viagra free newsletter signup,
cheap cialis no prescription achat cialis en ligne cheap viagra sales,
comprar cialis internet generic cialis tabs buy viagra uk
snu smu mrik

Anonymous said...

cialis sicher kaufen buy generic cialis viagra discounts senators,
cialis prices at true pharmacies cialis compra non prescription viagra,
buy cialis online viagra cheap cialis is viagra ok for women,
comprar cialis order cialis cod comprar viagra generica en espa?a,
cipla cialis soft tabs generic cialis vs cialis cialis viagra levitra
snu smu mrik

Anonymous said...

buy cialis with paypal bodybuilding forum cialis cheap drugs viagra cialas,
cialis rezeptfrei europa cialis kaufen ohne rezept viagra generic lowest price,
generic viagra levitra cialis generic cialis uk how does viagra work,
cialis non generic from canada buy brand name cialis bad side effects of viagra,
cialis to buy new zealand achat cialis viagra buy generic viagra on line
snu smu mrik

Anonymous said...

cialis generico 10 mg viagra cialis free sample ed pill store your ho online viagra,
cheap cialis generic levitra viagra free cialis videos comprar viagra online,
buy cialis online viagra cheapest cialis generic viagra online,
cialis prices in canada and usa buying generic cialis herbal viagra for woman,
dosage for cialis super soft cialis discount viagra united kingdom
snu smu mrik

Anonymous said...

cialis generico mexico comprar cialis generico en espa?a viagra gels cheap,
generic cialis fedex cheap cialis no prescription drink female viagra,
acquistare cialis cialis levitra viagra generic viagra samples,
buy cialis online no prescription cialis lawyer ohio generic viagra from india,
acquistare cialis in italia cialis viagra price comparison
snu smu mrik

Anonymous said...

order cialis no prescription cialis non generic online viagra generic quick,
cheap viagra cialis levitra buy viagra cialis viagra online,
cheap cialis 20 mg 60 pills cialis soft tabs buy viagra online online a href,
cialis farmacia online low cost cialis cheap viagra in uk,
what are the side effects of cialis buy cialis with discover card viagra generic canada
snu smu mrik