Articles of best practices

Why Does WordPress not output admin-ajax.php path by default?

It’s not uncommon for WordPress sites to have 10+ instances of the admin-ajax.php path outputted to the front-end for use by plugins and themes. Does anyone know if there is a reason WordPress core hasn’t added this as a default? It seems like it would save a ton of duplication.

How to create a list of items with fields in WordPress?

I’m new to WordPress and hoping some of you experts can help me figure out the best way to attack what seems like such a simple problem. I need to have two lists of items that the user can add to, delete and update that will show up on the home page of the site. […]

TwentyTen: Overloading template.php files vs. get_template_part

I’m studying TwentyTen, under the assumption that it contains the best practices for writing themes and modifying them using child themes. I’m noticing what looks like a really redundant practice, which is to overload not the base template file (eg: attachment.php) but instead to overload the template-part file (eg: loop-attachment.php). Can someone explain the benefit […]

apply filters only to specific post listing without check the url parameters

I have made a custom post type named as: slider, in my plugin class, I am adding a filter which calls the method remove_row_action that unsets view links from actions add_filter(‘post_row_actions’, array(&$this, ‘remove_row_actions’), 10, 1); public function remove_row_actions($action) { if (isset($_GET[‘post_type’]) && $_GET[‘post_type’] == ‘slider’)) { unset($action[‘view’]); return $action; }else{ return $action; } } It […]

Custom plugins/Manipulated plugins: Always a terrible idea to inherit these types of WP sites that discourage updates?

So I have been working on WP sites for a little bit now and I think I’m getting to the point where I’m starting to get to a wider range of clients with unique site builds. One site I was assigned to lately was a WP site that dealt with Automobile inventory and its biggest […]

WordPress for a business catalog site

I am completely noob with WordPress so I apologize in advance if my questions sounds completely stupid. Background I have a small business catalog site that I wrote long ago in plain HTML. Now I want to add some SEO and improve the design therefore I am looking to use a CMS for easy content […]

What is the best way to handle multiple calls to get_template_directory_uri() and similar functions?

Edit: Thanks for your replies, guys. This is exactly what I was after. You each brought up some good points. I think I’ll stick with using constants. This is really a best practices/performance question. I’m mainly concerned with the following functions: get_template_directory_uri() get_template_directory() get_stylesheet_directory_uri() get_stylesheet_directory() I’ve been under the impression that it is bad practice […]

Who is responsible for data sanitization in WordPress development?

I am studying how to write more secure WordPress code by implementing validation, sanitization and data escaping wherever necessary. Validation and escaping makes perfect sense, but I am a little confused about sanitization. If I use a function like add_post_meta, does this function do sanitization for me? What about set_option or other ones that interact […]

Should non-WordPress data get its own DB?

I couldn’t find anything on Google or on here about best practice for data that is not really WordPress related. Say we have a database of clients that we’ll be accessing through PHP/SQL. Should I just create new tables within the wordpress database or is it good practice to keep these in completely separate databases? […]

Failed to invoke other hook from the init hook

Related to this question (Use wp init hook to call other hooks?) but not the same. Sometimes, I found that the hook will failed to run when I place inside the init hook, e.g. Not Work: add_action(‘init’,’my_init’); function my_init() { add_filter(‘locale’, … } Work: add_action(‘init’,’my_init’); add_filter(‘locale’, … Of course some hooks/filters will just work okay […]