question
stringlengths
0
34.8k
answer
stringlengths
0
28.3k
title
stringlengths
7
150
forum_tag
stringclasses
12 values
I would like to give a CMS look to some of my pages. I want to customize them by removing the default widgets and adding other widgets as my wish (I will use plugins like My Custom Widget to add custom codes if I need) . Is there any possibility to customize the specific pages like this?
Take a look at this plugin, WidgetLogic . From the description: This plugin gives every widget an extra control field called "Widget logic" that lets you control the pages that the widget will appear on. I've used it successfully.
Disable Specific Widgets on Selected Pages of a WordPress Website?
wordpress
Assume I have SSH from a shared/managed-VPS hosting, and FTP access, but no fantastico. Thanks.
Yes . There is a script called easywp.php You upload it to your server and run it. it will install wordpress for you (i.e. download the .gz file, open it, etc ...) Another option is to download wordpress to your server using wget and ssh. you can do that using the command: <code> wget http://wordpress.org/latest.zip </code> if you want that wordpress install in Hebrew: use this script and then upgrade edit the easywp.php so it will download the latest Hebrew version (the name changes with each new release) change the script mentioned in option (1) to get the latest version for you
Quickest Way Besides FTP to Upload WordPress Files to a Web Server?
wordpress
What is the recommended way of creating a page with a table, in the style of the tables showing posts or users in the admin area? I am expanding the Cache Images plugin, and it contains a table with domains and a number of images from that domain. So there is no equivalent existing table that I can build upon (in the first version of this question, I asked about a table with posts, but there I could (maybe) stackexchange-url ("expand the existing post table")). Should I just base myself on the post overview page, and start with a <code> &lt;table class="widefat"&gt; </code> , or are there better functions that handle this now? Do you know a clean, empty example of a table with paging that I could base my work on?
This is what I generally use: <code> &lt;table class="widefat fixed" cellspacing="0"&gt; &lt;thead&gt; &lt;tr&gt; &lt;th id="cb" class="manage-column column-cb check-column" scope="col"&gt;&lt;/th&gt; // this column contains checkboxes &lt;th id="columnname" class="manage-column column-columnname" scope="col"&gt;&lt;/th&gt; &lt;th id="columnname" class="manage-column column-columnname num" scope="col"&gt;&lt;/th&gt; // "num" added because the column contains numbers &lt;/tr&gt; &lt;/thead&gt; &lt;tfoot&gt; &lt;tr&gt; &lt;th class="manage-column column-cb check-column" scope="col"&gt;&lt;/th&gt; &lt;th class="manage-column column-columnname" scope="col"&gt;&lt;/th&gt; &lt;th class="manage-column column-columnname num" scope="col"&gt;&lt;/th&gt; &lt;/tr&gt; &lt;/tfoot&gt; &lt;tbody&gt; &lt;tr class="alternate"&gt; &lt;th class="check-column" scope="row"&gt;&lt;/th&gt; &lt;td class="column-columnname"&gt;&lt;/td&gt; &lt;td class="column-columnname"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;th class="check-column" scope="row"&gt;&lt;/th&gt; &lt;td class="column-columnname"&gt;&lt;/td&gt; &lt;td class="column-columnname"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr class="alternate" valign="top"&gt; // this row contains actions &lt;th class="check-column" scope="row"&gt;&lt;/th&gt; &lt;td class="column-columnname"&gt; &lt;div class="row-actions"&gt; &lt;span&gt;&lt;a href="#"&gt;Action&lt;/a&gt; |&lt;/span&gt; &lt;span&gt;&lt;a href="#"&gt;Action&lt;/a&gt;&lt;/span&gt; &lt;/div&gt; &lt;/td&gt; &lt;td class="column-columnname"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr valign="top"&gt; // this row contains actions &lt;th class="check-column" scope="row"&gt;&lt;/th&gt; &lt;td class="column-columnname"&gt; &lt;div class="row-actions"&gt; &lt;span&gt;&lt;a href="#"&gt;Action&lt;/a&gt; |&lt;/span&gt; &lt;span&gt;&lt;a href="#"&gt;Action&lt;/a&gt;&lt;/span&gt; &lt;/div&gt; &lt;/td&gt; &lt;td class="column-columnname"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; </code> Hope that helps.
Creating a table in the admin-style?
wordpress
Have developed a site on the production box using a temporary address (http://IP-adddress). Now it's time to go live. Once, ages ago, I successfully used phpMyAdmin and did a search/replace, but am wondering if it's still "the best" way to go. Will these work okay, still? The site is in WordPress 3.0.1. <code> update wp_options set option_value=replace(option_value,'OLD URL','NEW URL') where option_value like "%OLD URL%"; update wp_posts SET guid=replace(guid, 'OLD URL','NEW URL'); update wp_posts SET post_excerpt=replace(post_excerpt, 'OLD URL','NEW URL'); update wp_posts SET post_content=replace(post_content, 'OLD URL','NEW URL'); update wp_postmeta SET meta_value=replace(meta_value, 'OLD URL','NEW URL'); </code> I've read a number of related posts here, but none with the actual queries. I thought this search and replace plugin sounded promising, but the only documentation I found was in German, which I can't read, so I'm too cautious to try it. And this thread about <a href="stackexchange-url moving from development to production has lots of information in it, but: much of it is over my head, and no queries listed. TYIA, Mike
Yes, these queries still work. This is a complete how-to: http://web-kreation.com/tutorials/migrating-a-wordpress-site-ftp-phpmyadmin-and-sql-queries/
Correct Search & Replace Queries for Changing URLs in a WordPress Database?
wordpress
I am desperately looking for some way (any way) to set default "screen options" and metabox order through the functions.php file. does anyone have any help they can provide here?
Setting the order of meta boxes on post edit pages You will need to remove the meta boxes, and add them again in the order you want. To disable meta boxes: (customize to your needs, look at the metabox id in the html code to know which name you should use as first parameter of the functions) <code> function my_remove_meta_boxes() { remove_meta_box('postcustom', 'post', 'core'); remove_meta_box('commentsdiv', 'post', 'core'); ... } add_action( 'admin_menu', 'my_remove_meta_boxes' ); </code> After removing them, you can use the add_meta_box function to add them at new positions: http://codex.wordpress.org/Function_Reference/add_meta_box. The order of the meta boxes depends on the order in which you call the add_meta_box function. E.g.: with the following code snippet, the comments meta box will be before the custom fields meta box. <code> function my_add_meta_boxes( $post_type, $post ) { if ( ('publish' == $post-&gt;post_status || 'private' == $post-&gt;post_status) &amp;&amp; post_type_supports($post_type, 'comments') ) add_meta_box('commentsdiv', __('Comments'), 'post_comment_meta_box', $post_type, 'normal', 'core'); if ( post_type_supports($post_type, 'custom-fields') ) add_meta_box('postcustom', __('Custom Fields'), 'post_custom_meta_box', $post_type, 'normal', 'core'); ... } add_action( 'add_meta_boxes', 'my_add_meta_boxes' ); </code> You may want to look at the file wp-admin/edit-form-advanced.php Setting which columns title show up on the post list page You need to use the filter manage_{$post_type}_posts_columns. E.g.: the following snippet will remove the comments column. <code> function my_remove_columns( $posts_columns ) { unset( $posts_columns['comments'] ); return $posts_columns; } add_filter( 'manage_post_posts_columns', 'my_remove_columns' ); </code> Setting the default results to be shown on the post list page Use the filters 'edit_{$post_type}_per_page' and 'edit_posts_per_page'. <code> function my_edit_post_per_page( $per_page, $post_type ) { $edit_per_page = 'edit_' . $post_type . '_per_page'; $per_page = (int) get_user_option( $edit_per_page ); if ( empty( $per_page ) || $per_page &lt; 1 ) $per_page = 1; return $per_page; } add_filter( 'edit_posts_per_page', 'my_edit_post_per_page' ); </code> To target a specific post type: use <code> add_filter( 'edit_{post type}_per_page', 'my_edit_post_per_page' ); </code> e.g. <code> add_filter( 'edit_post_per_page', 'my_edit_post_per_page' ); </code> for posts, <code> add_filter( 'edit_page_per_page', 'my_edit_post_per_page' ); </code> for pages. or use a condition within your function. e.g.: function my_edit_post_per_page( $per_page, $post_type ) { <code> if( $post_type == 'post' ) { $edit_per_page = 'edit_' . $post_type . '_per_page'; $per_page = (int) get_user_option( $edit_per_page ); if ( empty( $per_page ) || $per_page &lt; 1 ) $per_page = 1; } return $per_page; </code>
Set Default Admin Screen options & Metabox Order
wordpress
Is it possible to run more than one site on the same WordPress core and a set of plugins? I want to be able to have custom plugins and themes for each site, but have a base set that is the same, to make it easier to maintain.
Yes, it is possible . You can setup subdomains sites like this: <code> subdomain1.domain.com </code> , <code> subdomains2.domain.com </code> . Then, after you setup the network, use a domain mapping plugin to setup a domain name for each of them. <code> subdomain1.domain.com </code> becomes <code> domain1.com </code> , <code> subdomain2.domain.com </code> becomes <code> domain2.com </code> , etc. There are several domain mapping plugins out there: http://premium.wpmudev.org/project/domain-mapping (the one I would recommend, but it is on a paid membership site) http://wordpress.org/extend/plugins/wordpress-mu-domain-mapping/ (free one, but I never used it)
Running several WordPress sites on same core / plugins?
wordpress
In the past I've used the Day and Name or Month and Name settings. Should the date structure be omitted and just have /%postname%/ ? Ie does having the date information reduce the quality of the url?
@nevster, The best permalink structure for seo is /%category%/%postname%/ This permalink structure gives you the most keywords loaded into the URL of your post. Since the category that you’ve placed your post under usually relates to the post title, you will have an extra SEO benefit if other websites use that permalink structure to link your post. EDIT After reading over the link Mike shared below I felt I should also mention that starting the permalink string with %postname%, %category%, %tag%, or %author% will invoke WordPress's "use_verbose_page_rules" which will cause the rewrite matching system to generate individual rules for every Page, then check those first. If you have lots of pages, this is a big hit to the system. The performance hit happens at about the 50+ page mark. In order to have the ability to scale your site on a larger level you should start the permalink structure with a number like: /%year%/%category%/%postname%/ Your pages will always use the /%pagename%/ permalink structure any time you enable permalinks so the /%year%/%category%/%postname%/ will only be applied to your posts. If your site is more CMS than blog the optimal SEO url structure would be to use child pages where the parent page could be considered a category. For example a university website might have a parent page "Campus Offices" with child pages of "Business Affairs", "Athletics" etc.. Then URLS would like this: www.university.edu/campus-offices/athletics/ which is great for the user experience and seo.
What is the best permalink structure for SEO?
wordpress
When I started with my blog, the permalinks and following structure: <code> http://&lt;domain&gt;/%year%/%monthnum%/%day%/%postname%/ </code> Some time ago, I changed the permalink structure to " <code> http://&lt;domain&gt;/%postname%/ </code> " only. In order to tackle the external links to the old permalink structure, I added the following line in my htaccess-file: <code> RedirectMatch 301 /([0-9]+)/([0-9]+)/([0-9]+)/(.*)$ http://&lt;domain&gt;/$4 </code> Now the problem is that the redirect line breaks the archive links, eg. " <code> http://&lt;domain&gt;/2010/09/02 </code> " is redirected to the front page instead of showing the posts from Sept 2, 2010. Is it possible to correct the redirect directive in htaccess, or am I not going to be able to eat the cake and have it too?
RedirectMatch of Mod_Alias is not as powerful as Mod_Rewrite. If you have Mod_Rewrite on your host (Pretty Permalinks make use of it for example) you could make the redirect only if the URL is not in the Archive link format. To test for that case, there is <code> RewriteCond </code> and to make the redirect command, there is the <code> RewriteRule ... [R=301] </code> directive. An Example based on your data: <code> RewriteCond %{REQUEST_URI} !^/((20|19)[0-9]{2})/([0-9]{2})/[0-9]{2}$ [NC] RewriteRule ^/([0-9]{4})/([0-9]{2})/([0-9]{2})/(.*)$ http://&lt;domain&gt;/$4 [R=301,L] </code> This is untested but I think it should do the work. I've used quantifier ({2}) to better specifiy how many numbers you expect. Next to that in the RewriteCond I've created a pattern that only matches the 20.. and 19.. years. The first line (the condition, <code> RewriteCond </code> ) checks not to match an Archive-URL and only if not matched, the rule to do the redirect will be executed. The <code> RewriteRule </code> is basically doing the same as your <code> RedirectMatch </code> directive.
Change of permalink structure - redirects in htaccess breaks the archive links
wordpress
Hey guys. I am working on a plugin and I am trying to figure out all of the possible scenarios in which the plugin can be used. I am aware of the new Multi-Site feature. If the plugin is network activated, then it will basically be forced upon all of the blogs within that website. What happens if the plugin is just activated, but not network activated? Does this mean that it's giving the user the choice of enabling it? In other words: does activating the plugin mean it will appear in each blog admin's plugin list, allowing them to enable it or not? If this is true, then that means that if the plugin is not activated, then it won't show up in each blog admin's plugin list, correct? So the scenarios are: network activated => forced upon all users activated => each user now has the option to enable it or not disabled => the user won't even see it in their plugin list Is this correct? Thanks, I would really appreciate any help.
You are right about network activated. About the other two: The user will always see all the plugins in their blog admin's plugin list. Activating a plugin means activating it only on the current blog, and you can deactivate it if it was previously enabled. These two options does not affect the other blogs in the network, only the current one. More details here: http://premium.wpmudev.org/wpmu-and-buddypress-plugins/activating-and-deactivating-regular-plugins/
Multi-Site Plugin Activated (Not Network-Activated), What Happens?
wordpress
I have installed WordPress via an auto-installer and later configured it as multisite. But whenever I create the WordPress site using auto-installer it doesn't give me the <code> .htaccess </code> file by default. So I've created an empty file with the name <code> .htaccess </code> in CPanel and pasted this code in to it: <code> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] # uploaded files RewriteRule ^files/(.+)wp-includes/ms-files.php?file=$1 [L] RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [L] RewriteRule . index.php [L] </code> Is it a right method ?
Sure this is not a problem. As long as you site works and redirects to the right pages there is no harm in doing this. You might also want to use it for protecting your wp-config file from hackers by adding this to your .htaccess: <code> &lt;Files wp-config.php&gt; Order Allow,Deny Deny from all &lt;/Files&gt; </code> Good luck :)
When WordPress Does Not Provide an .htaccess File for New Multisite Sites because of CPanel Fantastico Auto-Installer?
wordpress
I've got a WordPress blog on WordPress.com. When posting something I'm including some sample Java code in the <code> &lt;code </code> tags, is there any way I can have this formatted better? Such as syntax highlighting and line numbers etc? An example of what I have is here , even though I have the code tags it doesnt seem to make it any more readable than normal text Am I limited in choices as I've gone for the free option?
wordpress.com supports code syntax-highliting. You can read all about it here: http://en.support.wordpress.com/code/posting-source-code/ for your specific example use: <code> [sourcecode language="java"] package com.jameselsey.domain; import java.util.ArrayList; import java.util.List; import com.google.android.maps.GeoPoint; import android.app.Application; /** * This is a global POJO that we attach data to which we * want to use across the application * @author James Elsey * */ public class GlobalState extends Application { private String testMe; public String getTestMe() { return testMe; } public void setTestMe(String testMe) { this.testMe = testMe; } } [/sourcecode] </code>
Formatting Code Snippets on Free WordPress.com Account?
wordpress
I have just created a new Wordpress site (version 3.0.1) on a Windows 2003 server, but the 'Month and Time' permalink format does not work. It gives a 404 error when I use it. All of the other standard permalink formats work okay. Please can you tell me what would be causing this issue?
The type of permalinks you write about are also called "Pretty Permalinks" and are a feature of Wordpress that has been designed for the Apache HTTP Server with Mod_Rewrite enabled. Every other server is at first incompatible to this and you should not use those pretty permalinks on those system unless you know what you are doing. There are replacements for some rewrite rules available for other HTTP Servers like Lighty, NGINX ( nginx Compatibility (Wordpress Plugin) ) or as in you case IIS, which is already somehow supported by Wordpress because for a longer time there were two developers taking care of IIS specifically (IIRC it's the author of Enabling Pretty Permalinks in WordPress : URL Rewrite Module : Installing and Configuring IIS 7 : The Official Microsoft IIS Site ). Please ensure that you've checked the right docs about Pretty Permalinks and your specific server. Alternatively switch to Apache HTTP.
Why does the 'Month and Name' Permalink Format not Work on my new Wordpress Site (running on IIS7)?
wordpress
What is the best way to add custom fields to a WordPress comment form? (for example subject, image, etc...) And how do I use the data entered afterwards...
Hi @hannit cohen : This slideshow from Beau Lebens should be able to show you how: Hooking into Comments And this blog post from Otto should be able to show you more: WordPress 3.0 Theme Tip: The Comment Form
Adding Custom Fields to WordPress Comment Forms?
wordpress
I have a custom post type for a Slideshow which uses Custom Post Meta to insert the different slides. How can I code the <code> &lt;!--nextpage--&gt; </code> tag in between the sides in my slideshow.php so that they slides will paginate? Right now when I try to do it the code doesn't show because it by it's nature it commented out.
This question was more extensively discussed at Hybrid support forum. I made and posted snippet for custom pagination of custom fields content there.
Hard code the nextpage tag into my theme?
wordpress
I've added a few different <code> custom_post_types </code> to my Wordpress 3 installation. They are all a bit different from eachother, and should store unique information in <code> custom_fields </code> . But while one may store a <code> product_id </code> , another will not. One will have a <code> source_url </code> and another will not. Rather than having to instruct my editors on which custom fields should be used with which custom posts, how can I make each custom post include its custom fields as part of the UI itself? If you visit "daily_cartoon" you would have a screen that asks only for a title , caption , and media . If you visit "daily_product" you would have a screen that asks only for a title , price , summary , etc.
Hi @Jonathan Sampson : There are several plugins to make Custom Post Types easier and some allow you to define Custom Fields too, in no particular order: WP Easy Post Types GD Custom Posts And Taxonomies Tools Custom Post Type UI Simple Fields As I mentioned above I've been working on one that does not provide a User Interface like these to instead an extensible API for complex field types (and simple ones too.) But after spending an hour trying to package it I realized it's not ready for distribution yet. Maybe in a few weeks. These plugins listed above should meet your basic needs for now and I will try to make mine compatible with the data stored by all of these in the future in case you do decided to use mine in the future. You also might find this post a bit of help too: <a href="stackexchange-url Tips for using WordPress as a CMS?
Making Custom Fields Standard in the Admin UI
wordpress
I am looking into optimizing my WP blogs, and one thing that comes out is that several of the most acclaimed solutions people are offering (Such as eaccelerator and Nginx), are only available if I had an unmanaged account. According to other reasons you might detail, which is better (performance wise) for managing a WP site? (that is assuming you don't have experience in unmanaged solution but was willing to learn)
@Tal, In terms of performance an unmanaged VPS will be better than a managed one. A Managed VPS will almost always come with CPanel which is great for shared hosting and for hosting companies to easily manage your VPS for you. You can still install any of the Opcode caching tools (APC, eAccelerator, XCache, MemCached) on a managed VPS with CPanel but you would have problems getting Nginx to work. Performance Issues with a CPanel Managed VPS Un needed services and processes (TailWatch, entropychat, exim, imap, ipaliasis, named, spamd, syslogd, etc...) The Cpanel UI uses up valuable resources Your stuck with Apache as the only server option Only options for running PHP are dso, cgi, or fcgid (no mod_fastcgi) Issues with Managing your own VPS Security (Your will be responsible for the security of the VPS Learning Curve No support to fix something you screw up or overlook Mail servers and FTP servers are difficult to get working You will be doing everything via command line/SSH Resources to Help You If you do decide to go the unmanaged route there are a lot of great resources to guide you through every step of setting up your VPS The Linode Library The VPS.Net community forums VPSBible (membership site) The Slicehost community tutorials The Bottom Line With unmanaged, you get a blank partition on a hard drive, a power cord and a network cable, maybe a wiki, some docs a forum, and Google. If your comfortable with this then go for it. You will learn so much by setting up your own server environment.
In terms of performance - Is unmanaged VPS better then a managed one - for WP sites?
wordpress
I'm building a Theme Options page for my theme, and I've managed to get most of it working fine. But now I'm trying to show and hide certain parts in my theme based on a simple check box. An example: Show featured content slider ? - Yes - No When the user selects yes I want to enable the following code in a certain template of my theme: <code> &lt;?php locate_template( array( 'includes/slider.php'), true ) ?&gt; </code> So how can I wrap this code so that it only shows when Yes is clicked? I think it's some kind of conditional statement but I have now idea how to approach this. Since I can't write php I need some help with this :) The name of the option is called bpslick_featured. Thanks in advance!
@Bowe You would need to create an array in your options function for the checkbox and give it an id a default state and assign the "checkbox" type to it. Here is a sample assuming you already have the code in place for the admin panel <code> &lt;?php // Set variables for the options panel $themename = "your_theme_name"; $themeshortname = "yt"; $mythemeoptions = array(); //The Option function function cool_theme_options() { global $themename, $themeshortname, $mythemeoptions; $themeoptions = array ( array( "name" =&gt; __('Show featured content slider','your_theme_name'), "desc" =&gt; __('When checked, the slider will be added to the home page.','your_theme_name'), "id" =&gt; "show_featured_slider", "std" =&gt; "false", "type" =&gt; "checkbox" ), ); } //The Option Form function my_cool_theme_admin() { global $themename, $themeshortname, $themeoptions; // Saved or Updated message if ( $_REQUEST['saved'] ) echo '&lt;div id="message" class="updated fade"&gt;&lt;p&gt;&lt;strong&gt;'.$themename.' settings saved.&lt;/strong&gt;&lt;/p&gt;&lt;/div&gt;'; if ( $_REQUEST['reset'] ) echo '&lt;div id="message" class="updated fade"&gt;&lt;p&gt;&lt;strong&gt;'.$themename.' settings reset.&lt;/strong&gt;&lt;/p&gt;&lt;/div&gt;'; // The form ?&gt; &lt;div class="wrap"&gt; &lt;h2&gt;&lt;?php echo $themename; ?&gt; Options&lt;/h2&gt; &lt;form method="post"&gt; &lt;?php wp_nonce_field('theme-save'); ?&gt; &lt;table class="form-table"&gt; &lt;?php foreach ($themeoptions as $value) { // Output the appropriate form element switch ( $value['type'] ) { case 'text': ?&gt; &lt;tr valign="top"&gt; &lt;th scope="row"&gt;&lt;?php echo $value['name']; ?&gt;:&lt;/th&gt; &lt;td&gt; &lt;?php foreach ($value['options'] as $key=&gt;$option) { if ($key == get_option($value['id'], $value['std']) ) { $checked = "checked=\"checked\""; } else { $checked = ""; } ?&gt; &lt;input type="radio" name="&lt;?php echo $value['id']; ?&gt;" value="&lt;?php echo $key; ?&gt;" &lt;?php echo $checked; ?&gt; /&gt;&lt;?php echo $option; ?&gt;&lt;br /&gt; &lt;?php } ?&gt; &lt;?php echo $value['desc']; ?&gt; &lt;/td&gt; &lt;/tr&gt; &lt;?php break; case "checkbox": ?&gt; &lt;tr valign="top"&gt; &lt;th scope="row"&gt;&lt;?php echo $value['name']; ?&gt;&lt;/th&gt; &lt;td&gt; &lt;?php if(get_option($value['id'])){ $checked = "checked=\"checked\""; } else { $checked = ""; } ?&gt; &lt;input type="checkbox" name="&lt;?php echo $value['id']; ?&gt;" id="&lt;?php echo $value['id']; ?&gt;" value="true" &lt;?php echo $checked; ?&gt; /&gt; &lt;?php echo $value['desc']; ?&gt; &lt;/td&gt; &lt;/tr&gt; &lt;?php break; default: break; } } ?&gt; &lt;/table&gt; &lt;p class="submit"&gt; &lt;input name="save" type="submit" value="Save changes" class="button-primary" /&gt; &lt;input type="hidden" name="action" value="save" /&gt; &lt;/p&gt; &lt;/form&gt; &lt;form method="post"&gt; &lt;?php wp_nonce_field('theme-reset'); ?&gt; &lt;p class="submit"&gt; &lt;input name="reset" type="submit" value="Reset" /&gt; &lt;input type="hidden" name="action" value="reset" /&gt; &lt;/p&gt; &lt;/form&gt; </code> Next add the function in functions.php that calls the slider if the box is checked. <code> &lt;?php function cool_theme_slider_option() { // load the custom options global $themeoptions; foreach ($themeoptions as $value) { $$value['id'] = get_option($value['id'], $value['std']); } if ($show_featured_slider == 'true') { locate_template( array( 'includes/slider.php'), true ) } } // end function add_action('wp_head', 'cool_theme_slider_option'); ?&gt; </code> This code has not been checked to make sure it works exactly as is but meant to show an example for using a checkbox option in your theme.
How can I display/hide certain content based on a Theme Option field?
wordpress
By default, when adding <code> &lt;!--nextpage--&gt; </code> , the following links are displayed: Pages: 1 2 I need to replace "Pages:" with a graphic arrow which links back to the previous page, and append a graphic arrow to the end of the links that links to the next page. I'm guessing there's a way to do this in the functions file?
Just specify an image as the "nextpagelink" and "previouspagelink" instead of the &lt;&lt; or > > : <code> &lt;?php wp_link_pages(array('before' =&gt; '&lt;div class="pagenav"&gt;&lt;strong&gt;Navigate&lt;/strong&gt;', 'after' =&gt; '&lt;/div&gt;', 'next_or_number' =&gt; 'number', 'nextpagelink' =&gt; __('&lt;img src="PUT YOUR IMAGE URL HERE" /&gt;'), 'previouspagelink' =&gt; __('&lt;img src="PUT YOUR IMAGE URL HERE" /&gt;'))); ?&gt; </code> Also, you are correct that by default you are limited to either "Numbers" or "Next/Previous" links but a plugin can extend this: http://wordpress.org/extend/plugins/wp-pagenavi/ Bonus: Add this to your function.php and it will add a "Nextpage" button next to the "More" button in the WYSIWYG editor: <code> // Add Next Page Button to TinyMCE Editor add_filter('mce_buttons','wysiwyg_editor'); function wysiwyg_editor($mce_buttons) { $pos = array_search('wp_more',$mce_buttons,true); if ($pos !== false) { $tmp_buttons = array_slice($mce_buttons, 0, $pos+1); $tmp_buttons[] = 'wp_page'; $mce_buttons = array_merge($tmp_buttons, array_slice($mce_buttons, $pos+1)); } return $mce_buttons; } </code>
How to edit theme functions file to modify pagination?
wordpress
I have installed the Seaweed (Wordpress Plugin) . I have successfully installed it and I can able to edit the content. But the save function is not functioning popularly. when I clicked on the "save button", the processing bar displays and nothing happens beyond that. Has any one try it ? Could any one help me to make use of it.
From what I read on the plugins description it's compatible with WP 2.9.2. Next to that I assume from the description that it interacts with the theme a lot. I would therefore install the Default (Wordpress Theme) and try if it works with that theme. Maybe it works with this theme? Maybe you just run into a Javascript error or you have Javascript disabled? Please check these source of errors as well, because it's written that the plugin makes use of AJAX which means Javascript.
Seaweed Plugin not working
wordpress
Let's say we are currently hosting our WordPress blog on certain domain and would like to move it to a new domain. How to do this with the least hassle and SEO hit? Are there any plugins that could help with this? (for example providing automatic cross-domain 301 redirection or similar)
I recommend handling the 301 redirect in your web server rather than in WordPress. mod_rewrite or RedirectMatch will be much more efficient than spinning up WordPress to deliver a <code> Location </code> : header. <code> &lt;VirtualHost *:80&gt; ServerName busted-cheap-url.com # mod_alias RedirectMatch permanent (.*) http://great-new-url.com$1 # OR mod_rewrite RewriteEngine on RewriteRule (.*) http://great-new-url.com$1 [R=301] &lt;/VirtualHost&gt; </code> There are several methods for changing the blog URL; I tend to prefer setting a new <code> WP_HOME </code> and <code> WP_SITEURL </code> in <code> wp-config.php </code> as a quick fix, and running SQL commands in the database as a more permanent solution. See also: Changing The Site URL stackexchange-url ("Easily Move a WordPress Install from Development to Production?"), which recommends several ways to move a blog to a new URL
How to transfer a WordPress blog to a different domain?
wordpress
I understand that every time a visitor goes to a website, it triggers the PHP code that then demands system resources. My situation is that I have many websites, some not used, just sitting there, and I am wondering if they are demanding anything from my server. I know that there is wp-cron file, that is supposed to work only if there is some visitor to the site. But what about google bots, do they count ? If not - then how come these sites backup would still work and send the file to my e-mail? p.s: I feel like this question should be phrased as a ZEN question: "If a WordPress is on a server - and no one listens - did it load?"
It's not likely an unused site is using mach resources except for harddrive space. There may be something left in memory but on a typical server thats doubtfull. google bots trigger the site exactly the same as a regular user except it doesnt load unnessasary files like javascript, css or images (except maybe for image search). wp-cron I believe can be triggered using a cron job. I'm not sure if wordpress attemps to do this by default, It may vary depending on the server config.
Does a WP site consumes memory resources when there are NO visitors?
wordpress
We're planning on installing WordPress on Windows Server 2008 to be consistent with the rest of our servers and leverage administrative expertise. The server will not be running anything else. Are there any gotcha's to be had for Wordpress on Windows versus Linux (outside of server licensing costs)?
I've installed WordPress on my virtual server running Windows Server 2008 R2. Installation was easy, no troubles. I installed PHP using Web Platform Installer. PHP 5.3 performs well on IIS7 and you can also use WP super cache to increase performance. There haven't been any downsides for me so far :)
Are there any downsides to installing WordPress on Windows versus Linux?
wordpress
How to add automatically keyword to taxonomies when a post published, and assign them to the post for example i have in my post edition, a custom meta box, when you complete this input, a function should generate a group of keywords in background , and i want these keywords are automatically adding to a specific custom taxonomy in that post when it published, this is possible? i try with wp_set_object_terms and nothing working great, thx sorry for my worst english
You would use the save_post hook, in your hooked function use wp_insert_term as described here: http://codex.wordpress.org/Function_Reference/wp_insert_term Then use wp_set_object_terms on the post to assignt he taxonomy term you just created as follows: http://codex.wordpress.org/Function_Reference/wp_set_object_terms for example: <code> function my_save($post_id) { wp_insert_term( 'bannanapost', 'fruit'); wp_set_object_terms( $post_id, 'bannanapost', 'fruit', true ) } add_action('save_post','my_save'); </code> The above code, placed in functions.php of your theme, would add the term 'bannanapost' to each post when saved, in the fruit taxonomy
How to add automatically keyword to taxonomies when a post published, and assign them to the post
wordpress
A would like to create a website in WordPress that allows user to create wedding websites. What suggestions can you give me on how to implement it?
Hi @Humera Maniya: I've only got a minute to offer suggestions tonight but I thought I'd quickly point you to two (2) other answers here on this website that provide information you'll need. Much of what I'd suggest for your use-case is identical to what I recommended on these other answers: <a href="stackexchange-url Tips for using WordPress as a CMS? <a href="stackexchange-url Implementing a CrunchBase.com Clone using WordPress? The other thing I can tell you is to look at WordPress Multisite as it will allow you to set up as many different websites on the same WordPress installation as you like. It's basically was WordPress.com is running on. Here are some articles that can explain it: How to Enable Multisite in WordPress 3.0 How to Enable Multisite in WordPress 3.0 (video) WordPress 3.0 Walkthrough: Getting Started with Multisite Creating a Network (the sites on a multisite installation are called a "network" ) WordPress 3.0: Multisite Domain Mapping Tutorial
Suggestions for Implementing a Wedding Website in WordPress?
wordpress
I am currently using Amazons Cloud Front service with the super awesome and easy to use W3 Total Cache wordpress plugin. All appears to be working correctly but I do get a chronic error in the admin panel from W3 Total Cache saying: Recently an error occurred while creating the CSS / JS minify cache: Some files were unavailable, please check your settings to ensure your site is working as intended Does anybody have any thoughts on this? Thanks in advance!
Eric, Updating to the development version might solve the problem but I suggest submitting a bug report to Fredrick. This will help him in the development of the plugin and help you by determining the cause of the problem. To submit the bug report go to support in the plugin admin and fill in all the information and Fredrick will investigate. It usually takes him a day or 2 depending on how busy he is but I know he investigates all issues brought to his attention.
W3 Total Cache plugin chronic message
wordpress
By default, my site's RSS feed URLs are in this format: <code> category/[category-name]/feed/ </code> As far as I can tell, that doesn't allow me to view a feed using multiple categories. Is anyone aware of a simple workaround, or is this something I'll need to write myself?
Maybe this might help: http://wordpress.org/support/topic/how-to-create-rss-feed-that-includes-multiple-categories
How do I view a feed consisting of posts from multiple categories?
wordpress
After enabling SuperAdmin and multisite functionality in WP3 many users are getting redirected to a sign-up url. I do not have account sign-up enabled, how do I turn this off? It seems to happen when any invalid subdomain is used including my-domain.com instead of www.my-domain.com. How do I fix?
I am answering my own question so others can find it in the future. defining <code> NOBLOGREDIRECT </code> in <code> wp-config.php </code> to point to the url of your choice will correct this problem. Sample: <code> define('NOBLOGREDIRECT', 'http://www.my-domain.com'); </code>
How do I fix unexpected redirection of visitors after enabling multisite on WP3?
wordpress
Online researching shows that there are many plugins out there to perform caching on WP. Just to name a few: WP Super Cache W3 Total Cache WP Widget Cache DB Cache Reloaded 1 Blog Cacher Hyper Cache Is using just one plugin good, or is there a point in using more then one at the same time?
@Tal, Generally speaking you should only be using one caching plugin. WP Super Cache, W3 Total Cache, Hyper Cache and DB Cache Reloaded all drop files directly in your wp-content directory and they would conflict with each other and cause errors if you were using more than one. I would recommend using W3 Total Cache because it gives you the option of using 5 levels of caching. Page Cache, DB Cache, Object Cache, Minify, and Browser Cache plus it has built in support for using a CDN.
How many caching plugins should be used?
wordpress
I'm trying to get WordPress to highlight a specific item in my menu when a post (any post) is viewed. I'm thinking that adding the post to the menu item, then suppressing display of sub-menus might help, but my 'Menus configuration' page doesn't show posts as items to add to the menu. Does anyone know why that is, or if there's a better alternative to this method? I'm using a copy of the default TwentyTen theme which calls <code> wp_nav_menu </code> in <code> header.php </code> .
You should be able to take the body class (single) and the nav item class (to be determined) and specify the style you'd like to show in the stylesheet. Something like this: <code> .single .topnav-item-29 {color: #fff; background: #333;} </code>
How do I add a post to a menu
wordpress
To Separate or Not to Separate...That is the Question? I currently have what I believe is a mistake in my site architecture. I initially built my two lines of business into the same site. Engineering/Design work and Equipment Liquidation. Learning the hard way I realize I need dedicated domains. I plan to use the same look and feel for both but have 2 separate domains/subdomains. The question is should I install a separate instance of WP for each or simply build it in the same structure with a different landing page and limited navigation between each. Obviously the latter is easier initially but I am concerned this would cause further difficulty later. Anyone have experience with this sort of situation? The theme I am using will support this but I am not convinced it is a good plan. Feel free to look at the site http://realitycramp.com , just be gentle in terms of criticism as it is a work in progress. Amazed at the quality of contribution on this site. MM/RC
Some time ago, I started a site that served as my professional portfolio. It was running on WordPress, so when I decided to add a blog it was really easy to just flip a switch and start writing. As time went on, though, I realized that the blog and the portfolio served totally different purposes - and I wanted to add a third feature for creative writing (not related to my portfolio or my professional/business blog in any way). Originally, my portfolio was on my domain and I added a second WordPress installation on a subdomain. This worked, but it was a pain to manage. I had two copies of every plug-in, two copies of WordPress, and two copies of my theme. Whenever an upgrade came out, I had to do everything twice . When I added my third site (on a second subdomain), this added a third set of steps. It wasn't a scalable solution at all . And this is the same scenario I see you in today. There are three ways you can move forward: Separate WordPress installations This is quick, easy, and pretty much foolproof. But I guarantee you'll run into effort and scalability issues in the future. WP-Hive My solution was to install a plug-in on top of WordPress (pre-3.0) that allowed me to host multiple sites off the same installation. It worked well - I created 3 separate domains and pointed them all at the same folder on my server. WordPress handles the database and all the routing. Now I have one installation, one set of plug-ins to update, and one central group of themes to work with. WordPress MultiSite With 3.0 came the ability to host multiple sites on multiple domains from a single instance of WordPress. I highly recommend anyone with a multiple-site infrastructure to migrate to this solution. It's easier to maintain than either of the solutions presented above and makes your system scalable (whether you think you'll grow now is immaterial ... but if you do the work now and grow later, you'll be thanking your younger, wiser self).
Splitting an Evolving Site into Multiple Sites, or Maintaining as One Site?
wordpress
Is there a recommended way to log (failed) cron actions from your plugin? For example, I have a plugin that synchronizes with an external service every hour. I want to log how much was changed, but also when the synchronization failed. What would you recommend here? A new database table? The Log Deprecated Notices plugin does this with a custom post type, but this might be too much overhead? I believe WordPress does not come with a standard logging package?
Use a file to write the events to. There are several drawbacks here; Filesystem permissions . When you deploy your app, you will have to take care to remember to give the webserver permission to write to the file. And to be extra sure, you'd have to write code which checks whether you can write to the file and issue a warning when you can't. This adds complexity and is likely a cause for deployment issues. Accidental deletion . You could accidentally delete the custom logfile and loose your records. This might be inconvenient. Custom logformat . You'd have to come up with a custom (machine readable?) text format to write the events to your file. When you have to change the log format, there's no convenient way to migrate old records. When you want to do some kind of analysis on the logs, you'd have to parse the records. This leads to more code and more complexity. Complexity is bad. Use a database table . Create your own database table and log the events there. None of the drawbacks listed above apply. It doesn't add a lot of complexity. Automate the creation and deletion of the table using a plugin hook and you have a reasonably reliable log system I think. Send an e-mail . Depending on the relevance of the logs, you could always opt for this method. I figure you'd probably want to send an e-mail in case of a failure anyway. Use the OS logger . When you use the syslog function in PHP, you can write events to the system logger (syslog on Unix, Event Log on Windows NT). Configuring a user defined syslog complicates deployment. Finally; you should consider if you want to log the normal case and exceptions, or only exceptions. Jeff Atwood did a good writeup about this. Hope this helps!
How do I log plugin (cron) actions?
wordpress
I have created a custom post type and added various meta boxes/fields to this custom post type. All is working excellent except for one element... Instead of utilizing the default interface for selecting a taxonomy I would like to just have a drop down menu for the user to select from. The idea here is to enable the admins to add taxonomy elements which can be managed centrally however for a specific post to only be associated with one taxonomy. Further more, I would prefer to just add this drop down into one of my existing meta boxes. Does anyone happen to have any sample code which would enable me to complete this task?
I answered this question on a different post: stackexchange-url ("stackexchange-url
Custom Post Type - Taxonomy Dropdown Menu?
wordpress
I would like to add a custom logo to my entire blog network's dashboard. I went trough a recipe on smashing magazine and got this code: <code> //hook the administrative header output add_action('admin_head', 'my_custom_logo'); function my_custom_logo() { echo ' &lt;style type="text/css"&gt; #header-logo { background-image: url('.get_bloginfo('template_directory').'/images/custom-logo.gif) !important; } &lt;/style&gt; '; } </code> Where do I add it? I think that I should add it in <code> functions.php </code> . But if so I should add the code to every theme in my mutlinetworks. Does any one have idea to add it to the entire network? I should also able to set only for a particular sub and not to entire network If I change my mind in future :) Thank you!
If you want this logo to show up across your network sites regardless of the theme I'd advise you to create a new PHP file inside <code> wp-content/mu-plugins </code> (create the directory if it doesn't exist) and drop that code inside the new file. You can name your file whatever you like - for example <code> my-network-tweaks.php </code> . That file will be loaded automatically as a plugin on all of the sites. And if you'd like to override this image for a particular site you can make that function pluggable. Like this: <code> &lt;?php //hook the administrative header output add_action('admin_head', 'my_custom_logo'); // if override function exists load it up instead if(function_exists('override_my_custom_logo')) { function my_custom_logo() { override_my_custom_logo(); } // fallback to original function } else { function my_custom_logo() { echo ' &lt;style type="text/css"&gt; #header-logo { background-image: url('/path/to/images/custom-logo.gif) !important; } &lt;/style&gt; '; } } ?&gt; </code> Note that I've changed the image path because we want it to point to a single file for the whole network. Using <code> get_bloginfo('template_directory') </code> would cause it to load the image from the theme directory. If you want to override the image for a single site, just use Tom J Nowell's code renaming the function to <code> override_my_custom_logo </code>
How do you add custom logo to entire themes
wordpress
Can I customize and edit the subject field in the "Password Reset" notification mails sent from our multisite blogs? I have tried some plugins like My brand login and white label CMS etc. But I can't edit this in password reset notifications . Does anyone help me understand how to edit it ? Update: Today I tried with another installation .But it is not making any change.The Word 'wordpress' in from mail address is still there.I have added - <code> add_filter ( 'wp_mail_from_name', 'my_filter_that_outputs_the_new_name' ); </code> to the code given by Doug .Am I missing something?Could you help me to solve this?
You can change them using a filter . The filter hooks you want to use are: For the first email message (confirming they really want to reset the password): <code> 'retrieve_password_title' </code> <code> 'retrieve_password_message' </code> For the follow-up email message (sending the new username and password): <code> 'password_reset_title' </code> <code> 'password_reset_message' </code> Update: To create and use these filters, put the following or similar code in your <code> functions.php </code> file: <code> function my_retrieve_password_subject_filter($old_subject) { // $old_subject is the default subject line created by WordPress. // (You don't have to use it.) $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); $subject = sprintf( __('[%s] Password Reset'), $blogname ); // This is how WordPress creates the subject line. It looks like this: // [Doug's blog] Password Reset // You can change this to fit your own needs. // You have to return your new subject line: return $subject; } function my_retrieve_password_message_filter($old_message, $key) { // $old_message is the default message already created by WordPress. // (You don't have to use it.) // $key is the password-like token that allows the user to get // a new password $message = __('Someone has asked to reset the password for the following site and username.') . "\r\n\r\n"; $message .= network_site_url() . "\r\n\r\n"; $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n"; $message .= __('To reset your password visit the following address, otherwise just ignore this email and nothing will happen.') . "\r\n\r\n"; $message .= network_site_url("wp-login.php?action=rp&amp;key=$key&amp;login=" . rawurlencode($user_login), 'login') . "\r\n"; // This is how WordPress creates the message. // You can change this to meet your own needs. // You have to return your new message: return $message; } // To get these filters up and running: add_filter ( 'retrieve_password_title', 'my_retrieve_password_subject_filter', 10, 1 ); add_filter ( 'retrieve_password_message', 'my_retrieve_password_message_filter', 10, 2 ); </code> You would do something similar if you also want to modify the follow-up email . Use the WordPress code as a guide for creating the subject line and message (look for the variables <code> $title </code> and <code> $message </code> ).
Customizing the Subject Field in WordPress' Notification Emails?
wordpress
I have a page structure like this: <code> -Home -Cars -Volvo 640 - Pics - Info -Porsche 911 - Pics - Info </code> I'd like to generate a list of cars on the Cars page of all the cars (which are child pages of Cars). How would I do this? The list is basically a sub-menu which should show all the cars in alphabetical order (note, I don't need links to the 'grandchildren' - Pics, Info). I also need to grab Custom Field data from each car page, and put that beside the link to the page.. is that possible?
You could use <code> get_pages </code> to do this, like so: <code> &lt;?php $args = array( 'post_type' =&gt; 'page', 'child_of' =&gt; 7, ); $postobj = get_pages($args); foreach($postobj as $item){ $dir = get_bloginfo('template_directory'); // Theme directory $title = $item-&gt;post_title; $parent = $item-&gt;post_parent; $id = $item-&gt;guid; $name = $item-&gt;post_name; </code> Once you get to here, you can pull out your custom fields and put them into variables. <code> $model_number = get_post_meta($item-&gt;ID, 'model_number', true); </code> I would use an <code> if </code> statement of some kind to build those top headings. For instance you could do: <code> if($model_number == true){ echo stuff; } else { echo other stuff; } } ?&gt; </code> It's rough, but I think this could get you quite a long ways. Essentially, you're programmatically building your headings and returning everything to get printed. The key is formatting everything and getting your conditions set up right.
How to generate a list of child pages, and use some of their custom fields?
wordpress
Is there a way of manually specifying which page is currently "active" when using <code> wp_nav_menu() </code> ? I have a "Products" page, and on that page I have links to various (dynamic) custom taxonomies. When I click on one of these taxonomies, I stay on the "Products" page but <code> wp_nav_menu() </code> loses reference to that fact that I'm still on the "Products" page. Is there a way I can fix this? Thanks! Jon
If you just want to add the <code> current_page_item </code> class to one menu item, you could hook up to the <code> nav_menu_css_class </code> filter, and add that class if needed. It is called when the menu is printed. If you want access to the whole menu and add classes, hook in to the <code> wp_get_nav_menu_items </code> filter, where you get the whole <code> $items </code> array. You can edit the <code> classes </code> properties of individual items.
How to manually specify the current active page with wp_nav_menu()
wordpress
Given that I can't access the dashboard/admin pages on my blog (that's a future question), and that I have shell access to my hosting server, can I find out the current version of WordPress from the command line? I tried grepping for the string '@since' in all the php files in the top level directory for the blog, and the latest I can see is 2.5...
grep wp_version wp-includes/version.php
Determining WordPress' Version from the Host's Command Line?
wordpress
Related to this stackexchange-url ("question"). Any recommendation on tools, plugins for optimizing a large eCommerce site on WP. Currently hitting 1000 items and 5000 more items coming. It seems the optimizations would be different than a standard blog serving thousands of users. The number of stores being developed on WP is increasing and putting a package of optimizations together would appear helpful. MM/RC
I've developed a 55k product ecommerce site using Wordpress with the Shopp plugin and can share what I've done to MySQL to eke out better performance, YMMV and some (or all) of these may not apply to your situation. Determine how much you need to increase buffers/caches by by looking at the output from a "show status" sql command - there are tools which pretty up this output which may be useful, I often just use phpmyadmin to get an idea. http://blog.mysqltuner.com/ is a handy resource and utility too. Make sure your query cache is on and that it's large enough to have a very low low memory punes number. Make sure your the number of key reads is not too high (this being a relative value), increasing key_buffer_size can help with that. Make sure that the number of temporary tables being created is low, reduce that number by increasing tmp_table_size. Turn on the slow query log and log slow queries, re-run those queries manually with explain statements, add indexes change column types, etc, as needed. For one query we were getting insane explain statements (as in comparing many, many more rows than it "should" have been), upgrading to a newer version of MySQL caused that same query to be much better optimized (and much quicker) by MySQL itself. If you're using full-text indexing I don't believe InnoDB tables are an option - just don't update products during your busy times. If your ecommerce package supports it you can minimize customer disruption (performance or otherwise) by making changes on your staging server and then moving over just the product tables with a dump from stage and loading onto production - this will not work without some additional work for the rest of your Wordpress installation however. If your site design and UX can support it guiding the users into a "browsing" mode vs. a "searching" mode (eg: clicking around a site vs typing searches into the search box) can help you take advantage of some very easy database level and Wordpress level caching. Pre-load your caches - easy caching like query caches and Wordpress-level caching can also be pre-loaded by spidering your site with wget. You can also pre-load the cache for searches by using user search behavior (via your logs) and re-getting those requests when you need to fill the caches.
Scaling a WP eCommerce site
wordpress
I have my wordpress install under svn. I was on version 2.9.2. These were the steps I took: saved a copy of my current wordpress directory cd into my top level wordpress directory <code> svn up </code> (just to make sure that I have the latest of 2.9) <code> svn sw http://core.svn.wordpress.org/tags/3.0.1/ . </code> (upgrade) run wp-admin/upgrade.php got this error "Fatal error: Call to undefined function is_multisite() in (my install directory) /wordpress/wp-includes/wp-db.php on line 505" I looked around and some people think it's a memory issue with PHP. So I tried the Memory Bump plugin and that didn't work. Any ideas? Update: Found this post . Downloaded the latest 3.0 tar and overwrote my wp-settings.php with the one in the download. Get different errors now. "Fatal error: Cannot redeclare wp_load_image() (previously declared in / myinstalldir /wordpress/wp-includes/media.php:241) in / myinstalldir /wordpress/wp-admin/includes/image.php on line 168" When I perform and <code> svn status </code> I see lots of 'S' flags (switched). Do I have to be concerned with that? wp-settings.php has that flag. Update: Here's the output of the above <code> svn sw </code> from the root Wordpress directory. Update: Output of <code> svn st </code> here . (Migrated the long listings to pastebin) Update: Output of <code> svn info </code> <code> Path: . URL: http://core.svn.wordpress.org/tags/3.0.1 Repository Root: http://core.svn.wordpress.org Repository UUID: 1a063a9b-81f0-0310-95a4-ce76da25c4cd Revision: 15559 Node Kind: directory Schedule: normal Last Changed Author: ryan Last Changed Rev: 13165 Last Changed Date: 2010-02-15 09:38:59 -0800 (Mon, 15 Feb 2010) </code>
I also used SVN before to update my wordpress installation. Up the working copied will get messed up very quickly with all the manual updates or files created by plugins. I would always recommend to use the update functionality of wordpress if you only want to step from one tagged version to another one. Although, I also use SVN for a local copy of wordpress to be able to quickly test my plugins in some old version real quick. I use Eclipse to switch from one to another tag and until now it worked out. But you'll never know. UPDATE : I just tried to switch a clean checkout of 2.9.2 to 3.0.1 which looks like it is working, but I can only see the backend and not the frontend of the default single blog. UPDATE : What even the debug mode doesn't tell me: As the default pre WP 3.0 theme is no longer available I just have to switch to the new "2010" theme. Now everything is working. So switching does work, but as I said before, your working copy usually get's messed up with a lot of files that might cause some problems updating your WP copy with SVN switch.
Error upgrading from 2.9.2 to 3.0.1
wordpress
I was playing with: <code> $wp_meta_boxes </code> , <code> $menu </code> and <code> $submenu </code> global arrays to remove "things" on admin dashboard (using unset on PHP <code> foreach </code> iterations). Now I'm stuck trying to remove without using jQuery or JavaScript: Favorites action menu. Screen options panel. Thanks in advance.
I once did extend the screen panels, putting a third one next to screen and help. But that was mainly by javascript. So you can remove them with javscript I'm sure. There were no hooks or so, that's why I opened a ticket as well with a patch because I thought that it would be useful to have. I got some traction lately, so maybe this feature will be implemented in 3.1 / 3.2: Ticket #9657 - Allow custom screen_meta dropdown panels Maybe the patch still works so you can apply the patch and use the hooks. Some kind of related / master ticket is: Ticket #11517 - Make Admin more MVC-like
Remove favorites action menu and screen options panel
wordpress
Hay I am creating my first wordpress plugin. Everything is going well so far. I have been able to add a new navigation tab to the dashboard which links to a function which basicalliy uses 'include' to spit the content of a HTML page onto the wordpress admin area. Heres my code <code> add_action('admin_menu', 'rooms_menu'); function rooms_menu() { add_menu_page('Rooms', 'Rooms', 'read', 'rooms-admin', 'show_hotel_dashboard', '' , 9); } function show_hotel_dashboard(){ include 'dashboard.html'; } </code> pretty straight forward, the dashboard.html page is a very simple html page. Now, heres my issue, within this dasboard.html page, how do i link some links to functions? Say i have a link which is <code> &lt;a href='do_action.php'&gt;Do action&lt;/a&gt; </code> when i click that link it actually goes to do_action.php not the action within my plugin. Any ideas?
Rather than include an HTML file, include a PHP file instead. Then, at the top of your PHP file you can check to see if any data's been submitted and process it before displaying the form. So instead of what you have, try: <code> function show_hotel_dashboard(){ include 'dashboard.php'; } </code> Then on the page do things like: <code> &lt;a href="dashboard.php?action=do_something"&gt;Do something&lt;/a&gt; </code> And in your <code> dashboard.php </code> file, start with <code> &lt;?php if($_POST["action"] == "do_something") { // Do something } else { // Output your regular dashboard page } ?&gt; </code>
wordpress plugin noob situation
wordpress
I am getting a bit frustrated over here after having spent a few hours trying to accomplish this fairly simple task without any luck. Essentially I have 5 custom post types which I created and all I want to do is show each of them in a specific order directly under the "dashboard" . From the WordPress documentation it seems that you can't really do this because the highest menu order seems to be "5". And above L I am guessing some expert reading this can show me the simple way that I can order the admin menu exactly the way I want to by utilizing the functions file and without utilizing a plugin (which I know exists). Please go ahead and try to create 5 separate post types and include them in a specific order directly under the dashboard... it seems this is not possible.??... is there some type of jquery hack to make this work that someone could share with me or preferably without utilizing jQuery?
Hi @BinaryBit: It's no wonder you are a bit frustrated; the admin menu is one of the most obtuse and frustrating implementations through WordPress core. Honestly, I don't know what they were thinking when they designed it that way. @EAMann did an excellent job of explaining how the admin menus work in WordPress (I wish I had been able to read that about 4 months ago... :) Still, after I figured it out how it worked I was still at a loss to work with it without devoting enough time to keep my head straight while I tried to do simple things. So that's why I built a Menu API that simplifies and streamlines working with the WordPress admin menu. They are 100% compatible with WordPress' existing structures and still very much in alpha since I've been the only one using it. I'm sure there are use-cases they do not yet handle. But I'll post the code here for you and others to try out. You can download the file to drop in your theme's directory here: wp-admin-menu-classes.php and what follows shows how you might call the functions in your theme's <code> functions.php </code> file: <code> &lt;?php require_once('wp-admin-menu-classes.php'); add_action('admin_menu','my_admin_menu'); function my_admin_menu() { swap_admin_menu_sections('Pages','Posts'); // Swap location of Posts Section with Pages Section rename_admin_menu_section('Media','Photos &amp; Video'); // Rename Media Section to "Photos &amp; Video" delete_admin_menu_section('Links'); // Get rid of Links Section $movie_tags_item_array = get_admin_menu_item_array('Movies','Movie Tags'); // Save off the Movie Tags Menu update_admin_menu_section('Movies',array( // Rename two Movie Menu Items and Delete the Movie Tags Item array('rename-item','item'=&gt;'Movies','new_title'=&gt;'List Movies'), array('rename-item','item'=&gt;'Add New','new_title'=&gt;'Add Movie'), array('delete-item','item'=&gt;'Movie Tags'), )); copy_admin_menu_item('Movies',array('Actors','Add New')); // Copy the 'Add New' over from Actors renamed_admin_menu_item('Movies','Add New','Add Actor'); // Rename copied Actor 'Add New' to 'Add Actor add_admin_menu_item('Movies',array( // (Another way to get a 'Add Actor' Link to a section.) 'title' =&gt; 'Alt Add Actor ', 'slug' =&gt; 'post-new.php?post_type=actor', ), array(// Add Back the Movie Tags at the end. 'where'=&gt;'end' )); add_admin_menu_item('Movies',$movie_tags_item_array,array(// Add Back the Movie Tags at the end. 'where'=&gt;'end' )); delete_admin_menu_section('Actors'); // Finally just get rid of the actors section } </code> What's more, these functions are even under consideration (as a base) for inclusion in WordPress 3.1 so if we're lucky these might even become standard!
Changing the Order of Admin Menu Sections?
wordpress
Is this a good example of usage of <code> current_filter() </code> ? <code> &lt;?php add_filter("_my_filter", "common_function"); add_filter("_another_filter", "common_function"); function common_function(){ $currentFilter = current_filter(); switch ($currentFilter) { case '_my_filter': echo "Called by My Filter"; break; case '_another_filter': echo "Called by another filter"; break; } } </code> So I am guessing <code> current_filter() </code> is used to get the name of the filter for which the current execution is happening?
Hi @Raj Sekharan : Looks good to me, but is wanting to know the current usage really your question or do you want to understand where <code> current_filter() </code> gets it's information from? If the latter, here's basically what happens in all the different hook processing functions, e.g. <code> do_action() </code> , <code> apply_filters() </code> , <code> do_action_ref_array() </code> , <code> apply_filters_ref_array() </code> ( greatly simplified, of course ): <code> &lt;?php function &lt;process_hook&gt;($hook, $value) { global $wp_filter, $wp_current_filter; $wp_current_filter[] = $hook; // "Push" the hook onto the stack. $value = call_user_func($wp_filter[$hook]['function'],$value); array_pop($wp_current_filter); return $value; } </code> Then all that <code> current_filter() </code> does is retrieve the last hook "pushed" onto the global <code> wp_current_filter </code> array, i.e.: <code> &lt;?php function current_filter() { global $wp_current_filter; return end( $wp_current_filter ); } </code>
Is This A Correct Example Usage Of current_filter()?
wordpress
With the new WordPress and it's new features, it seems like WordPress is capable of much more than a simple blog engine. But how well does WordPress scale being used by say 10k -> 100k users per day? With that many users a big part of it will be to have a good cache strategy, but how well is WordPress developed to help, making this easy and give you the control you need. Fx being able to cache part of a page and only render user customized parts, support master/slave db setup and stuff like that?
Hi @googletorp: Clearly nothing scales as well as static files served by a fast web server and any CMS that has to figure out what to load and then load it will not perform as well, WordPress or otherwise. One of the issues is the number of database queries required per URL request and my 2 prior years experience working exclusively with Drupal and now 2+ years with WordPress is that WordPress is much better in that department. That said, almost nothing with any power is going to scale "out-of-the-box" ; it's all about what can you do as your scalability needs grow? On the low end of "lots of traffic" there are great caching plugins and integrations with inexpensive CDNs you can do a pretty good job on a no-IT budget and low hosting budget. Here are some other questions &amp; answers to review: stackexchange-url ("Steps to Optimize WordPress in Regard to Server Load?") stackexchange-url ("Options for CDN with WordPress Including Supporting Plugins?") stackexchange-url ("Configuring WordPress for Amazon CloudFront Caching?") There are options for profiling to identify performance bottlenecks : stackexchange-url ("Profiling a WordPress Website for Deployment on Shared Hosting?") Once bottlenecks are identified you can do localized optimization with things like the Transients API . This Q&amp;A gives an example that can be optimized using Transients API and shows how: stackexchange-url ("Using WP_Query to Query Multiple Categories with Limited Posts Per Category?") If you thing really get want to pull out the big guns you can configure Memcached , HyperDB , Nginx and/or more to speed things up (it seems the latter is really evolving into the way to get amazing scalability out of WordPress): Enable Memcached for your WordPress How To Speed Up WordPress With Nginx And WP Super Cache HyperDB Nginx as a front-end proxy cache for WordPress And finally there are emerging WordPress-focused webhosts specializing in performance such as WP Engine , ZippyKid and others: stackexchange-url ("Best-of-Breed features of a high-end WordPress web host?") So the good news is all of the scales very nicely ; from the very low end of free and easy with technical complexity and cost only grow as traffic significantly grows. Start small with WordPress and it will be great. If your traffic does grow and you are monetizing it even reasonably well you'll find it very cost effect to scale as you need it. At least IMO. :)
How well does WordPress scale?
wordpress
At any one time I have a number of blog articles that are in draft. Generally, if I encounter something useful, I'll note it in a draft blog entry, to revisit, research and write up at a later date. So, while these aren't accessible from any hyperlink, I find I am still able to reference them by going to the link directly. E.g: http://www.jameswiseman.com/blog/?p=xxxx (where 'xxxx' is the post number). Recently, on my site logs, I have seen an IP (from Ljubljana, Slovenia) that has been accessing these draft posts, which although not particularly sensitive, is still kind-of annoying. I'm guessing they are using the method above. Is there any way of stopping this? EDIT : Given the response below, I am indeed unable to access the post when logged out, however I am still seeing from my access logs hits on my draft pages. Any more thoughts?
Yes, you (read: the logged in user) will be able to see the drafted post. But, a guest will not be able to read it. To test it, login to one browser and create a draft. See its URL in another browser where you don't login (no cookie, etc).
Stopping People Viewing Draft Posts
wordpress
I've created a custom taxonomy called 'productCategories' using <code> register_taxonomy() </code> function. I've set the rewrite slug to 'products'. My question is: How do I render a different template to <code> archive.php </code> for my custom taxonomy /products ? Thanks, Jon
Create a template file called <code> taxonomy-productCategories.php </code> . For more information, see the Template Hierarchy . I find this image particularly helpful.
How do I create a custom archive page depending on the custom taxonomy type?
wordpress
I was just wondering if something like this would work: The page displays a form, with a captcha code inside it. When this form is generated, a transient is set to store the captcha code. The vistor submits the form After submit <code> $_POST['captcha'] </code> is compared to the transient from the database; if matched return success, otherwise fail Delete the transient What do you think? Is this secure?
I think that, while this method could be secure, there are many advantages to using an off-the-shelf captcha system, both in terms of the security of the captcha images/audio/media, and also in terms of performance advantages like caching. If you use a captcha widget which is JavaScript based, for example, the underlying WordPress-generated page could actually be completely cached as a static page by a number of caching plugins. If you are generating the captcha in PHP each time, this would not be possible If you do go down this route, one thing you'll want to do as well is to add a hidden nonce to the form as well to make sure that the user agent responding to the captcha is the one who you just generated it for. WordPress's wp_nonce function can help you do this easily. Otherwise, if you do not flush your captcha transients carefully, it's possible for someone to cache that page with the captcha and have another user agent send the response.
Using transients to store captchas
wordpress
I have a custom post type that includes a custom taxonomy, called <code> client_name </code> . There is a page that loads these custom post types and displays them. What I need to develop is a dropdown list that displays all the custom taxonomy of those custom posts, which I have done, but I need to remove duplicates, and arrange them alphabetically, which is where I am having problems. This is what I am trying for removing duplicates (it doesn't work): <code> &lt;?php &lt;form method="post" id="clientform" action="" onsubmit="return getURL(this.url.value)"&gt; &lt;select name="url" id="client"&gt; &lt;option selected="selected"&gt;By Client&lt;/option&gt; &lt;?php $args=array( 'post_type' =&gt; 'our_work', 'post_status' =&gt; 'publish', 'order' =&gt; 'ASC', 'posts_per_page' =&gt; -1 ); $my_query = new WP_Query($args); $k=0; if( $my_query-&gt;have_posts() ) { while ($my_query-&gt;have_posts()) : $my_query-&gt;the_post(); $termArray[$k] = array (trim(get_the_term_list( $post-&gt;ID, 'client_name'))); // $text = trim(get_the_term_list( $post-&gt;ID, 'client_name')); for ($i = 0; $i &lt;= $termArray.count; $i++ ) { for ($j = 0; $j &lt;= $tempArray.count; $j++) { if ($tempArray[$i] == $tempArray[$j]) { unset($tempArray[$k]); $termArray = array_values($termArray); } } // end of for $k++; ?&gt;&lt;option value="&lt;?php bloginfo('url'); echo "/client_name/"; echo $termArray[$k]; ?&gt;"&gt;&lt;?php echo $termArray[$k]; ?&gt;&lt;/option&gt;&lt;?php } ?&gt; &lt;?php endwhile; } wp_reset_query(); ?&gt; &lt;/select&gt; &lt;input type="submit" id="clientsubmit" value="Search" /&gt; &lt;/form&gt; </code> Ok, now I ran across this PHP function the other day and it does what I want, I just dont know how to use it correctly. <code> array_unique($input); </code> Help me out guys .... Note the code listed above is only one code branch I was trying, not the whole file. UPDATE Hey this does help me quite a bit, it and I found this to use, this gets me like 95% done, but not 100% yet. I tried your code, and I tried this one I am using, and it removes the dup's but anything that comes after it wont display hmm.... Heres the WP code: <code> &lt;?php if( $my_query-&gt;have_posts() ) { while ($my_query-&gt;have_posts()) : $my_query-&gt;the_post(); $termArray[$i] = trim(get_the_term_list( $post-&gt;ID, 'client_name')); $termArray = array_unique($termArray); $termArray = array_values($termArray); print_r($termArray); print_r(sizeof($termArray)); if ($termArray[$i] != '') { ?&gt;&lt;option value="&lt;?php bloginfo('url'); echo "/client_name/"; echo $termArray[$i]; ?&gt;"&gt;&lt;?php echo $termArray[$i]; ?&gt;&lt;/option&gt;&lt;?php }// end of if $i++; endwhile; } wp_reset_query(); </code> And here is the output from the array, it duplicates the array output because it is called every time a new post is called within the loop. The page is available here: <code> http://magicvideo.com/cms/work/ </code> View the source to see what i mean.
Hi @Hunter Brelsford: Good to see you here over from the WordPress Group on LinkedIn . Maybe I misunderstand your question but it sounds like you are simply trying to get rid of dups in an array? For example, let's say you have an array clients: <code> &lt;?php $clients = array( 'Jones Construction', 'Smith Wholesale', 'Smith Wholesale', 'Williams Dry Cleaning' ); </code> And you want to convert to an array like this? <code> &lt;?php $clients = array( 'Jones Construction', 'Smith Wholesale', 'Williams Dry Cleaning' ); </code> ( If yes, that's a PHP question and not a WordPress question, normally something stackexchange-url ("we send away"), but I'll go ahead and answer here anyway. ) Tis easy; since array keys are unique in PHP just flip the array (exchange the values with their keys) then return the array keys and you'll have your unique array, like so: <code> &lt;?php $clients = array( 'Jones Construction', 'Smith Wholesale', 'Smith Wholesale', 'Williams Dry Cleaning' ); print_r(array_keys(array_flip($clients))); </code> That code prints: <code> Array ( [0] =&gt; Jones Construction [1] =&gt; Smith Wholesale [2] =&gt; Williams Dry Cleaning ) </code> Was that what you were after? UPDATE: Hi @Hunter Brelsford : I'm responding to your update. Okay, why don't we try and tackle this a different way? Here's a standalone example you can copy to the root of your website as <code> test.php </code> and then run it as <code> http://magicvideo.com/test.php </code> to see it work: <code> &lt;?php include "wp-load.php"; header('Content-Type:text/plain'); global $wpdb; $sql = &lt;&lt;&lt;SQL SELECT DISTINCT tt.term_id FROM {$wpdb-&gt;posts} p INNER JOIN {$wpdb-&gt;term_relationships} tr ON p.ID = tr.object_id INNER JOIN {$wpdb-&gt;term_taxonomy} tt ON tt.term_taxonomy_id = tr.term_taxonomy_id WHERE 1=1 AND p.post_status='publish' AND p.post_type='our_work' AND tt.taxonomy='client_name' SQL; $terms = $wpdb-&gt;get_results($sql); $term_ids = array(); foreach($terms as $term) { $term_ids[] = $term-&gt;term_id; } $terms = get_terms('client_name',array( 'include'=&gt; implode(',',$term_ids), )); print_r($terms); </code> We use raw SQL to query the terms in the <code> taxonomy='client_name' </code> for <code> 'post_type='our_work' </code> and then we collect the <code> $term-&gt;term_id </code> s to filter the list of taxonomy terms. I used raw SQL because WordPress doesn't provide a good way to get this data through an API, at least not that I could find on short notice ( if someone else knows of a better way via the API that doesn't require loading a lot more data than necessary please let me know ). Hopefully this will suggest an approach so that you'll be able to use this code in your example? Let me know if know if not.
Removing Duplicate Custom Taxonomy Terms from within a Dropdown Select?
wordpress
I'm trying to show child-pages in a certain order, in a list. This is my code to output the pages as a list <code> $parent = $wp_query-&gt;post-&gt;ID; wp_list_pages("title_li=&amp;child_of=$parent&amp;echo=1&amp;sort_column=post_title" ); </code> Now I want to show the first four of the pages in a particular order <code> -Summary -Info -Groups -Entries -Other Page -Another Page </code> In other words, Summary, Info, Groups, Entries should be shown in that order (providing they exist), and other pages below. How would I achieve that? I've noticed there are parameters to include and exclude pages using wp_list_pages. These parameters take page ID numbers as variables , so I perhaps the pseudo-code is <code> - make a array of the IDs of child pages which include Summary, Info, Groups, Entries in their titles, and order these correctly - make a array of the IDs of child pages which don't include the 4 pages - join these arrays together - print out the html of the array of page IDs </code>
Based on your comments here is another option , using wp_list_pages and without having to work with arrays and pulling content manually, I'm leaving out a bunch of the options, just the bare essentials. <code> &lt;ul&gt; &lt;?php $priority_pages = '5,1,3,7'; wp_list_pages(array('include' =&gt; $priority_pages); wp_list_pages(array('exclude' =&gt; $priority_pages); ?&gt; &lt;/ul&gt; </code> since, wp_list_pages, just gives you the <code> &lt;li&gt; </code> elements, you can use this function a couple of times to pull all the pages you need. So now you can only get the pages you want out the top, and then pull in the rest. You can use all the rest of the options to sort and filter the tree like normal (Note, I like using arrays instead of the string, code looks cleaner IMO). Read the codex page for wp_list_pages for more options To get a list of ID's with what you want. <code> &lt;?php $my_wp_query = new WP_Query(); $all_wp_pages = $my_wp_query-&gt;query(array('post_type' =&gt; 'page')); $parent = $wp_query-&gt;$post-ID; $children = $get_page_children($parent, $all_wp_pages); ?&gt; </code> What we have now is an array in <code> $children </code> with the information we need. What I would at this point is loop through <code> $children </code> looking for the filed <code> post_title </code> to equal what you want, and store that <code> ID </code> . With these store as an array, you would be able to use those with the include, exclude functions of <code> wp_list_pages </code> So not 100% complete, but it will get you started <code> &lt;?php $priority_pages_a = array(); foreach($children as $child) { if(strpos($child-&gt;post_title,"Summary") { $priority_pages_a[0] = $child-&gt;ID; } elseif (strpos($child-&gt;post_title,"Info") { $priority_pages_a[1] = $child-&gt;ID; } } $priority_pages = implode(",",$priority_pages_a); ?&gt; </code> What we've done is created an array that puts the ID into the array order that you want. Then implodes that into a comma separated string, for which you can use the <code> wp_list_pages </code> to get the ones you want / need. The <code> get_page_children </code> doesn't touch the database, but the get all pages does :/ so it's a wash. I haven't tested this code altogether, but it should work. Also note there is a <code> get_page_by_title </code> , so if your titles are exactly 'Summary' then you can use it to get the ID, but in your question you said contains, so I went with this route instead.
Listing Child Pages in a Certain Order?
wordpress
I am wondering how to prevent WordPress from applying in-line styles to image enclosing div's in posts. <code> &lt;div class="img size-medium wp-image-3267 alignright" style="width:190px;"&gt; </code> Edit: The post is generated in the theme file by using <code> the_content() </code> . That width declaration is causing my post to display a horizontal scrollbar under the content. The weird thing is, the horizontal scroll bar only appears if the image is set to align right. Aligning the image to the left doesn't cause the scroll bars to appear. I am able to remove the scrollbar by setting the .post overflow from 'auto' to 'hidden'. Does anyone know how WordPress applyies the inline style? Or how to override it? For now, I've set .post overflow to be hidden, but I'm worried that down the line, that might bite me. Thanks
WordPress doesn't wrap <code> &lt;image /&gt; </code> tags with <code> &lt;div&gt; </code> elements by default ... so there's probably something in your theme or a plug-in on your site that's adding the element wrapper. I suggest switching to the default TwentyTen theme and disabling plug-ins to compare the generated markup. Then re-enable plug-ins one at a time and switch back to your theme to see which set of code is adding the unwanted <code> &lt;div&gt; </code> blocks.
How to Prevent WordPress from Automatically Applying Inline Styles to Post Images?
wordpress
We're running a WordPress multisite instance on two Rackspace Cloud servers, one web and one database, with 30 or so sites currently. I've put Nginx in front for static assets and Apache handles all dynamic requests. I've also configured Memcached for the database and APC op code caching for PHP. W3 Total Cache is enabled by default across all of the sites we have. It's wicked fast with one issue: Apache processes regularly weigh in between 80 and 120 MB. The web server has 2 GB of memory, meaning I get 15 or so processes until things go on the fritz. The processes obviously shouldn't be that large but I'm perplexed as to why they are. What's a good strategy for identifying what's going on? Thanks in advance! Update 10/2/10: For those wondering, the resolution of the memory issue problem was disabling PHP xdebug (was inadvertently enabled on configuration and caused random memory usage spikes).
The apache process memory amount you talk about (80 to 120 MB per process) can be split into two reasons. Apache Wordpress Apache You can optimize apache by only loading the number of modules you need and other optimization tweaks that will reduce the memory. If you have not optimized that yet, give it some tweaks. Wordpress Wordpress just consumes a lot of memory and is not very optimized at all. I would start with replacing the database class with something more properly implemented. That should gain more speed and reduce the memory usage a lot. Next to that I have not that much to suggest. Not using Worpdress is not considered helpful I guess. Strategies To find out what's going on, you need to track how much memory a wordpress request is taking up. There is a get peak usage function ( <code> memory_get_peak_usage() </code> ) you could use to monitor worpdress memory usage. If it comes close to the 80 - 120 MB you wrote about, you know that wordpress is creating your headaches. You might want to log the time-stamp, peak memory, execution time and requested URI. Using Nginx to serve cached wordpress pages will most certainly help you because it will prevent wordpress from getting loaded - even for those "inbound" caches like the one you use. They are conceptually broken because they are a wordpress plugin, so at least a part of wordpress needs to be loaded even for cached results.
What's the ideal way to profile WordPress memory usage?
wordpress
The textarea in which posts are written and edited doesn't handle image layout very well. Inserted images seem to be aligned with the left edge of the textarea, or the right edge of the previous image. This is often hard to work with, and users have to understand that this isn't the way they will show up once published. I'm after a better-looking, and more usable layout. I'd like to be able to ALWAYS have non-floated images appear left justified and stacked one on top of the other. Is this solved by modifying the admin css, or does the formatting of images in the textarea accomplished another way?
Add this to your theme's <code> functions.php </code> file: <code> add_editor_style(); </code> By default that function will load a file called <code> editor-style.css </code> which is located in the root directory of your theme. The functions accepts a filename or an array of filenames as parameter. Reference in the Codex: http://codex.wordpress.org/Function_Reference/add_editor_style If you want (or need to have) more control over the custom CSS file name and location you can use this function instead: <code> function custom_editor_style($url) { if ( !empty($url) ) $url .= ','; // Change the path here if using sub-directory $url .= trailingslashit( get_stylesheet_directory_uri() ) . 'editor-style.css'; return $url; } add_filter('mce_css', 'custom_editor_style'); </code>
Format the Layout of Images In The Edit Post Textarea?
wordpress
I'm trying to archive my tweets in Wordpress and display recent ones in my sidebar. I've installed the Twitter Tools plugin, configured it, and added its widget to my sidebar. Twitter Tools is creating blog posts for each of my tweets, so I know it is authorized by Twitter successully. However, the sidebar widget just displays "No tweets available at the moment." I've tried the procedure described here to uninstall and reinstall Twitter Tools to no avail. I'm also using the Ultimate Category Excluder plugin to exclude the tweet posts from my feed and homepage. I'm worried that might be the problem but others seem to be using this setup successfully. Any ideas?
I kept digging on this and I found that the Twitter Tools widget depends on a table called wp_ak_twitter. I didn't have this table, probably because my Wordpress database user doesn't have create table privileges. I create the table by hand and now the widget is working.
How do I get the Twitter Tools widget to display my tweets?
wordpress
Imagine I have a site set up with pages in this kind of hierarchy.. <code> -Home -Cars -Volvo 850 -Volvo 850 tech spec -Volvo 850 pictures -Porsche 911 -Porsche 911 tech spec -Porsche 911 pictures -other cars etc </code> Now you can see that I have a bunch of Cars. On each of the car pages (Volvo 850, Porsche 911) I have some Custom Fields where I have entered various data about the Car (by the way, I'm using the Custom Field Template plugin to make entry of this data easy in wp-admin). These fields are displayed on the page. (the fields are not entered on the tech spec and pictures pages) What I would like to do is display a list on the cars on the Home page (below), which gets the data from the Custom Fields. What would be the best way to (a) access this custom field data (which can change when new cars are added or edited), and (b) display the data in a certain order (for instance by top speed)..? <code> --------------------------------------- | Car | Top Speed | --------------------------------------- | Porsche 911 | 200 | | Audi 444 | 180 | | Volvo 840 | 160 | --------------------------------------- </code> I guess the pseudo-code is <code> * find all pages which are an immediate descendant of the Cars page (not the tech spec and pictures) * get the custom data from these pages * display data in Top Speed order </code>
This one might get you started (this one is for the size as you can see since i do value 1 times value 2) (just to give an example of more advanced queries) <code> global $edl_global_join; global $edl_global_orderby; global $wp_query; function edl_posts_join ($join) { global $edl_global_join; if ($edl_global_join) $join .= " $edl_global_join"; return $join; } function edl_posts_orderby ($orderby) { global $edl_global_orderby; if ($edl_global_orderby) $orderby = $edl_global_orderby; return $orderby; } add_filter('posts_join','edl_posts_join'); add_filter('posts_orderby','edl_posts_orderby'); $edl_global_join = "JOIN $wpdb-&gt;postmeta meta1 ON (meta1.post_id = $wpdb-&gt;posts.ID AND meta1.meta_key = 'TOPSPEED')" . "JOIN $wpdb-&gt;postmeta meta2 ON (meta2.post_id = $wpdb-&gt;posts.ID AND meta2.meta_key = 'ANOTHER_THING')"; $edl_global_orderby = " meta1.meta_value * meta2.meta_value DESC"; $wp_query = new WP_Query($args); </code> and then just run the loop I wrote a "CAR class" which among others displays meta fields such as: <code> $car-&gt;display_meta_size(); </code> which is actually the following method in that class: <code> // // specific display for size overviews // function display_meta_size() { $this-&gt;mMetaData-&gt;GetValuesFromWP(); ?&gt; &lt;table width="100%"&gt; &lt;?php $this-&gt;mMetaData-&gt;ShowIcon(); $this-&gt;mMetaData-&gt;ShowSize(); ?&gt; &lt;/table&gt; &lt;?php } </code> where the method GetValuesFromWP() is from the wp metadata class : <code> // get the values stored in WordPress function GetValuesFromWP() { global $post; $custom = get_post_custom($post-&gt;ID); foreach ($this-&gt;mArrMetaDataFields as $str_meta_data_field) { $this-&gt;MetaDataWpValues[$str_meta_data_field] = $custom[$str_meta_data_field][0]; } $this-&gt;MetaDataWpValues['SPECIAL'] = $custom['SPECIAL'][0]; } </code> (so in the join function totally above add the page selection(s))
Getting Custom Field data from a page hierarchy
wordpress
I've just created a draft on my blog, and it's post ID is 1. After creating another draft, the post id for this last post is 3! I was hoping to see them in sequential order, so in the future I'll have a nice auto-incremented numbering like <code> ../archives/1 ../archives/2 </code> some months later... <code> ../archives/154 ../archives/155 </code> I have no problem diving into code, but I was wondering if someone happens to know a simple solution to achieve this. Thank you.
The ID of a post is not meant to be a sequence number in the sense that for post N the following post is N+1. The ID is an auto-incremented field in the posts table, which includes many things that are not published posts, e.g., drafts, pages, attachments. So there is really no way to force WordPress to assign sequential IDs in that field. There are ways to produce a sequence number and then use it in the permalink structure, but any efficient system will involve storing the IDs in a separate location (table or option) and writing a custom rewrite plugin. That last bit is quite advanced. It would be an intriguing problem for the experienced hacker to produce a plugin that solves this problem without significant performance degradation.
Change Permalinks Structure to a Sequential Number for Each Post?
wordpress
I need mathematics on a WordPress site and I'm having trouble finding a suitable LaTeX plug-in. I've tried several solutions including MathJax (which is slow and renders inconsistently) and the WP QuickLaTeX plugin which works well but does not allow displayed equations (only inline equations) and stores all images on an external site. I'd like a plugin that allows inline and displayed equations, stores images locally and does not take an age to render the maths on a page. Does it exist?
I'm developer of WP-QuickLaTeX plugin. It is developed for mathematicians driven by feeling that math doesn't deserve to be published with poor quality on the Web. In fact, besides correct formula positioning and meaningful error messages, WP-QuickLaTeX can store images on a local server too . How to do that is explained on WP-QuickLaTeX home page: "If you want maximum performance you might create <code> ql-cache </code> folder in <code> wp-content </code> . It will be used by WP-QuickLaTeX for caching necessary data to decrease loading time of your pages. Just make sure <code> ql-cache </code> is writable (by <code> chmod 777 </code> or through File Manager in cPanel)." Soon we will release new version of the plugin. It will include such features: Precise adjustment of font size (in pixels). Rendering in specified size will be done by high-quality rendering engine (with anti-aliasing, etc.) not by image interpolation. Adjustment of foreground and background colors. Now we use black color for text and transparent background. New version will allow to set up colors a-la HTML/CSS way (i.e. using hex digits for RGB: #FFFFFF for white, #FF0000 for red, etc.) Settings page in administrator dashboard for tuning up. Anyone interested could check test page for the QuickLaTeX.com . I would appreciate any feedback (please leave comments on WP-QuickLaTeX home page or send me email via pavel@holoborodko.com). Besides we have many plans for the future - stay tuned. As for displayed equations, you can use LaTeX command <code> \displaystyle </code> to force this mode. And yes, another problem is that some environments cannot be used in inline mode. But there are exist some workarounds (like using <code> aligned </code> instead of <code> align </code> environment). Please use it for the moment. We are planning to implement displayed math mode in future versions. 2010-10-25 Update: New version of WP-QuickLaTeX has been released. It includes displayed equations and custom LaTeX document preamble among other new features. I would appreciate any feedback on its usage. 2011-02-08 Update: Now it allows native LaTeX syntax directly in the posts, display equations numbering, <code> tikZ </code> graphics, etc.
Recommendations for a LaTeX Plugin?
wordpress
I wish to be able to give different ads to visitors of different "types". For example: People from country X will get one ad, while people from country Y will get no ads. First time visitors will get an ad. Returning visitors won't. The ad can be either google ads or something else. Any plugin or hack to do it?
There are systems that do something similar, particularly for Example 2. What Would Seth Godin Do , for example, stores a cookie in the user's browser that tracks the number of times they've visited the site. If they're a new visitor (have visited less than 5 times), it displays a message suggesting they subscribe to the site's RSS feed. It would be a simple matter to build a similar system that displays a Google ad for first-time or new visitors but not for returning visitors.
Offering Ads Dependent on Visitor Type?
wordpress
I wish to tag visitors who came to my site and clicked the RSS button. My goal is to "Segment" this visitors in Google Analytics, so I'll be able to see where my "new readers" are coming from. How can it be done in WordPress?
The best way is to track this in Feedburner - that will tell you how many "subscribers" you may have at any time. If you want to track how many people click on your RSS feed link on your WordPress site you can tag the link with some Google Analytics tracking code. See http://www.google.com/support/analytics/bin/answer.py?hl=en&amp;answer=55578 for help
Tracking RSS subscribers in Google Analytics
wordpress
So I continue to run into this issue and I just looking for the best and simplest solution to solve this problem. I have come to make use of custom post types in many different projects and have extended these with custom metaboxes which I have then further extended by adding custom scripts such as jQuery event calendar selectors... All of this works great except for one key issue... I don't want these custom jQuery scripts to load on every page in the admin. I am essentially just looking for a way to just have these custom jquery fields loaded when I am on the "edit post" page for a SPECIFIC post type. What's the best solution here? UPDATE 1 First of all, thank you very much. I am actually shocked that plugin developers dont make sure of things like this because as I am finding out this is one of the key reasons that problems exist with different plugins. I am having some further issues though with this. For example... I have modified the script to call the if statement like this: <code> if (is_admin() &amp;&amp; $pagenow=='post-new.php' OR $pagenow=='post.php' &amp;&amp; $typenow=='events') </code> As you can see I am trying to set things up so that my scripts ONLY get called when I am adding or editing a post within the post type of "events". I don't want the script to load on any other page and also don't want it to run on the list of page within the post type of "events" so I would think the if statement is correct. The problem however seems to be that the script only gets loaded when I create a new post within this post type but it does not seem to work when I am editing an existing post. Could you test this out and maybe let me know what I could be doing wrong? Here is the exact code which I am using... maybe there is a better or simple way of doing this? <code> &lt;?php // INCLUDE METABOX CUSTOM JQUERY DATEPICKER 2 add_action('admin_init','load_admin_datapicker_script'); function load_admin_datapicker_script() { global $pagenow, $typenow; if (is_admin() &amp;&amp; $pagenow=='post-new.php' OR $pagenow=='post.php' &amp;&amp; $typenow=='events') { $ss_url = get_bloginfo('stylesheet_directory'); wp_enqueue_script('jquery'); wp_enqueue_script('custom_js_jquery_ui',"{$ss_url}/admin-metabox/js/jquery-ui-1.7.1.custom.min.js",array('jquery')); wp_enqueue_script('custom_js_daterangepicker',"{$ss_url}/admin-metabox/js/daterangepicker.jQuery.js",array('jquery')); wp_enqueue_script('custom_js_custom',"{$ss_url}/admin-metabox/js/custom.js",array('jquery'),NULL,TRUE); wp_enqueue_style('custom_css_daterangepicker',"{$ss_url}/admin-metabox/css/ui.daterangepicker.css"); wp_enqueue_style('custom_css_jquery_ui',"{$ss_url}/admin-metabox/css/redmond/jquery-ui-1.7.1.custom.css"); } } </code> Also... if I wanted to add three post types and load different JS scripts for each post types then would I just duplicate the code above three separate times or is this not a good way of doing this? For example... would it be better to just call: global $pagenow, $typenow; At the top of my functions file or does it matter or complicate things when I duplicate it more than once? On a different problem related to the same... I for example am utilizing the "gravity forms" plugin but I have noticed their scripts run on every page on the admin which is causing issues with other plugins. How would i go about modifying their script to ensure the scripts only get loaded when I need them. UPDATE 2 I have modified my functions.php file with the code provided by Mike (below) however it seems that the applicable javascript is still being included when you create a NEW Post or Page. This means that when you attempt to create a NEW Post or Page either by creating a new default wordpress post/page or when you create a NEW post/page based off one of your custom post types. The code proposed by Mike IS working on all other admin pages and it DOES work when you "EDIT" an existing post/page or custom post type. Any suggested modifications to make this work correct? Here is my current code: <code> &lt;?php add_action('admin_init','load_admin_datapicker_script'); function load_admin_datapicker_script() { global $pagenow, $typenow; if (empty($typenow) &amp;&amp; !empty($_GET['post'])) { $post = get_post($_GET['post']); $typenow = $post-&gt;post_type; } if (is_admin() &amp;&amp; $pagenow=='post-new.php' OR $pagenow=='post.php' &amp;&amp; $typenow=='events') { $ss_url = get_bloginfo('stylesheet_directory'); wp_enqueue_script('jquery'); wp_enqueue_script('custom_js_jquery_ui',"{$ss_url}/admin-metabox/js/jquery-ui-1.7.1.custom.min.js",array('jquery')); wp_enqueue_script('custom_js_daterangepicker',"{$ss_url}/admin-metabox/js/daterangepicker.jQuery.js",array('jquery')); wp_enqueue_script('custom_js_custom',"{$ss_url}/admin-metabox/js/custom.js",array('jquery'),NULL,TRUE); wp_enqueue_style('custom_css_daterangepicker',"{$ss_url}/admin-metabox/css/ui.daterangepicker.css"); wp_enqueue_style('custom_css_jquery_ui',"{$ss_url}/admin-metabox/css/redmond/jquery-ui-1.7.1.custom.css"); } } ?&gt; </code>
First, I assume you are using <code> wp_enqueue_script() </code> to load your scripts , right? That said, if I understand your question then what you need is something like the following . You'll have to edit it for your details, of course, but it gives you the general framework. We are hooking <code> admin_init </code> with the function <code> load_my_script() </code> to tests the global <code> $pagenow </code> for a match with the admin page <code> edit.php </code> , and the global <code> $typenow </code> to see if the post type is the one you want. The rest are just details which you can read about stackexchange-url ("here") if you need to learn more: <code> &lt;?php add_action('admin_init','load_my_script'); function load_my_script() { global $pagenow, $typenow; if ($pagenow=='edit.php' &amp;&amp; $typenow=='my-custom-type') { $ss_url = get_bloginfo('stylesheet_directory'); wp_enqueue_script('jquery'); wp_enqueue_script('my-custom-script',"{$ss_url}/js/my-custom-script.js",array('jquery')); } } </code> UPDATE I'm replying to your update. Unfortunately ( for whatever reason ) <code> $typenow </code> does not have a value during <code> admin_init </code> so you'll need to get the <code> post_type </code> by loading the post based on the URL parameter <code> 'post' </code> as you see in the follow example (I've copied the line above and line below from your example so you can see where to place it): <code> &lt;?php global $pagenow, $typenow; if (empty($typenow) &amp;&amp; !empty($_GET['post'])) { $post = get_post($_GET['post']); $typenow = $post-&gt;post_type; } if (is_admin() &amp;&amp; $pagenow=='post-new.php' OR $pagenow=='post.php' &amp;&amp; $typenow=='events') { </code> P.S. As for your other questions, please post them as new question on the site for me or others to answer. Since we are working so hard to help you, please take great care to give your title the best title you possibly can and also please write your questions as clearly and succinctly as possible with good formatting and proper English. If you'll do this it will help with the same issues recognize your question as being similar to what they need and it will make it easier on us who are answering your questions. I ask this of you ( and of all others who ask questions on WordPress Answers ) as a favor in exchange for taking the time effort to answer your questions because I and the other moderators want to make WordPress Answers a tremendous resource for the community instead of yet another sloppy forum that is hard to read and hard to find answers like so many other sites on the web. UPDATE #2 I thought you might have had an operator precedence issues in your if statement but when I tested before I didn't run into it. If it is behaving as your say then you almost certainly do so try this instead (sorry, I don't have time to test this right now to ensure for certain that it works): <code> &lt;?php add_action('admin_init','load_my_script'); function load_my_script() { global $pagenow, $typenow; if (empty($typenow) &amp;&amp; !empty($_GET['post'])) { $post = get_post($_GET['post']); $typenow = $post-&gt;post_type; } if (is_admin() &amp;&amp; $typenow=='events') { if ($pagenow=='post-new.php' OR $pagenow=='post.php') { $ss_url = get_bloginfo('stylesheet_directory'); wp_enqueue_script('jquery'); wp_enqueue_script('my-custom-script',"{$ss_url}/js/my-custom-script.js",array('jquery')); } } } </code>
Loading External Scripts in Admin but ONLY for a Specific Post Type?
wordpress
Am I allowed to remove the "Powered by WordPress" link in the footer?
Yes WordPress is licensed using the GPL v2 license so you are "free" to do whatever you want to with it ( "free" as in "free speech" , not "free" as in "free beer!" .)
Removing the "Powered by WordPress" Link?
wordpress
I know how to do it manually, but is there any tool to help me with that?
Here is a free and good step by step tutorial with video. How To Convert an XHTML Website Template into a WordPress Theme http://www.jonbishop.com/2010/03/convert-html-wordpress/ There are many tools on market which claims to PSD/Xhtml 2 Wordpress http://www.divine-project.com/ http://www.artisteer.com/ http://www.artisteer.com/ but coding manually is the best way. No quick way to get custom and great themes.
Tools for Converting an Existing Website Design to a WordPress Template?
wordpress
I'd like to create an "All Posts" page on the Ocean Bytes blog that contains an unordered list of all Titles of the posts to date, with each title hyperlinking to its blog post. There appear to be several plugins that do something like this, but most do not list Wordpress 3.0+ as supported yet, or they want to subset the blog postings by Year and then Month which is not desired. Any suggestions for the "best way"? Thx.
I ended up creating a page template called "allposts-page.php" in the Twenty-Ten Themes folder containing the following code: <code> &lt;?php /** * Template Name: All Posts * * A custom page template for displaying all posts. * * The "Template Name:" bit above allows this to be selectable * from a dropdown menu on the edit page screen. * * @package WordPress * @subpackage Twenty_Ten * @since Twenty Ten 1.0 */ get_header(); ?&gt; &lt;div id="container"&gt; &lt;div id="content" role="main"&gt; &lt;h2&gt;Archive of All Posts:&lt;/h2&gt; &lt;ul&gt; &lt;?php wp_get_archives('type=postbypost'); ?&gt; &lt;/ul&gt; &lt;/div&gt;&lt;!-- #content --&gt; &lt;/div&gt;&lt;!-- #container --&gt; &lt;?php get_footer(); ?&gt; </code> I then created a new page using the Wordpress Admin system with a title of "All Posts" and selected the "All Posts" template from the drop-down. Didn't need to enter anything in the body. The resulting page can be found via: www.oceanbytes.org/all-posts/ The default for "wp_get_archives" is "monthly" but I chose "postbypost" as I wanted to just list all posts as on long list. More options can be found on the Wordpress site via Function Reference/wp get archives
Create an "All Posts" or "Archives" Page with WordPress 3.0?
wordpress
Just wondering if people have any thoughts around the best way to setup Wordpress 3 to use for development, staging and production. I currently have an install that I just use for dev, before moving the files to stage for a friend to review. This normally goes back and forwards for a while until they are happy. Then it goes to prod. It's a fairly manual process, so open to any suggestions as to how to best automate parts of this. What works for you?
Ok i've found a couple of solutions if anyone is looking. They aren't perfect but they are doing the job. For the main development period before go-live I use Deploymint (http://markmaunder.com/2011/08/19/deploymint-a-staging-and-deployment-system-for-wordpress/). This is based on Git and is great for your moves between Dev, Stage and Production. However, the problem with it is that when you take your snapshot of Prod to bring back to Dev, if Prod keeps changing (ie. new posts, edits, comments etc.), there is no capability to merge (yet?) and so that will be lost. I've been using this for major changes (Design etc.) and it has worked fine. To get around the issue of merges, I just look at the changeset to find which files I need to update. The second part of the equation is Crowd Favorite Ramp (http://crowdfavorite.com/wordpress/ramp/). Ramp is good for using stage to make changes to content before pushing them to prod. Great for the content guys and helps to prevent embarrassing changes to Prod!
Wordpress 3 MU for a development/stage/production site
wordpress
How do you set up routing rules correctly with Nginx to support WP Super Cache for a WordPress (3.x) site?
Hi @jschoolcraft : Does this articles address your question? WordPress, Nginx and WP Super Cache If not, maybe there would be something in these? 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
Configuring Routing Rules for WordPress+Nginx and WP-SuperCache?
wordpress
I am building a website for a charity event and i would like for people to register for this event. The form should contain name, email and other custom questions. Also I would like a page where to list the persons registered. I was thinking of using the user system + a plugin for listing the user list. What plugins would you use? Thanks.
Hi solomongaby: Forms For the form I would suggestion using GravityForms . It's super easy to use to design and post a form, and here's an example form we made for requests to be a presenter . GravityForms is $39 per server but if you ask they may be willing to give a charity a free copy? Registration I would probably just recommend using EventBrite like we did for our WordPress business conference . EventBrite is free to use if your event is free and the fees are well worth the lack of headache if you are charging. Using EventBrite (or a similar service) will be much, much easier than trying to implement something in WordPress for a one-time event. I wrote a shortcode to make display easy (you can put the code in your theme's <code> functions.php </code> file). Here's the prototype usage for the shortcode: <code> [eventbrite src="{event_url}" width="{width}" height="{height}"] </code> And this is what the shortcode looked like in use ( be sure to substitute your own event URL of course ): <code> [eventbrite src="http://www.eventbrite.com/tickets-external?eid=582216425&amp;amp;ref=etckt" width="620" height="500"] </code> And finally here's the PHP source code for the short code: <code> &lt;?php add_shortcode('eventbrite', 'eventbrite_show_widget'); function eventbrite_show_widget($args) { $valid_types = array('ticket-form',); $div_style = 'border:1px solid black;color:white;background:red;padding:10px;'; $default = array( 'type' =&gt; 'ticket-form', 'url' =&gt; '', 'src' =&gt; '', 'width' =&gt; '100%', 'height' =&gt; '500', ); $args = array_merge($default,$args); extract($args); if (empty($url) &amp;&amp; empty($src)) { $html =&lt;&lt;&lt;HTML &lt;div style="$div_style"&gt; &lt;p&gt;The "eventbrite" shortcode much have an attribute of either "&lt;b&gt;&lt;i&gt;src&lt;/i&gt;&lt;/b&gt;" or "&lt;b&gt;&lt;i&gt;url&lt;/i&gt;&lt;/b&gt;", i.e.:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;[eventbrite type="ticket-form" &lt;b&gt;&lt;i&gt;src&lt;/i&gt;&lt;/b&gt;="http://www.eventbrite.com/tickets-external?eid=582216425&amp;ref=etckt"]&lt;/li&gt; &lt;li&gt;[eventbrite type="ticket-form" &lt;b&gt;&lt;i&gt;url&lt;/i&gt;&lt;/b&gt;="http://www.eventbrite.com/tickets-external?eid=582216425&amp;ref=etckt"]&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; HTML; } else if (!empty($url) &amp;&amp; !empty($src)) { $html =&lt;&lt;&lt;HTML &lt;div style="$div_style"&gt; You should only the "&lt;b&gt;&lt;i&gt;src&lt;/i&gt;&lt;/b&gt;" attribute or the "&lt;b&gt;&lt;i&gt;url&lt;/i&gt;&lt;/b&gt;" attribute when using the "eventbrite" shortcode. &lt;/div&gt; HTML; } else if (!in_array($args['type'],$valid_types)) { $valid_types = implode('&lt;/b&gt;&lt;/i&gt;"&lt;/li&gt;&lt;li&gt;"&lt;i&gt;&lt;b&gt;',$valid_types); $html =&lt;&lt;&lt;HTML &lt;div style="$div_style"&gt; &lt;p&gt;When using the "eventbrite" shortcode you must specifiy an attribute of "&lt;b&gt;&lt;i&gt;type&lt;/i&gt;&lt;/b&gt;" with one of the following valid values:&lt;/p&gt; &lt;ul&gt;&lt;li&gt;"&lt;i&gt;&lt;b&gt;$valid_types&lt;/b&gt;&lt;/i&gt;"&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;i.e.:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;[eventbrite &lt;b&gt;&lt;i&gt;type&lt;/i&gt;&lt;/b&gt;="&lt;b&gt;&lt;i&gt;ticket-form&lt;/i&gt;&lt;/b&gt;" src="$url$src"]&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; HTML; } else { $html = &lt;&lt;&lt;HTML &lt;div id="eventbrite"&gt; &lt;iframe src="$src$url" width="$width" height="$height" allowtransparency="true" scrolling="auto"&gt;&lt;/iframe&gt; &lt;/div&gt; HTML; } return $html; } </code>
WordPress Plugin for One-Time Event Registration?
wordpress
I'm looking for something like they are using here: http://www.jennyreviews.com/as-seen-on-tv/triple-joint-formula/ Look under "Related Product Reviews" I checked the source but could not find the plugin code listed. Maybe its a widget?
@Scott B , It looks like they are using a related posts query based on category. When a single Item (post) is being displayed the query looks up the category id then displays posts from the same category. Add The following code to your sidebar or even to the bottom of single.php depending on where you want to display the "Related Posts" <code> &lt;!--Begin Related Posts--&gt; &lt;?php if ( is_single() ) : global $post; $categories = get_the_category(); foreach ($categories as $category) : $posts = get_posts('numberposts=4&amp;exclude=' . $GLOBALS['current_id'] . '&amp;category='. $category-&gt;term_id); //To change the number of posts, edit the 'numberposts' parameter above if(count($posts) &gt; 1) { ?&gt; &lt;div class="widget" id="more-category"&gt; &lt;h3 class="widgettitle"&gt;&lt;?php _e('More in',''); ?&gt; &amp;#8216;&lt;?php echo $category-&gt;name; ?&gt;&amp;#8217;&lt;/h3&gt; &lt;ul&gt; &lt;?php foreach($posts as $post) : ?&gt; &lt;li&gt;&lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/li&gt; &lt;?php endforeach; ?&gt; &lt;/ul&gt; &lt;/div&gt; &lt;?php } ?&gt; &lt;?php endforeach; ?&gt; &lt;?php endif; ?&gt; &lt;!--/related posts--&gt; </code> What this is doing is first getting the category of the current post being displayed, omitting the current item from the query, then checking to make sure there are more than 1 posts in that category. If there are then it will output "More in Your category name" followed by the permalink to the post. If you wanted to show the featured image you could change the last section to look like this: <code> &lt;div class="widget" id="more-category"&gt; &lt;h3 class="widgettitle"&gt;&lt;?php _e('More in',''); ?&gt; &amp;#8216;&lt;?php echo $category-&gt;name; ?&gt;&amp;#8217;&lt;/h3&gt; &lt;ul&gt; &lt;?php foreach($posts as $post) : ?&gt; &lt;li&gt;&lt;?php the_post_thumbnail(); ?&gt;&lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/li&gt; &lt;?php endforeach; ?&gt; &lt;/ul&gt; &lt;/div&gt; </code>
Related posts widget or plugin needed
wordpress
I've been plugging away with WordPress for some years now. In that time, I've never really taken time to fully understand the platform. It powers my site, and that's been enough. But I feel I need to know more about the system to get the most use out of it. Please suggest any books that cover WP in some depth. I don't necessarily need WordPress 101, but I am particularly interested in making use of WP's extensibility, as well as building themes.
Hi @Grant Palin : If you are like me you probably view most books as being much too simple to really learn anything useful from because publishers are always trying to dumb them down to reach a broader audience. If you are like me, these two are probably some of the better books on the market because I think they are among the more advanced : Build Your Own Wicked WordPress Themes WordPress Plugin Development – Beginner’s Guide Of course the books recommended by the others have their merits so, unless the cost of these books is significant to you I'd recommend grabbing them all and seeing what you can learn! Of course be sure to come back here to ask question about anything that's unclear or that that you have to take to a much great depth!
Recommendations for an In-Depth WordPress Book?
wordpress
I have written a plugin that puts a (google) favicon in front of each link in my blog. Really simple. Just uses a simple preg_replace_callback on hrefs: <code> $changed_html_reference = preg_replace_callback(self::HTML_REF_REGEX, array($this,'AddExtraHtmlToOneHref'), $strHtmlBodyText); </code> with a <code> add_filter('the_content', array($this,'ReplaceAll'), 9); </code> for the replacement and a default call to the google site for the icon (snip out of class) : <code> const GOOGLE_ICON_URL = 'http://www.google.com/s2/favicons?domain='; function HttpDownloadFeed() { $parsed_url = parse_url($this-&gt;url); $data_r = wp_remote_get(self::GOOGLE_ICON_URL . $parsed_url['host']); $data = $data_r['body']; return $data; } </code> I now have taken the approach of making my own cache class which stores the icons in directories like e.g. /cache/com/facebook/www/f.png. But I am now thinking about the location of that class. For easiness i placed the cache in the wp-content directory. The following questions I have: could i plugin an existing cache / cache plugin to do the caching for me? what is the best location for my own cache thing? should i put it under /wp-content/cache or /plugins/myplugin/mycache or even /themes/mytheme/cache ? or is there even a better approach to this? (I am using the com/facebook/www approach because i also store session date of stumbleupon, delicious etc...in there and i only want to call these pages/feeds once incl. the request for a google favicon) (and since i need to display the icon and not all browser support inline displaying of icons embedded in html i need to write them to a directory available to the client).
Most of WordPress caching functionality is set up with text (serialized if needed) in mind. Since you need to store binary data it is probably better to maintain own cache. As for location of cache I think it depends: for single personal installation I would pick directory that is short and makes nice URL, for example I store icons at <code> /images/icons/ </code> ( <code> /images/ </code> being my directory for all images) for something that might be used across different installations or by other users I think <code> /plugins/myplugin/mycache/ </code> makes most sense if functionality is packaged as plugin (same but in theme directory, if part of theme)
Plugin a specific cache functionality?
wordpress
Is there a way to add a arbitrary hyperlink to the WordPress admin menu (I mean the menu on the left when you log into the admin dashboard)? For example, can one add a link to Google? In my particular case, I'd like to add a styleguide page for a Wordpress theme I'm working on so I can show the user how different HTML elements are styled with the theme and to demo how to style various things nicely. This is the code I have so far ( note: it is incomplete ): In functions.php I have added a new menu item in the Appearance section: <code> add_action('admin_menu', 'create_theme_style_page'); function create_theme_style_page() { add_theme_page('Theme Styleguide', 'Theme Styleguide', 'administrator', basename(__FILE__),'build_styleguide_page'); } function build_styleguide_page() { echo "Not sure what goes here to redirect admin to a arbitrary url?"; } </code> In <code> build_styleguide_page() </code> , attempting to redirect with <code> header() </code> gives a error ( Cannot modify header information ).
Hi @Tom , If I understand your question correctly you don't so much need to know how to add a link to the menu (it seems you already know that) but instead need to learn how to get your link to redirect correctly, right? Redirecting to an External URL from an Admin Menu Item If so what you need to do is to not use the menu item function but instead "hook" WordPress early enough such that it hasn't output anything except possibly HTTP headers. The earliest hook when calling <code> /wp-admin/themes.php </code> appears to be <code> after_setup_theme </code> and it appears to work well. Use a "Menu Slug" So You Can Test for it in a Hook But to get it to work we first need to modify your call to <code> add_theme_page </code> in the <code> admin_menu </code> hook / your <code> create_theme_style_page() </code> function. We dropped the fifth parameter (the function to call to implement the admin option) because we don't need it, and changed the fourth parameter (the "menu slug" ) to be <code> themes.php?goto=build-styleguide-page </code> . Although we could have chosen almost literally anything for the fourth parameter, given we are going to redirect I routed to the same page ( <code> themes.php </code> ) as other appearance options for consistency. I also just arbitrarily came up with the name <code> goto </code> because WordPress doesn't use it and it seems to make sense for this. <code> add_action('admin_menu', 'create_theme_style_page'); function create_theme_style_page() { add_theme_page( 'Theme Styleguide', 'Theme Styleguide', 'administrator', 'themes.php?goto=build-styleguide-page' ); } </code> BTW, we got rid of your <code> build_styleguide_page() </code> function because we don't need it for this solution. Redirect in the Earliest Hook for <code> themes.php </code> : <code> after_setup_theme </code> As our last bit of code we implement our <code> after_setup_theme </code> hook in our <code> redirect_from_admin_menu() </code> function. We have it test to see if the current page is <code> themes.php </code> and to ensure a URL parameter of <code> goto </code> was passed on the URL. Then it tests the value of <code> goto </code> using a <code> switch </code> / <code> case </code> statement to see if it has a value of <code> 'build-styleguide-page' </code> ; if so it redirects to your stated hypothetical e.g. Google otherwise we just redirect back to the admin dashboard: <code> add_action('after_setup_theme', 'redirect_from_admin_menu'); function redirect_from_admin_menu($value) { global $pagenow; if ($pagenow=='themes.php' &amp;&amp; !empty($_GET['goto'])) { switch ($_GET['goto']) { case 'build-styleguide-page': wp_redirect("http://www.google.com"); break; default: wp_safe_redirect('/wp-admin/'); break; } exit; } } </code> Notes: I chose to use the <code> switch </code> / <code> case </code> statement in the <code> after_setup_theme </code> hook / <code> redirect_from_admin_menu() </code> function so that it would be easier to add additional <code> goto </code> redirects if you need to; just add more case statements. the <code> wp_redirect() </code> and <code> wp_safe_redirect() </code> functions don't actually terminate; you need to explicit issue an exit statement to get WordPress to stop and not override your redirect. Hope this helps!
Adding an Arbitrary Link to the Admin Menu?
wordpress
I currently have this: <code> mysite.com/product-name mysite.com/another-product </code> etc where product-name and another-product are posts. I then have a custom post type called Changelogs, which I have for each product, is it possible to have the url something like: <code> mysite.com/product-name/changelog mysite.com/another-product/changelog </code> If so, how would I go about doing it?
There is no such thing as "Sub Posts" in Wordpress already built in. But it could be possible that you create a plugin that is introducing "Sub Posts" in the style you describe them. Technically you're not talking about subposts but about the URL-Layout. So in Wordpress you add an endpoint ("changelog") that you can handle with some plugin, for example switching display to some other post. Once this did not properly work with endpoints but I think it's somehow fixed now. Haven't used it tough, so my answer is only informative so far. Related: Rewrite API Ticket #12779 - Better support for custom post types in WP_Rewrite Ticket #12605 - Unable to add Endpoints to custom post_types Ticket #9476 - add_rewrite_endpoint() doesn't work Ticket #2433 - Provide some API for WP_Rewrite Ticket #12935 - Evolve the URL Routing System
URL Design for Sub-Posts?
wordpress
The pages like "about" will be created automatically when a new blog is created. Likewise I need some other pages which should appear automatically when a blog is created under my multisites. How can I configure the default pages to be created with a new blog under a multisite? For ex.: If I have a multisite on <code> example.com </code> . Every blog created under this site should have Home, About, My store, My address.
I recommend creating a function in your functions.php file that ties to the action hook <code> activate_blog </code> . Use the WordPress functions get_pages() to see if your default pages exist. If they do not, create them with wp_insert_post . <code> add_action('activate_blog','my_default_pages'); function my_default_pages(){ $default_pages = array('About','Home','My Store','My Address'); $existing_pages = get_pages(); foreach($existing_pages as $page){ $temp[] = $page-&gt;post_title; } $pages_to_create = array_diff($default_pages,$temp); foreach($pages_to_create as $new_page_title){ // Create post object $my_post = array(); $my_post['post_title'] = $new_page_title; $my_post['post_content'] = 'This is my '.$new_page_title.' page.'; $my_post['post_status'] = 'publish'; $my_post['post_type'] = 'page'; // Insert the post into the database $result = wp_insert_post( $my_post ); } } </code> To test this function on your own site, try setting the hook to <code> wp_head </code> . It will run on each page load and insert the pages that don't exist, with the content in $my_post['post_content']. *Does the 'activate_blog' hook run when blogs are created in a multi-site context? I don't know.* Refer to the codex page for wp_insert_post that I linked to for the complete list of default parameters available.
Can I set some default pages to be created on every creation of a new blog
wordpress
I started developing a site with over a dozen custom post types. I'd like to rename a few of them, not just the display value, but the actual custom post type name. I'm worried however that by just running a SQL update query that I'll miss some places where I need to change things or overwrite part of serialized data. I have already inputed over 3,000 items, so I can't just restart with a clean database. What would be the best way to rename a custom post type? How about renaming a taxonomy?
SQL query for renaming the posts: <code> UPDATE `wp_posts` SET `post_type` = '&lt;new post type name&gt;' WHERE `post_type` = '&lt;old post type name&gt;'; </code> SQL query for renaming taxonomy: <code> UPDATE `wp_term_taxonomy` SET `taxonomy` = '&lt;new taxonomy name&gt;' WHERE `taxonomy` = '&lt;old taxonomy name&gt;'; </code> That should take care of all of the database areas. Just remember to match the new names in the code where the post types or taxonomies are registered. As far as I know, this is not handled in any plugins yet.
Renaming Custom Post Types and Taxonomies
wordpress
We have template tags and some functions that start with get. Sometimes it would be just nice in themes to do like: <code> $title = the_title(); </code> to use the html later on. This is just a simplified example, naturally there is some function like get_the_title(); But that works for that function only. I'm wondering why there is no such function like this: <code> function get_output() { $args = func_get_args(); $callback = array_shift($args); ob_start(); call_user_func_array($callback, $args); return ob_end_clean(); } </code> That could convert any function that has output into a returning function: <code> $title = get_output('the_title'); </code> Any idea why about that has never been thought about? Every theme author or hacker can make use of such, right?
In direct response to the question, WordPress does not include a function for this partly because it does not specifically apply to WordPress functionality. I.e. it's a PHP (potential) problem, not WordPress. Also, I wouldn't say it's WordPress' responsibility to provide workarounds for plugins etc that don't provide an function to return data (which is against the general WordPress style).
Why is there no global function in wordpress to return the output of any function call?
wordpress
I am using an attachment.php file to show large versions of images that have been clicked on elsewhere. I'd like to pull the image alt text as a caption under the image with javascript, but the alt text isn't included when when wp_get_attachment_image_src() is used. I don't think WP has a function to retrieve it, so I need my own. To write that function I need to know...Where is the alt text for an image stored? My attachment page uses <code> wp_get_attachment_image_src() </code> , which doesn't include the alt text. <code> &lt;div class = "entry"&gt; &lt;?php if ( wp_attachment_is_image( $post-&gt;id ) ) : $att_image = wp_get_attachment_image_src( $post-&gt;id, "large");?&gt; &lt;a href="&lt;?php echo wp_get_attachment_url($post-&gt;id); ?&gt;" title="&lt;?php the_title(); ?&gt;" rel="attachment"&gt; &lt;img class="attached_img" src="&lt;?php echo $att_image[0];?&gt;" width="&lt;?php echo $att_image[1];?&gt;" height="&lt;?php echo $att_image[2];?&gt;" class="attachment-medium" alt="&lt;?php $post-&gt;post_excerpt; ?&gt;" /&gt; &lt;/a&gt; } &lt;?php endif;?&gt; &lt;/div&gt; </code> This shows: <code> &lt;div class = "entry"&gt; &lt;a href="http://www.example.com/wp-content/uploads/2010/07/photo_namejpg" title="My_Photo_Title" rel="attachment"&gt; &lt;img class="attached_img" src="http://www.example.com/wp-content/uploads/2010/07/photo_name_and_size.jpg" width="393" height="500" class="attachment-medium" alt="" /&gt; &lt;/a&gt; &lt;/div&gt; </code> I'm aware that the <code> $post-&gt;post_excerpt </code> is being called in the above code, but I am not sure what to replace it with to get the image's alt attribute.
I recently did some research for a client project recently so lo-and-behold I get to use it here! After the text you'll see a categorized list of most (all?) of the image handling functions from within WordPress 3.0.1 (I grouped them in some semblance of order but don't put too much credence in my categorization.) Anyway, answering what (I think) you need instead of what you asked for ( okay, I'll answer that too, at the end ) I think what you need is the <code> wp_get_attachment_image() </code> function which will return an HTML string containing these attributes: <code> 'src' </code> , <code> 'class' </code> , <code> 'alt' </code> and <code> 'title' </code> . WordPress 3.0 Image Handling Functions So here are WordPress' image handling functions for your and other's reference ( jump below for the answer to your exact question ): Image Support/Thumbnails <code> set_post_thumbnail_size( $width = 0, $height = 0, $crop = FALSE ) </code> <code> add_image_size( $name, $width = 0, $height = 0, $crop = FALSE ) </code> <code> get_intermediate_image_sizes() </code> <code> wp_constrain_dimensions( $current_width, $current_height, $max_width=0, $max_height=0 ) </code> Attachment <code> get_attached_file( $attachment_id, $unfiltered = false ) </code> <code> is_local_attachment($url) </code> <code> update_attached_file( $attachment_id, $file ) </code> <code> wp_attachment_is_image( $post_id = 0 ) </code> <code> wp_count_attachments( $mime_type = '' ) </code> <code> wp_delete_attachment( $post_id, $force_delete = false ) </code> <code> wp_get_attachment_image($attachment_id, $size = 'thumbnail', $icon = false, $attr = '') </code> <code> wp_get_attachment_image_src($attachment_id, $size='thumbnail', $icon = false) </code> <code> wp_get_attachment_metadata( $post_id = 0, $unfiltered = false ) </code> <code> wp_get_attachment_thumb_file( $post_id = 0 ) </code> <code> wp_get_attachment_thumb_url( $post_id = 0 ) </code> <code> wp_get_attachment_url( $post_id = 0 ) </code> <code> wp_insert_attachment($object, $file = false, $parent = 0) </code> <code> wp_update_attachment_metadata( $post_id, $data ) </code> MIME Types <code> wp_match_mime_types($wildcard_mime_types, $real_mime_types) </code> <code> wp_mime_type_icon( $mime = 0 ) </code> <code> wp_post_mime_type_where($post_mime_types, $table_alias = '') </code> Uploads <code> media_handle_upload() </code> Filesystem <code> _wp_relative_upload_path( $path ) </code> <code> wp_upload_dir( $time = null ) </code> HTML <code> get_image_tag($id, $alt, $title, $align, $size='medium') </code> Low Level Image Handling: <code> wp_load_image( $file ) </code> <code> image_constrain_size_for_editor($width, $height, $size = 'medium') </code> <code> image_downsize($id, $size = 'medium') </code> <code> image_get_intermediate_size($post_id, $size='thumbnail') </code> <code> image_hwstring($width, $height) </code> <code> image_make_intermediate_size($file, $width, $height, $crop=false) </code> <code> image_resize( $file, $max_w, $max_h, $crop = false, $suffix = null, $dest_path = null, $jpeg_quality = 90 ) </code> <code> image_resize_dimensions($orig_w, $orig_h, $dest_w, $dest_h, $crop = false) </code> As promised the Image's <code> 'alt' </code> text is stored as a string in <code> wp_postmeta </code> with the meta_key of <code> '_wp_attachment_image_alt' </code> . As you probably already know you can load it with a simple <code> get_post_meta() </code> like so: <code> $alt_text = get_post_meta($post-&gt;ID, '_wp_attachment_image_alt', true); </code>
How To Retrieve An Image Attachment's Alt Text?
wordpress
How can I get a total word count of one author's posts? I would like to be able to see what the total word count of their output is, summed across all of their posts (ideally with a breakdown by category/tag/page-or-post). There's gotta be a contemporary plugin for this.
I use a plug-in called Post Word Count to sum the total number of published words across my entire site ... then again, I'm the only author, so this is a pretty simple example. But you could start with this plug-in and add a filter that changes the query based on the author's ID. Basically: <code> function post_word_count_by_author($author = false) { global $wpdb; $now = gmdate("Y-m-d H:i:s",time()); if ($author) $query = "SELECT post_content FROM $wpdb-&gt;posts WHERE post_author = '$author' AND post_status= 'publish' AND post_date &lt; '$now'"; else $query = "SELECT post_content FROM $wpdb-&gt;posts WHERE post_status = 'publish' AND post_date &lt; '$now'"; $words = $wpdb-&gt;get_results($query); if ($words) { foreach ($words as $word) { $post = strip_tags($word-&gt;post_content); $post = explode(' ', $post); $count = count($post); $totalcount = $count + $oldcount; $oldcount = $totalcount; } } else { $totalcount=0; } return number_format($totalcount); } </code> This function will return a total count of all published words by that author (based on the author ID). If you don't specify an author ID, it will return a count of all published words. This won't count post revisions, drafts, or schedule posts, just those currently visible to users. Disclaimer, I haven't tested this yet, but it's based on the original Post Word Count plug-in and should work just fine.
Total Word Count For Posts By One Author
wordpress
Is there an easy way to limit to one (per post) the number of images to upload through media upload?
I won't go into the code specifics right now, because I am not sure if you need me to. You essentially need to modify the <code> SWFUpload </code> JavaScript settings array to set the <code> file_upload_limit </code> to <code> 1 </code> . Unfortunately I don't believe SWFUpload allows you to change that settings variable after it has been <code> init </code> ed, because it has already launched the Flash embed with the settings. So, you would have to hook into the <code> flash_uploader </code> filter to disable it setting up the "normal" Flash uploader, then hook into the <code> pre-upload-ui </code> action and set up the Flash uploader using the same variables as WordPress does, but att the <code> file_upload_limit </code> setting. (Look at Line 1446 of <code> media.php </code> to see what I mean). If you did it that way, you would also have to disable the HTML upload form so user's can use that to bypass the Flash uploader. Instead, you could (easier, but maybe not so usable to the user) hook into <code> load-async-upload.php </code> action (see Line 202 of <code> admin.php </code> ) to reject the upload request if the current user had already uploaded an image for the given post. That would require the user selecting the image in the Flash Uploader, then it throwing an error once it has uploaded saying "You can not upload another file"
Restrict the number of images to upload per post
wordpress
I have been looking at the plugin API a bit more in depth recently and I was wondering what real differences there were between action and filter hooks . They both are events that receive data as a parameter and they seem to both be able to do the same things. Obviously I see that actions are called when actions take place and filters are called when data is manipulated, but it seems to just be a semantic naming difference. Besides semantics and what they are used for, what real differences are there between them?
Hi @Sruly : You've pretty much answered your own question, but I'll elaborate a bit. Action Hooks Actions Hooks are intended for use when WordPress core or some plugin or theme is giving you the opportunity to insert your code at a certain point and do one or more of the following: Use <code> echo </code> to inject some HTML or other content into the response buffer, Modify global variable state for one or more variables, and/or Modify the parameters passed to your hook function (assuming the hook was called by <code> do_action_ref_array() </code> instead of <code> do_action() </code> since the latter does not support passing variables by-reference .) Filter Hooks Filter Hooks behave very similar to Action Hooks but their intended use is to receive a value and potentially return a modified version of the value. A filter hook could also be used just like an Action Hook i.e. to modify a global variable or generate some HTML, assuming that's what you need to do when the hook is called. One thing that is very important about Filter Hooks that you don't need to worry about with Action Hooks is that the person using a Filter Hook must return (a modified version of) the first parameter it was passed. A common newbie mistake is to forget to return that value! Using Additional Parameters to Provide Context in Filter Hooks As an aside I felt that Filter Hooks were hobbled in earlier versions of WordPress because they would receive only one parameter; i.e they would get a value to modify but no 2nd or 3rd parameters to provide any context. Lately, and positively however, it seems the WordPress core team has joyously (for me) been adding extra parameters to Filter Hooks so that you can discover more context. A good example is the <code> posts_where </code> hook; I believe a few versions back it only accepted one parameter being the current query's "where" class SQL but now it accepts both the where clause and a reference to current instance of the <code> WP_Query </code> class that is invoking the hook. So what's the Real Difference? In reality Filter Hooks are pretty much a superset of Action Hooks. The former can do anything the latter can do and a bit more albeit the developer doesn't have the responsibility to return a value with the Action Hook that he or she does with the Filter Hook. Giving Guidance and Telegraphing Intent But that's probably not what is important. I think what is important is that by a developer choosing to use an Action Hook vs. a Filter Hook or vice versa they are telegraphing their intent and thus giving guidance to the themer or plugin developer who might be using the hook. In essence they are saying either "I'm going to call you, do whatever you need to do" OR "I've going to pass you this value to modify but be sure that you pass it back ." So ultimately I think that guidance provided by the choice of hook type is the real value behind the distinction . IMO, anyway. Hope this helps!
Difference Between Filter and Action Hooks?
wordpress
Hey guys. Is there a plugin out there that can easily notify a user of a follow up reply to their comment? I used to use subscribe to comments but it hasn't been updated since 2007. Also, I think I remember being the 'unsubscribe' process to be pretty tedious or confusing. I would like it if each email had an 'unsubscribe' link at the bottom which instantly unsubscribed the user from that notification thread. I would like to continue using the WordPress comment system. I don't want to substitute it for something else like disqus.
Subscribe to Double-Opt-In Comments
Comment Follow-Up Notifier?
wordpress
Ok, so I'm using the WPAlchemy class to create custom field write panels in the write post page, and so far everything has gone great... However, there's one issue I can't seem to figure out. I'm trying to use the custom field values of "event dates" to sort events on a custom page template. I followed the instructions "Query based on Custom Field and Sorted by Value" found in the codex to try and setup the custom query, but it doesn't seem to be working? Here's the code from the custom page template for the " Events " page: <code> &lt;?php /* Template Name: Events */ get_header(); ?&gt; &lt;div id="depthead" class="grid_12"&gt; &lt;h2&gt;Upcoming Events&lt;/h2&gt; &lt;/div&gt;&lt;!--/depthead--&gt; &lt;?php $querystr = " SELECT wposts.* FROM $wpdb-&gt;posts wposts, $wpdb-&gt;postmeta wpostmeta WHERE wposts.ID = wpostmeta.post_id AND wpostmeta.meta_key = '_events_meta[event_date]' AND wposts.post_type = 'post' ORDER BY wpostmeta.meta_value DESC "; $pageposts = $wpdb-&gt;get_results($querystr, OBJECT); ?&gt; &lt;?php if ($pageposts): global $post; $cnt=0; foreach ($pageposts as $post): $cnt++; setup_postdata($post); ?&gt; &lt;div id="article-&lt;?php echo get_the_ID(); ?&gt;" class="listingbox grid_3"&gt; &lt;div class="deptpostimg"&gt; &lt;a href="&lt;?php the_permalink(); ?&gt;" title="&lt;?php the_title_attribute(); ?&gt;"&gt;&lt;img src="&lt;?php echo $events_metabox-&gt;get_the_value('event_thumbnail'); ?&gt;" style="outline:1px solid #000" alt="&lt;?php the_title_attribute(); ?&gt;" /&gt;&lt;span class="event-date"&gt;&lt;?php $events_metabox-&gt;the_value('event_date'); ?&gt;&lt;/span&gt;&lt;/a&gt; &lt;/div&gt;&lt;!--/deptpostimg--&gt; &lt;h4 class="listing-titles"&gt;&lt;a href="&lt;?php the_permalink(); ?&gt;" title="&lt;?php the_title_attribute(); ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/h4&gt; &lt;div class="excerpt"&gt; &lt;?php the_excerpt(); ?&gt; &lt;/div&gt;&lt;!--/excerpt--&gt; &lt;/div&gt;&lt;!--/article-&lt;?php echo get_the_ID(); ?&gt;--&gt; &lt;?php if($cnt % 4 == 0) { ?&gt; &lt;div class="grid_12 rowseparator"&gt; &lt;hr /&gt; &lt;/div&gt;&lt;!--/rowseparator--&gt; &lt;?php } ?&gt; &lt;?php endforeach; endif; ?&gt; &lt;/div&gt;&lt;!--/wrapper--&gt; &lt;?php get_footer(); ?&gt; </code> It's like it's not picking up the custom field keys... The class I'm using to create these custom write panels stores them all as an array, hence the reason I've attempted to access them by using: <code> _events_meta[event_date] </code> Maybe that's the problem, but I don't know how to fix it if it is... Any ideas? EDIT: Here's an image so you can see just how the custom fields are stored in the database. Hopefully that helps you figure out why on earth <code> _events_meta[event_date] </code> won't work in the query?
Josh, take a look at: http://farinspace.com/wpalchemy-metabox-data-storage-modes/ ... I am thinking I will be changing how WPAlchemy stores values by default ... making EXTRACT mode default ...
Sorting WordPress Posts via Custom Field Values?
wordpress
We're working on a plugin where any logged-in user has the ability to submit a new "pitch", or standard post type with custom status of "pitch". Once the pitch is in the system, other logged-in users can vote on the idea, volunteer to participate, or comment on the story in progress. It was simple to list all unpublished posts on a single view by querying the database for posts with <code> post_status != 'publish' </code> . I'd like to set it up so both logged-in and unlogged-in visitors can click through on the title and view the post on a single view as well. Default WordPress behavior is to return a 404 unless you have sufficient permissions. I believe viewing permissions are handled in the query object , and I don't see a simple way to unset them. Any creative ideas? Thanks in advance.
Answered my own question on this one. As it turns out, it was pretty simple in WordPress 2.9.2. Basically, I applied a filter to 'the_posts' which would run another query if the object was empty. Because we're looking up posts that haven't been published, we need to use our own custom SQL as well. Trying to use the WP_Query object will, well, put you in an endless recursive loop.
Showing Unpublished Posts to Logged-out Users?
wordpress
Is there a way to automatically register widgets when a new site is registered with a multi site setup? E.g. inside <code> wpmu_new_blog </code> ?
In your themes <code> functions.php </code> file you can check wether or not it get's installed for the first time on that blog. This can be done by using an option. An option can be set to flag that it's installing. This option that signals that an install is immanent can be used in a hook of the <code> init </code> jointcut so to flag for automatic widget registration. Widgets can be registerd with wp_set_sidebars_widgets() . After that's done, kill the flag. Keep in mind that switching themes kills the widgets configuration. So this is for first-time use only. A full working example on how to register widgets on theme activation can be found in the Semiologic Reloaded Theme . It's available for download, feel free to suit yourself.
How to automatically register widgets on new blog?
wordpress
I have different menu items. When the user clicks on a menu item, I want them to go to a particular destination. Each menu's destination has a different background color. I'm thinking that I can pass a variable around and based on the value, I can set the bgcolor. This is just one example of why I want to pass data around. Does Wordpress have anything built in that allows me to do this? Should I use session variables?
I have different menu items. When the user clicks on a menu item, I want them to go to a particular destination. Each menu's destination has a different background color. When you say destination I assume you mean page or post. If you use WordPress's built in body class and post class you can target the page or post in your CSS and assign a different background color for each. How to use WordPress body class: In header.php add body_class() between the body tags and WordPress will assign a different class to each page. The body tag: <code> &lt;body &lt;?php body_class(); ?&gt;&gt; </code> This will output your body tag in html like so: <code> &lt;body class="page page-id-11 page-template page-template-default"&gt; </code> To assign the background color in css: <code> body.page-id-11 { background:#000000; } </code> Then you would just repeat the above for each page that needs a different background color. How to use WordPress post class: In your template file that is displaying the post, single.php or index.php add the following in the loop: <code> &lt;div id="post-&lt;?php the_ID(); ?&gt;" &lt;?php post_class(); ?&gt;&gt; </code> This will output your html like so: <code> &lt;div id="post-47" class="post-47 post type-post hentry category-your-category tag-your-tags"&gt; </code> Use CSS to target the post just like we did the body using any of the outputted class or ids
How to pass data around?
wordpress
I have a client that strongly prefers to disable .htaccess files because they like to set the Apache configurations themselves. However, they still want SEO-friendly URLs. Is there a way to have custom permalinks with no .htaccess file? My research thus far seems to indicate this is not possible, but perhaps one of brilliant developers knows how the seemingly impossible can be possible. Thanks in advance!
Hi @Mike Lee : To answer your question it is helpful to understand how everything works. Apache Serves URLs that Match Files and Directories Apache is designed to serve files explicitly matched by URL, or to serve the <code> index.php </code> found in a directory when the directory is explicitly matched. But Apache Can Serve URLs Matched by Regex with <code> mod_rewrite </code> If you want Apache to match URLs for where there are no real directories (the case with WordPress and pretty permalinks) then you must have some way to tell Apache how to handle URLs differently. And that's exactly what <code> mod_rewrite </code> was designed to allow; it gives server administrators the ability to set rules for matching URLs using regular expressions. Those rules route the result to other URLs, often including actually <code> .PHP </code> files and sometimes with URL parameters passed. Ultimately the rules specify that actual files get loaded. And <code> mod_rewrite </code> is Configured with Either <code> .htaccess </code> or <code> httpd.conf </code> To configure <code> mod_rewrite </code> you can only do it inside <code> .htaccess </code> or within the <code> httpd.conf </code> file or one of the files it includes, like potentially <code> httpd-vhosts.conf </code> . Actually I'm surprised if you client has the skills to control Apache that they don't know this already. WordPress Always Uses the Same Simple <code> .htaccess </code> File Moving on to what WordPress does, when you set permalinks WordPress writes the following to the <code> .htaccess </code> file, assuming it is writable ( and in this first example assuming your website site is served from the root ): <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> Caveat: When Your WordPress Front Page Directory is Not Root If your site is instead served from <code> /blog </code> then the <code> .htaccess </code> file written would look like this: <code> &lt;IfModule mod_rewrite.c&gt; RewriteEngine On RewriteBase /blog/ RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /blog/index.php [L] &lt;/IfModule&gt; </code> WordPress Routes All Non-File/Directory Matching URLs to <code> index.php </code> So as you can see, the only thing WordPress uses <code> .htaccess </code> for is to map any URL to the domain to <code> /index.php </code> (or <code> /blog/index.php </code> in the 2nd example) except when a URL matches an actual file (such as an <code> .jpg </code> / <code> .gif </code> / <code> .png </code> image, a <code> .css </code> stylesheet, a <code> .js </code> script, etc.) or when it matches an actual directory (which as far as I know is not relevant in a standard WordPress install.) In <code> PHP </code> WordPress Parses <code> $_SERVER['REQUEST_URI'] </code> To Decide What to Load Inside its <code> PHP </code> code WordPress grabs the value of <code> $_SERVER['REQUEST_URI'] </code> which contains the full URL request sans the domain and scheme (i.e. scheme is <code> http </code> or <code> https </code> ) and it then parses the value to determine what URL was requested and thus what pages it should load. Bypassing <code> .htaccess </code> ? Get Apache to Load Virtual URLs (but good luck with that!) So if you want to somehow bypass <code> .htaccess </code> your job would be to get Apache to respond to an arbitrary URL then load WordPress and set <code> $_SERVER['REQUEST_URI'] </code> to be the URL path plus parameters; IOW spoofing it but in a good way. That said, I know if know of no ways that are not overly complicated to do that. Embedding <code> /index.php/ </code> (Maybe?!?) Even though *Chris_O* is correct about prepending <code> /index.php/ </code> to your URLs I cringe whenever I see that. It adds 10 characters to every URL making them longer and less meaningful to search engines but far worse makes them less sharable and looks cryptic to users. Sorry Chris I know you meant well, but ugh! Create Real Directories for Every URL (Maybe?) One way to get pretty permalinks without touching Apache would be to write a script that would generate an actual directory for every URL that you want and then store an <code> index.php </code> there that would load WordPress. Of course that would be huge effort for tiny benefit and it would require the server to have write access which has to be worse than using an <code> .htaccess </code> file. I hate to admit but this is what I did circa 1998 with an <code> .ASP </code> -based website when <code> IIS </code> didn't support URL rewriting (and even today it's still a real PITA!) It was an ugly hack, was a pain to maintain and I hated it but the URLs sure were great for both users and for SEO! Best Solution? Add Rewrite Rules to <code> httpd.conf </code> Back to what's probably your best the solution, and @Simon Brown actually recommended it; add your rewrite rules to <code> httpd.conf </code> or one of the include files like <code> httpd-vhosts.conf </code> (which is how Apache is configured at localhost on my Mac.) Add the following directive making sure to change the directory to match the directory for your site: <code> &lt;Directory "/home/example_user/public_html/"&gt; RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] &lt;/Directory&gt; </code> Bonus! With Lockdown Comes Performance Too This last option should eliminate any <code> .htaccess </code> and put control back in their hands. Even better it's slightly more performant since <code> httpd.conf </code> is only loaded once when Apache starts but <code> .htaccess </code> files are loaded and parsed on every URL request! P.S. One more thing to consider would be to front-end Apache with a caching server like Nginx which I believe is becoming a best practice for high-traffic WordPress sites that really need to be performant. It might take green field tweaking because I don't think most people have been using Nginx to do the URL rewriting for Apache but if that direction interests you here are some links to pursue: WordPress Nginx proxy cache integrator Using Nginx as a caching proxy with Wordpress+Apache Nginx as a front-end proxy cache for WordPress WordPress, Nginx and WP Super Cache Nginx &amp; WordPress MU w/ wp-super-cache How To Speed Up WordPress With Nginx And WP Super Cache Nginx Rewrite Rules for W3 Total Cache Plugin Tweak Nginx for WordPress – Pretty URLs &amp; WP Super Cache
Setting up WordPress with Custom Permalinks and no .htaccess File?
wordpress
I've submitted a few patches for WordPress core on Trac (one of which has been used) but every time I think about doing it I cringe because my setup for doing so is incredibly tedious. Can someone please detail out the steps needed to submit a patch for core, and then the best way to streamline the process so it's not so tedious? I work Mac OS X and PhpStorm currently but I'm thinking a shell script might be easiest? Or maybe a PHP Script that does all the rote work? One of the issues is I don't fully understand what I need to be starting with. Do I start with trunk? Do I have to download a new copy and add to/edit that copy with my code every time I want to create a patch? Again, while I have done it working with SVN and patching is really outside my current skillset and I want to change that. Hoping you WordPress patching experts can come to my rescue. Thanks in advance. UPDATE: After @hakre's answer I figure I should add more to the question: Can I create patches from older version or must I use trunk? If I'm working on a project using the released version (3.0.1) can I modify it and create a patch for core or do I have to download and set up a pristine and new copy of trunk and newly make my modifications there? Can I do with shell scripts so I can encode the login into the script and just run the script to recreate everything I need and/or to create the patch? And what are the pitfalls? All of these questions seem to be assumed by those who know how WordPress's SVN works and as such are always glossed over in any discussion.
The easiest way to create a patch is described here: http://wordpress.org/download/svn/ Can I create patches from older version or must I use trunk? You should create the patch against the same version you want it applied against. In other words, don't expect a patch created against WP 3.0.1 to apply cleanly on WP 3.1-alpha. If I'm working on a project using the released version (3.0.1) can I modify it and create a patch for core or do I have to download and set up a pristine and new copy of trunk and newly make my modifications there? You don't have to set up a new installation for each new patch. You can just use svn revert to get back to a pristine copy. Also, the database doesn't have to be clean each time. Actually, it's better if you have some modifications, to simulate a live environment.
Easiest Way to Create a Patch for Submission to WordPress Core?
wordpress
Is it possible to create multiple "custom background" administration pages? A site I'm doing now needs 2 different background in 2 different areas, I would really love giving my client the same experience for both backgrounds in terms of colour/image/select-repeat etc. Any Ideas?
Hi @Amit: The answer is "Yes, it is possible." The follow up question is "Do you really want to?" I thought it would be fun to see if I could build a plugin to do what you are asking for so I decided to see if it was possible. Of course I was able to make it work but I fear that the plugin code I wrote needs to be so tightly coupled with the existing code in WordPress that it might easily break on a core update. This code handles all the admin console side of things by creating a new menu item in the Appearance section called "Special Background." What it does not do is provide any way to actually use the background; that's phase two of the plugin and will require hooking many of the functions in <code> /wp-includes/themes.php </code> and frankly I don't know if I'll get a chance to write that code. The reason I stopped without doing it is I didn't know the requirements for where the special background should show and where the regular one would show. I assume maybe for selected pages and/or URL paths? Nonetheless, here if the code for the plugin (which you can also download from gist ): <code> &lt;?php /* Plugin Name: Special Background Plugin URI: stackexchange-url Example to show how to add a special background using exiting background admin page in core. Version: 0.1 Author: Mike Schinkel Author URI: http://mikeschinkel.com/custom-wordpress-plugins/ */ add_filter('admin_menu','add_special_background_menu_item'); function add_special_background_menu_item() { add_theme_page(__('Special Background'), __('Special Background'),'edit_theme_options','special-background','special_background_admin_page'); } add_filter('admin_init','add_js_for_special_background'); function add_js_for_special_background() { global $custom_background; if (is_special_background_page()) { wp_enqueue_script('custom-background'); wp_enqueue_style('farbtastic'); } $hook = 'load-appearance_page_special-background'; add_action($hook, array(&amp;$custom_background, 'admin_load')); add_action($hook, array(&amp;$custom_background, 'take_action'), 49); add_action($hook, array(&amp;$custom_background, 'handle_upload'), 49); } add_filter('theme_mod_background_image', 'theme_mod_special_background_image'); add_filter('theme_mod_background_image_thumb','theme_mod_special_background_image_thumb'); add_filter('theme_mod_background_repeat', 'theme_mod_special_background_repeat'); add_filter('theme_mod_background_position_x', 'theme_mod_special_background_position_x'); add_filter('theme_mod_background_attachment', 'theme_mod_special_background_attachment'); add_filter('theme_mod_background_color', 'theme_mod_special_background_color'); function theme_mod_special_background_image($defaults) { return theme_mod_special_background_image_attrs('image',$defaults); } function theme_mod_special_background_image_thumb($defaults) { return theme_mod_special_background_image_attrs('image_thumb',$defaults); } function theme_mod_special_background_repeat($defaults) { return theme_mod_special_background_image_attrs('repeat',$defaults); } function theme_mod_special_background_position_x($defaults) { return theme_mod_special_background_image_attrs('position_x',$defaults); } function theme_mod_special_background_attachment($defaults) { return theme_mod_special_background_image_attrs('attachment',$defaults); } function theme_mod_special_background_color($defaults) { return theme_mod_special_background_image_attrs('color',$defaults); } function theme_mod_special_background_image_attrs($attr,$defaults) { if (is_special_background_page()) { $mods = get_option( 'mods_' . get_current_theme() ); $defaults = (!empty($mods["special_background_{$attr}"]) ? $mods["special_background_{$attr}"] : ''); } return $defaults; } add_filter('pre_update_option_mods_' . get_current_theme(),'pre_update_option_special_background_image',10,2); function pre_update_option_special_background_image($newvalue, $oldvalue) { static $times_called = 0; if (!empty($_POST) &amp;&amp; is_special_background_page()) { if ((isset($_POST['action']) &amp;&amp; $_POST['action']=='save') || isset($_POST['reset-background']) || isset($_POST['remove-background'])) { switch ($times_called) { case 0: $newvalue = special_background_image_value_swap('image',$newvalue,$oldvalue); break; case 1: $newvalue = special_background_image_value_swap('image_thumb',$newvalue,$oldvalue); break; } } else { if ($times_called==0 &amp;&amp; isset($_POST['background-repeat'])) { $newvalue = special_background_image_value_swap('repeat',$newvalue,$oldvalue); } if ($times_called==1 &amp;&amp; isset($_POST['background-position-x'])) { $newvalue = special_background_image_value_swap('position_x',$newvalue,$oldvalue); } if ($times_called==2 &amp;&amp; isset($_POST['background-attachment'])) { $newvalue = special_background_image_value_swap('attachment',$newvalue,$oldvalue); } if ($times_called==3 &amp;&amp; isset($_POST['background-color'])) { $newvalue = special_background_image_value_swap('color',$newvalue,$oldvalue); } } $times_called++; } return $newvalue; } function special_background_image_value_swap($swap_what,$newvalue,$oldvalue) { $newvalue["special_background_{$swap_what}"] = $newvalue["background_{$swap_what}"]; $newvalue["background_{$swap_what}"] = $oldvalue["background_{$swap_what}"]; return $newvalue; } function special_background_admin_page() { global $custom_background; if (is_special_background_page()) { global $parent_file,$submenu_file,$title; $parent_file = 'themes.php'; $submenu_file = 'themes.php?page=special-background'; $title = 'Special Background'; require_once(ABSPATH . 'wp-admin/admin-header.php'); ob_start(); $custom_background-&gt;admin_page(); $html = ob_get_clean(); $html = preg_replace('#&lt;h2&gt;([^&lt;]+)&lt;/h2&gt;#','&lt;h2&gt;Special Background&lt;/h2&gt;',$html); echo $html; include(ABSPATH . 'wp-admin/admin-footer.php'); exit; } } function is_special_background_page() { global $pagenow; return ($pagenow=='themes.php' &amp;&amp; isset($_GET['page']) &amp;&amp; $_GET['page']== 'special-background'); } </code> Frankly it is too much code to explain proactively but I'll be happy to answer specific questions.
Multiple Custom_Background, is it possible?
wordpress
The following snippet is from a sidebar widget that lists "recent posts". Since its on the home page and I feature my lastest sticky post prominently on that page, I want to skip over the sticky in this loop. However, the <code> post_not_in=sticky_posts </code> has no effect. <code> &lt;?php $the_query = new WP_Query("showposts=$number&amp;offset=1&amp;order=ASC&amp;post_not_in=sticky_posts"); while ($the_query-&gt;have_posts()) : $the_query-&gt;the_post(); $do_not_duplicate = $post-&gt;ID; ?&gt; </code>
I took @tnorthcutt's answer from WordPress' Codex on <code> query_posts() </code> about Sticky Parameters and created a tandalone example you can drop as <code> test.php </code> into your website's root and see it run by navigating to a URL like this, with your domain substituted: http://example.com/test.php Some notes on the code; I had to use an array equivalent of the query string you passed to <code> WP_Query() </code> because the <code> post__no_in </code> argument can't be passed in as a comma delimited string (not sure why, probably an oversight?). Also I wanted to make sure you know that starting with an <code> offset=1 </code> (instead of <code> offset=0 </code> ) means you'll be excluding the first post that otherwise would be returned by the query. Of course you'll still get the number of posts specified by <code> $number </code> assuming you have that many applicable posts +1. So here's the code: <code> &lt;?php header('Content-Type:text/plain'); include "wp-load.php"; $number = 5; $the_query = new WP_Query(array( 'showposts' =&gt; $number, 'offset' =&gt; 1, // This will cause the query to skip over first post 'order' =&gt; 'ASC', 'post__not_in' =&gt; get_option("sticky_posts"), )); while ($the_query-&gt;have_posts()) : $the_query-&gt;the_post(); the_title(); endwhile; </code>
Excluding Sticky Posts from The Loop and from WP_Query() in WordPress?
wordpress
By default, WordPress shows previous and next links when content is split onto different pages. Is there a way to get it to use proper pagination (with numbers), perhaps with a plugin?
yes, try wp-pagenavi http://wordpress.org/extend/plugins/wp-pagenavi/
Displaying Numeric Pagination vs. Previous and Next Links in WordPress?
wordpress
I would like to add Google custom search to my wordpress.com site. I have pasted HTML code from custom search to text widget in a sidebar, but instead of search box, I got text: <code> Loading google.load('search', '1', {language : 'en'}); google.setOnLoadCallback(function() { var customSearchControl = new google.search.CustomSearchControl('007267089725385613265:gmydx5gtw6u'); customSearchControl.setResultSetSize(google.search.Search.LARGE_RESULTSET); var options = new google.search.DrawOptions(); options.setAutoComplete(true); customSearchControl.draw('cse', options); }, true); </code> I guess wordpress.com does not allow Google's JavaScript to execute. Am I doing something wrong? Can this be resolved?
JavaScript is not allowed on WordPress.com blogs.
Add Google custom search to wordpress.com
wordpress
Some WordPress themes have their links encrypted in the footer and I am not able to edit them if I want to edit the links. This is the example code I found: <code> &lt;?php </code> <code> eval(base64_decode('Pz4gCQkNCg0KCQk8ZGl2IGNsYXNzPSJjbGVhciI+PC9kaXY+DQoNCgkNCg0KCTwvZGl2Pg0KDQoJPCEtLSAvTWFpbiAtLT4NCg0KCQ0KDQoJPCEtLSBGb290ZXIgLS0+DQoNCgk8ZGl2IGlkPSJmb290ZXIiPg0KDQoJPD9waHAgdGhlX3RpbWUoJ1knKTsgPz4gPD9waHAgYmxvZ2luZm8oJ25hbWUnKTsgPz4gLiAgV29yZFByZXNzIC4gPD9waHAgaWYoaXNfaG9tZSgpKSA6ID8+PGEgaHJlZj0iaHR0cDovL3dvcmRwcmVzc3RoZW1lc2ZvcmZyZWUuY29tLyIgdGl0bGU9IldvcmRwcmVzcyB0aGVtZXMiPldvcmRwcmVzcyB0aGVtZXM8L2E+PD9waHAgZW5kaWY7ID8+PC9kaXY+DQoNCgk8IS0tIEZvb3RlciAtLT4NCg0KDQoNCjwvZGl2PjwvZGl2PjwvZGl2Pg0KDQo8IS0tIC9QYWdlIC0tPg0KDQoNCg0KDQoNCjw/cGhwIHdwX2Zvb3RlcigpOyA/Pg0KPC9ib2R5Pg0KDQoNCg0KPC9odG1sPiA8Pw=='));?&gt; </code> Does any one know how to find the footer link we want from them and edit them?
Well, this is the output from that function: <code> ?&gt; &lt;div class="clear"&gt;&lt;/div&gt; &lt;/div&gt; &lt;!-- /Main --&gt; &lt;!-- Footer --&gt; &lt;div id="footer"&gt; &lt;?php the_time('Y'); ?&gt; &lt;?php bloginfo('name'); ?&gt; . WordPress . &lt;?php if(is_home()) : ?&gt;&lt;a href="http://wordpressthemesforfree.com/" title="Wordpress themes"&gt;Wordpress themes&lt;/a&gt;&lt;?php endif; ?&gt;&lt;/div&gt; &lt;!-- Footer --&gt; &lt;/div&gt;&lt;/div&gt;&lt;/div&gt; &lt;!-- /Page --&gt; &lt;?php wp_footer(); ?&gt; &lt;/body&gt; &lt;/html&gt; &lt;? </code> So, if you want to get rid of that base64 encoded line, and use this, do it. I think that was just their way of keeping total non-programmers from messing with the attribution links. If the theme is GPL licensed, then you are under no obligation to keep any part of that code there. And there's a pretty strong case to be made that themes are GPL by their very nature (which is not to say the other side doesn't have strong arguments too. However, as Mike pointed out in the comments, this question will not be answered until someone litigates, so let's just leave that whole argument out of this question). EDIT To get the above output, I did this: <code> &lt;pre&gt; &lt;?php $out = base64_decode('Pz4gCQkNCg0KCQk8ZGl2IGNsYXNzPSJjbGVhciI+PC9kaXY+DQoNCgkNCg0KCTwvZGl2Pg0KDQoJPCEtLSAvTWFpbiAtLT4NCg0KCQ0KDQoJPCEtLSBGb290ZXIgLS0+DQoNCgk8ZGl2IGlkPSJmb290ZXIiPg0KDQoJPD9waHAgdGhlX3RpbWUoJ1knKTsgPz4gPD9waHAgYmxvZ2luZm8oJ25hbWUnKTsgPz4gLiAgV29yZFByZXNzIC4gPD9waHAgaWYoaXNfaG9tZSgpKSA6ID8+PGEgaHJlZj0iaHR0cDovL3dvcmRwcmVzc3RoZW1lc2ZvcmZyZWUuY29tLyIgdGl0bGU9IldvcmRwcmVzcyB0aGVtZXMiPldvcmRwcmVzcyB0aGVtZXM8L2E+PD9waHAgZW5kaWY7ID8+PC9kaXY+DQoNCgk8IS0tIEZvb3RlciAtLT4NCg0KDQoNCjwvZGl2PjwvZGl2PjwvZGl2Pg0KDQo8IS0tIC9QYWdlIC0tPg0KDQoNCg0KDQoNCjw/cGhwIHdwX2Zvb3RlcigpOyA/Pg0KPC9ib2R5Pg0KDQoNCg0KPC9odG1sPiA8Pw=='); echo str_replace( '&lt;', '&amp;lt;', $out ); ?&gt; &lt;/pre&gt; </code>
Editing Links in the Footer of WordPress Themes with Base64 Encrypted Code?
wordpress
I w'd like to know If I can Integrate my other web-sites created to my wordpress multisite using the CMSs like Dolphin ( integration discussion ) Oxwall status.net sharetronix peoplepods yetanotherforum vidiscript Tikiwiki shapado (script, inspired by stackoverflow) ( seems to integrate with wordpress.com via OpenID ) These are the Opensource scripts for social networking and micro blogging.I have the websites created with all these scripts for different purposes like social networking and micro blogging .I w'd like to Integrate these websites to my wordpress multi site.So my users need not sign up/sign in for every site and access all of them with single account . There are some other users of dolphin and shapado who are willing to integrate their site to wordpress .So I have listed all the scripts using for my websites .So this topic may be useful to others who are looking for Integration of the popular Opensource CMSs to wordpress . Right now we have some SSO plugins which allows us to login using popular logins like facebook,google etc. But these SSO modules are not available for the above mentioned scripts .How ever the direct Integration is always helpful . Does any body have Idea on this?
Integration is a topic at large. There are many strategies on how to combine multiple webapplications under one site-design and URL-layout. This normally means you have to make up your mind first on how to combine and integrate the applications. Normally app exists next to each other sharing a menu, header and a footer. For security reasons it's important that the different webapplications do not share the same database and webspace. Otherwise things like a security breach in one of the applications can be used to attack the full site. Some applications even deliver integration modules for wordpress, I once had a gallery app that was able to hook inside my wordpress theme. But integrational work is nothing click-ready so to say, you're bulding a website with multiple apps.
I w'd like to know If there are simple solutions to integrate other CMSs to wordpress
wordpress
How can I disable automatic linking? For example if I write http://www.test.com I don't want it converted to a link.
WordPress does not automatically convert URLs to hyperlinks.
Disable automatic linking
wordpress
I've got a subdirectory in which I'd like to implement a completely different theme for my site (basically, its a sales letter). Can someone tell me how to do that? Do I need to install a separate copy of wordpress in the subdirectory?
To slightly sidestep your actual question, the template hierarchy allows you to have a custom handler for any post ID, category, taxonomy term, etc. That may be the quickest way to solve your problem: just create a template file that stands on its own and only serves request to one post (or category, or however the sales letter(s) are identified). You don't have to call <code> get_header() </code> , <code> get_footer() </code> or any of the other template functions, so you're free to have a completely different page structure for a single post on your site.
Using Multiple Themes in a Single WordPress Site?
wordpress
I've changed a file <code> wp-content/languages/pl_PL.po </code> <code> #: bfa_header.php msgid "notice" msgstr "napis" msgid "Online Information Website" msgstr "Internetowy Portal Informacyjny" msgid "something" msgstr "coś" </code> I've added the second pair. It works for another language, but doesn't work for this one. All other messages are working. What might be the problem?
Looks like you may not be able to just add a pair to your .po file, without first adding it to the wordpress.pot file: http://codex.wordpress.org/Translating_WordPress#gettext_files . You'll also need to compile your .po file into a .mo (Machine Object) file in order for your changes to take effect. I'm not certain that will work, but it should be a good start.
One of the messages in .po file doesn't show up
wordpress
I am using the plugin wp-multi-network(http://wordpress.org/extend/plugins/wp-multi-network/) to maintain child networks under multi site.Using this I can create child networks.But I can’t set sign up functionality to child networks .And If the main network is mainnetwork.com and childnetwork has the domain like childnetwork . mainnetwork.com .The sites set under this child network would not get the domain as site. childnetwork. mainnetwork.com . Does any body have Ideas to get these functionalities? And does any one w’d like to share your experience and the knowledge you have with this plugin? (I got got answers by my self and updating the topic .So it may be useful to others) The child networks childnetwork1. mainnetwork.com and childnetwork2. mainnetwork.com also should have the sign up functionality .If I want to give a complete access on childnetwork1. mainnetwork.com to a person 'X' or group "X group" .X can able to use it as his own blog network and he can let others to create blogs same as me.So I still have control on that child network and at the same time X acts as super admin for the blog network. The basic purpose of the wp-multi-network plugin is the same.Presently one cannot able to set signup functionality to child networks .But Admin of child netoworks as well as the super admin can create sub-sites under child networks from their dashboards . So this a multisite can be used as network of networks .
I suggest you start over with that in the Wordpress Support Forums of the WP Multi Network Plugin . I can only suggest this because I do not have any special experience with that plugin and I assume that it has DNS implications for the hosts you'd like to use it on. Additionally you might want to make your question more clear and tell more about the setup you're running (Server, Services, DNS and so on). Which steps did you have already done and the like. But probably you find your answer already in that forum.
Does any one have Idea to get these functionalities with the plugin wp-multi-network
wordpress
How can I disable the default feed on WordPress.com and use Feedburner feed instead? I know how I can in a self-hosted WordPress site, but I do not know how to in a free WordPress.com site.
EDIT You can not disable the default WordPress.com feed but you have an option: If you have the css upgrade, add <code> #feedarea {display:none;} </code> to remove the default links. Use the feedburner widget code and add it to a text widget. Assign a class to it and using css absolute positioning move it to where the default links were. My Original Answer below only applies to self hosted WordPress Claim your feed URLs at Feedburner Then add this to your .htaccess under #END WORDPRESS <code> RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(feed|wp-atom|wp-feed|wp-rss|wp-rdf|wp-commentsrss)(.+)\ HTTP/ [NC,OR] RewriteCond %{QUERY_STRING} ^feed [NC] RewriteCond %{HTTP_USER_AGENT} !^(FeedBurner|FeedValidator) [NC] RewriteRule .* http://feeds.feedburner.com/YourFeedburnerURL ? [R=307,L] RewriteRule ^comments/?.*$ http://feeds.feedburner.com/YourFeedburnerCommentsURL [L,R=302] </code>
Use Feedburner instead of default feed on WordPress.com?
wordpress
I'm at a loss with this. Do you see anything wrong with the code below specific to the noindex, nofollow checkboxes? The meta box gets drawn to the screen fine, but the values do not stick. The code for the custom page title and custom excerpt works fine. <code> // =================== // = POST OPTION BOX = // =================== add_action('admin_menu', 'my_post_options_box'); function my_post_options_box() { if ( function_exists('add_meta_box') ) { add_meta_box('post_header', 'Custom Post Header Code (optional)', 'custom_post_images', 'post', 'normal', 'low'); add_meta_box('post_title', 'Custom Post Title', 'custom_post_title', 'post', 'normal', 'high'); add_meta_box('post_title_page', 'Custom Post Title', 'custom_post_title_page', 'page', 'normal', 'high'); add_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', 'page', 'normal', 'core'); add_meta_box('categorydiv', __('Page Index Options'), 'post_categories_meta_box_modified', 'page', 'side', 'high'); } } //Adds the custom images box function custom_post_images() { global $post; ?&gt; &lt;div class="inside"&gt; &lt;textarea style="height:70px; width:100%;margin-left:-5px;" name="cb2_customHeader" id="cb2_customHeader"&gt;&lt;?php echo get_post_meta($post-&gt;ID, 'cb2_customHeader', true); ?&gt;&lt;/textarea&gt; &lt;p&gt;Enter your custom html code here for the post page header/image area. Whatever you enter here will override the default post header or image listing &lt;b&gt;for this post only&lt;/b&gt;. You can enter image references like so &amp;lt;img src='wp-content/uploads/product1.jpg' /&amp;gt;. To show default images, just leave this field empty&lt;/p&gt; &lt;/div&gt; &lt;?php } //Adds the custom post title box to posts function custom_post_title() { global $post; ?&gt; &lt;div class="inside"&gt; &lt;p&gt;&lt;input style="height:25px;width:100%;margin-left:-10px;" type="text" name="cb2_customTitle" id="cb2_customTitle" value="&lt;?php echo get_post_meta($post-&gt;ID, 'cb2_customTitle', true); ?&gt;"&gt;&lt;/p&gt; &lt;p&gt;Enter your custom Post Title here and it will be used for the html &amp;lt;title&amp;gt; for this post page and the Google link text used for this page.&lt;/p&gt; &lt;/div&gt; &lt;?php } //Adds the custom post title box to pages function custom_post_title_page() { global $post; ?&gt; &lt;div class="inside"&gt; &lt;p&gt;&lt;input style="height:25px;width:100%;margin-left:-10px;" type="text" name="cb2_customTitle" id="cb2_customTitle" value="&lt;?php echo get_post_meta($post-&gt;ID, 'cb2_customTitle', true); ?&gt;"&gt;&lt;/p&gt; &lt;p&gt;Enter your custom Page Title here and it will be used for the html &amp;lt;title&amp;gt; for this page and the Google link text used for this page.&lt;/p&gt; &lt;/div&gt; &lt;?php } //adds the custom categories box function post_categories_meta_box_modified($post) { global $post, $noindexCat, $nofollowCat; $noindexCat = get_cat_ID('noindex'); $nofollowCat = get_cat_ID('nofollow'); if(in_category("noindex")){ $noindexChecked = " checked='checked'";} if(in_category("nofollow")){ $nofollowChecked = " checked='checked'";} ?&gt; &lt;div id="categories-all" class="ui-tabs-panel"&gt; &lt;ul id="categorychecklist" class="list:category categorychecklist form-no-clear"&gt; &lt;li id='category-&lt;?php echo $noindexCat ?&gt;' class="popular-category"&gt;&lt;label class="selectit"&gt;&lt;input value="&lt;?php echo $noindexCat ?&gt;" type="checkbox" name="post_category[]" id="in-category-&lt;?php echo $noindexCat ?&gt;"&lt;?php echo $noindexChecked ?&gt; /&gt; noindex&lt;/label&gt;&lt;/li&gt; &lt;li id='category-&lt;?php echo $nofollowCat ?&gt;' class="popular-category"&gt;&lt;label class="selectit"&gt;&lt;input value="&lt;?php echo $nofollowCat ?&gt;" type="checkbox" name="post_category[]" id="in-category-&lt;?php echo $nofollowCat ?&gt;"&lt;?php echo $nofollowChecked ?&gt; /&gt; nofollow&lt;/label&gt;&lt;/li&gt; &lt;li id='category-1' class="popular-category" style="display:none;"&gt;&lt;label class="selectit"&gt;&lt;input value="1" type="checkbox" name="post_category[]" id="in-category-1" checked="checked"/&gt; Uncategorized&lt;/label&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;?php } add_action('save_post', 'custom_add_save'); function custom_add_save($postID){ if (defined('DOING_AUTOSAVE') &amp;&amp; DOING_AUTOSAVE) { return $postID; } else { // called after a post or page is saved if($parent_id = wp_is_post_revision($postID)) { $postID = $parent_id; } if ($_POST['cb2_customHeader']) { update_custom_meta($postID, $_POST['cb2_customHeader'], 'cb2_customHeader'); } else { update_custom_meta($postID, '', 'cb2_customHeader'); } if ($_POST['cb2_customTitle']) { update_custom_meta($postID, $_POST['cb2_customTitle'], 'cb2_customTitle'); } else { update_custom_meta($postID, '', 'cb2_customTitle'); } } } function update_custom_meta($postID, $newvalue, $field_name) { update_post_meta($postID, $field_name, $newvalue); } </code>
I'm not sure but I think the simple answer is you have not yet added <code> "noindex" </code> and <code> "nofollow" </code> as categories to your site . Go to the category page in the admin and add them and then I think your code will work, it did for me: http://example.com/wp-admin/edit-tags.php?taxonomy=category Of course if you need to add those categories programmatically, ideally for use in a plugin activation so it only ever has to run when the plugin is first activated you can use the following code: <code> &lt;?php /** Include the WordPress Taxonomy Administration API */ require_once(ABSPATH . 'wp-admin/includes/taxonomy.php'); $categories = get_categories('hide_empty=0&amp;fields=names'); if (!in_array('noindex',$categories)) wp_insert_category(array('cat_name'=&gt;'noindex')); if (!in_array('nofollow',$categories)) wp_insert_category(array('cat_name'=&gt;'nofollow')); </code> UPDATE: @Scott B : Is it possible that you never associated the <code> category </code> taxonomy with the <code> page </code> post type? You know that Pages ( <code> post_type='page' </code> ) don't get categories by default, right? Somewhere in your code you need to run <code> register_taxonomy_for_object_type() </code> ; my guess is you haven't? If I'm right then adding this to your code will almost certainly solve your problem: <code> add_action('init','attach_category_to_page'); function attach_category_to_page() { register_taxonomy_for_object_type('category','page'); } </code>
Categories for Pages Not Saving in Admin with Custom Categories Metabox?
wordpress
What are the differences between using <code> WP_Query() </code> and <code> get_posts() </code> ? Which is better to use in what case and why?
Well, <code> get_posts() </code> actually instantiates a new <code> WP_Query </code> object, so if you're comfortable using <code> WP_Query </code> directly, don't even bother with <code> get_posts() </code> ; <code> get_posts </code> will only return the results from the database, whereas <code> WP_Query </code> gives you the whole functionality of the class.
Differences Between WP_Query() and get_posts() for Querying Posts?
wordpress
Is it possible to get your WordPress site to upgrade itself automatically? What I mean is, when plugins etc. needs to be upgraded, can you just press a button, or have a cron job, download the new update and handle whatever else is needed, so your WordPress site always is up to date?
If you're using the most recent version of WordPress, there are two ways you can update your plugins by just clicking a button (OK, maybe a couple, but it's still really easy). Under Dashboard in your WP admin, there will an Updates option. Click on that and you should see something like this: Choose Select All and then click Update Plugins and the system will do it for you. I would advise against updating plugins totally automatically (as in without clicking any buttons yourself). It's important to check out the change log on the plugin's page and also its compatability with whatever version of WP you're running. For example, if you're running 2.8 you might upgrade automatically without checking only to find out that the latest version of the plugin isn't backward compatible with your WP install and requires WP 3.0.1. The other way to update your plugins is to go to the Plugins page in the admin, sort by Upgrade Available , check the plugins compatibility and change log, select Upgrade Automatically and then reactivate the plugin when the process is done upgrading the plugin.
Plugin for automated upgrade of WordPress core and it's plugins?
wordpress
I would like to use Google Search as opposed to the built-in search provided by the WordPress engine. What would be the best way to integrate Google Search?
There are a couple of plugins that provide this functionality: Google Custom Search Plugin Google Ajax Search
Best way to Integrate Google Search?
wordpress
I'm currently trying to develop a plugin that will embed a Google Earth Tour into a WP post / page via a shortcode. The issue I am running into is that for the tour to load, I have to add an <code> onload="init()" </code> into the <code> &lt;body&gt; </code> tag. I can modify a specific template file, but since this is for release, I need to add it dynamically via a hook. Any ideas?
Did some more digging and found a 'better' way to get it working (Google makes it hard to get their damn Earth Tours embedded, and their gadget doesn't work). I ended up making a plugin that uses a combination of a shortcode and a custom field.
Adding onload to body
wordpress