For best pratices please see the WordPress coding standards, to be found in the Core Contributor Handbook.

learn more… | top users | synonyms

11
votes
2answers
345 views

Plugin SVN & update API - how are plugins identified?

One thing that's never been clear to me (especially since I haven't submitted a plugin to the repository) is how a plugin's unique "ID" (slug) is generated (i.e. this list). Is it a choice by the ...
4
votes
3answers
294 views

Fallback when Transient API fails

I'm trying to figure out how to best solve an issue I have with 3rd party API's (OG, Foursquare, Yelp, etc.). I use the transient API to call and store the various data in order to: Not exceed any ...
1
vote
1answer
431 views

Is it recommended to pass some data to scripts in `wp_enqueue_scripts`?

I have on many occasions used wp_enqueue_script to pass some 'query variables' to scripts like this: function my_enqueue_scripts(){ $tempurl = urlencode( get_bloginfo( 'template_url' ) ); ...
0
votes
1answer
254 views

What are “best practices” for wp-config.php

Just started reading Professional WordPress®: Design and Development I'm reading the section on "Advanced wp-config Options". I see many options which I think are pretty cool/useful, but before I ...
3
votes
2answers
127 views

Which to use to execute code during the saving of a plugin settings page?

I'm writing a plugin with a settings/option page and I want some php code to be executed whenever someone saves the settings on that page and that page alone. Which actions do I need to hook into to ...
2
votes
1answer
507 views

Recommend a guide to catching plugin errors, please?

I'm working on a small plugin and on some WP installations it throws up the white screen of death. I'm new to this, and would like to know if there is a decent guide out to there (so far my googling ...
0
votes
1answer
3k views

When to use Wordpress loop or Foreach loop?

Under what circumstances would you, (should you?) use a foreach loop, instead of the wordpress loop. I have no real coding need, but I'm curious. What's good practice here? Should I: ...
0
votes
2answers
134 views

Tips for managing code when developing a parent theme framework

I have started work on an open source theme framework that pulls in lots of great code & resources from elsewhere. For example it uses: jQuery Option Framework Theme LESS etc etc. Most of ...
1
vote
2answers
294 views

Applying OO patterns and principles to plugin development

I'm busy writing my first plugin, using PHP 5.3.5. I come from a C# environment, and I must say I'm more than happy with the level of support for good, solid OOP techniques in PHP. However, I'm a ...
5
votes
4answers
4k views

Where to put third party PHP library?

I'm developing a couple of open-source plugins and a theme (all part of a "suite") that all use the same third party PHP library. I'm wondering what is the best way to include it in Wordpress. Here ...
9
votes
1answer
3k views

Using classes instead of global functions in functions.php

In many themes I've seen (including TwentyEleven) and in the examples I've found online, when building the functions.php file for a theme all functionality is declared in a global scope. To clarify, ...
1
vote
1answer
308 views

Limitations when modifying wp_title with a filter

When constructing the HTML <title> attribute in a theme, I found there is a convenient hook for modifying wp_title. However, a quick review of themes indicates using this hook is not common ...
4
votes
2answers
1k views

Remove before_widget / after_widget content from Wp_Widget_Text

I want to take the text widget and remove the preceding / trailing markup from the text output currently showing as <div class="textwidget">Test</div> The before_widget / after_widget ...
4
votes
2answers
691 views

Loop.php vs looping inside template file

What is best practice for WP with regard to using loop.php (loop-single.php, etc) versus looping inside the template file? Does it matter with regard to efficiency or ?
12
votes
1answer
17k views

numberposts? showposts? posts_per_page?

So the documentation on the Codex is pretty clear that showposts is deprecated. But that same documentation mentions nothing of numberposts. Instead, posts_per_page is listed. But if we turn to the ...
1
vote
1answer
68 views

How would I go about creating a user ranked post popularity page?

I currently run a music blog using Wordpress as my CMS and i'm looking to redesign the site in the very near future. Part of my plan for the redesign is to try and integrate a user ranking system for ...
2
votes
1answer
656 views

When to check if a function exists

I've just started developing a WP plugin, and i've been reading some code from other plugins as a way to get started. I've seen a couple of plugins that wrap all or some of their functions in the ...
0
votes
2answers
177 views

separate posts to have (kind of) 2 blogs?

Before putting a lot of effort in this, just to find out it's not possible: Let's say I have two different categories and I want the user to be locked in one of them after choosing it from a ...
1
vote
1answer
150 views

What can I expect when moving from a hosted (WordPress.com) blog to one hosted by Page.ly

As I mentioned here, I'm planning to moving my blog to a new hosting provider from WordPress.com. I think I've settled on Page.ly as the new home for it, and I was hoping to get the benefit of ...
5
votes
3answers
428 views

Editing Complex Pages in Visual Mode

This might be a stupid question, and maybe I've missed some best practices thing, but I've been having this problem with clients using sites on WordPress. Let's say we have a fairly complex page that ...
1
vote
3answers
502 views

will post_id ever change? Can I safely use post_id for custom queries?

What are the best practices for using post_id? Can I use this safely in my templates to call specific posts, or will these post_id's ever change? The reason I ask is that randomly today the ...
11
votes
1answer
7k views

Plugin Form Submission Best Practice

I have done a lot of researching and haven't found quite what I am looking for, so I am hoping that I can be pointed in the right direction. I am developing an Events plugin that will book a ticket ...
5
votes
2answers
3k views

Making $ globally accessible with jQuery.noConflict()

The Codex promotes this method of using $ inside a plugin/theme JavaScript file: jQuery(document).ready(function($) { // $() will work as an alias for jQuery() inside of this function }); But ...
30
votes
8answers
12k views

Conditionally Loading JavaScript/CSS for Shortcodes

I released a plugin that creates a shortcode and requires a JavaScript file and a CSS file to load on any page that contains that shortcode. I could just make the script/style load on all pages, but ...
3
votes
1answer
102 views

What is the canonical way to link to pages?

I can easily link to my archives page by creating a link: <a href="http://server.com/wordpress/archives.php">Archives</a>. As I was editing my WP template, I noticed that there are a ...
52
votes
7answers
13k views

Best collection of code for your .htaccess file [closed]

We have the Best Collection of Code for your functions.php file thread, so I thought that it might be useful to create a thread for our .htaccess files. AND PLEASE REMEMBER TO ADD ANY OF YOUR OWN ...
3
votes
2answers
113 views

WordPress Plugin as 'Library' From Abstract Application?

Here is my thought, and I could be digging myself a huge hole. That's why I'm here ;) I am looking to develop a complex application but I want this application to run both as a standalone script as a ...
5
votes
2answers
819 views

Complex widget form UI - examples and best practices

I'm contemplating a widget with quite a number of options, which will make for a lengthy widget form. To improve the user experience with this form, I'd like to divide it into sections. I don't feel ...
5
votes
4answers
4k views

When is get_template_part() preferable to simply using the template.php files?

In this post on wordpress.stackexchange.com I asked whether using get_template_part(), as demonstrated in the TwentyTen theme, is a recommended best practice. The general consensus I got was that it ...
0
votes
2answers
698 views

Best practice for including plugin output in a template without using shortcode?

I need your recommendation for the best practice here: A custom post type I have created needs a list of attachments at the end of the post content. I have created a series of functions that handle ...
39
votes
3answers
2k views

Opinions and recommendations on the best barebones base theme [closed]

Preamble I'm finding myself building more and more WP sites "from scratch" as it were (ie: ignoring any theme designs out there and just creating a design wireframe purely on the needs of the client. ...
0
votes
2answers
421 views

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, ...
7
votes
4answers
9k views

don't publish custom post type post if a meta data field isn't valid

I have a custom post type (CPT) called event. I have a meta box for the type with several fields. I would like to validate some fields before publishing an event. For example, if an event's date is ...
16
votes
4answers
3k views

Plugins in symlinked directories?

When I develop plugins I test them on multiple versions of WordPress by symlinking my plugin directory in the different wp-content directories. This is great since I only have to edit the files once, ...
4
votes
2answers
767 views

What are the current recommended best-practices for comments.php?

I'm getting ready to submit a theme to the .Org repo and wanted to make sure that everything is in ordnung. One of the biggest holes left in my design is the comments template. I've taken a look at ...
0
votes
2answers
216 views

muliple wordpress multisite installs on the same sever

I want a separate production and test/dev instance. Is it possible to have two installs of wordpress multi on the same server, using different databases or do I need 2 servers, one for test and one ...
9
votes
1answer
12k views

Embedding a SOAP Client into a WordPress Plugin?

What is the best way to embed a SOAP client into a WordPress plugin that one would distribute via the WordPress plugin repository? Is it best to use? The PHP 5.x Soap Client, The Zend Soap Client, ...
5
votes
2answers
1k views

Pitfalls when Distributing Plugins that Access SOAP Web Services?

I'm wondering what pitfalls (if any?) developers here have run into when distributing WordPress plugins via the WordPress plugin repository that embed a SOAP client for accessing SOAP web services for ...
0
votes
1answer
4k views

Sub-loop / nested loops Best Practices

I'm trying sort through the morass that is WP documentation, and just need someone to clear up the use of the term "The Loop" and how it relates to subloops. My understanding of "The Loop" is that ...
0
votes
2answers
165 views

What is the best practice to localize content? (Geographic not langauge)

I have a website that needs to display state-specific versions, for a few states. Obviously, I will need to parse the IP address to gain geographic information. Before I start making that plug-in, I ...
7
votes
2answers
3k views

Return $post_id when DOING_AUTOSAVE?

I see the following pattern over and over, on this site and on other places: add_action( 'save_post', 'wpse14169_save_post' ); function wpse14169_save_post( $post_id ) { if ( defined( ...
26
votes
7answers
7k views

When Should we NOT Recommend a Client use WordPress? [closed]

As responsible professionals there has to be a line where we say, WordPress is not supposed to be used for that. When is WordPress not the answer?
11
votes
3answers
14k views

How do i best handle custom plugin page actions?

I'm constantly running into the same annoyance, so i thought i'd see if there's any ideas or experience out there... I've created a plugin that uses it's own admin page. It has to. Now that i sorted ...
0
votes
1answer
295 views

unregister a sidebar widget

The codex says it is depreciated. As a long time plugin user, I know how annoying it is when plugins don't clean up after themselves, is it's deprecation indication that it is necessary?
5
votes
4answers
2k views

What is the best way to load the WP environment in a subdomain of my multisite Wordpress install?

I have a subfolder install of WP multisite, let's say at "domain.com". I now need to load the WP environment in subdomains of domain.com, say "sub1.domain.com", "sub2.domain.com", ... ...
0
votes
2answers
5k views

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, ...
1
vote
2answers
2k views

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 ...
0
votes
2answers
348 views

How to determine which capability to use?

For example, I want to use add_menu_page() function to add a menu item to the dashboard. To control which users will be able to access it, I'm supposed to use capabilities... <?php add_menu_page( ...
0
votes
1answer
119 views

Why should I keep my personal wordpress separate from my “professional” one?

(this might be better suited as a community wiki, can one of the mods edit it please?) Info : I have one main blog, where I discuss IT stuff like programming, android, Java etc which compensates my ...
14
votes
2answers
2k views

Best Practices for Regression Testing WordPress Websites?

Hi all, I'd like to hear what others who are delivering complex non-blog solutions to clients with WordPress as a platform what they are using for automated Regression Testing? For those not ...