145
votes
3answers
37k views
When should you use WP_Query vs query_posts() vs get_posts()?
It seems like half the tutorials in the codex and around the blogosphere use query_posts() and half use WP_Query. What's the deal?
10
votes
3answers
8k views
Pagination not working with custom loop
I've got a custom loop that I'm using to display some Real Estate listings that will be available within 60 days. I'm calling it with the following function:
<?php
$sixtydays = date('Y/m/d', ...
47
votes
3answers
17k views
When to use WP_query(), query_posts() and pre_get_posts
I read @nacin's You don't know Query yesterday and was sent down a bit of a querying rabbit hole. Before yesterday, I was (wrongly) using query_posts() for all my querying needs. Now I'm a little bit ...
20
votes
1answer
5k views
A tool to analyze rewrite rules? [closed]
Is there a good tool to analyze my rewrite rules? I always get confused with the regexes and the parameter replacements.
I have created something myself and will post it here so others can use it, ...
16
votes
3answers
854 views
Where to put my code: plugin or functions.php?
Is there an easy to understand scheme to decide what kind of code belongs to a plugin or the theme’s functions.php?
There are many cases and many debates about that topic, mostly because there are ...
94
votes
19answers
20k views
How to: Easily Move a WordPress Install from Development to Production?
I do development on one box and use a second for production. Right now I just dump the database and then do a find a replace for the URL changes; then copy over the files and import the new SQL.
Are ...
55
votes
12answers
6k views
Verifying that I have fully removed a WordPress hack?
My for-fun WordPress blog at http://fakeplasticrock.com (running WordPress 3.1.1) got hacked -- it was showing an <iframe> on every page like so:
<iframe ...
168
votes
108answers
59k views
Best Collection of Code for your functions.php file [closed]
Please vote on the question and any answers you find useful by clicking on the UP arrow on the left hand side of the question or answer.
As with many others who are now viewing this post, I have been ...
6
votes
3answers
301 views
Where do I put the code snippets I found here or somewhere else on the web?
Many posts here or somewhere else contain code, but they do not say where to put it.
Example:
I have found this post: How do I turn off 301 redirecting posts (not canonical)?
I'm a newbie with PHP. ...
32
votes
3answers
29k views
Menu items description? Custom Walker for wp_nav_menu()
Normal Wordpress Menu looks like:
Home | Blog | About us | Contact
But I've seen many pages with descriptions under these links:
Home Page | Our Blogs | About us
| ...
15
votes
2answers
3k views
Create more Meta Boxes as needed
I'd like users to be able to create and remove additional meta box fields as needed.
For example, say a music podcast with a variable amount of songs played per episode.
The user should be able to ...
25
votes
1answer
2k views
What's the preferred method of writing AJAX-enabled plugins?
I'm wondering what the preferred method is for dealing with AJAX calls. Should one use the same plugin php file to process the POST or a separate one? Which is cleaner or safer?
18
votes
1answer
3k views
Where is the right place to register/enqueue scripts & styles
I am using WordPress 3.1.4 by now. I am confused with where (which hook) do I use:
to register and/or enqueue
scripts and styles
on front- and back-ends?
Questions:
Which are right hooks to ...
49
votes
11answers
8k views
WordPress frameworks and parent themes [closed]
By now there is a considerable amount of WordPress code around that is meant to be re-used by other developers. Unfortunately there is little to none practical and solid information on it and ...
51
votes
7answers
12k views
Steps to Take to Hide the Fact a Site is Using WordPress?
I have a website for which we are trying to be discreet about the fact that we are using WordPress. What steps can we take to make it less obvious?
37
votes
17answers
2k views
WPSE Plugin Repository: The plugins that came out of WP-Answers
Link your WPSE-Plugins
If you answered a question and made a plugin out of your code, than this is your place to share it.
The Idea:
An old comment from @MikeSchinkel during the beta phase where he ...
17
votes
4answers
4k views
Custom post types, taxonomies, and permalinks
This is driving me nuts and I'm sure it's simple but nothing I search for comes up with a simple structure (everything is very complex).
I have a custom post type "product_listing" and a custom ...
14
votes
2answers
2k views
Programmatically add widgets to sidebars
I would like to programmatically add widgets to my two sidebars that I've got. I couldn't find any official way of doing it?
I started looking in the database. I've found that it's the ...
78
votes
9answers
8k views
Tips for using WordPress as a CMS? [closed]
I want to use WordPress as a CMS for a reasonably basic site rather than a blog. I have several pages and at the moment, I don't intend to have a "news" page.
While there are ways to make this work, ...
47
votes
11answers
24k views
Adding a Taxonomy Filter to Admin List for a Custom Post Type?
I have created a Custom Post Type called 'listing' and added a Custom Taxonomy called 'businesses'. I would like to add a dropdown list of Businesses to the admin list for the Listings.
Here is what ...
10
votes
2answers
4k views
How to create a permalink structure with custom taxonomies and custom post types like base-name/parent-tax/child-tax/custom-post-type-name
I've been combing this site and google for the answer and I've come up completely empty. Basically I want to do exactly what this post asks, but I need a hierarchical taxonomy. The answer given in ...
3
votes
2answers
2k views
Ajax and autocomplete
I got a set of meta boxes on a custom post type. Two of them are simple input/text-type fields, that should have autocompleted input:
A) Another Custom Post Type
B) Users
Now I have the problem ...
7
votes
1answer
662 views
How can I use WordPress functions in my stylesheet?
I have my style.php file looking like this.
<?php header('Content-Type: text/css');?>
#div{
background:<?php echo get_option('bgcolor');?>;
}
This does not work, but when I do ...
7
votes
2answers
3k views
$ not defined using jQuery in Wordpress
I know that jQuery is loaded, because I can switch out the $ for 'jQuery' and everything behaves as expected, but this will be a messy script if I can't fix this
This script:
...
73
votes
37answers
7k views
Objective Best Practices for Plugin Development? [closed]
Starting a community wiki to collect up objective best practices for plugin development. This question was inspired by @EAMann's comments on wp-hackers.
The idea is to collaborate on what objective ...
40
votes
10answers
16k views
Display a portion/ branch of the menu tree using wp_nav_menu()
I have a menu defined in WP Admin that looks like this:
I want to be able to display all the child links on the sidebar whenever I am at a parent page. For example, if the user is on my "About Us" ...
32
votes
3answers
8k views
What is the preferred way to add custom javascript files to the site?
I've already added my scripts, but I wanted to know the preferred way.
I just put a <script> tag directly in the header.php of my template.
Is there a preferred method of inserting external or ...
24
votes
2answers
12k views
Uninstall, Activate, Deactivate a plugin: typical features & how-to
I'm making a wordpress plugin. What are typical things I should include in the uninstall feature?
For example, should I delete any tables I created in the install function?
Do I clean up my option ...
9
votes
2answers
4k views
How To Add Custom Form Fields To The User Profile Page?
The user profile page has the following fields:
Username
First Name
Last Name
Nickname
Display name
Contact Info
E-mail
Website
AIM
Yahoo IM
Jabber / Google Talk
How can more fields be added to ...
10
votes
4answers
420 views
How to mark every 3rd post
I'm working on a WordPress site for my band and I'd like to mark every 3rd post on our blog page to have a special class applied to it, anybody have any pointers on how to achieve this? Any help is ...
7
votes
5answers
2k views
Change the text on the Publish button
Is there a way to change the text of the publish button on a custom post type to say some different? For example, Save instead of Publish. And also remove the draft button?
1
vote
2answers
582 views
Shortcode always displaying at the top of the page
I'm using a shortcode to pull in different loops via the loops-name.php. For some reason it is always at the top of the page. I googled it and using echo instead of return causes that problem but with ...
13
votes
1answer
9k views
Need help with add_rewrite_rule
SOLUTION
I've gone with Update 3 and have got it working. What I had misunderstood, was that I believed that a rewrite rule would change designers/?designer=some-designer&bid=9 to ...
11
votes
3answers
4k views
Implementing a CrunchBase.com Clone using WordPress?
I wish to create something like CrunchBase.com
with WordPress.org (So to have one website that is a "database", and another one, which is a blog, that connects to it).
Is it possible? and how?
...
13
votes
2answers
7k views
Using wp_query is it possible to orderby taxonomy?
My question is simple, I'm using WP_Query to retrieve some custom type posts filtering by a taxonomy using tax_query.
Now my problem is I would like to orderby the taxonomy, but from documentation ...
5
votes
2answers
1k views
Add extra parameters after permalink?
How can I add extra parameters after a permalink, specifically if I'm using a custom post type?
For example, let's say http://mysite/album/record-name was the permalink. How can I make ...
44
votes
27answers
6k views
Software for WordPress Theme and Plugin Development? [closed]
What software do you use for your WordPress related needs?
Please state your OS.
On windows XP I use:
filezilla (FTP)
notepad++ (for reading of PHP / CSS files)
firebug (a firefox extension to ...
12
votes
2answers
5k views
Mixing custom post type and taxonomy rewrite structures?
Basically I want to achieve a glossary using custom post types and have some issues setting up rewrites the way I want them to be. I want it like that:
The main glossary URL:
...
12
votes
2answers
4k views
How to Protect Uploads, if User is not Logged In?
I use wordpress for a private site where users upload files.
I use the "Private WordPress" to prevent access in to the site if the user is not logged in.
I would like to do the same to the files ...
4
votes
3answers
2k 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 ...
4
votes
3answers
4k views
changing notification emails from WordPress <wordpress>@mydomain.net to something else
How do I change notification emails address from WordPress @mydomain.net to something else.
I want to do this because WordPress @mydomain.net ends up getting flagged as junk mail.
Thanks
Daniel
1
vote
2answers
2k views
Retrieve 1st image in post and set it as featured image, when post is saved/updated
I need to set a featured image for every post I publish. So, when a post is published/updated, the script would scan the post for the first image using a script like this:
// Get URL of first ...
3
votes
1answer
650 views
Template issues getting ajax search results
I'm trying to put search results into a div with ajax. The issue is I'm getting errors saying undefined function have_posts() when the the search template is accessed. It also took issue with ...
4
votes
1answer
1k views
Force category choice before creating new post?
How can I force the user to first choose a category before continuing to the editor when creating a new post? I want to set some default content, but this is based on the category, so I need to know ...
1
vote
1answer
284 views
How to Rewrite Wordpress URL for a Plugin
I am trying to build a Wordpress plugin here with a custom user admin area. What I would like to do is when the user adds /edit at the end of the page, it should open a page from my plugin. So for ...
1
vote
1answer
148 views
short code output too early
I'm trying to create a shortcode base on the following code:
<ul class="filter">
<li>Filter:</li>
<li class="link-store"><a href="<?php echo get_permalink( 23 ); ...
32
votes
6answers
4k views
framework for plugin/theme options panel? [closed]
I found that the longest part of a plugin or theme development is creating the options panel, at least in my case.
So i like to know what's your take on that.
Do you use a ready made framework or ...
21
votes
5answers
2k views
Where Can I Find a List of WordPress Hooks?
Where can I find a list of all the WordPress hooks and over-ridable functions (pluggable, scriptable, etc)?
Edit: Plugin is here: ...
26
votes
3answers
4k views
Are transients garbage collected?
This question got me thinking Transient RSS feeds in wp_options not removed automatically?
Transients are supposed to expire and be deleted. However the only way I see this handled is when transient ...
9
votes
1answer
2k views
How can I add a URL field to the attachments window?
For example...
add_action('init', 'reg_tax');
function reg_tax() {
register_taxonomy_for_object_type('category', 'attachment');
}
Adds a "Category" input field to the media manager and ...
