question
stringlengths
0
34.8k
answer
stringlengths
0
28.3k
title
stringlengths
7
150
forum_tag
stringclasses
12 values
WordPress obviously comes from a blogging background but can be used to serve sites with a lot of Pages. However, where it falls short for me is not in regard to performance but in the Admin area's handling of lots of Pages, child pages etc. It quickly becomes a chore to move through the list of Pages trying to find what you're looking for, especially without the ability to drill down into page hierarchies etc. What techniques / plugins do people use to deal with this issue?
I use the CMS Tree View plugin , and it works very well. It collapses all your pages under their parent pages, among other features.
How can we make managing lots of pages in WordPress Admin better?
wordpress
I'm working on a site for a local homeschool group, and they'd like to have a page(s) with a member directory on the site. Any suggestions? Something like the Business Directory plugin would probably be great, just more focused on listing individuals. Edit: I actually want a plugin that lets me create listings manually, as opposed to using the existing user/member list in WordPress. That will work better in this case.
Hi @tnorthcutt Hey, based on your requirements I'd suggest you consider just using <a href="stackexchange-url Custom Post Types with custom fields and defining your own layout. That way you won't be painted in to the limitations of a plugin that doesn't meet you needs exactly, and it sounds like Custom Post Types will fit your requirement pretty much spot on. Here's <a href="stackexchange-url another answer I previously wrote that give that discusses Custom Post Types. In addition I'll point you to a 2nd answer I wrote where I described <a href="stackexchange-url How to Recreate CrunchBase in WordPress using Custom Post Types . After all, there is really very little technical implementation difference between creating a directory of companies and a directory of people, right?
What is a good member directory plugin?
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? Thanks, Tal
@Tal Gailili : Absolutely , WordPress would be a great platform for a CrunchBase clone! Use Custom Post Type and Custom Taxonomies What you want to look at are Custom Post Types and Custom Taxonomies [see <a href="stackexchange-url this answer I gave on a very similar subject]. Example Code for your Company's Post Type and Taxonomies With WordPress 3.0 you can create a <code> company </code> custom post type and then one or more custom taxonomies that apply to the company such as category, funding and status. To bootstrap your efforts here's code you can drop in to your theme's <code> functions.php </code> file to get your started: <code> register_post_type('company', array( 'label' =&gt; __('Companies'), 'public' =&gt; true, 'show_ui' =&gt; true, 'query_var' =&gt; 'company', 'rewrite' =&gt; array('slug' =&gt; 'companies'), 'hierarchical' =&gt; true, 'supports' =&gt; array( 'title', 'page-attributes', 'excerpts', 'thumbnail', 'custom-fields', 'editor', ), ) ); register_taxonomy('company-category', 'company', array( 'hierarchical' =&gt; true, 'label' =&gt; __('Categories'), 'query_var' =&gt; 'company-category', 'rewrite' =&gt; array('slug' =&gt; 'categories' ), ) ); register_taxonomy('company-status', 'company', array( 'hierarchical' =&gt; true, 'label' =&gt; __('Status'), 'query_var' =&gt; 'company-status', 'rewrite' =&gt; array('slug' =&gt; 'status' ), ) ); register_taxonomy('company-funding', 'company', array( 'hierarchical' =&gt; true, 'label' =&gt; __('Funding'), 'query_var' =&gt; 'company-funding', 'rewrite' =&gt; array('slug' =&gt; 'funding' ), ) ); </code> Other Post Types you might want: If you really want to clone CrunchBase you'd be wanting to create custom post types for each of these (though I'm guess you want something similar but for a different market?): People Financial Organizations Service Providers Funding Rounds Acquisitions Company Listing Page For your company's listing page (like this one on CrunchBase) I'd probably create a WordPress " Page " called " Companies " ( imagine that! ) and then use a post list shortcode plugin like List Pages Shortcode (if you use that one you will need to make a one-line modification to support Custom Post Types like I show here.) With that plugin and modification you can add the following text to your " Companies " Page and it will list out all the companies in a bulleted list on that page which you can style with CSS: <code> [list-pages post_type="company"] </code> Company Specific Layouts Then for a custom layout for each company you can make a copy of the theme template file <code> single.php </code> and name it <code> single-company.php </code> and make whatever modifications you want to the layout there. User Company Submissions And if you want to let people submit companies consider using Gravity Forms ( not an affiliate link; US$39 per site license and worth every penny.) If you need more... There's more I'm sure but that will get you most of the basic functionality you need. If you need more, ask another question here on WordPress Answers! Hope this helped.
Implementing a CrunchBase.com Clone using WordPress?
wordpress
I started a blog recently. Currently I'm using a free theme and some plugins that are working well enough for now. And, my overall goal is to produce content and not become a WordPress developer, etc. In the meantime, I do need to upgrade my technical skills. I have one goal of customizing my current theme within 1 -3 months and potentially developing a custom theme in 6 - 8 months. I am looking for recommendations on books, ebooks, or websites to help me with the following: CSS - beginning to intermediate level PHP - beginning - I'm not interested in becoming a coder, but want to be able to tweak, troubleshoot and understand better. XHTML - beginning to intermediate level - 10 years ago I did HTML coding, but then moved into management. Obviously there is a huge amount of info on this via Google, etc. I'm hoping for some practical suggestions from the experts in order to avoid dead ends. thanks. -wdypdx22
W3Schools http://www.w3schools.com/ is agreat site for learning about HTML, CSS, PHP etc..
I'm looking for some good references (manuals)
wordpress
My site has a theme which I created myself, and while it works, I often have to tweak the theme or use plugins to modify the appearance or behaviour. I've been looking at ways to modify my theme so that there's less jumping around to make changes. Ideas include some basic SEO, gallery functionality, fields for analytics and feedburner, and widgets. What features do you consider useful to build into a theme to reduce modifying it later or having to use plugins?
It's all site-dependent. I have a few core things I build in to any theme's functions.php though: Change logo on admin page to suit the client's company Hide WP-Stats smiley graphic Hide WP.me short URLs and replace with their chosen provider Add option for Twitter, Facebook, and Buzz buttons and ability to pull in Tweets Google Analytics option Minify JS/CSS ... plus i'm forgetting some stuff, i'm sure.
Building useful features into your theme
wordpress
The Plugin developer center says "Your plugin must be GPLv2 Compatible.". But I found that the Topsy plugin is under GPLv3. http://www.gnu.org/licenses/rms-why-gplv3.html states that GPLv2 and GPLv3 are incompatible. So should this be allowed? I want to use some code from the Topsy plugin. Then, should I release my plugin under GPLv2 or GPLv3 ??
If you're following the rules (you never want to start out by breaking them), then any WordPress plug-in you write and submit to the repository must be licensed as GPLv2. There was a huge storm of discussion over this last year because the example readme file mistakenly said "GPL, version 2 or any later version" ... which is why some plug-ins went the GPLv3 route. Once it was pointed out that plug-ins had to be licensed using version 2 to be in compliance with the license of WordPress core, many plug-ins relicensed to version 2 and several that refused were removed from the repository. Unfortunately, quite a few flew under the radar and missed the update. My suggestion would be to: Contact the developers of Topsy and ask them to either relicense the plug-in or give you explicit permission to use some of their code and license your release under GPLv2 Wait until getting affirmation from Topsy before using any of their code in your own system. Technically , Topsy is in violation of WordPress' core license, and it's the WordPress Foundation's responsibility to pursue that (not yours). However, to make sure that you keep your own code in compliance and avoid any legal fallout should they pursue action against Topsy, you should either get permission to use the code in an appropriate manner or find something else to work with. Update After considerable discussion via email, in forums, on IRC, and on Trac, the core team clarified that any plugins hosted in the WP repository must be licensed as compatible with GPLv2 . This means, for the most part, your plugins should either be explicitly GPLv2 or GPLv2+ ("or any later version"). This is to prevent the possibility of accidentally rolling plugin code into core. Core is explicitly licensed as GPLv2+, so any code that is rolled in to the project must be capable of being licensed in the same way. However, you can still license your privately-hosted plugins as GPLv3. This is still compatible with the "or any later version" stipulations of core while remaining separate (since it's not hosted in the same location).
GPL and plugins
wordpress
While I've been able to get this working for normal WP categories I've been unable to get it working for custom taxonomies. I'd like to loop through each custom taxonomy (categories in my case) and produce a number of posts for each. An example of the output would be: <code> Category 1 post from category one post from category one read more category one Category 2 post from category two post from category two read more category two </code> Of course it would repeat through any available taxonomy for the custom post type.
I thought I would provide another answer as the above one is a little hacky, also I added another layer that gets all taxonomies for a post_type. <code> $post_type = 'post'; // Get all the taxonomies for this post type $taxonomies = get_object_taxonomies( (object) array( 'post_type' =&gt; $post_type ) ); foreach( $taxonomies as $taxonomy ) : // Gets every "category" (term) in this taxonomy to get the respective posts $terms = get_terms( $taxonomy ); foreach( $terms as $term ) : $posts = new WP_Query( "taxonomy=$taxonomy&amp;term=$term-&gt;slug&amp;posts_per_page=2" ); if( $posts-&gt;have_posts() ): while( $posts-&gt;have_posts() ) : $posts-&gt;the_post(); //Do you general query loop here endwhile; endif; endforeach; endforeach; </code> It would be recommended to add each post found to a <code> $post__not_in </code> array, so you could pass that to the <code> WP_Query </code> to prevent duplicate posts coming through.
Loop through custom taxonomies and display posts
wordpress
Is there an API I can call, inside my plug-in, to determine the plug-in's version? I just want to have my plug-in emit a html comment with it's own version number ... for diagnostic purposes.
@david : Both @Adam Backtrom and @Viper007Bond give some good advice so I thought I'd take their advice and see if I couldn't implement something, see below. What follows iS a plugin called WP Active Plugins Data that parses the header metadata for all active plugins anytime any plugin is activated and it stores all the metadata for each plugin into an array option in <code> wp_options </code> . I designed it for both regular WordPress plugins and multisite site-wide plugins. You can download it here from gist but I've also copied the code here for your review: <code> &lt;?php /* Plugin Name: WP Active Plugins Data Plugin URI: http://mikeschinkel.com/wordpress-plugins/wp-active-plugins-data/ Description: Loads Plugin Data on Plugin Activation and Persists to wp_options for quick retrieval. Version: 0.1 Author: Mike Schinkel Author URI: http://mikeschinkel.com Note: Written for stackexchange-url get_active_plugin_version($plugin_path_file, $sitewide = false) { return get_active_plugin_attribute($plugin_path_file,'Version'); } function get_active_plugin_attribute($plugin_path_file, $attribute) { $all_plugins_data = get_active_plugins_data($plugin_path_file,$sitewide); return (isset($all_plugins_data[$attribute]) ? $all_plugins_data[$attribute] : false); } function get_active_plugins_data($plugin_path_file, $sitewide = false) { $failsafe = false; $plugin = plugin_basename(trim($plugin_path_file)); $sitewide = (is_multisite() &amp;&amp; ( $sitewide || is_network_only_plugin($plugin))); if ($sitewide) { $all_plugins_data = get_site_option('active_sitewide_plugin_data',array()); } else { $all_plugins_data = get_option('active_plugin_data',array()); } if (!$failsafe &amp;&amp; !is_array($all_plugins_data) || count($all_plugins_data)==0) { $failsafe = true; // Don't risk infinite recursion if ($sitewide) { $active_plugins = get_site_option('active_sitewide_plugins',array()); } else { $active_plugins = get_option('active_plugins',array()); } persist_active_plugin_data(null,$active_plugins,$sitewide); $all_plugins_data = get_active_plugin_version($plugin_path_file,$sitewide); } return $all_plugins_data[$plugin_path_file]; } add_action('update_site_option_active_sitewide_plugins','persist_sitewide_active_plugin_data',10,2); function persist_sitewide_active_plugin_data($option, $plugins) { persist_active_plugin_data(null,$plugins,'sitewide'); } add_filter('update_option_active_plugins','persist_active_plugin_data',10,2); function persist_active_plugin_data($old_plugins, $new_plugins, $sitewide=false) { $active_plugin_data = array_flip($new_plugins); $plugin_dir = WP_PLUGIN_DIR; foreach($new_plugins as $plugin) { $active_plugin_data[$plugin] = get_plugin_data("$plugin_dir/$plugin"); } if ($sitewide) update_site_option('active_sitewide_plugin_data',$active_plugin_data); else update_site_option('active_plugin_data',$active_plugin_data); } </code> Want to see how it works? Here's a test file you can drop in the root of your WordPress site ( <code> http://example.com/test.php </code> .) Make sure you have both this plugin and Akismet activated before you test it. <code> &lt;?php /* * test.php - Place in root of WordPress website. * * Before running be sure to activate both Akismet and the WP Active Plugin Data plugin * */ include "wp-load.php"; header('Content-type:text/plain'); $akismet = "akismet/akismet.php"; echo "Akismet Version: " . get_active_plugin_version($akismet); echo "\n\nAkismet Description: " . get_active_plugin_attribute($akismet,'Description'); echo "\n\nAll Akismet Data:\n"; print_r(get_active_plugins_data($akismet)); </code> If it's not exactly what you need at least it should give you a good starting point. Hope this helps.
Is there a way for a plug-in to get it's own version number?
wordpress
I'm working on a plugin that would ideally be able to do things when a user does something through a different plugin. I can add custom hooks in those plugins but obviously this wouldn't work well for when I want to distribute my plugin. Is there a good way to add hooks to other people's plugins from my own plugin? Is the only real solution to ask the author to include custom hooks so that other developers can build off of their work? Example: I want to do something in my plugin when someone retweets an article. If there was a custom hook in whatever the popular retweet plugin is that I could hook in to and fire off of, that would be great. There isn't, so I can modify their plugin to include it, but that only works for my copy, and I don't want to try to redistribute that. Do we just need to try and be better plugin developers so that we can all play nice together?
@Ryan Elkins: I guess the answer depends on how import each use-case is to you. In some cases it would be something you need quick-and-dirty, in others it might be a more significant use-case. Here are the two things that come to mind: Look for Alternate Hooks within WordPress Core If it's something quick and dirty some times you can use other downstream hooks from core to modify what you need, or both upstream and downstream hooks via the use of <code> ob_start() </code> / <code> ob_end_clean() </code> (see stackexchange-url ("@Todd Perkins answer") to " stackexchange-url ("Dealing with large HTML output via plugin code") " for a code example.) To track down the hooks you could use check out the stackexchange-url ("Instrument Hooks plugin") I posted yesterday to help you find the hooks that you can potentially use. Submit a Patch with your Desired Hook to the Plugin Developer If your use-case is more significant to you or the community I'd recommend going ahead and adding the hook that you need to the plugin. Then test it well to ensure it really addresses your use-case after which you can submit a patch to the plugin developer in hopes that he or she will apply it. This way you make it as easy as possible on them by giving them tested code and you get to work through the use-case yourself to ensure it is really what you need. I can't tell you how often I thought I needed a certain hook only to find after trying to implement one I needed a hook but one that was different than I first envisioned. If you are not familiar with creating a patch here is a good article on patching WordPress core for which most applies to patching plugins and for that which does not it will hopefully be obvious what to do: How to Patch WordPress Hope this helps? P.S. One thing I find a bit disappointing and that your question addresses is the percentage of plugins that are designed only for end-users, i.e. that have no hooks of their own. Imagine if WordPress were designed like most plugins? It would be inflexible and a very niche solution. Maybe things would be different if WordPress were to have the ability to auto-install plugins on which other plugins depended? As it is I typically have to write a lot of the functionality I need from scratch because clients want things a certain way and the available plugins, while 90% there don't allow me the flexibility to update the remaining 10%. I really do wish those leading the WordPress community would identify a way to ensure that plugins are rewarded for following best practices (such as adding in hooks for other developers) much like good answers are rewarded on a StackExchange site.
Hooking in to plugins
wordpress
I have a plugin that, among other things, has a javascript file that requires a few user specific settings. What would be the best way to get those settings into javascript from the plugin's settings parameters? In other words, if I make those settings part of the settings page where the user can enter them, how would I best be able to get those values into javascript? Would I have to use something to append some script tags and set them via PHP on every page load? Would setting a cookie be a better way to do this?
better is, you use the functions of WP for this, a example for multilanguage: <code> add_action( 'admin_enqueue_scripts', 'add_scripts' ); function add_scripts($where) { wp_localize_script( 'post2media', 'post2media_strings', $this-&gt;localize_vars() ); } function localize_vars() { $strings = array( 'btntext' =&gt; __( 'Link with post', INPSYDE_P2M_TEXTDOMAIN ), 'txtallnone' =&gt; __( 'Include in gallery:', INPSYDE_P2M_TEXTDOMAIN ), 'txtall' =&gt; __( 'All', INPSYDE_P2M_TEXTDOMAIN ), 'txtnone' =&gt; __( 'None', INPSYDE_P2M_TEXTDOMAIN ), 'ttlcb' =&gt; __( 'Include image in this gallery', INPSYDE_P2M_TEXTDOMAIN ) ); return $strings; } </code> use this in js-file: <code> jQuery(function ($) { buttonaddfunc = function() { btntext = post2media_strings.btntext; reg = /\d+/; $( '.savesend &gt; .button' ) . each( function() { inputname = $( this ) . attr( 'name' ); number = reg . exec( inputname ); $( this ) . after( '&lt;input type="submit" value="' + btntext + '" name="link[' + number + ']" class="button"&gt;' ); } ); $( '.describe-toggle-on' ).unbind( 'click', buttonaddfunc ); }; $( '.describe-toggle-on' ).bind( 'click', buttonaddfunc ); </code> } ); Also see the post from Otto
Modifying a JS file with data from plugin settings
wordpress
How do I add stuff to themes such as Arjuna-X without losing it when the theme is updated? Are child themes a good way to do it or are there other options? What if a new version of the theme comes out with native support for a feature I added?
There are three ways to do this Functions.php Put your additions in functions.php and back up that file before you update your theme. Then you can port over any additions as necessary. Child theme Build a child theme that adds the functionality - in reality, this would be an even better way to use a custom functions.php file because it wouldn't be overwritten by updates. Custom plug-in Completely isolate the new functionality from the theme and add it in using WordPress' hooks and filters. This way, you lose nothing in upgrades and can selectively turn off features if/when native support is added by the themes.
Adding goodies to themes
wordpress
What is the best way to have multiple blogs on one site? I am not talking about Multisite. What I want is one website with 5 blogs. All accessible from one menu and editable from one backend, I could use categories, though I am looking for something else. Multisite would take a lot of tweaking.
If you don't want to use Multisite , yet still want to have multiple blogs with a common backend, another idea is: Customize your theme's Author Templates so each author's "blog homepage" has a distinct design Create several different stylesheets, one per author. Use some conditional logic to display the appropriate stylesheet when viewing an individual blog post, so that the post matches that author's homepage design. Create several different sidebars , one per author. This will allow you to have different widgets per author. You'll need conditional logic to know which sidebar to display too. Of course, this would require quite a bit of tweaking too. Multisite might be less work.
5 blogs on one WordPress site
wordpress
What would be your suggestions for learning CSS and WordPress theme development ? I have been using WordPress for over 4 years now, but I have never really gotten comfortable with CSS or theme design (I could tweak it here and there, but that's not really doing much). I would love to be able to do these, but don't know where to start. Most guides I came across are not WP specific, and I fear I'd go through redundant material. Thanks
First of all differ between the stuff. WP is not CSS and CSS is not WP. But WP themes make use of CSS. So if you learn about CSS you're basically not doing wrong (good thing with CSS is, it is common between all websites). The other part is HTML. And then you have PHP. So these are three computer languages that are used with each other: a programming language: PHP a structural language: HTML a domain specific language: CSS Then you have a multi-layer network architecture: PHP is executed on the server and HTML and CSS is provided by the server but read / processed by the Browser on the client computer. So even if themes might look simple, with WP this all gets interchangeable mixed and you must yourself put the stuff apart again. PHP is in "Theme" (PHP) Files, HTML is generated (and as well is) inside those Theme files, CSS is in the CSS file. So basically you need to decide yourself what you want to learn. Most resources differ between PHP and HTML/CSS. Based on your question I can only suggest to you to learn CSS. It is very powerful after you have fully understood the Cascade. You need to know HTML forehand (not PHP, just HTML). In the end CSS is absolutely important for the visual representation of a website, it's a power tool to decorate any website. So you can use that with everything, even wordpress themes ;) Go for it. If you haven't understood until now after 4 years, spend yourself some education. I suggest some book like http://oreilly.com/catalog/9780596101978 which is perfect for self-education (next to practicing). CSS itself is very well deined by the W3C as well as HTML is. The definition there is not very user-friendly but it's correct so with some will you can learn a lot there as well. w3schools is nice made as well (and that site somehow makes it over the years, looks at least some brain is behind it). HTML/CSS, that is the WWW, grab your source :D For PHP there is php.net. For wordpress, well, it's always changing and consumes resources of your personal career, so do not focus too much on to it. Its well kept developed anyway so, just look for whats good for you, do not focus on wordpress too much.
How to start learning CSS and theme development?
wordpress
I have a WP backup file of sample content I use when I set up a new site on my WP multisite install (I use it for theme dev work for clients). Is there a way to trigger the import function to fire when I create a new site? I've looked at the WPMU blog defaults plugin, but there are features it doesn't have that I would like (such as post tags and child/parent categories). A little more detail... Settings > Import (actually Tools > Import, since it moved from the Settings menu a release or two ago) is what I'm looking to automate. As I mentioned, I have a WXR file of content I normally import manually whenever I create a new site. I would like to remove that manual step from my workflow. The backup file itself is stored on my dev server, so WP would have direct access to it.
Have a look at this plugin http://wordpress.org/extend/plugins/wp-dummy-content/stats/ It is random content so if you need to always to load the same content you will have to look at the code and create your own version. One pain of theme development is setting up all the pages and blog posts in order for you to see how your site will look � one by one by one. No more! WP-Dummy-Content is a WordPress plugin that will generate a bunch of pages, sub-pages and posts which you specify. Titles and content are automatically generated for you as well, and you have a few choices as to the type and length of content. One click generates an entire site. Choose what type of content to insert: single paragraph, multi paragraphs, styled (lists, blockquotes, links, etc.), or random. One click DELETES all content created by the plugin!
Is there a way to trigger an automatic import of a WP backup on creation of a new WP multisite site?
wordpress
WordPress is quite a memory hog, and I've been thinking of using nginx rather than apache. The one major consideration before doing that is if there are any plugins which will stop working. I have tested a few and they seem to work, but I need to find out if there are any which might break.
I unfortnately have no experience with this but evidently it can be done as these articles and plugins address some of the issues: HOWTO: Install WordPress On Nginx WordPress + nginx Compatibility Plugin Howto nginx + wordpress + ubuntu shortest setup Nginx front-end proxy cache for WordPress WordPress Pretty Permalinks with Nginx WordPress, Nginx and WP Super Cache Also are you familiar with WP Engine WordPress hosting ? They are evidently using it in a hybrid form with Apache, probably as a front-end proxy. Back in Startup Mode… Announcing WP Engine! Hope these help.
What issues would you face if you use Nginx
wordpress
Where can I find a list of all the WordPress hooks and over-ridable functions (pluggable, scriptable, etc)? Edit: Plugin is here: stackexchange-url ("stackexchange-url
@Arlen: As Keith S points out Adam Brown's List of Hooks is the defacto resource of hooks for WordPress. However, it's not perfect: It doesn't show the hooks in order of when they are called, It doesn't provide file name or line number where invoked, It doesn't provide a number of arguments passed, It's not a complete list because some hooks can be called dynamically, And it doesn't show hooks from plugins. So while Adam's list is a great resource especially for understanding when hooks were historically added it's not nearly as useful as if you were able to instrument the hooks on any given page on your own site. I've been toying with this idea for a while so your question triggered me to write a plugin called " Instrument Hooks for WordPress ." You can find the full source below the screen shot and can you can also download it from gist here . So here's a screenshot of what the instrumentation looks like: You trigger the instrumentation by using the URL parameter <code> instrument=hooks </code> , i.e.: http://example.com?instrument=hooks And as promised, here's the source (or download it here.): <code> &lt;?php /* Plugin Name: Instrument Hooks for WordPress Description: Instruments Hooks for a Page. Outputs during the Shutdown Hook. Version: 0.1 Author: Mike Schinkel Author URI: http://mikeschinkel.com */ if ($_GET['instrument']=='hooks') { add_action('shutdown','instrument_hooks'); function instrument_hooks() { global $wpdb; $hooks = $wpdb-&gt;get_results("SELECT * FROM wp_hook_list ORDER BY first_call"); $html = array(); $html[] = '&lt;style&gt;#instrumented-hook-list table,#instrumented-hook-list th,#instrumented-hook-list td {border:1px solid gray;padding:2px 5px;}&lt;/style&gt; &lt;div align="center" id="instrumented-hook-list"&gt; &lt;table&gt; &lt;tr&gt; &lt;th&gt;First Call&lt;/th&gt; &lt;th&gt;Hook Name&lt;/th&gt; &lt;th&gt;Hook Type&lt;/th&gt; &lt;th&gt;Arg Count&lt;/th&gt; &lt;th&gt;Called By&lt;/th&gt; &lt;th&gt;Line #&lt;/th&gt; &lt;th&gt;File Name&lt;/th&gt; &lt;/tr&gt;'; foreach($hooks as $hook) { $html[] = "&lt;tr&gt; &lt;td&gt;{$hook-&gt;first_call}&lt;/td&gt; &lt;td&gt;{$hook-&gt;hook_name}&lt;/td&gt; &lt;td&gt;{$hook-&gt;hook_type}&lt;/td&gt; &lt;td&gt;{$hook-&gt;arg_count}&lt;/td&gt; &lt;td&gt;{$hook-&gt;called_by}&lt;/td&gt; &lt;td&gt;{$hook-&gt;line_num}&lt;/td&gt; &lt;td&gt;{$hook-&gt;file_name}&lt;/td&gt; &lt;/tr&gt;"; } $html[] = '&lt;/table&gt;&lt;/div&gt;'; echo implode("\n",$html); } add_action('all','record_hook_usage'); function record_hook_usage($hook){ global $wpdb; static $in_hook = false; static $first_call = 1; static $doc_root; $callstack = debug_backtrace(); if (!$in_hook) { $in_hook = true; if ($first_call==1) { $doc_root = $_SERVER['DOCUMENT_ROOT']; $results = $wpdb-&gt;get_results("SHOW TABLE STATUS LIKE 'wp_hook_list'"); if (count($results)==1) { $wpdb-&gt;query("TRUNCATE TABLE wp_hook_list"); } else { $wpdb-&gt;query("CREATE TABLE wp_hook_list ( called_by varchar(96) NOT NULL, hook_name varchar(96) NOT NULL, hook_type varchar(15) NOT NULL, first_call int(11) NOT NULL, arg_count tinyint(4) NOT NULL, file_name varchar(128) NOT NULL, line_num smallint NOT NULL, PRIMARY KEY (first_call,hook_name))" ); } } $args = func_get_args(); $arg_count = count($args)-1; $hook_type = str_replace('do_','', str_replace('apply_filters','filter', str_replace('_ref_array','[]', $callstack[3]['function']))); $file_name = str_replace($doc_root,'',$callstack[3]['file']); $line_num = $callstack[3]['line']; $called_by = $callstack[4]['function']; $wpdb-&gt;query("INSERT wp_hook_list (first_call,called_by,hook_name,hook_type,arg_count,file_name,line_num) VALUES ($first_call,'$called_by()','$hook','$hook_type',$arg_count,'$file_name',$line_num)"); $first_call++; $in_hook = false; } } } </code>
Where Can I Find a List of WordPress Hooks?
wordpress
I am already using Piwik to register all stats of my blog site. What I need now is a simple and lightweight plugin that stores the number of visitors for single posts. It would be nice if it provides a way to show the number of readings inside the post.
I think you want wp-postviews
Looking for simple and lightweight plugin for post reading stats
wordpress
I am using Similarity by David Miller; it is nice, but it misses some features. I would like to: Assign more "weight" on some specific posts (specify them by ID is ok) Assign more "weight" to most recent posts (the plugin that I am using it prefers many times very old posts based on tag/category than recent) Do you known if it exists a plugin with these features?
I think http://wordpress.org/extend/plugins/yet-another-related-posts-plugin/ might help..
Looking for similar posts plugin with custom tuning
wordpress
I turned on debug mode in WordPress and the first request of the day I get this error: Warning: http_request() [function.http-request]: Timeout was reached; Operation timed out after 1000 milliseconds with 0 bytes received (/wp-cron.php?doing_wp_cron) in /public/wp-includes/class-http.php on line 1218 I know what cron jobs are and I understand how WordPress might want to run periodic jobs (and since HTTP is stateless, running a "cron" job on the first request of the day makes sense) but why does it time out?
It's a bug: http://core.trac.wordpress.org/ticket/11831
Why do I get the timeout warning?
wordpress
I have found and downloaded a theme. However I want to tweak the CSS some to change the design, colours etc. a bit. How should I go about doing this, while still being able to update the theme without loosing the changes.
While you can't modify it without changing it, you can isolate the parts you change by creating a Child Theme. In summary: Create a theme directory on peer with your "parent" theme, Create a <code> style.css </code> file in your new directory that has a <code> Template: </code> declaration in the comments naming your parent theme and an <code> @import url(../%parent-theme%/style.css) </code> to import the CSS from the parent theme, Activate your new theme in the WordPress admin console, Add new files and/or copy files from your parent theme directory to your child theme directory and modify them to your preference, and That's it! I could give you lots more details but basically this guy does a really good job of explaining How to Create a Child Theme so better for me just to point you to it. When you want to upgrade the parent theme just upgrade; it will leave your child theme in-tact. Of course your child theme may not work perfectly if they've changed the parent too much and/or if you copied and modified theme files they updated in the new version you won't get the new functionality without modifying them too, but it's a lot better from starting over each time! Hope that helps.
Customizing a WordPress theme without changing it?
wordpress
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 allow me to play with a website elements) Other things which I don't use regularly, but would like to use more - xaamp (local version of WP) - github/SVN (a version control system for my files) What about you?
OS Windows 7 x64 Using PhpStorm excellent non-free IDE, a lot of focus on speed and productivity Xdebug debugger, a lot of useful functions to dump, trace stack, profile WinSCP secure file transfer, folders sync, remote editing, backup Uniform Server WAMP stack, portable, up to date components Internet Explorer Collection easy way to have multiple IE for testing Cobian Backup local files backup Dropbox off-site backup storage (in context of WP) HeidiSQL MySQL client Balsamiq Mockups interface sketching Console2 command line interface Firefox Portable those plugins won't run themselves Firebug do I need to explain? :) HTML Validator integrates with source view YSlow performance Page Speed performance Web Developer various nifties SEO Doctor solid no-fluff on-page SEO check View Source Chart color-coded and foldable page source view WordPress plugins BackupBuddy backup and migration WordPress Console cool, handy, but glitches at times Codestyling Localization must have for translations list hooks (shameless plug) several functions for hooks debug Theme-Check runs battery of tests on theme for official repository theme requirements Core Control very useful to debug file system access, network access and wp cron Codex Generator (shameless plug) functions research and filling up Codex Version control Subversion official WP repository Unfuddle Mercurial Bitbucket Git Unfuddle Considering Chrome plenty development extensions already, Firefox is damn slow Deprecated Notepad++ almost never use it since picked up NetBeans PHPXref easier to navigate code inside NetBeans WP Tuner great performance profiling, unfortunately not maintained and broke for WP3 MoWeS became too much trouble to struggle with component updates and stability issues (Apache started to crash all the time) NetBeans moved on to PhpStorm eAccelerator - modern version don't provide object cache, somewhat unstable (occasional crashes) webgrind - no need anymore, PhpStorm can now parse and display profiler logs CSE HTML Validator just never get to use it on top of everything else MySQL Query Browser replaced with HeidiSQL
Software for WordPress Theme and Plugin Development?
wordpress
I recently wrote my first WP plugin that adds a shortcode for embedding a custom jquery image gallery into posts. It's primarily just dumps a good chunk of HTML into the post, along with javascript necessary for initialization. However, I had to build the HTML output procedurally, as a string in PHP. This kind of tag soup always drives me nuts, and I'm used to working with MVC frameworks which provide things like helper functions and partial templates for generating HTML. What is the general approach for plugin authors who need to manage large amounts of dynamically built HTML or JS?
@Byran M. I tend to use two constructs I don't often see other WordPress developers using often, which surprises me, but I like them a lot. 1.) Heredocs You can store large blocks of text as heredocs string that might look like this so I can store worrying about mixing single and double quotes: <code> $html=&lt;&lt;&lt;HTML &lt;input type="{$type}" size="{$size}" id="{$id}" class="{$class}" value="{$value}" /&gt; HTML; </code> Note that the variables might be passed to a function as an array and then <code> extract() </code> ed or you could assign them in other ways. Also note that I use the braces not because they are always required but they make the code easier to read. (Of course with functions like <code> the_content() </code> being materially different from <code> get_the_content() </code> WordPress doesn't always make this style of coding easy.) What's more, although it may not be relevant to you is if I use heredoc names like HTML, SQL, etc. then my IDE PhpStorm does syntax injection and will give me autocomplete and syntax coloring within the heredoc. 2.) String Concatenation using an Array The other idiom I like to use is to collect the content into an array and then <code> implode() </code> the array. Although I've never benchmarked this so it could be less helpful than I assume I do know that repeated string concatenation is a killer as strings get larger (if anyone knows why this approach isn't any better or if you know a better approach I'd love to hear feedback): <code> function my_get_form_and_fields($input_items) { $html = array(); $html[] = '&lt;form name="my_form" method="get"&gt;'; foreach($input_items as $input_item) { extract($input_item); $html=&lt;&lt;&lt;HTML &lt;input type="{$type}" size="{$size}" id="{$id}" class="{$class}" value="{$value}" /&gt; HTML; $html[] = '&lt;/form&gt;'; return implode("\n",$html); } </code>
dealing with large HTML output via plugin code
wordpress
My WordPress admin is constantly nagging me to upgrade to version 3.0. However, we use the Flutter plugin to provide all our CMS-like features. It's a pretty great plugin, but it doesn't seem to have been under active development lately, and I hear grumblings it's not compatible with WP 3.0. Is anyone having luck with it? Should I wait around until an updated version is released, or start thinking about re-developing features of our site? Thanks.
Magic Fields is very similar to flutter and is compatible with WordPress 3 If do you want switch between flutter to magic fields you have here a little help for do it http://magicfields.org/script-for-migrate-from-flutter-v-1-1-and-1-0/
Will Flutter work with WordPress 3.0?
wordpress
I'd like to show post comments on their own page without the parent post. I know I can use wp_list_comments() on the single post page and pass a callback function to use my own comment display markup. I plan to do this so I can include a link with each comment that will show that comment on it's own page. If this weren't WordPress I'd use: <code> &lt;a href = " www.example.com/individual_comment.php?comment_id = $comment_id"&gt;View single comment&lt;/a&gt; </code> ...and grab the $comment_id from the query string. What would that link look like in WordPress? ie: what string would I include to get directly to, let's say, my_comments.php where I call get_comment($comment_id) and comment_template()? <code> &lt;a href = "&lt;?php bloginfo('url');?&gt;/what/goes/here?comment_id = $comment_id"&lt;View single comment&lt;/a&gt; </code>
You could probably just create a new page in WordPress, and give that page a custom template. Then the url would just be whatever it normally would be to get to that page. The only difference is that the custom template you are using would be setup to accept the comment_id via the querystring, and then just get the details for the specific comment, and in the template code echo out the details of the comment. So, if you have a page in wordpress called "Comment Details" that you create, you could access that page via http://www.domain.com/comment-details (assuming you have permalinks enabled). So your link would look like this: <code> &lt;a href = "&lt;?php bloginfo('url');?&gt;/comment-details?comment_id=$comment_id"&gt;View single comment&lt;/a&gt; </code> The "Comment Details" page would be set up to use a custom template that would contain the code to spit out the details.
Linking to Page Showing Only Comments Without Parent Post
wordpress
My wordpress required me to check some Trackbacks and I checked and accepted them. They are listed in the comment administration and I activated "allow Trackbacks/Pingbacks on this page" on the relevant articles and pages. But they do not appear below the relevant posts and pages. Comments are displayed, but not Trackbacks. Does this maybe result from me using the "SimpleX" Theme? Can I somehow modify it to display them? Or did I just miss a checkbox?
On what posts did you expect a trackback? SimpleX should support trackbacks, but displays them in a separate box .
Why do Trackbacks/Pingbacks not appear below my posts/pages?
wordpress
I would like to have a single post on my front page (always the latest), but let normal paging work. So the front page has post 1, the next page should have post 2-11 (1-10 is fine too), then 12-21 or 11-20, and so on. I know I can stackexchange-url ("change the number of posts depending on the context"), but setting this to "1" on the homepage means the further pages also show only one post. My main problem is that <code> /page/2/ </code> and so on works, but <code> /page/1/ </code> always redirects to the real home page, <code> / </code> . This means posts 2-10 are always skipped, since page 2 shows 11-20. I currently solve this by linking to my archive, but this is not ideal when you come to the first posts of the year and there are fewer posts and no obvious way of continuing.
I solved it using the <code> offset </code> query parameter . This allowed me to edit the query in the <code> pre_get_posts </code> hook, and seems to be the cleanest way to do this, without a new query. Now the home page shows only one post, and <code> page/2/ </code> shows posts 2-11. All links keep working, no other modification is required. <code> add_action('pre_get_posts', 'set_offset_on_front_page'); function _set_offset_on_front_page(&amp;$query) { if (is_front_page() &amp;&amp; is_paged()) { $posts_per_page = isset($query-&gt;query_vars['posts_per_page']) ? $query-&gt;query_vars['posts_per_page'] : get_option('posts_per_page'); // If you want to use 'offset', set it to something that passes empty() // 0 will not work, but adding 0.1 does (it gets normalized via absint()) // I use + 1, so it ignores the first post that is already on the front page $query-&gt;query_vars['offset'] = (($query-&gt;query_vars['paged'] - 2) * $posts_per_page) + 1; } } </code>
How to show a single post on the front page but have normal paging?
wordpress
In my plugin, I want to test to see if jQuery or Prototype (or both) are going to be loaded by another plugin. So, have <code> wp_enqueue_script('jquery') </code> or <code> wp_enqueue_script('prototype') </code> has already been called. I have code appropriate to my plugin in files <code> plugin.prototype.js </code> and <code> plugin.jquery.js </code> and if Prototype is queued, my plugin will use <code> plugin.prototype.js </code> . This way I avoid loading more than necessary into the site. If neither has loaded, I will queue up whichever is smaller. How can I test to see what has been queued up? How do I make sure my code runs last?
Use <code> wp_script_is() </code> to check if a script is in the queue. <code> function add_my_scripts() { $doing_jquery = wp_script_is('jquery', 'queue'); $doing_prototype = wp_script_is('prototype', 'queue'); var_dump($doing_jquery, $doing_prototype); } add_action('wp_print_scripts', 'add_my_scripts'); </code>
Test to see if jQuery or Prototype is queued by another plugin?
wordpress
I have a client who wants to put on an event. She wants to manage it on her site. The requirements: Display information about the event Sell tickets and correlate with name and email address Payment for tickets via PayPal Allows for cancellations / returns if they happen It may be a recurring event, so allow people to sign up for future events Anything like that exist?
This one is the best I know of: Event Calendar / Scheduler The main features include: Day/Week/Month/Year/Agenda view + ability to create custom view Drag-n-drop support to configure event date and time Customizable appearance Single/multi-days events (daily, weekly, monthly or yearly basis) Customizable time scale Recurring events Multilingual
Plugin for event management?
wordpress
Use case: I have a post type that relates to a music show. The 'show time' is grabbed through the post publish date which is set to some time in the future. I've found a function that takes future dated blog posts and leaves the date but marks the post as published on save but haven't been able to figure how to customize it for a custom post type. The function is below. <code> &lt;?php function setup_future_hook() { // Replace native future_post function with replacement remove_action('future_post','show', '_future_post_hook'); add_action('future_post', 'show', 'publish_future_post_now'); } function publish_future_post_now($id) { // Set new post's post_status to "publish" rather than "future." wp_publish_post($id); } add_action('init', 'setup_future_hook'); ?&gt; </code>
Awesome combining both the answers from Mike and Jan I came up with this which works only on the post type in question. We don't need the conditional of show because the 'future_show' hook only grabs the post type of show and updates that. <code> &lt;?php function setup_future_hook() { // Replace native future_post function with replacement remove_action('future_show','_future_post_hook'); add_action('future_show','publish_future_post_now'); } function publish_future_post_now($id) { wp_publish_post($id); } add_action('init', 'setup_future_hook'); ?&gt; </code>
Marking future dated post as published
wordpress
I need to have an alternating (even, odd...) class on posts to provide alternate highlights on a column. The best thing would be to attach this to the post_class() so that it's on every instance of post_class(). Below is the code I have at this point to achieve this effect. <code> &lt;?php // setting other variables for alternating categories $style_classes = array('even', 'odd'); $style_counter = 0; ?&gt; &lt;?php if (have_posts()) : ?&gt; &lt;?php while (have_posts()) : the_post(); ?&gt; &lt;div class="&lt;?php $k = $style_counter%2; echo $style_classes[$k]; $style_counter++; ?&gt;"&gt; &lt;?php the_cotent(); ?&gt; &lt;/div&gt; &lt;?php endwhile; ?&gt; &lt;?php endif; ?&gt; </code>
You should add the following code in <code> functions.php </code> : <code> add_filter ( 'post_class' , 'my_post_class' ); global $current_class; $current_class = 'odd'; function my_post_class ( $classes ) { global $current_class; $classes[] = $current_class; $current_class = ($current_class == 'odd') ? 'even' : 'odd'; return $classes; } </code> This ensures that all the odd posts on the page will have the class 'odd' and all the even posts will have the class 'even' just by using <code> post_class() </code> in your theme.
Alternate post_class on each post
wordpress
Everytime WordPress stats updates, I need to provide the API key. Is there some way to automate this?
This is why: http://plugins.trac.wordpress.org/browser/stats/tags/1.7.2/stats.php#L685 The deactivation hook deletes your database information. I'm guessing you're manually deactivating the plugin, updating, and then re-activating? If so, that runs the deactivation hook. Fortunately, that's not from the latest version. This is: http://plugins.trac.wordpress.org/browser/stats/tags/1.7.3/stats.php#L686 So that shouldn't happen anymore. By the way, you shouldn't think that this means you were doing anything wrong. They shouldn't be deleting information on deactivation, only on uninstall. Kind of strange that they were doing it at all...
WordPress stats API key
wordpress
I use Art Direction plugin to create customized posts sometimes. I also want to use Super Cache plugin for traffic spikes. However I've found that once you have Supercache activated Art Direction plugin no longer works, due to the way Supercache renders your html. Is there anyway to get around this? Or is there another caching plugin that works with Art Direction?
I believe the only way to currently get around this is to not directly use Art Direction but replicate that functionality yourself. There are a few pages that talk you through doing that: http://digwp.com/2010/02/custom-css-per-post/ http://wordpress.org/support/topic/plugin-art-direction-conflict-with-wp-super-cache Hope that helps!
Plug-in Conflict: Art Direction and Super Cache
wordpress
Aside from the actual WordPress dashboard, what tools are available for writing posts, moderating comments, and otherwise administering your site? Please identify whether you're referencing a desktop tool, a web-based tool, or a mobile tool.
Windows Live Writer Windows Live Writer (WLW) is hands down the best, if you are on Windows. One of the things I love about it is its plugin architecture and how many people have written useful plugins for WLW . Qumana I searched far and wide for an equivalent on the Mac and didn't find a match but came close: Qumana : Qumana still can't touch WLW because it doesn't strip garbage HTML (like from a Word .doc) like WLW does and it doesn't have a plugin architecture, but I keep hoping... :)
What tools are available for managing/writing to WordPress?
wordpress
I'm posting this as a community wiki because I'd like to get a collaboratively edited list of features for a high-end WordPress webhost. For example, if you are running a high-traffic WordPress-based site and/or a WordPress site that needs really hardened security what features would you love to see offered so that you don't have to implement everything that exceeds the most basic installation of WordPress core? Many of us know that WP Engine has just launched and it's the closest thing to a high-end webhost specifically for WordPress that I'm aware of. But rather than have there be only one, it would be great if there were many webhosts offering a much higher level. Admittedly I'm weak in this area which is one of my reasons for posting but I'll start with a strawman list of desired features. Let's ignore the non-WordPress related things like 24 hour phone support, etc. and ask that we also be specific i.e. don't just say " performance optimized " or " highly secure " like you see on this site, but actual specifics that indicate a specific implementation: Preinstalled Memcached support Standard .htaccess tuning for GZIP support Optional integration with Amazon Cloud Front for upload files Automatic file and database backup with an advanced admin console like a "Time Machine" on the Mac but for WordPress in the Browser. Files that are automatically versioned upon FTP upload into SVN or GIT Automatic database versioning into SVN or GIT Pre-selected list of verified and supported plugins What else? I'm sure there's a much longer list than I've come up with. Another speciality feature could also be White-labeled turnkey WordPress multisite hosting . What I mean by this is a service that allows someone with marketing and sales experience in a vertical niche (for example, " Dry Cleaners ") to offer website hosting for their market without having to do any technical work whatsoever, including having the host handle all support as well as signup and billing but do it white-label. I think there's a huge market for this. Note I'm not asking because I want to create such a service, I don't, but I would like to see a definitive reference for webhosts who would consider offering such a service. UPDATE: Another feature that would be nice to have would be to have a service that could synchronize WordPress core, themes and plugins across multiple servers so that managing multiple server instances for a site that needs to scale would be easier and handled by the hosting company. (ref: Ticket #13067 - Configuration of Plugin and Theme Repository/ies) UPDATE #2: Yet another feature would be to offer an option to use a Sphinx Search server and to interface it with WordPress using one of these plugins: WP Sphinx Search WordPress Sphinx Search Plugin WordPress Sphinx Plugin Search API (See Also) UPDATE #3: Cron scheduling via robust and reliable Linux cron as an alternative to WordPress' pseudo-cron (see also and this). Possibly incorporate admin functionality i.e. with one of the following plugins: Crony CronJob Manager Cron View Plugin WP-Crontrol UPDATE #4: Over on the LinkedIn WordPress group someone offered free hosting and I asked him what his service would offer to which he replied the following (need to become a member to see this link, membership is free but I think you have to be approved by the group moderator first): suPHP PHP Minify FFMPEG PHP Mcrypt and all Dependancies ION Cube Loaders GD Library LAME MPlayer/MEncoder Zend Optimizer AMR codec support AC3 codec support AAC codec support MP3 codec support OGG/Vorbis codec support x264 codec support DivX/XviD codec support win32 codec support FLVtool2 W3 Total Cache plugin for use with Highwinds CDN In addition to those items he also mentioned: Latest up to date version of PHP Latest up to date version of MySql MySql configured with high allocations of RAM Systems configured to do their best not to run anything in Swap And in addition to all the above someone else in the group suggested it would be nice to have: Opcode PHP cache like APC or eAccelerator UPDATE #5: The question " <a href="stackexchange-url What steps can I take to optimize wordpress in regard to server load " has some useful comments related to this topic.
I think we also need a few more features: Minifying JS, CSS and the HTML that is being sent down the wire. Caching the op-code of the PHP that will be generated (apart from Memcached). Upload the JS, CSS and Images that are used in the theme and/or plugin to a CDN and sync automatically. Option to use one of the public CDN netwoks like Google for common resources like jQuery. Offer a common CDN for all the WordPress admin scripts and images (which should be the exact same on multiple installations of WordPress) so that I can have that work just a little faster. Managed DNS - To ensure that they can restore a backup of your site on another location automatically in case they have issues with the current hardware. With this they can automatically switch your domains over to the new settings.
Best-of-Breed Features of a High-End WordPress Web Host?
wordpress
First of all, I can't use Trac, which is what the WP dev community uses to track bugs. However, my consulting company is using WordPress as a CMS for just about everything - product information, sales portal, news site, etc. I'd like to set it up to integrate our plug-in listing with a bug tracker ... Right now, I have Flyspray set up as a standalone bug tracker. It works alright, but it's a separate domain ( http://bt.jumping-duck.com ) so that it remains separate from WordPress. But I'd like to be able to pull in numbers of tickets onto the WP page listing our plug-ins. Ideally, users could also submit bug reports directly from the plug-in info page. Does anyone have any experience integrating WP with a bug tracking system like this? Should I stick with keeping the two systems separate?
I don't see any reason not to make WordPress into a bug tracker. Essentially, tickets would be a non-hierarchical custom post type which would have several taxonomies, such as priority, status, etc.
Integrating WP as a CMS with a Bug Tracker
wordpress
I'm updating plugins installed on my wordpress site. However, for almost an hour, it's still doing maintenance mode. When I accidentally hit reload, I got BIG white screen of death saying: "Briefly unavailable for scheduled maintenance. Check back in a minute." Is there anything I can do to fix this mess?
How to clear the "Briefly unavailable for scheduled maintenance" message after doing automatic upgrade? As part of the automatic upgrade WordPress places a file named <code> .maintenance </code> in the blog base folder (folder that contains the wp-admin folder). If that file exists, then vistors will see the message Briefly unavailable for scheduled maintenance. Check back in a minute. To stop that message from being displayed to vistors, just delete the <code> .maintenance </code> file. The automatic upgrade should be executed again, just in case it failed.
Plugin upgrade issue
wordpress
My team and I are working with a client who has an existing WordPress site with a fair bit of content and a custom theme they built. It is a group blog, meaning it has several bloggers all around the world who are adding &amp; editing content all the time. Our job is to create an entirely new theme, with quite a few new features. Some of these features will require new custom widgets, plugins, and database fields. We're currently working off our own development machines and integrating them into a single development server. All code is versioned in SVN. Our appointed DBA is manually merging any database changes into the dev DB right now, though hopefully he'll be able to automate that soon. We just started talking about our production release process. Meaning: once we're done, how are we going to get all of our custom code onto the production (the live) server smoothly and with as little disruption as possible? We have a few plans in mind, but I would love to hear how others have tackled this issue too. Are there any best practices to follow or known pitfalls to avoid? Thanks in advance!
If you follow SethMerrick's advice, you can greatly reduce the switchover time by lowering the TTL on the appropriate DNS records to 5 mins or so several hours (depending on what the current TTL is) before you change the IP address. By doing this you are telling remote DNS servers to only cache the address for 5 mins. Once you change the IP, you can increase the TTL to whatever it was before. To further minimize the effect, do the switchover during a low traffic period.
Do you have any effective strategies for launching a v2 of a WP site?
wordpress
I want to allow readers of my WordPress-driven sites who comment frequently the ability to sign up and have their own account on the site. However the ratio of actual readers versus spam scripts using the sign-up form is something like 1:100. Is there a reasonable solution for preventing these bogus accounts from being created while still allowing reader sign-ups? Last I looked, I couldn't find anything for account creation like what spam-prevention measures are available for comments.
Sabre is great plugin, it allows me to block dozens of spam user registration per week. It has also many useful features to control the style and captcha's complexity.
How Do I Prevent Junk Account Creation?
wordpress
Most people are aware that minimizing the number of plugins used is a good way to help keep a WordPress site running fast. However, does that general rule include deactivated plugins?
No it doesn't. At least, not on the front end, or in the back end in any non-plugin area. WordPress only loads files whose filepaths are stored in the active_plugins option in the database and ignores everything else completely.
Do deactivated plugins slow down a WordPress site?
wordpress
I would really like to add @anywhere support to my blog, as my posts usually mention two or three Twitter users. I'm not much of a code monkey though, and so I'm looking for something that adds @anywhere without me having to do too much configuration. Is there a plugin available where I can add @anywhere and configure it through the WordPress administration panel?
I use Otto's Simple Twitter Connect . It's pretty amazing, and doesn't require too much configuration.
How can I add @anywhere to my blog?
wordpress
I'm using SEO Ultimate. The 404 monitor module is reporting several 404 errors. The errors are reported for urls that do not exist; 3 of them did exist as drafts but were never published. I checked my xml sitemap, but no luck there. Additionally, the link checker is not showing any broken links. Anyone experienced with SEO Ultimate who can point me in the right direction? thanks.
Check the referring URL and the user agent. Usually these are caused by robots that found a link to the draft or happened to be scanning your site while you were previewing the posts. I wouldn't worry about it unless it was an actual user that was getting the error.
An issue with SEO Ultimate
wordpress
Twice now I've updated wordpress, only to realise that (facepalm) it overwrites some changes I've made to the custom template - to sidebar or something similar. Obviously I don't HAVE to update, but it's better to for add-ons etc, and I like having the latest products and bug fixes. What are other people's strategies for straightforward updates to wordpress without losing custom modifications to the default template?
Very simple : if you use the default template, rename it folder name and css file declaration) and it won't be updated. If you want the updates (for instance the Twenty One is often updated), create a child theme . Infos here : http://codex.wordpress.org/Child_Themes
Updating WordPress overwriting customization tweaks - strategies?
wordpress
My WordPress now is at version 2.7. I want to upgrade it to 3.0.1 using Auto update function. I'm using FTPS connection type. The upgrade should be straight forward, however, I keep on encountering this error: Installation Failed Downloading update from http://wordpress.org/wordpress-3.0.1.zip … Unpacking the update… Verifying the unpacked files… Installing the latest version… Could not copy file.: /wp-admin/css/theme-editor.dev.css Installation Failed I've checked the permission for the <code> /wp-admin/css </code> folder, and it's set to 777. What is the problem? I've searched the internet, but it seems that a lot of people has the same problem . Any ideas?
Auto update doesn't always work, it almost always works. I'd just upgrade manually and not worry about it. The few times I've had an auto update failure it succeeds the next time a new version comes out (after I'm manually updated during the breakage).
WordPress 3.0.1 Auto Update Problem
wordpress
Sometimes I want to develop WordPress themes when I have no internet connection. I need the Function Reference and Template Tags to be productive. I searched for a downloadable or SVN copy of the Codex but could not find one. I ended up trying to mirror it using <code> wget </code> , but the results were spotty (it's too huge!). Is there a better way?
I Use a much faster and easier way to create a local copy of the codex without installing a local server and without installing copy of mediawiki, its called ScrapBook which is a Firefox extension, that helps you to save Web pages and manage the collection. Key features are lightness, speed, accuracy and multi-language support. using it's Save Web site (In-depth Capture)feature you can set the directories you want to save , which in your case would be <code> Function Reference </code> and <code> Template Tags </code> you can also organize your collections just like bookmarks, edit saved files and highlight key parts of pages and the best thing about it is the built in full text search.
Local copy of WordPress Codex?
wordpress
I realize this may be a broad question on the surface, but I'm looking for specific examples of setups/workflows that people use to keep a version history of edited files on a WordPress site. For instance, when developing a site (and even after it's live), I often make changes to CSS and PHP files, but I don't have a great way of reverting to older versions of those files. For my purposes, making changes on a local development installation and then copying those changes over to the live site is often more trouble than I'd like. Any suggestions on how to get started using a versioning tool to track edits to files on a live site?
I am not sure how much you know about using version control, but I recently switched from SVN to GIT and find that to be great! Though it depends in you live site's server has GIT installed (or will let you). I have a GIT setup on the live server also, running of a branch called something like <code> production </code> . Whenever I finish implementing / fixing something locally, I merge it into the <code> production </code> branch, then SSH into the live site's server and pull in the changes. Beats dragging files over FTP when you never know if you are overwriting changes etc. I would recommend putting some time it getting aquatinted with GIT (if you haven't already), I find it much easier and less hassle than SVN when it comes to changing / adding loads of files (and unlike SVN it doesn't put stupid <code> .svn </code> folder everywhere ). So: Sure, I am on a Mac, so sorry if none of these applies. Code Editor: Coda Installed GIT through Ports (using Porticus) Git: GitX If I were to set everything up a new, I would do: Install Coda Install Porticus (which will require you to install Ports, but there is information on that page) Once you have installed Porticus, open it open, search for "git-core" and Install that. Download and Install GitX 7-5 There is a good guide on setting up a git repo here , but at it's basic: 1. Open Terminal. 2. <code> cd </code> to where you want your site to reside. <code> $: mkdir mysite &amp;&amp; cd mysite </code> 3. <code> $: git init </code> and thats it! If you add files to this folder then continue to the next step Once you have set up a GIT repository locally (above article) then if you open that directory in GitX you will be able to commit stuff etc etc. Setting it all up on the server can be a bit tricky, I have a MediaTemple and a Dreamhost account which both have GIT out of the box. The link in 5. tells you how to add a remote repo, do you dont have to do that until you want to bring your live site into the equation. I would recommend getting everything working locally first (unlike SVN, GIT doesn't require a remote repository, so you can bo everything on your machine for the time being)
Getting Started with Subversion, Git, or similar Version Control System to keep a History of my Files?
wordpress
what the best way to include images from the template's images folder? is it by using <code> get_bloginfo('template_url') </code> ? I understood that its better to hard code the path to the images folder since this way you save function calls in PHP.. any thoughts?
The easiest and simplest way to do it is define a unique variable in your theme's <code> functions.php </code> file. Such as: <code> &lt;?php $theme_name_images = get_bloginfo('stylesheet_directory') . '/images/'; ?&gt; </code> No need for classes as a previous answer suggested. EDIT: It should be get_bloginfo, instead of bloginfo(), as Viper007Bond kindly pointed out.
what the best way to include images from the template's images folder?
wordpress
About a month ago I started a WordPress blog on a hosted server related to a hobby. So, I am new to this at present. Since I'm concerned about security, one thing I did was to install the plugin WP Security Scan. According to the plugin results, my site checks out except that I get this in the results as a red flag: The file .htaccess does not exist in wp-admin/ (I ssh'd in there and it does not exist) Ok, so I did a considerable search on the issue and find too much info on .htaccess. I've been through Hardening WordPress on the WordPress.org site, etc. And also ran into this article: http://digwp.com/2010/07/wordpress-security-lockdown/ Anyway, I've basically gotten confused with the plethora of information available. What should the .htaccess file in wp-admin contain? I've read that this .htaccess file should password protect the wp-admin directory and I've also read that this can cause functionality problems. Help with this is greatly appreciated. Thanks. -wdypdx22 Update Ok, so I'm not logged in to my blog and using a different computer than usual. I enter the url www.mysite.com/wordpress/wp-admin/ and there is a redirect to login. If that's what happens, then is an htaccess file even needed in the wp-admin directory?
UPDATE : When I first posted my answer I missed the crux of the question; my answer was about <code> .htaccess </code> security in general and is now listed below the double line (look down if it interests you.) Unfortunately I don't have specific experience with securing <code> /wp-admin/ </code> using <code> .htaccess </code> so I'll simply list the two resources I will pursue when and if I need it: Hardening WordPress with .htaccess AskApache Password Protection, For WordPress The first one recommends the following (and here is some discussion about it.) <code> &lt;Files ~ "\.(php)$"&gt; AuthUserFile /etc/httpd/htpasswd AuthType Basic AuthName "restricted" Order Deny,Allow Deny from all Require valid-user Satisfy any &lt;/Files&gt; </code> The latter has lots of information, especially in the comments, but admittedly providing you a list to read is not the answer you were looking for. Sorry I couldn't have been more helpful on this one. ======================================== Typically WordPress only has the following which handled permalink processing and is not related to security: <code> # BEGIN WordPress &lt;IfModule mod_rewrite.c&gt; RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] &lt;/IfModule&gt; # END WordPress </code> Recently I've found the WP htacess Control plugin that manages a lot of <code> .htaccess </code> for you and I rather like it a lot. After tweaking it's settings it added the following options: <code> # WPhtC: Disable ServerSignature on generated error pages ServerSignature Off # WPhtC: Disable directory browsing Options All -Indexes # WPhtC: Protect WP-config.php &lt;files wp-config.php&gt; order allow,deny deny from all &lt;/files&gt; # WPhtC: Protect .htaccess file &lt;files ~ "^.*\.([Hh][Tt][Aa])"&gt; order allow,deny deny from all &lt;/files&gt; </code> It also added these options which are about performance instead of security: <code> # WPhtC: Setting mod_gzip &lt;ifModule mod_gzip.c&gt; mod_gzip_on Yes mod_gzip_dechunk Yes mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$ mod_gzip_item_include handler ^cgi-script$ mod_gzip_item_include mime ^text/.* mod_gzip_item_include mime ^application/x-javascript.* mod_gzip_item_exclude mime ^image/.* mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.* &lt;/ifModule&gt; # WPhtC: Setting mod_deflate &lt;IfModule mod_deflate.c&gt; AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/javascript text/css application/x-javascript BrowserMatch ^Mozilla/4 gzip-only-text/html BrowserMatch ^Mozilla/4.0[678] no-gzip BrowserMatch bMSIE !no-gzip !gzip-only-text/html Header append Vary User-Agent env=!dont-vary &lt;/IfModule&gt; </code> Beyond this one there are some plugins I haven't tried but that are focused on security and that interact with <code> .htaccess </code> - you might try them each just to see what they do to the <code> .htaccess </code> file: WP Super Secure and Fast htaccess (also) BulletProof Security Silence is Golden Guard WP-BlockYou Stealth Login HTTP Authentication AskApache Password Protect Beyond that, if you want to know the (IMO) #1 expert resource on Apache security related to WordPress you can find it on AskApache.com; dude is hardcore! His blog won't solve your " too much information " problem but at least you can view it as an authoritative resource! Here are some examples (though not all are directly WordPress related they all are applicable): Advanced WordPress wp-config.php Tweaks Example .htaccess for WordPress Advanced WordPress 404 Mod_Security .htaccess tricks .htaccess Plugin Blocks Spam, Hackers, and Password Protects Blog Anyway, hope this helps.
Security and .htaccess
wordpress
Is there anyway I can add an html link from the quick press on the Wp-admin Dashboard? Does it accept html? If only I could do that, I wouldn't have to go to create new post everytime I wanted to blog.
QuickPress does allow html to be added. Just try it. Add this as the content of your post inside QuickPress: <code> &lt;b&gt;&lt;a href="stackexchange-url Link!&lt;/a&gt;&lt;/b&gt; </code>
Html and links via Quick press
wordpress
I'm new to WordPress. Which steps would I need to do, to get my new design implemented as a WordPress theme?
An alternative to a "skinnable" theme framework like Carrington (which indeed is awesome) is to integrate a design you've done from scratch. This is how I learned how to create custom WordPress themes. Note: this is a hacky method that involves lots of experimentation. But if you're like me, and learn best when you're playing around with your hands, this may teach you a lot. BTW, I assume you know HTML, CSS, and PHP. If not, working knowledge of those technologies would be required to build a new theme from scratch. Working knowledge of LAMP is also helpful. First, build out your design in static code: HTML and CSS. Make sure it's cross-browser friendly and includes all of the elements a WordPress blog would (i.e. comments, archive pages, etc). Also, place all of the CSS code into a single file named "style.css" and make sure all external file references (for CSS, images, JS, etc) use relative URLs, not absolute URLs. Get WordPress running on your local machine. This will require installing Apache, PHP, and MySQL onto your desktop or laptop. If you're using Windows, the WampServer is a nice solution. If you're using a Mac, MAMP works well too. Then install WordPress. Open up the files for the Default theme that comes with the WordPress installation package. It's in the /wp-content/themes/default/ folder. This theme probably has more files than you'll need. As an alternative, you can also start with the Classic theme instead, which has fewer theme files, in /wp-content/themes/classic/ of course. BTW: the Default theme is selected by default (duh), but if you want to start with the Classic theme, make sure you activate that theme within the WP admin, so you can see how it looks. In your browser, keep the Theme Development section from the WordPress Codex open. You'll be needing it very often. On the Template Files List , you'll see how that list maps to the files you see in the Default (or Classic) theme. Some theme files are required, some aren't. Depending on the kind of person you are, you can now start mucking around with the theme files and see what works, what breaks, etc. You can even start moving pieces of your own design into this theme. Or, you can read the Theme Development instructions carefully (the info on The Loop is especially important), then come back and muck with the files. When I started doing this, lots of stuff would break. Don't worry if that happens, that's why you're doing this on your own local machine and not on a public website. The breakages are part of the fun of learning. Eventually, you'll be able to slowly move pieces of your HTML and CSS into the Default or Classic theme, then get it all running. That's when you'll graduate from a n00b to an Apprentice. And after that, you'll be able to move pieces of PHP code (which are WordPress' Template Tags ) out of the Default or Classic theme, and into your HTML. That's when you'll graduate to a Journeyman. (I consider a Senior Journeyman someone who can write their own widgets, plugins, and themes with great ease. And a Master, well, at that point, you're contributing back to the WordPress Core. I'm definitely not that.) I hope this helps.
How to create a new theme from scratch?
wordpress
I've read a few tutorials on how to add the functionality of the custom menus added in version 3.0 to my theme but they all seem to differ somewhat, and I'm not sure whether they contain superfluous code. In addition I read that the code to register your theme as menu-compatible changed between the RC and the public release. What's the simplest way of adding support for custom menus to my theme?
The easiest way is to use the <code> register_nav_menus </code> function.This should be hooked into <code> 'after_setup_theme' </code> : <code> function my_cool_menu_function(){ register_nav_menus( array( 'primary' =&gt; 'Primary Navigation' )); } add_action( 'after_setup_theme', 'my_cool_menu_function' ); </code> Then, in your theme, simply call that menu's position: <code> wp_nav_menu( array( 'theme_location' =&gt; 'primary' ) ); </code>
How do I add support to my theme for custom menus?
wordpress
Now with those custom post types and other bits of content that don't necessarily need to be organized chronologically by date, for example: the client has a 100 T-Shirts as custom post type "SHIRT" and he wants to set their appearance order. What approach you suggest taking for letting the editor/admin of the site SORT their order?
I might suggest these: http://drewgourley.com/order-up-custom-ordering-for-wordpress/
visually sort ordering "custom post types" for end users
wordpress
I have some options I want my client to be able to change, and so I need an options page for my theme that I can show for those with "editor" status. How can I do this and utilise the options in my pages?
This tutorial is pretty awesome for explaining the basics, and you end up with a nicely styled options panel at the end of it too. There are a few such tutorials around, it's surprisingly easy to get the hang of. I've never tried it but you should be able to add a bit of PHP checking whether the current user has a high enough permission level and displaying an error message if not, or just to stop it from adding the link to the options page in the first place. Best to get familiar with how to actually build the page first, however.
How do I create my own admin button and theme settings page?
wordpress
Usually when I create some form of query, I use an array for my arguments like this: $postslistArgs = array( 'child_of' => 320, 'parent' => 320 ); $postslist = get_pages($postslistArgs); There are other times, however, when I need/want to use URI-style query parameters like this: get_pages('child_of=320&parent=320'); That's all straightforward, but is there any way possible to use the URI parameter style on more advance union/intersection queries such as <code> post__not_in </code> that require an array of IDs?
WP_Query uses PHP's native <code> parse_str </code> function, which uses the following structure to denote arrays: <code> 'post__not_in[]=1&amp;post__not_in[]=2&amp;post__not_in[]=3' </code> is the same as <code> array( 'post__not_in' =&gt; array( 1,2,3 ) ) </code>
Use union/intersection query_posts variables in uri request parameter form?
wordpress
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, the focus in the wp-admin console is clearly on new posts, and creating pages with custom content like maps and galleries feels like I'm working around the system rather than with it. Do you have any suggestions as to using WordPress as a CMS? Specifically: Are there any good boilerplate themes that are designed around a CMS rather than a blog? Are there any good plugins to help with treating WordPress as a CMS? Alternatively, should I be using WordPress at all?
The killer feature that caused WordPress 3.0 to cross over from an extensible blogging tool to the CMS for 8 out of 10 needs is Custom Post Types (with the addition of Custom Taxonomies from v2.9) with an honorable mention going to the new Menu system in 3.0. So if you want to learn WordPress as a CMS then study Custom Post Types. Here's a few articles to get you started: Custom post types in WordPress Rock-Solid WordPress 3.0 Themes using Custom Post Types Everything You Need to Know About WordPress Custom Post Types Custom Post Types in WordPress 3.0 The WordPress Codex on Custom Post Types Adding Custom Field GUI to Custom Post Types in WordPress 3.0 Explore the Power of Custom Post Types to Maximize WordPress as a CMS Smarter Custom Post Types There are also several plugins to make Custom Post Types easier in no particular order and albeit all of them are still a long way from being fully mature so Caveat Emptor!: WP Easy Post Types GD Custom Posts And Taxonomies Tools Custom Post Type UI Simple Fields As for Themes, that's a different subject. While blog themes all implemented the same use-case pattern, each person's CMS needs are likely to be different because each business is different (a restaurant needs different layouts than a yoga studio than an movie theatre than a fabric store.) At least early on I think you'll be hard-pressed to find the perfect ready-made " off-the-shelf " theme for your business; best to find one that's generally good and plan on modifying it or get a WordPress designer to build you a custom one. Having them layer on top of themes like the Genesis Framework from StudioPress can be a good option. Best I can suggest is to look for ones that support the WordPress 3.0 menu system and then make your decisions from there. You can google for that and look for articles like this one: 22+ Fresh and Free WordPress 3.0 Ready Themes P.S. If you are asking about streamlining the admin user interface so that the Posts and Pages and other blogging tools take a back seat and your specific CMS content is featured in the admin instead then that's a different subject; can I suggest you ask another question for that one? UPDATE : Here are some screen shots from some projects I'm working on to give you an idea of what can be done:
Tips for using WordPress as a CMS?
wordpress
I want to force a secure connection on some of my pages (ones with forms), but I don't want the whole site to work with ssl (slows it down) Is there a way to configure specific pages to require ssl?
Use the admin-ssl plugin. For stuff outside of wp, use rewriite rule in apache
Is there a way to force ssl on certain pages
wordpress
I design &amp; build a lot of bespoke Wordpress themes for clients, and before I just took the best parts out of the default Kubrick and made my own 'vanilla' theme. The new default, TwentyTen is way too complex for my needs, and is a bit kitchen sink. Are there any lightweight WordPress 3 themes like these? http://designceo.com/20-lightweight-minimalist-wordpress-themes ? Thanks!
Just a suggestion and not necessarily the answer, but some of those are so basic I'm wondering if using the Starkers theme from Elliot Jay Stocks and just adding a bit of style to it, could make the simple theme you've been looking for.
Looking for a lightweight theme using WP3 new tags and features (not 2010)
wordpress
I use the great Changelogger plugin, which adds plugin version history to the plugins page when there is an update. Although I would like it to, it doesn't work from the updates page where you can update WordPress core, plugins, and themes. How and where can a new hook for that page be requested so that the changelogs can be added to that page too?
You'll want to make a new ticket here: http://core.trac.wordpress.org/ Explain why you want a new hook and how it could be used. Including a patch file also goes a long ways towards getting the hook included in WordPress.
How and where can we request new WordPress hooks to be added?
wordpress
Is it possible to rename the wp-admin folder? I know I could just rename it, but unless it's supported by the code lots of things would break. If I use a custom folder name, it will make it slightly more secure, security by obscurity and all that.
Unfortunately it's not currently possible nor does there appear to be will to consider it as a modification as you can see by this recent thread on the wp-hackers list and this ticket on trac. If you'd really like to see this be revisited I'd suggest: Present your case on wp-hackers but be forewarned your use-case better be good and not "security through obscurity" or it will get shot down as above. Present your argument in a trac ticket with the same caveats. Even better, upload a patch to trac that enables your desired functionality. It's much harder to say no when the work has already been done (but of course, they do have a preference for saying "no" a lot more often than they say "yes" so be forewarned.)
Can I rename the wp-admin folder?
wordpress
If I write a private plugin, is there any way to use the WordPress auto-update mechanism to update it? I want to encapsulate the functionality, but it's specific to my own 5 or so blogs, so it's not a good candidate for the public plugins resource. But I love the easy-updating mechanism. Is there a way to do this?
Looks like the applicable code is in <code> wp-includes/update.php </code> , <code> wp_update_plugins() </code> : <code> $to_send = (object) compact('plugins', 'active'); $options = array( 'timeout' =&gt; ( ( defined('DOING_CRON') &amp;&amp; DOING_CRON ) ? 30 : 3), 'body' =&gt; array( 'plugins' =&gt; serialize( $to_send ) ), 'user-agent' =&gt; 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ) ); $raw_response = wp_remote_post('http://api.wordpress.org/plugins/update-check/1.0/', $options); </code> It specifically checks api.wordpress.org. Technically speaking it would be possible to pass a key inside <code> $to_send </code> to delegate the check, but to my knowledge that is not a supported feature. If you hook into <code> set_site_transient_update_plugins </code> you could add your own package details into this variable. It looks like those values will be trusted when you run the plugin updater. See <code> wp-admin/update.php </code> and <code> wp-admin/includes/class-wp-upgrader.php </code> . Given the code in these two functions, I think it would be possible to inject your own update server, you just need to look at how the package details are formatted and match that.
Updates for a private plugin?
wordpress
I would like to place content in a sidebar of my blog articles when they are viewed in the archive, but not show this content when the blog articles are shown on the main page of my site. Can this be done?
Another approach: edit your theme files. <code> archive.php </code> can simply not call in the sidebar, and that will do what you're asking. Have a look at the Template Hierarchy for a view of what the individual files in a theme take care of.
How do I place content on archive pages but not on main page?
wordpress
Sometimes it would be nice to be able to set a draft to be published when I'm not in front of the keyboard. Is this possible? If so, how?
Since a picture is worth a thousand words: 1) Click "Edit" next to "Publish Immediately" 2) Change the date 3) Click "OK"
How can I delay the publishing of a page or post?
wordpress
In the Reading Settings, there is place to set the number of posts shown that affects the number of posts shown in all contexts. I'd like to show instead a certain number of posts on the homepage, and a different number of posts on pages like archive, search results, etc. I realize I could do this by editing the theme files and changing the query parameters there, but I'd prefer to have easier access to a simple settings page. A long time ago, I came across a plugin that did this, but I can't locate it now. Does anyone know of a plugin to do this, or even a function I could put in functions.php to accomplish the same thing?
I believe the best way to do this in a plugin is to run the following sample function when the <code> pre_get_posts </code> action hook is encountered. The <code> $wp_query </code> object is available, meaning your conditional tags are available, but before WordPress gets the posts, which means you are changing query vars prior to the first query being run, rather than adding a second query like when query_posts() is used in a theme file. <code> function custom_posts_per_page($query) { if (is_home()) { $query-&gt;set('posts_per_page', 8); } if (is_search()) { $query-&gt;set('posts_per_page', -1); } if (is_archive()) { $query-&gt;set('posts_per_page', 25); } //endif } //function //this adds the function above to the 'pre_get_posts' action add_action('pre_get_posts', 'custom_posts_per_page'); </code>
Show a different number of posts per page depending on context (e.g., homepage, search, archive)
wordpress
Below is an example. 3 classes attached to each item, except current item, which has 6. Can I pare this down somehow? <code> &lt;ul id="menu-global-nav" class="sf-menu"&gt; &lt;li id="menu-item-63" class="menu-item menu-item-type-post_type current-menu-item page_item page-item-5 current_page_item menu-item-63"&gt;&lt;a href="#"&gt;Home&lt;/a&gt;&lt;/li&gt; &lt;li id="menu-item-30" class="menu-item menu-item-type-post_type menu-item-30"&gt;&lt;a href="#"&gt;Services&lt;/a&gt; &lt;ul class="sub-menu"&gt; &lt;li id="menu-item-39" class="menu-item menu-item-type-post_type menu-item-39"&gt;&lt;a href="#"&gt;Case Studies&lt;/a&gt;&lt;/li&gt; &lt;li id="menu-item-38" class="menu-item menu-item-type-post_type menu-item-38"&gt;&lt;a href="#"&gt;Story Discovery&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li id="menu-item-32" class="menu-item menu-item-type-post_type menu-item-32"&gt;&lt;a href="#"&gt;Company&lt;/a&gt;&lt;/li&gt; &lt;li id="menu-item-29" class="menu-item menu-item-type-post_type menu-item-29"&gt;&lt;a href="#"&gt;Why Case Studies?&lt;/a&gt;&lt;/li&gt; &lt;li id="menu-item-28" class="menu-item menu-item-type-post_type menu-item-28"&gt;&lt;a href="#"&gt;Case Study Showcase&lt;/a&gt;&lt;/li&gt; &lt;li id="menu-item-27" class="menu-item menu-item-type-post_type menu-item-27"&gt;&lt;a href="#"&gt;Resources&lt;/a&gt;&lt;/li&gt; &lt;li id="menu-item-26" class="menu-item menu-item-type-post_type menu-item-26"&gt;&lt;a href="#"&gt;Online Store&lt;/a&gt;&lt;/li&gt; &lt;li id="menu-item-25" class="menu-item menu-item-type-post_type menu-item-25"&gt;&lt;a href="#"&gt;Contact Us&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; </code>
I'm going against the majority on this one :) Yes, it can be a good idea to strip it down. Personally I'm keeping only the <code> current-xxx </code> type classes and replacing them with <code> active </code> , and <code> active-parent </code> (for active parent or ancestor items). Why? around the web, active has became the standard class for active menu items (on top of that WP has inconsistent class naming conventions between its' own class names). you get to write less CSS rules; the bandwidth that you save might not be much, but it certainly makes the CSS file more readable Updated code: <code> // for custom menus add_filter('nav_menu_css_class', 'normalize_wp_classes', 10, 2); // for the page menu fallback (wp_list_pages) add_filter('page_css_class', 'normalize_wp_classes', 10, 2); /** * @param $classes array * @param $item object * @return array */ function normalize_wp_classes(array $classes, $item = null){ // old classes to be replaced with 'active' $replacements = array( 'current-menu-item', 'current-menu-parent', 'current-menu-ancestor', 'current_page_item', 'current_page_parent', 'current_page_ancestor', ); // if any of the classes above are present, // return an array with a single class ('active') return array_intersect($replacements, $classes) ? array('active') : array(); } </code> Update: For anyone using this code, the <code> active-parent </code> class is no longer required (unless you still need IE 6 support). Using the child selector ( <code> &gt; </code> ) you can effectively style the active parent and active child any way you want.
Why do Custom Nav Menus generate so many classes on list items? Can I manage this somehow?
wordpress
How can I stop WordPress from prompting me to enter FTP information when doing updates?
If you edit your <code> wp-config.php </code> file you can preload these FTP settings as constants read by WordPress. Keep in mind, on a shared host, you should be mindful of possible security implications. See Editing <code> wp-config.php </code> for more information. Your settings will vary, but these work for me and my hosting setup. I've included some of the unused constants, prefixed: <code> define('FS_METHOD', 'direct'); define('FTP_BASE', '/usr/home/username/public_html/my-site.example.com/wordpress/'); define('FTP_CONTENT_DIR', '/usr/home/username/public_html/my-site.example.com/wordpress/wp-content/'); define('FTP_PLUGIN_DIR ', '/usr/home/username/public_html/my-site.example.com/wordpress/wp-content/plugins/'); // define('FTP_PUBKEY', '/home/username/.ssh/id_rsa.pub'); // define('FTP_PRIKEY', '/home/username/.ssh/id_rsa'); define('FTP_USER', 'my-ftp-username'); define('FTP_PASS', 'my-ftp-password'); define('FTP_HOST', 'ftp.my-site.example.com'); // define('FTP_SSL', false); </code>
How can I stop WordPress from prompting me to enter FTP information when doing updates?
wordpress
The WordPress codex page for query_posts states that it does not cover all the parameters which query_posts takes: Parameters This is not an exhaustive list yet. It is meant to show some of the more common things possible with setting your own queries I couldn't find a reference of all the parameters which are accepted by query_posts, though, even in just a simple list form. Is there a cheat-sheet or something similar available with this data?
Below is everything from WordPress 3.0.1 found in the <code> parse_query() </code> function of /wp-includes/query.php <code> (lines 1246-1550) </code> . However, it's possible for a plugin to add parameters and so a list can never be fully complete: <code> attachment </code> <code> attachment_id </code> <code> author </code> <code> author_name </code> <code> cat </code> <code> category__and </code> <code> category__in </code> <code> category__not_in </code> <code> category_name </code> <code> comments_popup </code> <code> day </code> <code> error </code> <code> feed </code> <code> hour </code> <code> m </code> <code> minute </code> <code> monthnum </code> <code> name </code> <code> order </code> <code> orderby </code> <code> p </code> <code> page_id </code> <code> page </code> <code> paged </code> <code> pagename </code> <code> post__in </code> <code> post__not_in </code> <code> post_status </code> <code> post_type </code> <code> preview </code> <code> robots </code> <code> s </code> <code> sentence </code> <code> second </code> <code> static </code> <code> subpost </code> <code> subpost_id </code> <code> tag__and </code> <code> tag__in </code> <code> tag__not_in </code> <code> tag_id </code> <code> tag_slug__and </code> <code> tag_slug__in </code> <code> tag </code> <code> taxonomy </code> - (pre 3.1) <code> tb </code> <code> term </code> - (pre 3.1) <code> w </code> <code> withcomments </code> <code> withoutcomments </code> <code> year </code> Pre WP 3.1 <code> meta_key </code> <code> meta_value </code> Since WP 3.1 <code> fields </code> <code> meta_query </code> <code> tax_query </code>
What are all the available parameters for query_posts?
wordpress
When editing one of my custom post types I want to be able to list all entries by a custom field instead of the date they are published (which, for a custom post type probably isn't relevant). I got a lead from the comments of a blog post about custom post types and the author said it was possible and that he even made it so you could click on the column names for a custom sort. He mentioned the <code> posts_orderby </code> function which I noted in my own comments but now I can find the blog post anymore. Any suggestions? I saw one solution that used <code> add_action('wp', 'check_page'); </code> And the <code> check_page </code> function used <code> add_filter </code> to change the query but I'm pretty sure it would only work in the theme files, not in the admin area.
As you can probably imagine by the lack of answers provided, the solution is not exactly trivial. What I've done is create a somewhat self-contained example that assumes a custom post type of " <code> movie </code> " and custom field key of " Genre ". Disclaimer : this works with WP3.0 but I can't be sure it will work with earlier versions. You basically need to hook two (2) hooks to make it work and another two (2) to make it obvious and useful. The first hook is ' <code> restrict_manage_posts </code> ' which lets you emit an HTML <code> &lt;select&gt; </code> in the area above the list of posts where the " Bulk Actions " and " Show Dates " filters. The code provided will generate the " Sort by: " functionality as seen in this screen snippet: The code uses direct SQL because there is not a WordPress API function to provide the list of all meta_keys for a post types (sounds like a future trac ticket to me...) Anyway, here's the code. Note that it grabs the post type from <code> $_GET </code> and validates to make sure it is both a valid post type <code> post_type_exists() </code> as well as being a <code> movie </code> post type (those two checks are overkill but I did it to show you how if you don't want to hard-code the post type.) Lastly I use the <code> sortby </code> URL parameter as it doesn't conflict with anything else in WordPress: <code> add_action('restrict_manage_posts','restrict_manage_movie_sort_by_genre'); function restrict_manage_movie_sort_by_genre() { if (isset($_GET['post_type'])) { $post_type = $_GET['post_type']; if (post_type_exists($post_type) &amp;&amp; $post_type=='movie') { global $wpdb; $sql=&lt;&lt;&lt;SQL SELECT pm.meta_key FROM {$wpdb-&gt;postmeta} pm INNER JOIN {$wpdb-&gt;posts} p ON p.ID=pm.post_id WHERE p.post_type='movie' AND pm.meta_key='Genre' GROUP BY pm.meta_key ORDER BY pm.meta_key SQL; $results = $wpdb-&gt;get_results($sql); $html = array(); $html[] = "&lt;select id=\"sortby\" name=\"sortby\"&gt;"; $html[] = "&lt;option value=\"None\"&gt;No Sort&lt;/option&gt;"; $this_sort = $_GET['sortby']; foreach($results as $meta_key) { $default = ($this_sort==$meta_key-&gt;meta_key ? ' selected="selected"' : ''); $value = esc_attr($meta_key-&gt;meta_key); $html[] = "&lt;option value=\"{$meta_key-&gt;meta_key}\"$default&gt;{$value}&lt;/option&gt;"; } $html[] = "&lt;/select&gt;"; echo "Sort by: " . implode("\n",$html); } } } </code> The second required step is to use the <code> parse_query </code> hook that is called after WordPress decides one what query is should run but before it runs the query. Here we get to set values of <code> orderby </code> and <code> meta_key </code> in the query's <code> query_var </code> array which are documented in the Codex in the <code> orderby </code> parameter for <code> query_posts() </code> . We test to make sure that: We are in the admin ( <code> is_admin() </code> ), We are on the page that lists posts in the admin ( <code> $pagenow=='edit.php' </code> ), The page has been called with a <code> post_type </code> URL parameter equal to <code> movie </code> , and The page has also been called with a <code> sortby </code> URL parameter and that it wasn't passed a value of ' None ' If all those tests pass we then set the <code> query_vars </code> (as documented here) to <code> meta_value </code> and our <code> sortby </code> value for ' Genre ': <code> add_filter( 'parse_query', 'sort_movie_by_meta_value' ); function sort_movie_by_meta_value($query) { global $pagenow; if (is_admin() &amp;&amp; $pagenow=='edit.php' &amp;&amp; isset($_GET['post_type']) &amp;&amp; $_GET['post_type']=='movie' &amp;&amp; isset($_GET['sortby']) &amp;&amp; $_GET['sortby'] !='None') { $query-&gt;query_vars['orderby'] = 'meta_value'; $query-&gt;query_vars['meta_key'] = $_GET['sortby']; } } </code> And that's all you need to do; no " <code> posts_order </code> " or " <code> wp </code> " hooks required! Of course you actually do need to do more; you need to add some columns on your page that lists the posts so you can actually see the values that it is sorting by otherwise the users will get mucho confused. So add a <code> manage_{$post_type}_posts_columns </code> hook, in this case <code> manage_movie_posts_columns </code> . This hook gets passed the default array of columns and for simplicity I just replaced it with two standard columns; a checkbox ( <code> cb </code> ) and a post name ( <code> title </code> ). (You can inspect <code> posts_columns </code> with a <code> print_r() </code> to see what else is available by default.) I decided to add a " Sorted By: " for when there is a <code> sortby </code> URL parameter and when it is not <code> None </code> : <code> add_action('manage_movie_posts_columns', 'manage_movie_posts_columns'); function manage_movie_posts_columns($posts_columns) { $posts_columns = array( 'cb' =&gt; $posts_columns['cb'], 'title' =&gt; 'Movie Name', ); if (isset($_GET['sortby']) &amp;&amp; $_GET['sortby'] !='None') $posts_columns['meta_value'] = 'Sorted By'; return $posts_columns; } </code> Finally we use the <code> manage_pages_custom_column </code> hook to actually display the value when there is a post of the appropriate post type and with the probably redundant test for <code> is_admin() </code> and <code> $pagenow=='edit.php' </code> . When there is a <code> sortby </code> URL parameter we extract the custom field value that is being sorted by an display it in our list. Here's what it looks like (remember, this is test data so no comments from the peanut gallery on the movie classifications! :): And here is the code: <code> add_action('manage_pages_custom_column', 'manage_movie_pages_custom_column',10,2); function manage_movie_pages_custom_column($column_name,$post_id) { global $pagenow; $post = get_post($post_id); if ($post-&gt;post_type=='movie' &amp;&amp; is_admin() &amp;&amp; $pagenow=='edit.php') { switch ($column_name) { case 'meta_value': if (isset($_GET['sortby']) &amp;&amp; $_GET['sortby'] !='None') { echo get_post_meta($post_id,$_GET['sortby'],true); } break; } } } </code> Note that this only picks up the first " Genre " for a <code> movie </code> , i.e. the first meta_value in the case of multiple values for a given key. But then again I'm not sure how it would work otherwise! And for those unfamiliar with where to put this code you can put it in a plugin or more likely for the newbie in the <code> functions.php </code> file in your current theme. How this helps.
How to sort the admin area of a WordPress custom post type by a custom field
wordpress
In particular in table <code> wp_options </code> . After almost 2 years of blog production it seems increased a lot, and I don't know how many crap is in there. Do you know a plugin that works with WordPress 3.0 or safe query to run to search orphan keys/rows?
There is no query that will be 100% certain to delete everything unused and not delete those things because any theme or plugin can add options to the <code> wp_options </code> table. Still, with a little effort you can get a pretty good idea of what's not in use and then manually decide which of those things to delete and which not to. You can put the following code temporarily into your theme's <code> functions.php </code> file and then visit every (type of) page on your public-facing site and more importantly all the admin pages in the admin console. Once you've done that you can open your <code> wp_options </code> table and look at the field <code> use_count </code> (added by the code below) to see which options have a <code> use_count </code> equals to zero (the use count is mostly meaningless other than anything greater than 1 has been read or updated at least once since you added this code.) <code> global $wpdb; header('Content-Type:text/plain'); $results = $wpdb-&gt;get_results("SHOW COLUMNS FROM wp_options WHERE Field='use_count'"); if (count($results)==0) { $wpdb-&gt;query("ALTER TABLE {$wpdb-&gt;options} ADD COLUMN use_count int UNSIGNED NOT NULL DEFAULT '0' AFTER autoload"); } add_action('all','monitor_get_option_usage'); function monitor_get_option_usage($filter){ if (preg_match('#^option_(.*)$#',$filter)) { increment_option_use_count(substr($filter,7)); } } add_action('updated_option','monitor_update_option_usage'); function monitor_update_option_usage($option){ increment_option_use_count($option); } function increment_option_use_count($option) { global $wpdb; $wpdb-&gt;query("UPDATE {$wpdb-&gt;options} SET use_count = use_count + 1 WHERE option_name = '$option'"); } </code> With this you'll probably be able to identify options that are associated with long gone plugins, former themes and even options of your own you added early on but no longer use. Export them all to a backup (just in case) and then delete the ones you are comfortable deleting. Once you are done you can remove the <code> use_count </code> field (if you want to, doesn't hurt for it to be there) and also remove the code above from your <code> functions.php </code> file too. Although this is still not perfect it's much better than nothing. Hope it helps?
How can I delete orphan keys in WordPress database tables?
wordpress
I want to learn how to create a theme for WordPress. Where can I find information and resources on how to do it?
There are many different ways to learn to create your own theme. First, there's the "official" WordPress Codex on Developing Themes , but I'd say that it is more of a reference than a tutorial. Another approach and one I like a lot is to read some of the better tutorials about WordPress Theming on the various blogs around the web. Here are some reasonably good ones, in no particular order: " How to Build a Custom WordPress Theme from Scratch " on SpoonGraphics.co.uk (Feb 2010) " How To Create a WordPress Theme: The Ultimate WordPress Theme Tutorial " on Themeshaper.com (Jun 2009) " Building Custom WordPress Theme " on WebDesignerWall.com (Nov 2008) Yet another option is to check out some of the videos/screencasts on the subject such as this series of videos/screenacasts which I've found to be one of the better ones: WordPress Theme Tutorial by andrewanimation/AMPtutorials on YouTube: Part 1 - Setup Part 2 - Homepage and Functions Part 3 - Single Post Template Part 4 - Custom Comment Display Part 5a - Customizing Your Comment List Part 5b - Customizing Your Comment List Part 6 - Additional Pages Part 7a - Dynamic Sidebars Part 7b - Multiple Sidebars Part 8a - Adding a Theme Options Page Part 8b - Adding a Theme Options Page . Then of course there are the books you can get, if you must go this route (be sure to hunt for the used ones on Amazon; they are often much cheaper than new): stackexchange-url ("Smashing WordPress: Beyond the Blog") stackexchange-url ("Build Your Own Wicked Wordpress Themes") Rockstar WordPress Designer stackexchange-url ("WordPress Theme Design: A complete guide to creating professional WordPress themes") stackexchange-url ("WordPress 2.8 Themes Cookbook") stackexchange-url ("WordPress 2.8 Theme Design") . Lastly you can hang out here and ask questions and/or any of these other places where there are always WordPress-istas willing to help: WordPress Group on LinkedIn - for WordPress users, developers, and consultants, to connect, and to share ideas, questions, and contacts. WP Tavern Forum - forum with various sections for discussion including topics such as general WordPress, business, plugins and hacks, resources and tutorials, themes and templates, and troubleshooting. WP Garage - mailing list at Yahoo which provides advice and answers to questions relating to WordPress. Hope this helps!
Where can I learn to create my own theme?
wordpress
I want to have my custom field use HTML, how do I do that in such a way that I can use a rich text editor to view the content?
You can use Advanced Custom Fields plugin. It's pretty easy to use and very powerful, so it's the best choice right now, I guess.
I want to have my custom field use HTML, how do I do that?
wordpress
I'm having a strange problem with my w-admin login. This has only started since I upgraded to 3.0 When I go to wp-admin, the login form appears as normal, but when I enter my username and pass, I am presented with the login form again every time. Using the password recovery feature results in an email not found error. I know the username password and email are correct, b/c I have access to the mysql database and I can see the values (at least the user name and email). Anyone have any ideas of what could be going wrong?
The main cause I've seen for this is incompatible plugins. Via FTP, either download and delete all your plugins, or rename the existing plugins folder to plugins-old (or whatever) and make a new plugins folder. After this, copy your plugins from the old folder to the new folder one by one until the problem reappears. At that point, you have your culprit. Look for an updated version (after deleting the offending plugin from the new plugins folder so you can log in) of the offending plugin and go from there.
wp-admin seems to be redirecting
wordpress
I want to use HTML5 in my WordPress theme, how do I turn off wptexturize? I don't mind WP adding breaks, but I want them to be <code> &lt;br&gt; </code> and not <code> &lt;br /&gt; </code> . How do I get control over how those breaks show up in my code? EDIT: I only really care about the <code> &lt;br&gt; </code> tag issue, I don't mind the typographic changes it makes. EDIT2: Actually, I guess <code> &lt;img&gt; </code> tags matter too. Any self-closing standalone tags will matter here. So, <code> &lt;hr&gt; </code> might be an issue as well. Not to mention such <code> wp_head() </code> items as <code> &lt;link&gt; </code> and various <code> &lt;meta&gt; </code> tags.
Line breaks are added by <code> wpautop() </code> , not <code> wptexturize() </code> . <code> wpautop() </code> is also the function that automatically adds paragraph tags. You're better off fixing the <code> &lt;br /&gt; </code> 's than you are replacing the filter. Since <code> wpautop() </code> runs at priority 10, you can just hook in after that and fix it. <code> add_filter( 'the_content', 'html5_line_breaks', 25 ); function html5_line_breaks( $content ) { return str_replace( '&lt;br /&gt;', '&lt;br&gt;', $content ); } </code> Edit after OP update: WordPress functions are designed to output XHTML. In order to get rid of those trailing slashes site-wide, you're going to have to use an output buffer. You could use a filter similar to the one above to replace slashes in the post contents, but that wouldn't catch your head, sidebar, etc. It's a bit ugly and might have a small impact on performance, but here you go (drop this in a plugin or your theme's <code> functions.php </code> file): <code> if ( !is_admin() &amp;&amp; ( ! defined('DOING_AJAX') || ( defined('DOING_AJAX') &amp;&amp; ! DOING_AJAX ) ) ) { ob_start( 'html5_slash_fixer' ); add_action( 'shutdown', 'html5_slash_fixer_flush' ); } function html5_slash_fixer( $buffer ) { return str_replace( ' /&gt;', '&gt;', $buffer ); } function html5_slash_fixer_flush() { ob_end_flush(); } </code> That code says if you're not in the administration area and not doing an AJAX request handling, then start buffering the output through a filter and then using the WordPress shutdown hook, output that buffer.
How do I turn off self-closing tags for markup in WordPress (for HTML5, or HTML4, for example)?
wordpress
I have a spreadsheet (XLS) of names, email addresses, and passwords from another content management system. Is there a way to import these folks as users (I think subscriber level, but some may be Editors as well) into WordPress?
A new file, <code> import.php </code> : <code> &lt;?php define('WP_INSTALLING', true); // this is required. i forget why! include '/path/to/wordpress/wp-load.php'; include ABSPATH . WPINC . '/registration.php'; // wp_insert_user() $userdata = array('user_login' =&gt; 'jdoe', 'user_pass' =&gt; 'foobar'); $user_id = wp_insert_user($userdata); </code> Check <code> wp_insert_user() </code> for other possible fields. Run <code> update_usermeta() </code> for any additional needed meta fields. (Including user level, though there may be convenience functions.) Note that here at work we redefine the <code> wp_authenticate() </code> function (it's in <code> pluggable.php </code> , so it can be replaced by defining it in your own plugin) and creating user accounts on-demand if they don't exist at login time.
How can I import users into WordPress?
wordpress
I recently built a WordPress site based and am using BuddyPress for some interactive community functionality. Members are using the forums built into BuddyPress, but are looking for a way to attach or embed pictures in their posts. Is there any way to extend the BuddyPress forums to allow this, or are there existing plugins that allow this? Or, is there a better forum that can be integrated into WordPress?
And, since I can't (yet) post multiple links, here's two more answers in short succession. For attachments, there's: http://buddypress.org/community/groups/forum-attachments-for-buddypress/
Posting Photos and Other Attachments in a BuddyPress Forum?
wordpress
I want to export some or all of the posts of a blog into a format that makes sense to a publisher (traditional or self-publisher(e.g.: Lulu.com)) (MS Word, RTF, PDF, epub, something else). What tools are available to accomplish this?
Anthologize A great option is the Anthologize plugin. It works with WordPress 3.0, allows you to format your book in WordPress itself, and then publish everything automatically to PDF, ePub, and other formats.
How do I export my WordPress blog as a book?
wordpress
How do I make sure my blog is iPad / iPhone / Android / touch-device friendly?
I personally use the WP Touch plugin on my site. It automatically detects if the user is browsing with an iPhone (or iPad) and reformats the site into an iOS-friendly layout with touch-sensitive controls. There's an option at the bottom for visitors to display the normal site if they want. It's a very well-supported system, and I've used it on 3 of my own sites and 12 client sites so far without any issues whatsoever.
How do I make my blog iPad / iPhone / Android friendly?
wordpress
I'm at version 3.0 and want to move to 3.0.1 without having to download/unzip/delete/upload but I get this error when trying to update: Could not create directory.: /public/wp-content/upgrade/wordpress-3.tmp/wordpress Is is safe to chmod 777 the upgrade folder?
It should be relatively safe to chmod it to 777 for as long as you need to in order to upgrade, and then change back to what it was before. Generally speaking, 755 is the recommended directory permission.
Permissions to get autoupdate to work
wordpress
Suggestions for plugins, best practices, etc. welcome.
Just saw this article the other day: http://pluginize.com/blog/tutorials/how-to-create-a-simple-affiliate-program-in-wordpress/ They provide a tutorial and suggest using the following plugins: Gravity Forms WP Hide Dashboard Gravity Forms Affiliate Add-On Plugin The tutorial also has some code snippets that you will need to add. I haven't tried it out, but it would be great if you came back and posted your results, as I'm sure many people would find it useful. There are also a number of commercial products solely for this purpose; just google " affiliate platform Wordpress ".
How can I create an affiliate program in WordPress?
wordpress
How does one go about building a page in wordpress that contains a contact form full of custom fields, boxes, inputs, etc. completely determined by the author of the site. It seems odd that wordpress currently lacks this feature, but knowing the wordpress community, it's unlikely that we must do without.
Contact Form 7 is one of the most popular plugins to add a contact form to a WP blog. It supports multiple contact forms and you can add/remove fields as needed. Additional services such as reCAPTCHA and Akismet can be added. I use this on most of my blogs to power the contact features.
Contact Form on WordPress Sites?
wordpress
I've recently upgraded to WordPress 3.0, and am having a lot of problems with the autocomplete function when editing posts via 'quick edit' (e.g. /wp-admin/edit.php) - for example, editing tags. The autocomplete box often obscures the textbox I'm trying to enter text into, and sometimes gets 'left behind' once the 'update' button has been clicked. Is there a way to disable the autocomplete? UPDATE To clarify, this is a Wordpress autocomplete feature, not a browser-based one. UPDATE 2 It looks as if I need to remove the 'suggest' argument to "load-scripts.php", referenced at the bottom of each admin page like so: <code> &lt;script type='text/javascript' src='http://www.example.com/path/to/wordpress/wp-admin/load-scripts.php?c=1&amp;amp;load=hoverIntent,common,jquery-color,suggest,inline-edit-post'&gt; &lt;/script&gt; </code> That seems to be generated by: <code> do_action('admin_print_footer_scripts'); </code> but I lose the code trail at that point - anyone?
I have a solution I tested, and it works. The autocomplete for the tags is currently done via an ajax request to the file admin-ajax.php. The solution I would suggest is to block the processing of the request so that it does not return any result. I would do : <code> function no_tag_suggest() { if( DOING_AJAX == true &amp;&amp; $_GET['action'] == 'ajax-tag-search' &amp;&amp; $_SERVER['HTTP_REFERER'] == admin_url( 'edit.php' ) ) { die; } } add_action('admin_init', 'no_tag_suggest'); </code> The previous function verify: if it is an ajax request if the action paramater is 'ajax-tag-search' if the referer url is the '/wp-admin/edit.php' page If these 3 conditions are meet, no result will be returned and the tag suggestions not displayed. If you want to remove this autocomplete from all the pages, not the 'wp-admin/edit.php' only, you can do: <code> function no_tag_suggest() { if( DOING_AJAX == true &amp;&amp; $_GET['action'] == 'ajax-tag-search' ) ) { die; } } add_action('admin_init', 'no_tag_suggest'); </code> I would suggest you to look at the code of 'admin-ajax.php' to see all the 'action' parameters there, thus all the ajax requests you can kill with similar methods. I hope my explanation was clear. Don't hesitate to ask me if you want more details or have any question. Bounty for me? :)
Can I disable the autocomplete?
wordpress
How can I instruct wordpress to use a filename other than 'styles.css' for my main stylesheet - for example, styles-1.css? I'd like to do this for versioning and caching purposes.
<code> Style.css </code> is required for your WordPress theme. That's where WordPress gets the theme name and meta information for the Appearance > > Themes menu from. That said, you don't actually have to use <code> style.css </code> in your theme at all. I know of several readily available themes that don't use it, and I only use it in a handful of my custom designs. In <code> header.php </code> just place the following tag in place of the regular stylesheet link: <code> &lt;link rel="stylesheet" type="text/css" href="&lt;?php bloginfo('stylesheet_directory'); ?&gt;/style-1.css" /&gt; </code> This will load your alternative stylesheet as the page's stylesheet and completely ignore the regular <code> style.css </code> .
How can I version the main CSS file?
wordpress
I've got the Akismet plugin on my WordPress site but I've been getting more and more spammy comments (that get caught). I'm amazed at the number as the site isn't that popular and doesn't have much traffic. Are there any methods for reducing spam?
For my blog, I too run Akismet to catch any spam that is posted to my blog, but I also prevent spam from being posted in the first place using a few plugins: Cookies For Comments requires that people leaving comments have cookies and CSS stylesheets enabled. A stylesheet is added to your site that when loaded sets a cookie. This cookie is then looked for when a comment is left. No cookie? The comment is rejected. This is effective because most spam bots do not load stylesheets or accept cookies. Note this will not prevent spam left by humans (it'll be Akismet's job to catch that). Disable Trackbacks does exactly what it says it does. When you receive spam pings (links from other blogs), most often those are in the form of the deprecated trackback instead of the better and more modern pingback. Trackbacks, when used normally, require the person sending the trackback to enter a special URL from your blog into their blog. Trackbacks are pretty much never used legitimately anymore, so you can safely disable them and avoid lots and lots of ping spam. Akismet will take care of any pingback spam (it happens, but not nearly as much). With those two plugins installed along side Akismet, I only get a few spams and very rarely do any of them actually make it onto my blog. Hope that helps.
how to reduce the number of spam comments
wordpress
I've read articles about protecting wp-config.php using .htaccess as well as setting the correct file permissions but I want it all in one place. What should my .htaccess file look like and what folders is it safe to have 777 vs 755 permissions?
Hardening WordPress on the WordPress Codex is a very good article on how to secure your WordPress blog, which goes into quite some detail on file permissions, as well as some other methods of securing WP.
How to to secure WordPress file and folder permissions
wordpress
The custom types/taxonomies feature of WP 3.0 is a neat one. I can think of a few ways to use the duo: to display projects, a portfolio, or a gallery. What else can custom types and taxonomies be leveraged for?
Custom types can be leverage for anything that can be repeatable. So as you said a gallery or portfolio would work very nicely. I've already used them on a few different projects: Recipes Employee Roster Callouts for the homepage rotating sliders. Other ideas are: products for a commerce site—The custom taxonomies would make for some powerful option for each product. For custom sidebar content. Y An Ad manager. The possibilities are really endless. Anything that can be seen as a collection is really what this is for.
How can you use custom types/taxonomies?
wordpress
I'm using the All in One SEO plugin for my site. The extra fields and options it supplies seem like they could be handled via a theme, possibly negating the use for a plugin. Should SEO considerations be handled by a theme, rather than delegating the work to a separate plugin? It could reduce maintenance issues, takes up less space, and be more integrated.
Ideally, SEO should always be handled by the theme. Actually, most plug-in behavior that impacts the front-end of a site should be handled by the theme. Plug-ins like All in One SEO are quick solutions for people who don't want to invest the time required to re-code a theme they built, downloaded from a free site, or purchased from another developer. Putting the functionality in the theme itself gives you more control, makes WordPress faster, and means you don't need to worry about upgrades potentially breaking your site if they introduce new bugs that conflict with other systems you're using.
Should a SEO plugin be necessary?
wordpress
I'm aware of the requirements WP has for certain directories and files to be writable. I'm also aware that making permissions too loose can open security holes. Finally, I know that the user that (insert your server here) runs as on Linux systems can be a factor. Security aside, I like being able to download themes and plugins to my blog, and update them when necessary. Proper permissions seem to be a bit at odds with this preference. I've collected little bits of detail here and there, but I'd like to see a more definitive answer, if there is one: what is the preferred setup with a nod to security? What permissions should be in place, what user should the site run as, etc.
If you have FTP access to your server, the most secure setup is not having your themes or plugins directory writable by your webserver and instead having WordPress update files using FTP. When you go to update a plugin, WordPress will prompt you for your FTP details. The FTP method is a lot slower than direct file writes, but it is a lot more secure as a rogue script won't be able to modify your files.
What is the ideal setup to address security concerns?
wordpress
How can I allow moderated anonymous contributors to post to my blog?
I would probably either use GravityForms or CForms plugins to allow that, both have a "form to post" feature that creates a new post and lets the admin moderate it before publishing.
How can I allow moderated anonymous contributors to post to my blog?
wordpress
I was interested in the recent conversation about whether WordPress themes need to be licenced under the GPL or whether they can be closed source. The video can be reached from matts blog and my favourite discussion about it is Dave Winers blog post . My question is - am I allowed to license my theme under the aGPL ? or is this the same argument as if I wanted to use a closed source license?
Since WordPress is licensed as GPLv2, you can license any addition (i.e. theme) with a license that's compatible with version 2 of the GPL. Now here's the unfortunate part ... version 1 of the aGPL is not compatible with any version of the GPL. Version 3, however, is compatible with GPLv3 ... but not GPLv2. Short answer: no, you can't license a WordPress theme with aGPL because neither version of the aGPL is compatible with WordPress' license (GPLv2). Link to license compatibility chart for reference ... Update Strictly speaking, yes. WordPress themes are considered derivative works, so they must be licensed in a fashion compatible with the core project. WP is licensed as GPLv2+, so you can (if you want to) upgrade it to GPLv3 for distribution. That's important, because the only version of the aGPL that's compatible with the GPL is version 3 ... so your theme must be aGPLv3. That said, you're under no expectation to redistribute WordPress on your own ... I'm just pointing out the compatibility here. But to keep things simple, I will always advise against using the aGPL. In practice, it doesn't lend well for WordPress themes (feel free to ask me why, but that's beyond the scope of this question).
Am I allowed to license my Wordpress theme under the aGPL
wordpress
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 there better ways of doing this?
@Insanity5902 : Deployment of a WordPress site from one box to another has been a PITA since day one I started working with WordPress. (Truth-be-told it was a PITA with Drupal for 2 years before I started with WordPress so the problem is certainly not exclusively with WordPress.) It bothered me that every time I needed to move a site I'd have to spend so much often duplicated effort and it kept me from deploying to test as frequently as I would have preferred. So about 4-6 months ago I started working on a plugin to solve the webhost migration problem and I mentioned my ideas on the WP Tavern forum. Well fast forward to today and I've pretty much got it working and I'm conveniently calling it " WP Migrate Webhosts ." Even though the plugin is still very much beta (probably even alpha) given your question I think I'm ready to let people start banging on it. The envisioned use-case is that 1.) first the developer handles uploading all the changed theme and plugin files via FTP, 2.) then uploads the development MySQL database to the testing server in its entirety and finally 3.) then runs the plugin to migrate any references from the prior domain to the new one. (My plugin does not attempt to solve the merging of new database fields or tables with live data; THAT is a much bigger problem that I'm not sure how to solve.) You can download the plugin from my website and unzip into your plugins directory (if you don't know how to do this then this plugin is not for you because it requires someone who knows what they are doing to use it.) I'll keep this plugin online until I release it to WordPress.org after which you should look for it there. To use it you take a different approach in your <code> wp-config.php </code> that normal by commenting out the four (4) defines <code> DB_NAME </code> , <code> DB_USER </code> , <code> DB_PASSWORD </code> and <code> DB_HOST </code> and instead registering the defaults for webhosts and then registering info about each webhost itself. Here's what that segment of <code> wp-config.php </code> might look like (note the first section is the unneeded code commented out and also note that I set up my hosts file on my local machine with non-routable <code> .dev </code> top level domains to make day-to-day development easier. On the Mac VirtualHostX makes this a breeze): <code> // ** MySQL settings - You can get this info from your web host ** // /** The name of the database for WordPress */ //define('DB_NAME', 'wp30'); /** MySQL database username */ //define('DB_USER', 'wp30_anon'); /** MySQL database password */ //define('DB_PASSWORD', '12345'); /** MySQL hostname */ //define('DB_HOST', '127.0.0.1:3306'); require_once(ABSPATH . 'wp-content/plugins/wp-migrate-webhosts/wp-webhosts.php'); register_webhost_defaults(array( 'database' =&gt; 'example_db', 'user' =&gt; 'example_user', 'password' =&gt; '12345', 'host' =&gt; 'localhost', 'sitepath' =&gt; '', // '' if WordPress is installed in the root )); register_webhost('dev',array( 'name' =&gt; 'Example Local Development', 'host' =&gt; '127.0.0.1:3306', 'domain' =&gt; 'example.dev', 'rootdir' =&gt; '/Users/mikeschinkel/Sites/example/trunk', )); register_webhost('test',array( 'name' =&gt; 'Example Test Server', 'rootdir' =&gt; '/home/example/public_html/test', 'domain' =&gt; 'test.example.com', )); register_webhost('stage',array( 'name' =&gt; 'Example Staging Server', 'rootdir' =&gt; '/home/example/public_html/stage', 'domain' =&gt; 'stage.example.com', )); register_webhost('live',array( 'name' =&gt; 'Example Live Site', 'rootdir' =&gt; '/home/example/public_html/', 'password' =&gt; '%asd59kar12*fr', 'domain' =&gt; 'www.example.com', )); require_once(ABSPATH . 'wp-content/plugins/wp-migrate-webhosts/set-webhost.php'); </code> Hopefully this is (mostly) self explanatory. I attempted to make the code as clean as I could but unfortunately it requires those two cryptic <code> require_once() </code> lines before and after the block of webhost registration code since there was no way for me to " hook " WordPress before <code> wp-config.php </code> is called. Once you have updated your <code> wp-config.php </code> then you can simply use the URL shortcut <code> wp-migrate-webhosts </code> to go to the admin screen like so: http://example.com/wp-migrate-webhosts The above will take you to an admin screen like the following which has a fair bit of description text and allows you to migrate FROM any of the other webhost domains with a single click after selecting the domains to migrate from ( NOTE : this example shows going DOWN from test/stage/live servers to local development but rest assured it can migrate TO any domain where it happens to be located. This also means the plugin will be great for taking an existing live site and quickly getting a local development environment working! ): If it's not clear " migration " in this context means to update all the references in the current database to be appropriate for the currently defined webhost (and " current " is sniffed by inspecting <code> $_SERVER['SERVER_NAME'] </code> .) What's cool about the plugin is that it implements some basic migrations but anyone can hook it and perform their own migrations . For example, if you add a gallery plugin that stored full paths to images in the database you could hook the <code> migrate_webhosts </code> action which will be passed the " from " webhost and the " to " webhost each as an array of metadata and you'll be allowed to perform whatever you need to do in the database using SQL or any applicable WordPress API functions to do the migration. Yes any of us could do this without the plugin but without the plugin I found that writing all the code needed was more effort than it was worth. With the plugin it's just easier to write these tiny hooks and get it over with. You may also find my migrations fail in edge cases I've not tested and maybe you can help me improve the plugin? Anyone who wants to can email me via my gmail account (my alias is "mikeschinkel.") Also, the plugin was designed to accept user-define webhost metadata in addition to the ones it recognizes like <code> database </code> , <code> user </code> , <code> password </code> , <code> host </code> , <code> domain </code> etc. A perfect example might be <code> googlemaps_apikey </code> where you can store a the different API keys for each domain that your Google Map's plugin needs to operate correct (who among you who has used a Google Maps plugin hasn't deployed an app to a live server and forgotten to change the code to the correct API key? Come on, be honest... :) With this plugin, a <code> googlemaps_apikey </code> element in your register_webhost() array and a small custom <code> migrate_webhosts </code> hook you can effectively eliminate that as a concern! Well that's about it. I'm launching this plugin here on WordPress Answer's Exchange because @Insanity5902's question triggered it. Let me know if it's helpful, here if appropriate or via email if not. P.S. If you do decide to use this remember it is alpha/beta and that means it will change so be prepared for some minor surgery if you want to use it now and then use the released version once its been beaten on by many hands. P.P.S. What are my goals with this? I've love to see this migrate into WordPress core so that everybody would have access to it. But before that can even be considered lots of people have to be interested in using it to ensure it actually solves more problems then it potentially could create. So if you like the idea then by all means use it and help me gain momentum with it for eventual hopeful inclusion into WordPress core.
How to: Easily Move a WordPress Install from Development to Production?
wordpress
I am unable to install any theme/plugin to my wordpress 3.0 <code> Downloading install package from http://downloads.wordpress.org/plugin/contact-form-7.2.3.1.zip… Unpacking the package… Installing the plugin… Could not copy file. /public_html/blog/wp-content/plugins/contact-form-7/languages/wpcf7-lt_LT.po Plugin install failed. Downloading install package from http://wordpress.org/extend/themes/download/piano-black.2.2.zip… Unpacking the package… Could not create directory. /public_html Downloading install package from http://downloads.wordpress.org/plugin/contact-form-7.2.3.1.zip… Unpacking the package… Could not create directory. /public_html/blog/wp-content/upgrade/contact-form-7.tmp/contact-form-7 </code> I get similar messages everytime. Is there any solution? Update 12/01/2012 : If you're using a latest version of WP (3.1 and above, 3.3.1 as of today), you will not have any problems. These issues have been removed. Enjoy your WP.
headdesk Permissions on all WordPress files should be 644. Permissions on all WordPress directories should be 755. Exceptions: The uploads directory may need to be 775 or 777, depending on your server configuration. wp-config.php should be 600, 640, or 644, whatever is the lowest number that works. Never, ever, give higher permissions than those. That way lies dragons. If you're having trouble writing files, then the first thing to do is to install the Core Control plugin and try to figure out what is failing. Specifically, the "Filesystem" module lets you diagnose which mechanism WP_Filesystem is attempting to use. That way, you don't waste time screwing around with the wrong thing: http://wordpress.org/extend/plugins/core-control/ Once you know the mechanism (probably the FTP method or a direct method) then you'll better know how to approach the issue. If it's direct, then you either have a file ownership issue or a permissions issue. If it's FTP, then you may have a loopback connectivity issue, or a file ownership issue.
How to prevent plugin, theme installation failures on Wordpress?
wordpress
I just upgraded to the latest Wordpress and activated this theme. It displays the following Hello world! Posted on May 27, 2010 by admin Welcome to WordPress. This is your first post. Edit or delete it, then start blogging! Posted in Uncategorized | 1 Comment | Edit Is there an option to remove the Posted on and Posted in ?
I don't think there is an option to do that. You can edit the theme to remove those elements, but then you will have a problem when the theme gets updated (pretty frequently for Twenty Ten right now. But if you did want to do it, you have three ways to do it: You can edit PHP files for the presentation (e.g. loop.php) under Appearance/Editor and delete the whole section responsible for it You can edit functions.php that contains twentyten_posted_on and twentyten_posted_in functions to stub them out to return nothing You can edit CSS to make corresponding classes (entry-meta and entry-utility I believe) to be invisible. WordPress still has to do all work and it is still there in source code, but it could be the faster option. You could even use FireBug to test whether the display will look correct when you remove those. There are better and more esoteric ways to do it (child themes), but I am not sure I could describe it in a text box.
Remove "Posted on" and "Posted in" from the Twenty Ten Theme
wordpress
I want to use a good elegant slideshow control in my website. The website is created in wordpress and I am using the Thesis theme. I did find a Nivo slider but am stuck at the integration with Thesis (using the custom functions and custom css files). Can someone suggest a good non-flash slideshow widget which I can easily integrate with the theme (and also how to integrate it) Thanks.
Here is a list with some of the widgets: http://www.geeksucks.com/showcases/12-awesome-wordpress-slideshow-plugins.htm Then, here is the slideshow list from the official plugin directory: http://wordpress.org/extend/plugins/tags/slideshow
Slideshow control for use in Wordpress Thesis theme - non flash
wordpress
I have a y.wordpress.com blog and I contribute to another x.wordpress.com under the role editor adding post contributions.The owner's account is set to publicize to Twitter any updates he/she makes. I do not have the credentials of the owner for x.wordpress.com. How can I publish a post so that it publicizes to their Twitter account and not mine ?
From one of WP engineers: It's not possible for you to publish a post and have it publicized under the blog owners credentials. It sounds like you are setup as an author on blog x. If you were setup as a contributor you could write the post but it would have to be published by the owner of the blog. They would then be authorized to publicize the post when they published it. Otherwise the only option would be to publicize the post manually through Twitter. You can find more information on User roles here: http://en.support.wordpress.com/user-roles/ Okay just to clarify one thing, I am not talking about the owners WP credentials but rather the owners Twitter credentials. In any case, I thought there could be some kind of authorization like in any other twitter application. Since the author needs to be authorized by the owner to be able to be appointed and Twitter needs authorization from the owner to publish. Unless I am missing a hole between these two closed paths. In this case, I believe the Twitter credentials are tied to the individual's WordPress.com credentials. When a post is published it looks at the information for the person publishing and pull the Twitter account info from there. To quote from the Publicize docs page: "For multi-author blogs, each user that wants to connect to a Publicize service will need to do so separately as well." That page can be found here: http://en.support.wordpress.com/publicize/ I think it would be a nice feature to attach a Twitter (Facebook, Yahoo, etc.) account to the blog so that all posts published there could be publicized through one account. I'll pass that along to our developers and see what they think. There may be some complications with doing this that I haven't thought of which may be why they didn't implement the feature like that.
Using WordPress publicize with main account and editor user accounts
wordpress
I've got a WordPress site that includes pages pulled from a different database. The problem is that these other pages return a 404 status code. (The WordPress posts/pages are fine.) The 404'ed pages display fine, and I removed the "Page not Found" text from the title tag in WordPress. But Googlebot and W3C see the 404 header. So: wow does one tell Apache to suppress a 404 status? And will Apache override WordPress's 404 header? Does that make sense? What other info and things should I be looking at? Can I suppress the status code in .htaccess so I don't change WP core files?
You can either add custom rewrites to your pages. Or on the top of the template files that wrap your other pages just output <code> header('HTTP/1.1 200 OK'); </code> .
How does one suppress a 404 status code in a WordPress page?
wordpress
I need to create a variable that can be accessed throughout my WordPress Theme template files (index.php, header.php etc..). I know function definitions go inside the <code> functions.php </code> template file (in your theme path), but there's no such thing for variables. For example I constantly need to retrieve Categories in my Theme, so I would like to have this accessible from anywhere in my theme: <code> $categories = get_categories(); /* get_categories() is a wordpress function */ </code> This way I can simply access to allocated data, without having to re-allocate it every time I need to get my categories. Unfortunately adding that piece of code in my <code> functions.php </code> file, doesn't work, neither does making the variable <code> global </code> .
Apparently <code> global </code> does the trick. The problem was that my variable <code> $categories </code> should have been redefined with a <code> global </code> in front of it, in each template I needed to use it.
WordPress Theme variables scope
wordpress
By default, the WordPress tag cloud widget has a set amount of 45 tags to display. This can be seen in the <code> wp-includes/category-template.php </code> file. By default, the WooCommerce plugin which I have installed, and it's products tag cloud widget also resembles this. How do I modify this amount from within my <code> wp-content/themes/functions.php </code> file, to display for example, only 15 product tags? Here is what I have so far, but it is not working. <code> function custom_tag_cloud_widget($args) { $args['smallest'] = 8; //smallest tag $args['largest'] = 22; //largest tag $args['number'] = 15; //adding a 0 will display all tags $args['unit'] = 'pt'; //tag font unit return $args; } add_filter( 'widget_tag_cloud_args', 'custom_tag_cloud_widget' ); </code> When changing the number within the core <code> wp-includes.php/category-template.php </code> file to 15 however, it does work. Obviously, I don't wish to edit any core files and am looking for an alternative solution. Thanks.
Add the following to your theme's function.php. Default values are shown below, except changing 'number' from 45 to 15. Only the changed values need to be included, so you can either leave the default values or remove/comment out those lines. For Wordpress Tag Cloud widget: <code> function custom_tag_cloud_widget() { $args = array( 'smallest' =&gt; 8, 'largest' =&gt; 22, 'unit' =&gt; 'pt', 'number' =&gt; 15, 'format' =&gt; 'flat', 'separator' =&gt; "\n", 'orderby' =&gt; 'name', 'order' =&gt; 'ASC', 'exclude' =&gt; '', 'include' =&gt; '', 'link' =&gt; 'view', 'taxonomy' =&gt; 'post_tag', 'post_type' =&gt; '', 'echo' =&gt; true ); return $args; } add_filter( 'widget_tag_cloud_args', 'custom_tag_cloud_widget' ); </code> For WooCommerce Product Tags widget: <code> function custom_woocommerce_tag_cloud_widget() { $args = array( 'number' =&gt; 15, 'taxonomy' =&gt; 'product_tag' ); return $args; } add_filter( 'woocommerce_product_tag_cloud_widget_args', 'custom_woocommerce_tag_cloud_widget' ); </code>
Edit tag cloud widget number
wordpress
Here is my excerpt code. <code> // Generate custom excerpt length function wpbx_excerpt_length($length) { return 300; } add_filter('excerpt_length', 'wpbx_excerpt_length'); </code> How do I allow html like <code> &lt;a&gt; &lt;b&gt; &lt;i&gt; &lt;br&gt; </code>
COMPLETE GUIDE TO EXCERPTS I've recently answered a few questions regarding excerpts, so I'm going to give a detailed explanation covering as much as I can. HTML TAGS/FORMATTING <code> the_excerpt() </code> first of all doesn't accept any parameters, so nothing can be passed to it. It is a fact that <code> the_excerpt() </code> trims the content to 55 words, and all html tags are stripped before returning the text. <code> the_excerpt() </code> is located in wp-includes/post-template.php . To allow certain or all html tags in the excerpt, a new excerpt has to be created. First of all, the original function needs to be removed first, and then the new function needs to be hooked to <code> get_the_excerpt </code> . Please take note, this new excerpt will still be callable as <code> the_excerpt() </code> in template files, no need to change that. <code> get_the_excerpt() </code> is located in wp-includes/post-template.php . The excerpt uses <code> wp_trim_excerpt </code> to return the trimmed text, so we need to remove <code> wp_trim_excerpt </code> first from the excerpt filter. <code> wp_trim_excerpt() </code> is located in wp-includes/formatting.php , line 2355. This is how: <code> remove_filter('get_the_excerpt', 'wp_trim_excerpt'); </code> You can now add your new excerpt to <code> get_the_excerpt </code> <code> add_filter('get_the_excerpt', 'wpse_custom_wp_trim_excerpt'); </code> To allow html tags/formatting, we will need to specify which tags you will need to allow. You can use the following <code> strip_tags </code> statement to achieve that <code> $wpse_excerpt = strip_tags($wpse_excerpt, wpse_allowedtags()); </code> The second argument <code> wpse_allowedtags() </code> is a small function that is used to add the tags <code> the_excerpt() </code> will allow. For a complete list of valid HTML5 tags, go and check it out here . Here is function, add any html tags to this that you need to allow/keep <code> function wpse_allowedtags() { // Add custom tags to this string return '&lt;script&gt;,&lt;style&gt;,&lt;br&gt;,&lt;em&gt;,&lt;i&gt;,&lt;ul&gt;,&lt;ol&gt;,&lt;li&gt;,&lt;a&gt;,&lt;p&gt;,&lt;img&gt;,&lt;video&gt;,&lt;audio&gt;'; } </code> If you need to allow all HTML tags, that is, no stripping of any tags, the <code> strips_tags() </code> function can be omitted/removed completely. A point to note however, when html tags are allowed, these tags are counted as words, so your word count for excerpts with tags and without tags will not be the same. To correct that, you will need to remove these tags from the actual word count first so that only words are counted. I have written an excerpt that will allow all tags, count only words as words, and complete a sentence after the set amount of words (won't trim text mid-sentence) and add a read more text after the last word. Here is the complete code <code> function wpse_allowedtags() { // Add custom tags to this string return '&lt;script&gt;,&lt;style&gt;,&lt;br&gt;,&lt;em&gt;,&lt;i&gt;,&lt;ul&gt;,&lt;ol&gt;,&lt;li&gt;,&lt;a&gt;,&lt;p&gt;,&lt;img&gt;,&lt;video&gt;,&lt;audio&gt;'; } if ( ! function_exists( 'wpse_custom_wp_trim_excerpt' ) ) : function wpse_custom_wp_trim_excerpt($wpse_excerpt) { global $post; $raw_excerpt = $wpse_excerpt; if ( '' == $wpse_excerpt ) { $wpse_excerpt = get_the_content(''); $wpse_excerpt = strip_shortcodes( $wpse_excerpt ); $wpse_excerpt = apply_filters('the_content', $wpse_excerpt); $wpse_excerpt = str_replace(']]&gt;', ']]&amp;gt;', $wpse_excerpt); $wpse_excerpt = strip_tags($wpse_excerpt, wpse_allowedtags()); /*IF you need to allow just certain tags. Delete if all tags are allowed */ //Set the excerpt word count and only break after sentence is complete. $excerpt_word_count = 75; $excerpt_length = apply_filters('excerpt_length', $excerpt_word_count); $tokens = array(); $excerptOutput = ''; $count = 0; // Divide the string into tokens; HTML tags, or words, followed by any whitespace preg_match_all('/(&lt;[^&gt;]+&gt;|[^&lt;&gt;\s]+)\s*/u', $wpse_excerpt, $tokens); foreach ($tokens[0] as $token) { if ($count &gt;= $excerpt_word_count &amp;&amp; preg_match('/[\,\;\?\.\!]\s*$/uS', $token)) { // Limit reached, continue until , ; ? . or ! occur at the end $excerptOutput .= trim($token); break; } // Add words to complete sentence $count++; // Append what's left of the token $excerptOutput .= $token; } $wpse_excerpt = trim(force_balance_tags($excerptOutput)); $excerpt_end = ' &lt;a href="'. esc_url( get_permalink() ) . '"&gt;' . '&amp;nbsp;&amp;raquo;&amp;nbsp;' . sprintf(__( 'Read more about: %s &amp;nbsp;&amp;raquo;', 'wpse' ), get_the_title()) . '&lt;/a&gt;'; $excerpt_more = apply_filters('excerpt_more', ' ' . $excerpt_end); //$pos = strrpos($wpse_excerpt, '&lt;/'); //if ($pos !== false) // Inside last HTML tag //$wpse_excerpt = substr_replace($wpse_excerpt, $excerpt_end, $pos, 0); /* Add read more next to last word */ //else // After the content $wpse_excerpt .= $excerpt_end; /*Add read more in new paragraph */ return $wpse_excerpt; } return apply_filters('wpse_custom_wp_trim_excerpt', $wpse_excerpt, $raw_excerpt); } endif; remove_filter('get_the_excerpt', 'wp_trim_excerpt'); add_filter('get_the_excerpt', 'wpse_custom_wp_trim_excerpt'); </code> You can just remove the '//' from functions that you need extra. CUSTOM EXCERPT LENGTHS Sometimes you need to display simple excerpts of different lengths and it is not viable to write an excerpt for every post/function/page. Here is a nice small little function using <code> wp_trim_words </code> <code> function wpse_custom_excerpts($limit) { return wp_trim_words(get_the_excerpt(), $limit, '&lt;a href="'. esc_url( get_permalink() ) . '"&gt;' . '&amp;nbsp;&amp;hellip;' . __( 'Read more &amp;nbsp;&amp;raquo;', 'wpse' ) . '&lt;/a&gt;'); } </code> What this little function does is taking <code> get_the_excerpt </code> , trimming it to <code> $limit </code> set by the user, and returning the text with a read more link at the end. You can call this excerpt as follow in your template <code> echo wpse_custom_excerpts($limit); </code> where <code> $limit </code> will be your word count, so an excerpt of 30 words will be <code> echo wpse_custom_excerpts(30); </code> Just one thing to remember here, if you set your limit to more that 55 words, only 55 words will be returned as the excerpt is only 55 words in length. If longer excerpts are needed, use <code> get_the_content </code> instead. CUSTOM EXCERPT LENGTH If you just need to alter the length of <code> the_excerpt() </code> , you can use the following function <code> function wpse_excerpt_length( $length ) { return 20; } add_filter( 'excerpt_length', 'wpse_excerpt_length', 999 ); </code> Remember, you will need to set a priority bigger than 10 so that your custom function executes after the default. ADD READ MORE LINK All text returned by the excerpt have the hated <code> [...] </code> at the end that is not clickable. To add a read more text in the place of the hellips, use this function <code> function wpse_excerpt_more( $more ) { return ' &lt;a class="read-more" href="'. get_permalink( get_the_ID() ) . '"&gt;' . __('Read More', 'your-text-domain') . '&lt;/a&gt;'; } add_filter( 'excerpt_more', 'wpse_excerpt_more' ); </code> EDIT Excerpt first paragraph I want to keep this complete, so here is the excerpt that trims after the first paragraph Here is a function that keeps HTML tags in tact, adds a "Read More" link at the end of the excerpt and trims the excerpt after the first paragraph. <code> if ( ! function_exists( 'wpse0001_custom_wp_trim_excerpt' ) ) : function wpse0001_custom_wp_trim_excerpt($wpse0001_excerpt) { global $post; $raw_excerpt = $wpse0001_excerpt; if ( '' == $wpse0001_excerpt ) { $wpse0001_excerpt = get_the_content(''); $wpse0001_excerpt = strip_shortcodes( $wpse0001_excerpt ); $wpse0001_excerpt = apply_filters('the_content', $wpse0001_excerpt); $wpse0001_excerpt = substr( $wpse0001_excerpt, 0, strpos( $wpse0001_excerpt, '&lt;/p&gt;' ) + 4 ); $wpse0001_excerpt = str_replace(']]&gt;', ']]&amp;gt;', $wpse0001_excerpt); $excerpt_end = ' &lt;a href="'. esc_url( get_permalink() ) . '"&gt;' . '&amp;nbsp;&amp;raquo;&amp;nbsp;' . sprintf(__( 'Read more about: %s &amp;nbsp;&amp;raquo;', 'pietergoosen' ), get_the_title()) . '&lt;/a&gt;'; $excerpt_more = apply_filters('excerpt_more', ' ' . $excerpt_end); //$pos = strrpos($wpse0001_excerpt, '&lt;/'); //if ($pos !== false) // Inside last HTML tag //$wpse0001_excerpt = substr_replace($wpse0001_excerpt, $excerpt_end, $pos, 0); //else // After the content $wpse0001_excerpt .= $excerpt_end; return $wpse0001_excerpt; } return apply_filters('wpse0001_custom_wp_trim_excerpt', $wpse0001_excerpt, $raw_excerpt); } endif; remove_filter('get_the_excerpt', 'wp_trim_excerpt'); add_filter('get_the_excerpt', 'wpse0001_custom_wp_trim_excerpt'); </code>
Allow HTML in excerpt
wordpress
I am trying to change the checkboxes for the terms on the backend to radiobuttons. I found this topic: stackexchange-url ("Altering the appearance of custom taxonomy inputs") however wich helped me doing this. However, this will turn ALL terms checkboxes to radio buttons. Is it possible to apply this only for one taxonomy? My code: <code> add_action('add_meta_boxes','mysite_add_meta_boxes',10,2); function mysite_add_meta_boxes($post_type, $post) { ob_start(); } add_action('dbx_post_sidebar','mysite_dbx_post_sidebar'); function mysite_dbx_post_sidebar() { $html = ob_get_clean(); $html = str_replace('"checkbox"','"radio"',$html); echo $html; } </code> thanks
However, this will turn ALL terms checkboxes to radio buttons. Not only that, it'll turn any checkbox in a meta box - not ideal! Instead, let's specifically target the <code> wp_terms_checklist() </code> function, which is used to generate the list of checkboxes across the admin (including quick edit). <code> /** * Use radio inputs instead of checkboxes for term checklists in specified taxonomies. * * @param array $args * @return array */ function wpse_139269_term_radio_checklist( $args ) { if ( ! empty( $args['taxonomy'] ) &amp;&amp; $args['taxonomy'] === 'category' /* &lt;== Change to your required taxonomy */ ) { if ( empty( $args['walker'] ) || is_a( $args['walker'], 'Walker' ) ) { // Don't override 3rd party walkers. if ( ! class_exists( 'WPSE_139269_Walker_Category_Radio_Checklist' ) ) { /** * Custom walker for switching checkbox inputs to radio. * * @see Walker_Category_Checklist */ class WPSE_139269_Walker_Category_Radio_Checklist extends Walker_Category_Checklist { function walk( $elements, $max_depth, $args = array() ) { $output = parent::walk( $elements, $max_depth, $args ); $output = str_replace( array( 'type="checkbox"', "type='checkbox'" ), array( 'type="radio"', "type='radio'" ), $output ); return $output; } } } $args['walker'] = new WPSE_139269_Walker_Category_Radio_Checklist; } } return $args; } add_filter( 'wp_terms_checklist_args', 'wpse_139269_term_radio_checklist' ); </code> We hook onto the <code> wp_terms_checklist_args </code> filter, then implement our own custom "walker" (a family of classes used to generate hierarchical lists). From there, it's a simply string replace of <code> type="checkbox" </code> with <code> type="radio" </code> if the taxonomy is whatever we've configured it to match (in this case "category").
WordPress taxonomy radio buttons
wordpress
WordPress default setting is, most recent post is the first post of the blog. But, I need to "Most commented post should be the first post in the blog". ( Categories page as well as home page)
Alex, the codex is your friend. You have a parameter <code> orderby </code> which you can set to order posts by <code> comment_count </code> . You can get the complete list of parameters accepted by <code> orderby </code> in the codex page about <code> WP_Query </code> There is no need for any custom query, you can simply just alter the main query with the use of the action hook <code> pre_get_posts </code> . To order posts by comment count on the home and category pages, you can use the conditional tags <code> is_home </code> and <code> is_category </code> to target the homepage and category pages respectively. <code> function orderby_comment_count( $query ) { if ( $query-&gt;is_home() OR $query-&gt;is_category()){ if($query-&gt;is_main_query() AND !is_admin() ) { $query-&gt;set( 'orderby', 'comment_count' ); } } } add_action( 'pre_get_posts', 'orderby_comment_count' ); </code> EDIT This code should be placed in your functions.php or any file that is related to functions.php, ie, any file used for rendering functionalities like functions.php does
Most commented post should be the first post in the blog
wordpress
Hi I'm not a coder and I was wondering if anyone could edit this code to list all sites in the multi site network in alphabetical order? cause right now the code lists by registered date <code> &lt;?php // Query for getting blogs $blogs = $wpdb-&gt;get_results( $wpdb-&gt;prepare("SELECT blog_id, domain, path FROM $wpdb-&gt;blogs WHERE site_id = %d AND public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0' ORDER BY registered DESC", $wpdb-&gt;siteid), ARRAY_A ); // put it in array foreach ( (array) $blogs as $details ) {$blog_list[ $details['blog_id'] ] = $details;} unset( $blogs ); $blogs = $blog_list; // if is valid array if (is_array( $blogs ) ){ echo '&lt;ul&gt;'; $array= array(); // reorder $array= array_slice( $blogs, 0, count( $blogs ) ); for($i=0;$i&lt;count($array);$i++){ // get data for each id $blog = get_blog_details( $array[$i]['blog_id'] ); // print it echo '&lt;li&gt;&lt;a href="'.$blog-&gt;siteurl.'"&gt;'.$blog-&gt;blogname.'&lt;/a&gt;&lt;/li&gt;'; } echo '&lt;/ul&gt;'; } ?&gt; </code>
You can try to replace: <code> ORDER BY registered DESC </code> with: <code> ORDER BY domain ASC, path ASC </code> to get the sites in an alphabetical order.
List all sites in multisite
wordpress
This is really driving me up the wall now. Randomly, all my menu items for all menus are just being deleted on their own. Not the menus themselves but all items within them. This is a custom theme we built upon the Bones boilerplate. We've built plenty of sites on Bones though and we're not experiencing the problem with any others. I know the usual advice will be:- Deactivate all plugins and see if the problem persists. Revert to the default Wordpress theme and see if the problem persists. But this isn't particularly practical as it means breaking our website for weeks on end waiting to see whether the problem occurs again. Each time this happens, we have to manually rebuild all our menus and it is becoming a real pain now plus potentially catastrophic if Google crawl our website when these menu items have all been deleted. This only started happening since the 3.8 update but occurs within four days of reinstating all the menu items again. There is nothing of note in the error logs. This last happened in the past 48 hours and all we have in the error log from this period is the following (actual domain replaced with <code> domain.com </code> ):- <code> [Sun May 25 02:32:23 2014] [warn] RSA server certificate CommonName (CN) `plesk' does NOT match server name!? [Tue May 27 04:10:55 2014] [error] [client 188.143.234.90] script not found or unable to stat: /var/www/vhosts/domain.com/cgi-bin/php [Tue May 27 04:10:55 2014] [error] [client 188.143.234.90] script not found or unable to stat: /var/www/vhosts/domain.com/cgi-bin/php5 [Tue May 27 04:10:55 2014] [error] [client 188.143.234.90] script not found or unable to stat: /var/www/vhosts/domain.com/cgi-bin/php-cgi [Tue May 27 04:10:55 2014] [error] [client 188.143.234.90] script not found or unable to stat: /var/www/vhosts/domain.com/cgi-bin/php.cgi [Tue May 27 04:10:55 2014] [error] [client 188.143.234.90] script not found or unable to stat: /var/www/vhosts/domain.com/cgi-bin/php4 [Tue May 27 04:10:55 2014] [error] [client 188.143.234.90] script not found or unable to stat: /var/www/cgi-bin/cgi_wrapper/php </code> If all anyone can suggest is the above bullet points, then all I can really think of is to replicate the website in a dev environment and noindex the site for web crawlers (I've asked in various communities already) - there does seem to be a few other people that have experienced the same problem with little idea of resolution although for some it seemed to be related to plugins (although I don't have those plugins installed on our website). Frustrating! Can anyone shed some better light on how to get to the bottom (debug) of this one? I've just found stackexchange-url ("this same question") on here as well... The database has been repaired as well to no avail.
I'm going to answer my own question primarily to keep a log of debugging until I get to the bottom of this (hopefully resulting in an answer to my question for the benefit of other SE users):- 28th May 2014 Asked question as per above. Ongoing issue with menu items being deleted randomly all the time. Duplicated website on a sub domain for testing purposes. 6th June 2014 Menu items deleted on live site. Still intact on dev site however noticed there were 4 plugin updates as per the below:- CM Tooltip Glossary (active) Form Maker (inactive) Share This (inactive) Wordpress SEO (active) Updated all four plugins, within 10 seconds, all menu items were deleted on the dev site. Manually reinstated menu items. Manually deactivated and reactivated the plugins CM Tooltip Glossary and Wordpress SEO (trying to replicate part of the update process). After a few minutes, all menu items still intact and have not been deleted. I think perhaps update plugins one at a time in future so that can pinpoint exactly which is causing the issue. 8th June 2014 Okay, so the menu items on the live site have all just disappeared again. No updates in Wordpress were performed at all. They are still intact on dev site. No files had been modified on the server since 6th June for the live site. Manually reinstated menu items on the live site again. Two plugin updates available on the live site:- Form Maker (inactive) Share This (inactive) Updated both plugins, menu items still intact... One plugin update available on the dev site:- Form Maker (inactive) Updated plugin, menu items still intact... Ran a diff check on the database dumps before and after plugin updates and reinstating of the menu items on the live site (as suggested stackexchange-url ("in the comments")):- What is interesting is the insertion of the below line which is slapped in the middle of the <code> wp_posts </code> table:- <code> (1170, 2, '2014-06-08 11:02:05', '2014-06-08 10:02:05', ' ', '', '', 'publish', 'open', 'open', '', '1170', '', '', '2014-06-08 11:02:05', '2014-06-08 10:02:05', '', 0, 'http://www.domain.com/?p=1170', 4, 'nav_menu_item', '', 0), </code> This row is inserted between 688 and 689 so looks like this in the table:- <code> 688 1170 689 </code> Just seemed peculiar that it would insert this randomly there... I also noticed the following difference in the <code> wp_usermeta </code> table:- <code> (542, 2, 'nav_menu_recently_edited', '44'), </code> My user ID is 2 and this seems like it is suggesting that my user ID recently edited 44 nav menu items... Which would probably be the deleting of them all? Just installed the plugin Stream on live and dev sites to track any changes made in the Wordpress admin. Also upgraded every single module on the Apache server, including mysql and repaired the mysql database. Everything I came across on the server, I upgraded. I then added <code> max_input_vars </code> to the <code> php.ini </code> (2000). 12th June 2014 Menu items all deleted again in live site. No updates were processed. The menu items have been deleted without anyone even touching anything on the website. Menu items still intact on dev site. With the menu items not being deleted at the same time on live site and dev site (the site and database being identical other than loads more comments and things like that) is probably indicative of something, I'm just unsure what. Attempting Wordpress's built in database and repair tool by adding the following to <code> wp_config.php </code> :- <code> define('WP_ALLOW_REPAIR', TRUE); </code> Didn't seem to find anything wrong, results below:- The wp_users table is okay. <code> Failed to optimize the wp_users table. Error: Table does not support optimize, doing recreate + analyze instead </code> The wp_usermeta table is okay. <code> Failed to optimize the wp_usermeta table. Error: Table does not support optimize, doing recreate + analyze instead </code> The wp_posts table is okay. The wp_posts table is already optimized. The wp_comments table is okay. <code> Failed to optimize the wp_comments table. Error: Table does not support optimize, doing recreate + analyze instead </code> The wp_links table is okay. <code> Failed to optimize the wp_links table. Error: Table does not support optimize, doing recreate + analyze instead </code> The wp_options table is okay. <code> Failed to optimize the wp_options table. Error: Table does not support optimize, doing recreate + analyze instead </code> The wp_postmeta table is okay. <code> Failed to optimize the wp_postmeta table. Error: Table does not support optimize, doing recreate + analyze instead </code> The wp_terms table is okay. <code> Failed to optimize the wp_terms table. Error: Table does not support optimize, doing recreate + analyze instead </code> The wp_term_taxonomy table is okay. <code> Failed to optimize the wp_term_taxonomy table. Error: Table does not support optimize, doing recreate + analyze instead </code> The wp_term_relationships table is okay. <code> Failed to optimize the wp_term_relationships table. Error: Table does not support optimize, doing recreate + analyze instead </code> The wp_commentmeta table is okay. <code> Failed to optimize the wp_commentmeta table. Error: Table does not support optimize, doing recreate + analyze instead </code> The wp_snippets table is okay. <code> Failed to optimize the wp_snippets table. Error: Table does not support optimize, doing recreate + analyze instead </code> Repairs complete. Please remove the following line from wp-config.php to prevent this page from being used by unauthorized users. define('WP_ALLOW_REPAIR', true); Also installed logging from point 1 of @birgire's stackexchange-url ("answer"). 14th July 2014 I just wanted to confirm that since the removal of the Stealth Publish plugin, the menu items have no longer been deleted. Thanks to Rarst's contribution in the other thread that this one has been marked as a duplicate of. The plugin developer has been made aware of the issue on Wordpress but it is becoming apparent that they don't care and the plugin has been abandoned/is not maintained any longer.
Menu items (all menus) being deleted randomly on their own
wordpress