Need oop for wordpress theme? [duplicate]

It will be better if you code theme in OOPS(Object Oriented Programming) because OOPS provides following benefits over normal/procedural oriented programming. Benefits of Object Oriented Programming Modularity: The source code for a class can be written and maintained independently of the source code for other classes. Once created, an object can be easily passed around … Read more

Add class to DIV depending on page loaded

You might want to consider using the WordPress function body_class() <body <?php body_class($class); ?>> Then you could use the body class as your current page reference. This function is for example used by the Twenty-Twelve theme. For a single post it will become <body class=”single single-post …”> and for the home page: <body class=”home blog … Read more

Utilize Function in Child Theme / Template File

When you create a theme, you can use functions.php file for all utilize functions. Also this is the best place for all your require_once calls. One trick I would like to recommend for theme development approach: Don’t use direct require_one call to include your scripts. Instead of it, use locate_template function to load scripts. By … Read more

Include text in echoed hyperlink

Never just print the result of get_the_term_list() without additional checks. It might return an instance of WP_Error which is an object, not a string. Save the result of get_the_term_list() in a variable and print the terms only if there are terms and not an error: <?php $stores = get_the_term_list( $post->ID, ‘store’, ”, ‘, ‘ ); … Read more

Countdown to date function?

You can use the following function to display it <?php function days_to_go(){ $datetime1 = new DateTime(‘2013-3-2’);//Pass resignation date as a parameter. $datetime2 = new DateTime(now); $interval = $datetime1->diff($datetime2); echo $interval->format(‘%a days to go’); } ?> For more information on date_diff function see this page.

Post’s ID pattern?

Each auto-draft gets its own ID, each revision, each nav item, page, custom post type … The actual ID of a post should be irrelevant, this is really just needed for the database and ugly permalinks. You cannot get the last 30 items by inspecting the post ID only. Install a REST API on the … Read more

Creating Database Table vs. Adding MetaData to Post & User

While you might not be writing a plugin specifically, this resource will still be pertinent: http://codex.wordpress.org/Writing_a_Plugin#Plugin_Development_Suggestions From the codex Use the existing database tables instead of creating new custom tables if possible. Most use-cases can be accomplished with custom post types and meta data, custom taxonomy and/or one of the other standard tables and using … Read more

Removing the comment function within wordpress

Will unchecking these options not satisfy your needs (especially the last one)? Attempt to notify any blogs linked to from the article Allow link notifications from other blogs (pingbacks and trackbacks) Allow people to post comments on new articles All can be found at the top of the Discussion Settings page.

customize wordpress database error page

This works fine for me as db-error.php in wp-content: Delete the mailer block if you don’t want it <?php header(‘HTTP/1.1 503 Service Temporarily Unavailable’); ?> <?php $to = “[email protected]”; $subject = “My Database is down”; $message = “My Database is down”; $headers = “MIME-Version: 1.0\n”; $headers .= “Content-type: text/plain; charset=iso-8859-1\n”; $headers .= “X-Mailer: php\n”; $headers … Read more