Template function parameters
<?php the_time() ?>
...which will display the time of the current post, using the default time format.
However, many of these functions can accept optional parameters bewteen the brackets (). For example you could write:
<?php the_time( '%Y-%m-%d %H:%M:%S', 'Posted:' ) ?>
...which would display a full date + time for the current post, preceded by the text 'Posted:'.
How do I know which optional parameters I can use?
The best way for you to learn about available optional parameters, is to look at the the template functions list? and follow the link to the technical documentation for any specific function.
Notes about parameters
To add a parameter to a function, simply include it between the brackets (). If it is text (instead of a number), add quotes around the parameter. Examples:
<?php my_tag( 'my text parameter' ); ?> <?php my_tag( 123 ); ?>
You may have to specify several parameters... In this case, you must separate them with commas, like this:
<?php my_tag( 'first param', 'second param' ); ?>
The order of parameters is important! You must follow the exact order of the parameters as indicated in the technical documentation.
If a function accepts 3 parameters and you only want to set the third one, you still have to provide the first two parameters. In this case, you could simply use the default values for these parameters, as specified in the technical documentation.
<?php my_tag( '', '#', 'second param' ); ?>
Please note: the default value for optional parameters is often '' or '#'.
Some template functions, like the_date(), display something only if in some conditions. They generally accept parameters to display something before and after the output, only when they display something.
<?php the_title( '<h1>', '</h1>' ); ?>
would display <h1>title of the post</h1> only if the post has a title
Created by • Last edit by on 2012 Nov 18
No feedback yet
Form is loading...