adsense

How to Write Code for WordPress Syntax





Write the HTML
1. Write your Web site's HTML first. HTML provides the structure for Web pages, while all other Web languages -- for example, CSS, JavaScript and PHP -- add functionality and style afterwards. Make sure to use the proper doctype declaration for whichever HTML specification you use, whether HTML5 or XHTML.
2. Write well-formed HTML, and even when writing HTML5, close all tags and self-closing tags like '' by adding a space and a backslash, like this: '
'. Enclose your attribute values in single or double quotes. Use the W3C Validator service to check your code.

3. Cut up your HTML file into the following parts: header, body, sidebar and footer. The header begins with your doctype declaration and ends wherever the heading ends, not at the end of the '
' tag itself. The footer ends with your final '
' tag. Save these files as header.php, index.php, sidebar.php and footer.php, respectively.
Write the CSS
4. Write your theme's CSS in the style.css file. While you can include more CSS files in your themes, to minimize the number of server requests, write as much of your CSS in one file as you can.
5. Put each CSS selector on its own line, even when chaining selectors together. The Codex states that you should write each property-value pair on its own line as well, so do not write entire style rules on one line. Here is an example of proper CSS:#something {property: value;property: value;}
6. Write your selectors as single words without spaces or, if necessary, separate words in class names and IDs by using dashes. Do not 'camelcase' class and ID names, such as writing 'authorpage' as 'authorPage.' This is common in JavaScript but poor form in CSS.
Write the PHP
7. Replace HTML code in your PHP files with template tags wherever the page needs to load content written in the WordPress dashboard. Wrap template tags in opening and closing PHP tags as follows:

8. Wherever the template files load images, scripts or any other files that make up the theme, use 'bloginfo()' to make the path relative, as in the following example:
/js/myscript.js'>

9. Create a blank file, and save it as functions.php. Add your custom PHP functions to this file so that you can call them in any of your template files. Write your PHP by using alternating single and double quotes instead of escaping quotes with backslashes. Never write shorthand PHP tags anywhere in your theme. Capitalize any SQL database statements such as 'UPDATE' or 'WHERE ID.' Use proper indentation, and make your code as readable as possible.

Comments

0 Responses to "How to Write Code for WordPress Syntax"

Post a Comment

Popular Posts

About