INSTRUCTION
stringlengths
11
999
RESPONSE
stringlengths
0
999
SOURCE
stringlengths
16
38
METADATA
dict
WAMP vs XAMPP pros/cons - for running a local testing server What are the major pros/cons that can help in deciding which of the two to choose: WAMP vs XAMPP for running a local testing server for WordPress? PS: I now see Stack Overflow had a discussion about it.
Biggest difference - WAMP runs on Windows, XAMPP is multi-platform. Aside from that it's a matter of personal preference. They both provide you with an Apache-MySQL-PHP environment that runs pretty much the same under both systems.
stackexchange-wordpress
{ "answer_score": 22, "question_score": 38, "tags": "server, xampp, local installation" }
Is there a plugin to help with translation of other plugins? I remember seeing a plugin that helps with the translation of other plugins. Anyone remember the name of that plugin? Thanks.
Over years I tried and used lots of wordpress multilanguge solutions and at this moment the WordPress MultiLanguage plugin (WPML) seams to be the best. One of the features supported is the translations of the plugins.
stackexchange-wordpress
{ "answer_score": 4, "question_score": 2, "tags": "plugins" }
What is/are the best thing(s) I can do to make my WordPress blog more popular? What are the best things that I can do to get my Wordpress blog out there? What are good plugins that I can use to get listed in Googles search? Is there anything/anywhere else I can register my Wordpress blog to attract more visitors?
Provide content that people crave to find, consume and share. There is no technical solution to make site popular. If there was one - everyone would use it and field will be leveled again. There are a lot of minor tweaks to implement (heading structure, social buttons, etc), but none of those will automagically bring in traffic and none of those work exactly same across different blogs with different content. The best you can do on technical side is too keep an eye that your blog is reasonably fast and markup makes sense.
stackexchange-wordpress
{ "answer_score": 3, "question_score": 0, "tags": "seo" }
What is the best method for handling comments? A quick Google search shows a number of different options for comment plugins: !alt text Is there a "best" way to handle comments? I realize it will vary from site to site, but I'm looking for the best way to handle them on a "typical" site - no special requirements here. Is it worth using something like Disqus or another plugin or third party service, or should I stick with the built in comment handling?
I've personally stayed away from any external or 3rd party system. Many times commenters are apprehensive about using "another" account or service, esp with recent privacy issues with Facebook, etc. Also, many add bloat and delay page load to run their own scripts, etc and can be harder to style to fit within an existing theme. I would look to use the existing WP comment function, plus Askimet and some .htaccess rules to block out spam.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "plugin recommendation, comments, disqus" }
Is it possible to have more "levels" of draft/published statuses? Is there any way to have more post statuses other than just draft or published? For example, if you write a lot of posts, you may wish to type up all the content, and set the status of these posts as "Content - Drafted" Then you can re-style them, make text bold, add code highlighting etc, and set to "Styled - Drafted" Then as a final review you could set status to "Reviewed" Then finally, publish them Is it possible in the current wordpress version 3 to achieve such scenarios?
I found this plugin called EditFlow that says it allows you to add custom statuses. Apparently it's designed for use in a newsroom. (FYI, I searched the WordPress plugins directory for "custom post status.")
stackexchange-wordpress
{ "answer_score": 7, "question_score": 11, "tags": "post status" }
How to set custom cookies before output What's a surefire way to check/set cookies before the php headers are sent? Is there an action or filter that would be the best place to hook a `setcookie()` function?
Depends on whether or not you need to check against WordPress' user authentication. If you need to know whether they're a logged in user, hook onto `'init'`. Otherwise, the sooner the better. If it's something that should fire on every page load, and only checks for existence of the cookie and doesn't need to tap into any of WP's APIs, I'd put it into a custom MU-plugin named `0000a.php` to ensure that it fires before any non-core files could accidentally send headers.
stackexchange-wordpress
{ "answer_score": 3, "question_score": 5, "tags": "php, filters, cookies, headers, actions" }
How to create a page that isn't accessible via menus? I need to create a page in my site that I am able to access via url, but that won't be included in any of the navigation menus which are generated using `wp_list_pages()` on my site. How can I accomplish this?
### There is a good plugin that adds a meta check box under all pages that indicates whether you want the page to show up in menus. ### Exclude Pages Plugin The other option is to convert from wp_list_pages to the new custom menus. When using custom menus only pages you add to the menu will be included.
stackexchange-wordpress
{ "answer_score": 5, "question_score": 3, "tags": "customization" }
Problem using Press-this book marklet When I use the bookmarklet button to test bookmarking . Only some URLs might able to display the post page.For other URLs it is just showing an error: 404. The requested page was not found. I have deactivated all the plugins .But problem not solved .I have changed the theme though . Do any body have Idea on solving this problem? I am not sure how to solve the problem .I copied the screen shots of error here . !alt text
Problem resolved by my web-host's executives .They said that they had to white list a code on their servers .
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "plugins, errors" }
Conflicting post edit options under dashboard My dashboard( It is multisite Installation ) section for pages and posts conflicts with options when there are morethan 5 data fields . For example : I have these things under my Posts section in dashbpard : **Title Author Categories Tags Comments Date Forum-Linked Featured** Because of these many fields these options conflicts each other like shown in the screen shot : **Edit | Quick Edit | Trash | Preview | Purge from Page Cache** !alt text It is because of the increased fields like **forum-linked ,featured etc**. Some times when I install any other related plugins .The number of data fields increases and it becomes more ugly with the editing options . Could any one suggest me a good Idea to fix this ?
## Columns can be hidden from view using the screen options tab. ### On the upper right hand side of the dashboard click screen options !alt text ### Un check any of the columns you want to hide. !alt text ### Normally the edit options are displayed as horizontal text. A plugin or other function has changed this. !alt text
stackexchange-wordpress
{ "answer_score": 3, "question_score": 1, "tags": "content, dashboard" }
Mobilepress fails to translate short codes I launched mobile version of my site some days ago. It was looking fine. I used `mobilepress` for the same. But i found that `shortcodes` are being displayed as simple text. is there any other plugin to build efficient mobile version including short code translation
You can use WordPress Mobile Edition or WordPress Mobile Pack.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "plugins, customization, themes, mobile" }
Why 'C++' tag is converted to 'C# '? If I add the C++ tag, when updating the post it gets converted to C#. If I add the ++ tag, there's no conversion. Encoding for pages and feeds is UTF-8. Wordpress version 3.0.1
I can duplicate this behavior. Probably a bug. Only alphanumeric characters and dashes are allowed in tag slugs, so my slugs for C++ and C# were created as "c" and "c-2," respectively. Adding these tags to a new post by name rather than slug lumped them all into C#. (Or was it C++? Either way, they evaluated to the same.) Manually updating the slugs to "cpp" and "csharp" worked around the bug in my install. Have you customized your tag slugs, or are they "c" and "c-2?" **Update** : taxonomy.php does check that the slug matches before checking the full tag name, and they both evaluate to the same slug ("c"), hence the incorrect match.
stackexchange-wordpress
{ "answer_score": 4, "question_score": 2, "tags": "tags" }
want to create a subcategory.php to manage subcats Is it possible to create a `subcategory.php` and use it to manage subcategories? Or is there a way to get around this? If it is not possible.. is there something like this? <?php if(is_subcategory() || child() ) { //do stuff } else { // do else } ?>
I don't think it is possible to create a subcategory.php, but you can do the following in your category.php: $category = get_category( get_query_var( 'cat' ) ); if( !empty( $category->parent ) ) { // the category has a parent, so it is a subcategory // do stuff } else { // do else }
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "customization, php" }
Are there any drawbacks to install IntenseDebate on my blog? I am currently using on my blog the default comment system with in addition only the "Quote Comments" plugin. I have seen IntenseDebate and it seems it has many interesting features that probably (and hope) will push the visitors to leave more comments. The pros are clear but do you see any drawbacks that should I take into account before decide to install or not IntenseDebate plugin on my blog?
There's an excellent post here which, while it might not be completely balanced (it sets out from the start that it is against external commenting systems), it offers a good view of the cons of such systems. A quick summary of three main points (a mixture of my personal opinions and from the blog post): * Comments are stored externally - you no longer have 'possession' of the comments on your blog - they are stored by somebody else, physically away from the rest of your blog * Comments are often loaded in via AJAX _after_ the page has loaded, or even after they are in the viewport which can make your site appear slower to your readers * Issues with your comments 'provider' may disable comment functionality - if there is a problem on IDs side you will not be able to do anything about it
stackexchange-wordpress
{ "answer_score": 4, "question_score": 3, "tags": "plugins, comments" }
How can I hide the sidebar on specific pages? I'm using a child of the `twentyten` default theme and I want to hide the sidebar on some pages. What is the solution for that?
Actually, Twentyten has a no-sidebar page template already. !before Modify the template option in the page edit screen: !Template Option And viola: !After
stackexchange-wordpress
{ "answer_score": 4, "question_score": 1, "tags": "sidebar, theme twenty ten" }
How to control size of comments popup window? Is it possible to control the size of the window that is opened with `comments_popup_link()`?
According to docs it is set by function that sets up script for this functionality: `comments_popup_script(width, height, 'file');`
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "comments" }
Should I use a multisite installation to achieve a multi-language site? This is partly a follow up to my earlier question: How can I make a site viewable in multiple languages?. It turns out the client wants to have the content manually translated, rather than using something like Google's translation tools. With that in mind, my first thought is to use a multisite installation with subdirectories, i.e. site.com/en/, /fr, /cn, etc. Is this the most logical way to achieve the desired result. Keep in mind only the content needs to be in multiple languages, not the admin interface.
no you can use a single instalation of your WordPress and use this plugin WPML for setup your multilangual site. Keep multiple installations for any language is not a good idea.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "multisite, multi language" }
Custom query with query_posts doesn't show post without certain meta_key I'm using query_posts to sort order certain categories. My code look like this: query_posts('category_name=abs&orderby=meta_value_num&meta_key=field_ordering&order=DESC'); This does show post in exact sorting model as I specify. However, query above doesn't display that post doesn't have `meta_key` 'field_ordering' set in database. My problem is, I don't want to set it on ALL post, but I still can display the data. Any solutions?
Well, you can't sort by field that isn't there. You can modify query conditionally only in those categories which have that field and let default query work in rest. It would be something like: if( is_category('abs') ) query_posts( array_merge( array('orderby' => 'meta_value', 'meta_key' => 'field_order', 'order' => 'Desc' ), $wp_query->query ) );
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "query posts, post meta" }
WP Northwind for Theme Development? Is there any tool online that can quickly populate a WordPress3 database with faux information to assist in theme development? Perhaps creating 8 categories, inserting a dozen or so posts into each, adding a thumbnail for each, etc.
Just today read Dummy Content Filler Resources post that has several sets of data and plugins for WordPress listed.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "customization, plugin recommendation, theme development, database" }
List categories and exclude child categories The script below creates a listing of the categories in the site (excluding those in "uncategorized"). If possible, I'd like to modify it so that it only lists the top level categories (no child categories)... $cat_args = array('orderby' => 'name', 'show_count' => $c, 'hierarchical' => $h); $cat_args['title_li'] = ''; $cat_args['exclude_tree'] = 1; wp_list_categories(apply_filters('widget_categories_args', $cat_args));
After some trial and error, this is what it took to make it work... $cat_args = array('orderby' => 'count'); $cat_args['title_li'] = ''; $cat_args['exclude_tree'] = 1; $cat_args['exclude'] = 1; $cat_args['depth'] = 1; wp_list_categories(apply_filters('widget_categories_args', $cat_args));
stackexchange-wordpress
{ "answer_score": 2, "question_score": 2, "tags": "theme development" }
Can you call a template file without assigning template to a page in the admin panel? This idea is just to protect certain sections of my theme from over-zealous clients. I would like to add pages, that exist in the front end and can be added to the menu (using wordpress 3.0 api) but the page NOT be present in the 'Pages' dialogue in the admin panel, and is thus not user editable.
You can hook into template_redirect like this: function custom_template_redirect() { global $wp; if ($wp->query_vars['pagename'] == 'my-page-slug') { // check the page slug status_header(200); // a 404 code will not be returned in the HTTP headers if the page does not exists include(TEMPLATEPATH . "/test.php"); // include the corresponding template die(); } } add_action( 'template_redirect', 'custom_template_redirect' );
stackexchange-wordpress
{ "answer_score": 3, "question_score": 2, "tags": "page template" }
WordPress built in breadcrumb trail menu? Looking for a breadcrumb menu that can be called (preferably from a sidebar widget in header.php) that lists... Home > Parent Post/Page > Current Page/Post or alternately... Home > Parent Category > Current Page/Post or even Home > Grand Parent Category > Parent Category > Current Page/Post
Breadcrumb NavXT will let you do that, it has a built in widget and supports just about everything WordPress can do (breadcrumbs spanning multiple sites in a multi site setup does not work, yet).
stackexchange-wordpress
{ "answer_score": 2, "question_score": 3, "tags": "menus" }
How to add a widget to the post editing view? I would like to add some features (via authoring a plugin) to the post editor in wordpress. Is there a way to add a widget to the post editor view? Alternatively is there an existing plugin someone can point me too, that does this so I can see how they do it.
"Widgets" as you're calling them on the post edit screen are actually meta boxes. You can add as many as you want to do whatever you want using the `add_meta_box()` function. Once you know what they're called, it's fairly straight-forward to do a Google search for examples. Or check out some great tutorials listed in the Codex.
stackexchange-wordpress
{ "answer_score": 4, "question_score": 0, "tags": "plugin development, metabox, editor" }
Why is adoptStyles-css stylesheet link added to every page? By looking at the source of any of the WordPress pages on my site, I can see there is this stylesheet link: <link rel='stylesheet' id='adoptStyles-css' href=' type='text/css' media='all' /> The link is broken - the URL is not served by my WordPress. (the double slash is not the source of the problem) Has anyone seen this before? Where does this link come from? How to remove it/determine the plugin that is adding it?
File with this name comes up in search as part of Adsense Optimizer plugin (SVN). Curiously I don't see stylesheet actually being queued in code... Are you using this plugin? Up to date version?
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "plugins, css, debug, html" }
How many WP websites can go on one shared hosting account? Assuming you have a shared hosting account that enables multiple MySQL databases and multiple domain pointers. **How many standard WP-installed websites can it hold without problem?** (let's say each website gets around 1000-2000 visitors a day) If this depends on who is the hosting provider, please refer to whom is the one you are speaking of (which will enable the creation of some basic range). motivation: I recently asked a hosting provider to downgrade an account from VPS to share hosting, and they said it was not possible because of the number of websites and number of uniques (the installs are standard). I wish to understand if they are being greedy or just.
Number of installs is not determined by WordPress, it is determined purely by hosting resources and policies. From personal experience even one blog with 1k daily visits can border overusing CPU quotas on crappy shared hosting with overstuffed server. If you want to force this through - request specific resource usage policies and hard numbers on what server load your setup generates.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "hosting, vps, shared hosting" }
Comment Spammed vs Trashed What's the difference between marking a comment as spam and trashing it?
In vanilla WordPress the only difference is that trashed comments get deleted automatically after (customizable) time span. Adding plugins to the picture - it might make difference to what/how specific plugin learns from incoming spam.
stackexchange-wordpress
{ "answer_score": 3, "question_score": 2, "tags": "spam, trash" }
How to display html in only the first level of WP comments? How would I display html code in only the first level of threaded comments? _Example_ L1 Comment \----L2 Comment \--------L3 Comment L1 Comment I have a piece of html code that contains basically reads "Reply to (author name) or post a new comment" and only need it displayed on L1 comments.
You can do this in the comments loop: if( empty( $comment->comment_parent ) ) { //if the comment does not have a parent, then it is L1 echo 'my-custom-html'; }
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "comments, functions" }
Routine to convert custom post meta from old to new value I have two custom post meta objects that have been applied to all pages and posts in my sites. The names are MyCustomHeader and MyCustomTitle and I have one of these assigned to each post and page in my site. I've just decided to change the names of these two meta objects so that they do not appear in the Custom Fields fieldset. I've done this by placing an underscore character before them. This changes the values to "_MyCustomHeader" and "_MyCustomTitle". In order to account for the sites that have numerous references to the old post meta names, I need to create a routine that runs once (either in the form of a plugin or a script in my theme options that only executes on theme activation) that goes through the WP database and converts every value that was "MyCustomHeader to "_MyCustomHeader" and also "MyCustomTitle" to "_MyCustomTitle". Any help much appreciated. * scott
You can run the following sql queries: update wp_postmeta set meta_key=replace(meta_key,'MyCustomHeader','_MyCustomHeader') where meta_key like "MyCustomHeader"; update wp_postmeta set meta_key=replace(meta_key,'MyCustomTitle','_MyCustomTitle') where meta_key like "MyCustomTitle";
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "database, post meta" }
How can I tell WP which file to load by default in Appearance > Editor? When I navigate to... Appearance > Editor > Edit Themes The default file that gets loaded there is my options.css file (which I don't want anyone editing since it styles my theme options panel, not the theme itself.) How can I specify which file gets loaded there? Ideally, I'd like for my theme's current stylesheet to be loaded there. Is there a way that I can specify this in script from functions.php?
Looking at `theme-editor.php` code it calls `get_themes()` (fills global `$wp_themes` variable with themes, including full lists of theme files) and then simply picks first file out of files from current theme. It jumps to CSS because PHP and CSS files are stored separately and when arrays merge CSS comes on top. So you can just rename your file so it isn't first in list. More complex way would be to hook and run `get_themes()` earlier and then manually rearrange files in `$wp_themes`. I am not good with admin area, have trouble finding fitting hook to run it conditionally on editor page alone.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "theme development" }
"Plugin could not be activated because it triggered a fatal error." The code below is contained in a plugin file. It just seeks to execute an update query against the wp database. However, its generating a fatal error. Fatal error: Cannot redeclare ce3_cleanup() Do I need to load a config file to get acess to $wpdb->query? function ce3_cleanup() { $wpdb->query("update wp_postmeta set meta_key=replace(meta_key,'cb2_customHeader','_cb2_customHeader') where meta_key like 'cb2_customHeader'"); $wpdb->query("update wp_postmeta set meta_key=replace(meta_key,'cb2_customTitle','_cb2_customTitle') where meta_key like 'cb2_customTitle'"); } register_activation_hook(__FILE__, 'ce3_cleanup'); ?>
The recommended way to write that function would be: function ce3_cleanup() { global $wpdb; $wpdb->query( "update $wpdb->postmeta set meta_key=replace(meta_key,'cb2_customHeader','_cb2_customHeader') where meta_key like 'cb2_customHeader'" ); $wpdb->query( "update $wpdb->postmeta set meta_key=replace(meta_key,'cb2_customTitle','_cb2_customTitle') where meta_key like 'cb2_customTitle'" ); } register_activation_hook( __FILE__, 'ce3_cleanup' );
stackexchange-wordpress
{ "answer_score": 0, "question_score": 1, "tags": "plugin development" }
All new plugins generating 311 chars of unexpected output? At some point, I started getting a message about 311 characters of unexpected output at every plugin activation. The number is always the same, and it happens for every plugin activation, including reactivating plugins that were temporarily deactivated. The exact message: > The plugin generated 311 characters of **unexpected output** during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin. Is this likely to be a problem with a plugin that has extra whitespace in its files or something? I haven't yet gotten any problems with headers already having been sent. Possibly it's related to the weird 404 errors I get in wp-admin, but that problem was around long before this unexpected output issue.
Basically it goes like this (relevant steps only): 1. `plugins.php` page calls `activate_plugin()` function. 2. Function starts output buffering. 3. Includes plugin file. 4. Fires `activate_plugin` action. 5. Fires `'activate_' . trim( $plugin )` action. 6. Fires `activated_plugin` action. 7. If buffer is not empty it creates `WP_Error` object and returns it. 8. `plugins.php` page checks for error and displays error message. So output happens somewhere between steps 2 and 7. If it comes up for multiple plugins then steps 3 and 5 are safe to exclude, they are plugin-specific. So it is likely something in either `activate_plugin` or `activated_plugin`. Also actual unwanted output is passed in `WP_Error`object but not used (only its length). I'd try to dump hooks first, will take bit of extra code in core a bit to get to that output in `WP_Error` object.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "plugins, errors, installation" }
Define menu_order on Creation of New Custom Post? I've created a custom post type called `video` and I'm using a plugin called `Playlist_Order` (which changes the `menu_order` field) to allow the user to use a drag and drop interface to order their videos in a playlist. However, when adding a new post the video appears at the top of the playlist because it's given a default `menu_order` value of `0`. On creation of a new video post I would like it to appear last in the playlist - i.e. query all `video` post types, find the largest `menu_order` value and then set this `+1` for the new post. How can I implement this?
Hi **@fxfuture** : I think what you are looking for is the `wp_insert_post_data` hook. You can add this code to the bottom of your theme's `functions.php` file and/or you can add it to a plugin: add_filter('wp_insert_post_data','my_wp_insert_post_data',10,2); function my_wp_insert_post_data($data, $postarr) { $post_type = 'video'; if ($data['post_type']==$post_type && get_post($postarr['ID'])->post_status=='draft') { global $wpdb; $data['menu_order'] = $wpdb->get_var("SELECT MAX(menu_order)+1 AS menu_order FROM {$wpdb->posts} WHERE post_type='{$post_type}'"); } return $data; }
stackexchange-wordpress
{ "answer_score": 6, "question_score": 1, "tags": "custom post types" }
when should an action be added to init and when should it be added to wp_head How do you know when to add your action to init or wp_head. In particular with regards to scripts and styles, but also any other action.
From Codex Action Reference: > `init` Runs after WordPress has finished loading but before any headers are sent. Useful for intercepting $_GET or $_POST triggers. > > `wp_head` Runs when the template calls the wp_head function. This hook is generally placed near the top of a page template between <head> and </head>. This hook does not take any parameters. Basically `wp_head` runs when page is already being loaded, while `init` runs before that. Also don't forget that `init` fires on admin pages as well and anything front-end related must be excluded from there with `!is_admin()` check.
stackexchange-wordpress
{ "answer_score": 5, "question_score": 4, "tags": "init, wp head" }
Breadcrumbs with Custom Post Types? I've tried both Yoast Breadcrumbs and Breadcrumbs NavXT and I can't seem to get either to work with custom post types. Anyone had any luck with this? A single 'News' post on my site displays: Home -> Blog -> My News Post Instead of correctly displaying: Home -> News -> My News Post
Breadcrumb NavXT has Custom Post Type support since 3.6.0. You might encounter some options problem. Please try to reset them or take a look on the development version. Backup your settings first with the export / import settings feature.
stackexchange-wordpress
{ "answer_score": 5, "question_score": 4, "tags": "custom post types" }
Allow user to Edit Posts but not Add New? For one of my custom post types I want a specific user to be able to edit existing posts created by admin but not be able to Add New posts. How can this be done? If I define the user role as not being able to Publish it still allows them to add a new post and submit for review.
You will have to do something like this: function hide_buttons() { global $current_screen; if($current_screen->id == 'edit-post' && !current_user_can('publish_posts')) { echo '<style>.add-new-h2{display: none;}</style>'; } } add_action('admin_head','hide_buttons'); See: < for reference
stackexchange-wordpress
{ "answer_score": 3, "question_score": 5, "tags": "custom post types, user roles, capabilities" }
rewrite rules for custom post-type with a custom taxonomy I have a custom post type ('post' capabilities) called EVENTS and a custom taxonomy called VENUES (hierarchical). I want to be able to set the post's url to domain.com/my-events/%TAXONOMY%/%POST-TYPE% kind of like category/post-name, but it doesn't seem to work, the URL always render the %TAXONOMY% bit as is leaving the % signs.. Any ideas? ps. @John P Bloch, I'm using your plugin.
My plugin will be adding this functionality in the next release (in beta now). If you want, you can download the beta at < There are still known bugs in that beta version, though. I don't have the time to give you a proper answer on here at the moment (it's a pretty complicated fix); we'll see if I release the new version before I get around to it... ;) ## EDIT My plugin is now in its release candidate phase. If there are no more bugs found by Thursday morning, I'll release it. I don't anticipate this happening, though. You can find the release candidate at the same url as above. I think that should solve your problem. Taxonomy tags are the taxonomy's name (as registered. This may be different from the label).
stackexchange-wordpress
{ "answer_score": 2, "question_score": 2, "tags": "url rewriting" }
Changing 'view' link for custom post type on list post screen? How can I change the page that the 'view' action links to on the list post screen for a custom post type? **Update** I've got it to work with normal post types using the below code but where do I define the custom post type? function change_link($post_url,$post) { return '/video?id='.$post->ID; } add_filter('post_link',"change_link",10,2);
By adding a filter to the `'post_link'` hook. See the `get_permalink()` function for more info. For custom post types, you can use the `'post_type_link'` hook. It's a lot easier if you follow the source code _(this is for v3.0):_ * <
stackexchange-wordpress
{ "answer_score": 2, "question_score": 2, "tags": "custom post types, admin" }
How to set a unique WordPress theme for different pages? I am new to wordpress. I am trying to build a custon website based on it. I know some php and quite good html \ css \ js. I wanted to know if it's possible to set a uinque theme for different pages? Thank you!
Yes, it is possible with page templates. See - * Codex : Page Templates * Codex : Creating Your Own Page Templates
stackexchange-wordpress
{ "answer_score": 6, "question_score": 3, "tags": "themes" }
Custom Post Types and Categories? For the life of me I cannot seem to get categories to come into existence with my custom post type. I've added the following -- simple -- code to the bottom of my theme's `functions.php` file, yet see no categories in my custom post from the admin side. register_post_type("customy", array( 'label' => 'Customy', 'description' => 'Custom stuff for this site.', 'public' => true, 'hierarchical' => true, 'supports' => array('title', 'editor', 'author', 'thumbnail', 'revisions'), 'taxonomies' => array('category') )); register_taxonomy_for_object_type('category', 'customy');
It appears that although `register_post_type()` will add the new `post_type` immediately, it seems as though you need to bind up the logic into a function, and add it to the `init` action for the categories taxonomy to be associated with the `post_type`. A working example follows: function add_articles_post_type() { register_post_type("article", array( 'label' => 'Article', 'public' => true, 'hierarchical' => true, 'supports' => array('title','editor','author','thumbnail','revisions') )); register_taxonomy_for_object_type('category', 'article'); } add_action('init', 'add_articles_post_type');
stackexchange-wordpress
{ "answer_score": 4, "question_score": 1, "tags": "custom post types, categories, taxonomy" }
Defining capabilities for custom post type On creation of a custom post type I'm trying to define capabilities but it's not working. What's wrong with this code? $args = array( 'labels' => $labels, 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'query_var' => true, 'rewrite' => true, 'hierarchical' => false, 'menu_position' => null, 'supports' => array('title'), 'capabilities' => array( 'edit_post' => 'edit_video', 'edit_posts' => 'edit_videos', 'edit_others_posts' => 'edit_others_videos', 'publish_posts' => 'publish_videos', 'read_post' => 'read_videos', 'read_private_posts' => 'read_private_videos', 'delete_post' => 'delete_videos' ) );
You code seems to be correct. Try the following instead. $args = array( 'labels' => $labels, 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'query_var' => true, 'rewrite' => true, 'hierarchical' => false, 'menu_position' => null, 'supports' => array('title'), 'capability_type' => 'video' ); **Update:** You have to do some extra steps before making it work with the members plugin. See this forum post from Justin Tadlock (developer of the members plugin). < This plugin seems to be doing it automatically: <
stackexchange-wordpress
{ "answer_score": 9, "question_score": 5, "tags": "custom post types, capabilities, user roles" }
Plugin for sharing on social sites? I'm looking for a plugin that enables sharing an article on sites like Facebook, Twitter and LinkeIn. One catch is that I want a plugin that respect the privacy of the user and doesn't include trackware/spyware on the page. Can anyone recommend a good plugin for this? Thank you!
Sociable adds sharing links for any social network sites you want (configurable). To my knowledge, it doesn't add any trackware on the page (I have yet to see an officially hosted plugin do that).
stackexchange-wordpress
{ "answer_score": 4, "question_score": 4, "tags": "plugins" }
Plugin from WordPress.com for comment notification...available? WordPress.com has a rather cool feature when you add comments. The two features are: [x] Notify me of follow-up comments via email. [x] Notify me of new posts via email. Is this plugin available somewhere so that I can include it on my privately hosted blog?
< <
stackexchange-wordpress
{ "answer_score": 2, "question_score": 2, "tags": "comments, plugins, notifications" }
Always using the same ARRAY on different querys I have a function that returns an array os posts ids. At the moment, everytime i have a query i have to to this: $ids = agendados(); query_posts(array('post__not_in' => $ids ); Is there a way to maintain the array by calling that on header.php and use this array everytime a do a query_posts? I think that doing on my way its a overload of querys.. Thanks m8s Sorry about my poor english www.zarpa.eu
I don't like using categories for this, as they are supposed to be semantic terms. I do, however, like the idea of the global array. Instead of creating a new query directly, I will filter it through a function that will add the results to a global array and return the results: I add this to functions.php: function nt_globals($args){ global $used; $defaults = array( 'post__not_in' => $used, ); $query = wp_parse_args( $args, $defaults ); $queryObject = new WP_Query($query); foreach ($queryObject->posts as $item): $used[] = $item->ID; endforeach; return $queryObject; } Then I call the function whenever I want a query: $queryObject = nt_globals('posts_per_page=1'); while ($queryObject->have_posts()): $queryObject->the_post(); the_title(); endwhile;
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "query posts" }
Finding the page id I'm not sure if I'm blind here, but short of digging directly into the database tables, where would I find the database id for a post or a page?
IDs always show in links in admin area, like /wp-admin/post.php?post= **2164** &action=edit There are also some plugins that simplify this, quick search came up with Simply Show IDs.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "post meta, page specific settings" }
For performance is it better to build custom functionality into the theme or a plugin This question is related to this question: Do deactivated plugins slow down a WordPress site? When developing a website with custom functionality for a client, particularly a site that will expect lots of traffic, what is better from a performance perspective. To build the functionality into the theme itself or to build it into a plugin? Or is there any performance difference at all?
You're not going to get a noticeable difference doing it one way over another. Slowness comes from what the code is doing. If you're worried about performance, just make sure you're caching external requests whenever you can, that includes calls to the database.
stackexchange-wordpress
{ "answer_score": 6, "question_score": 4, "tags": "plugins, performance" }
Create mobile site with same content just different theme I have a wordpress site and want to create a different theme for mobile. I'd like to create a subdomain such as m.domain.com which will use a mobile optimized theme much different than the desktop version theme. I understand multisite will handle the subdomain problem but I want all the content, custom posts, plugins, etc to be in a single site in the admin. Is there anything out there that will allow me to create a mobile subdomain and have a separate theme applied to that subdomained site while keeping the content, posts, plugins in a single site in the admin? Thanks!
try to read this useful article: <
stackexchange-wordpress
{ "answer_score": 3, "question_score": 10, "tags": "multisite, wp admin, mobile" }
Displaying Post Title on Post Edit page? I'm trying to include the post title in a custom post type edit screen. For example if the post is called Biography, I want the edit page title to be 'Edit Biography'. I'm using the below code: function my_post_register() { $mypagetitle = $post->post_title; $labels = array( 'edit_item' => __('Edit '.$mypagetitle), Why isn't this displaying the post title?
This will do it: function edit_screen_title() { global $post, $title, $action, $current_screen; if( isset( $current_screen->post_type ) && $current_screen->post_type == 'post' && $action == 'edit' ) $title = 'Edit ' . $post->post_title; } add_action( 'admin_head', 'edit_screen_title' );
stackexchange-wordpress
{ "answer_score": 3, "question_score": 2, "tags": "custom post types, wp admin" }
Defining the value of a variable before a function? I'm trying to edit a plugin so that it only shows it's submenu if the user is an administrator but I don't know how to define the value of the variable before the function: function load_view( $name, $params = array(), $print_submenu_navigation = false ) { My code so far is: if (current_user_can('administrator')) { $print_submenu_navigation = true; } else { $print_submenu_navigation = false; } If I put this before the function I get a php error telling me it's expecting a function.
Wrong approach. `$print_submenu_navigation` will be filled in local scope when function is called with arguments, it's not a matter of global variables. You want something like this when function is called (not defined): load_view( 'name', array(), current_user_can('administrator') ) { Alternatively you can add your snippet **inside** the function, then input value for `$print_submenu_navigation` will overwritten with result of your check. And it's shorter to write it like this, function returns boolean: $print_submenu_navigation = current_user_can('administrator');
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "plugins, functions, variables" }
Migrating a page to be an article I've decided, that some second level pages I have, should really be blog articles. I want to copy and paste the title and body to an article and then delete the page (is there a better way of doing this?). Now I'm worrying about already existing links to the pages. I don't want them to break ... can I somehow enter the old URL as an alias URL for the article? Or maybe forward from < to < without showing the olt level-two-page in the navigation?
Use the Vice Versa plugin to change the post type. Redirect the URL per .htaccess: Redirect permanent /old-url /new-url
stackexchange-wordpress
{ "answer_score": 6, "question_score": 2, "tags": "url rewriting, urls" }
How to know the theme name of a wordpress blog? I visit < and want to know the theme name (so that I can use :) for my blog). How can I get it?
This method isn't always fireproof, but you can often look at the source code (right click on white space in the blog), and look for the word "themes." For instance, in the case of ltty.wordpress.com, this line appears: <link rel="stylesheet" href=" type="text/css" media="screen" /> The theme is "inove." A quick Google Search reveals this source: <
stackexchange-wordpress
{ "answer_score": 8, "question_score": 1, "tags": "themes" }
Can you host WordPress using Amazon Web Services such as EC2, RDS, EBS etc? I've been looking into the feasibility of using something like Amazon Web Services for hosting WordPress sites. I was wondering if it is possible and if so what people's experiences are of having done so. What aspects of AWS did you use?
You explicitly mention three services in your question title: EC2, RDS and EBS. If they're the three services you're interested in, then yes, very easily. EC2 + EBS are pretty much the same thing, EBS is simply a persistent storage extension to EC2, and RDS is a full MySQL database - you should be able to get those three services running together very easily. If you were looking to extend to some of the other AWS products, S3 is very easy to implement on WordPress for file uploads - check some of these plugins. SimpleDB, however, has very limited usefulness to us without a rewrite of how WordPress reads and writes to the database. There is an article by Amazon on how to create a plugin which adds tagging functionality that uses SimpleDB as the storage, but that is as much as I could find regarding the use of SimpleDB with WordPress.
stackexchange-wordpress
{ "answer_score": 7, "question_score": 8, "tags": "server, hosting" }
Why use widgets? I am very new to using WordPress and I was wondering what the benefits of using widgets is? Looking here it sounds like they are for people who are not programmers that want to add plugins to their site. Is that correct? or do widgets allow the site to be more robust in some way?
I battled with this very same question. I'm presently developing my own ability to develop WordPress sites. My employer is launching numerous websites on the engine, and is moving me from general PHP work to focused WordPress development. The thing is, these sites will all be managed by other people, and not myself. Using widgets allows the non-programmers to help develop the site without potential of breaking things. For instance, they can move things around in the sidebar, change up the contents of the footer, and so much more. That being said, I wish I could prevent them from doing some types of editing, but permit them to do others. While they can't break the site (to my knowledge), they could really make it ugly.
stackexchange-wordpress
{ "answer_score": 5, "question_score": 2, "tags": "widgets" }
featured posts order I'm trying to build a featured posts with a "tabbed" interface in my homepage. I'm using the "sticky" option of the posts in order to get them out of the main loop and in the "featured tabs". No problem here. The problem is I can't control the stickies order. Is there a way to set the order of sticky posts? A plugin, custom field... Is this stickies approach completely wrong? Thanks
It sounds like you want to use the 'sticky' functionality as a replacement for a tag or a category. Why not just put all the posts you want in a 'tab' category, then call your query for that category. You can use orderby in fancy ways (such as by post_meta($tab = get_posts('category=tab&orderby=date');
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "plugin recommendation, posts, custom field" }
What is the best caching option for WordPress multi-site on non-shared hosting? What caching plugin configuration do you recommend and why under the following assumptions: * full control of the server configuration * running WordPress in multi-site/multi-domain mode * most domains are not using `www.` prefix (cookies) * (desire) to be able to disable caching for specific IPs or based on a cookie, when you do changes to the site you don't need caching. Details: I'm using Firefox Google Page Speed plugin to try to optimize the speed of the website. Also please do not guide with generic guidelines, like smaller images. Let's be fair, using more than one caching plugin will bring you more problems than it will solve so please try to give a simple approach.
Basic answer to "what plugin" would probably be W3 Total Cache. It is one of the most functional and actively developed plugins at moment. However complete performance chain is much longer that WordPress plugin alone can handle. 1. Web server (Apache or something else) configuration (response time, time to first byte, headers). 2. Database (time spent processing queries). 3. PHP/WordPress (page generation time, memory consumption). 4. Front-end performance (amount of HTTP requests, bandwidth). Good start would be static caching plugin (like W3) with opcode memory-based cache like APC. But from there there are way more (and way more complex) things you could do, like content distribution networks, alternate web servers, etc.
stackexchange-wordpress
{ "answer_score": 4, "question_score": 13, "tags": "performance, cache" }
WordPress hosting - Shared/dedicated server? Any recommendations? I'm testing out a shared hosting package with Dreamhost at the moment which is only $2.95 a month for unlimited domains, storage space, bandwidth, mysql databases etc. But I'm currently only running one test site on it and it seems pretty slow. Am I going to run into problems if I host lots of sites on a shared hosting package. Should I be looking at a dedicated server instead? iPage seem to offer a similar package but with lots of extras for $3.50 per month. Have you had any experience with either company? Any advice greatly appreciated. Thanks
We've migrated a lot of people from Dreamhost after their site gets mildly popular, and they notice it's either down or slow. But, we don't offer hosting plans that are as cheap as them as well. I would recommend you check out zippykid.com (our site), page.ly, or wpengine.com if you're interested WordPress hosting that doesn't suck. I'd be willing to give you a coupon if I could get some of your feedback.
stackexchange-wordpress
{ "answer_score": 3, "question_score": 2, "tags": "hosting, shared hosting" }
How can you develop on a live WordPress installation that is using W3 Total Cache? Or to make it easier: you just want to disable the caching in order to see your changes in realtime. Any solution that would allow you to disable caching based on IP, logged user or cookie will be acceptable.
It has this natively: _Performance > Page Cache > General > Don't cache pages for logged in users_ You can always check if you are seeing cached page by looking at page source, W3 outputs status (commented out) at end of page.
stackexchange-wordpress
{ "answer_score": 8, "question_score": 3, "tags": "theme development, cache, customization, plugin w3 total cache" }
custom taxonomies label in hebrew I'm trying to add a custom taxonomy. using the following code: function cities_custom_taxonomies() { register_taxonomy( 'city', // internal name = machine-readable taxonomy name 'post', // object type = post, page, link, or custom post-type array( 'hierarchical' => false, // true for hierarchical like cats, false for flat like tags 'label' => 'City', // the human-readable taxonomy name 'query_var' => true, // enable taxonomy-specific querying 'rewrite' => true // pretty permalinks for your taxonomy? ) ); } add_action('init', 'cities_custom_taxonomies', 0); As long as I use label name in English, all works fine. Once I try to label it in Hebrew, I don't see the new taxonomy menu. any Idea ?
You can just wrap the english label name with the translation function `__( 'City', 'textdomain' )`, and put the hebrew version in your translation file. Reference: <
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "custom taxonomy" }
Get the 'slug' of a custom taxonomy Use case: I have a custom post type of 'show' for a music venue. In the sidebar we want to display any related 'show' to the current one on single-show.php. They will be related by a custom taxonomy of 'genre'. I figured I could dump the custom taxonomy slugs for a post (might be more than one) into a variable then pass that variable into a custom query for the sidebar post. Using get_the_term_list() works if there is a single taxonomy but if there are multiple it breaks (of course). Any thoughts on how to get an array of the custom taxonomy slugs for a give post into a variable?
You can do something like the following: $terms = get_the_terms( $post->id, 'genre' ); // get an array of all the terms as objects. $terms_slugs = array(); foreach( $terms as $term ) { $terms_slugs[] = $term->slug; // save the slugs in an array }
stackexchange-wordpress
{ "answer_score": 5, "question_score": 4, "tags": "custom post types, custom taxonomy, taxonomy" }
menu doesn't show in different languages I have a custom menu on a site with multiple languages (WPML plugin) The menu is not being displayed in any languages other than native. 1. Can the menu be translated? 2. Can the menu be shown in all languages without any change to the text? (when it's mostly names that shouldn't be translated)
Yes, the menu can be translated, and, yes, it will be shown in all languages. Does your menu use the WordPress 3 menu feature? If yes, the video here explains how to setup the translation: <
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "menus, multi language" }
How can you showcase premium themes to clients without having to pre-purchase the theme? If you use a premium theme service (my skills lie more in coding than artwork), what is a good way to show clients examples of what themes are available to them, without sending them to the theme service site in the first place (i.e. without letting them see the original purchase price), but without having to purchase the theme upfront? I know I can make a dummy WP site and use a theme switcher, but I don't want to purchase a bunch of themes that may never be used.
One option would be to display screenshots of the theme in action. Many theme services allow you to view a "demo page" and see how the theme is presented - taking a screenshot of this page and passing it to your client is pretty much the same as presenting a stylized wireframe or stylistic mockup of the final design. If it was an entirely custom site (i.e. you were responsible for the design as well), you'd likely present it this way _anyway_ before investing any time in actual development.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "themes" }
Simple plugin for showing RSS subscription links? Does someone know of a simple plugin for showing RSS feeds? I need something dead simple that only show the links and would rather re-use something before rolling one myself.
There is a plugin for this, RSS Icon Widget. However it looks like it hasn't been tested on any version past 2.8. It looks fairly simple, so it could still work. Otherwise the easiest way to accomplish this is to just create a new text widget and write the HTML to display any icon you'd like and link it to your feed. A plugin may even be overkill for this. I believe this is normally something that is built into your theme.
stackexchange-wordpress
{ "answer_score": 3, "question_score": 1, "tags": "plugins, plugin recommendation, rss" }
Problem with using wp-load.php outside of WordPress I'm trying to use wp-load.php in a page outside of wordpress so I can access all the functions in wordpress. Typically I just include the file like this require( $_SERVER['DOCUMENT_ROOT'].'/blog/wp-load.php' ); But it doesn't seem to be working. Any tips on what can be going on? Thanks, Paul
Including wp-load.php will not setup the WordPress query. See Integrating WordPress with Your Website for the right way.
stackexchange-wordpress
{ "answer_score": 6, "question_score": 1, "tags": "customization, outside wordpress" }
how do I encode links to specific archive searches? I want to embed links to the archive pages with specific search criteria. i.e Links to specific categories, links to specific authors etc etc At the moment I am adding the links using anchor tags, but these will fail if the permalinks change
WordPress can generate these, so you can too. You would need to use the same function that WordPress does. For category it would be something like: $category = get_category_by_slug( 'example' ); $link = get_category_link( $category->term_id ); Similarly there is `get_tag_link()` and on deeper level they all really use `get_term_link()` I didn't play much with authors, but there is `the_author_posts_link()` and probably some `get_` analogue.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "archives" }
Add custom text to Page Tamplate without need to know html I am new to wordpress. I have experience in css \ html \ js and asp.net (and also a bit of php now). I've added to my blog certain areas that are hard coded in html and css. In these areas I'd like to be able to set text based on the admin's input in the panel's page. I want a person who doesn't know html to be able to easily change the content of these hard coded areas. How can this be done? Thank you!
You have two solutions for this: 1. Use Custom Fields This is a very comprehensive guide: The Power of WordPress Custom Fields. There are some very useful plugins like Custom Field Template and Magic Fields which use them. 2. Use Widgets. The Widgets API allows you to easily build your own widgets.
stackexchange-wordpress
{ "answer_score": 4, "question_score": 2, "tags": "wp admin" }
How to register_sidebar() without messing up the order? How do you register a sidebar in a plugin without screwing up the pre-existing registered sidebars? (The ordering of the sidebar registrations, rather than the assigned ID, determines the sidebar data.)
function self_deprecating_sidebar_registration(){ register_sidebar( /* Your arguments here */ ); } add_action( 'wp_loaded', 'self_deprecating_sidebar_registration' ); Most themes will register the sidebar in their functions file, which is included before `init` but after plugins are loaded. Hooking onto `wp_loaded` should guarantee that your sidebar is registered after the theme's.
stackexchange-wordpress
{ "answer_score": 9, "question_score": 4, "tags": "plugins, register sidebar" }
WordPress.com Stats plugin is requiring login, and redirecting to WordPress.com on login I have my own private installation of Wordpress I've installed the wordpress.com stats plugin, so I get a stats feature like you get on the free wordpress blogs, its nice and simple, and works well Now on my blog, all I can see on the plugin (on my dashboard) is a login screen, and when I try to login it redirects me to my free blog (which I had to setup to get an API key) **Why has my plugin suddenly started requesting a login? It has been working fine for 2 weeks now** The login it expects is the login of my free blog, and when I do provide those credentials it redirects me to my free one. Screenshot of what I see on my dashboard :!alt text Tried to de-activate and re-activate plugin, no luck
The WordPress.com Stats plugin is broken as of this morning. It doesn't work on any of my sites and if you click this < You'll see lots of people are finding it borked this morning. You may have to wait a few days and try again once the issue is fixed.
stackexchange-wordpress
{ "answer_score": 3, "question_score": 0, "tags": "plugins" }
How to generate a sitemap with custom posts (not Google XML) I'm looking for a way to generate a sitemap for display on my site that includes my custom posts. I'm not looking for an xml sitemap generator for search engines -- that is sorted using Google XML Sitemaps and Get Up and Running's patch for that plugin. I'm specifically looking for something to display to users. Normally, I'd use Dagon's sitemap generator, but it does not support custom posts, and the author does not seem to be responding to queries. Any hacks/patches/code snippets/ideas?
Smart Archives Reloaded plugin should work with custom post types (it accepts query_posts/get_posts arguments so quite flexible).
stackexchange-wordpress
{ "answer_score": 1, "question_score": 3, "tags": "custom post types" }
Making a Contact Form 7 calendar entry "required" I'm using the Contact Form 7 Calendar "plugin plugin", but I can't figure out how to make the date field required. The syntax is `[datetimepicker your-label]`, and in the parent plugin (Contact Form 7), you would just put an asterisk in, like `[datetimepicker* your-label]` but this doesn't work with the calendar widget... Of course, I could always style it in CSS to appear as if its required, but I kinda need the validation there. I've looked in the plugin's documentation, but this isn't covered, and the author is not responding on the WP Support Forums. Has anyone used the Calendar add-on and been able to make the date field required? Anything I can do to tweak the javascript or whatever is used for validation -- I'm assuming its javascript (I'm sure js is very easy but I've never managed to find the time to learn it)? Or the php (I'm much more comfortable in php), but without breaking on plugin updates...
Apparently the answer is to read the installation instructions properly the first time round. The syntax within a contact 7 form is: `[cf7cal inputname]` or `[cf7cal* inputname]`
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "plugins, contact" }
Options for restricting access to wp-admin So i've installed a plug-in which allows me to enable two-factor authentication for my users. The problem is that to enable the plug-in i have to log in as that user and enable it via their profile page (wp-admin). This isn't a problem except for the fact that there's nothing stopping the users from logging in and disabling the two factor authentication which is an issue. I've looked around at a few issues and none have seemed to work, essentially i want restrict backend access to only a select few (myself and few others). I've tried stealth login and a few some htaccess solutions and none have seemed to work. Any ideas?
You could make it a mu-plugin ('Must Use' plugin). Any PHP file you put into /wp-content/mu-plugins/ will automatically get included in WordPress. You can't deactivate the plugin (unless you have ftp access to the server). If you go with a mu-plugin, make sure to put the functionality into a subdirectory and bootstrap it with a php file in the mu-plugins directory. ## EDIT After reading the comment, I think I understand the problem better. It sounds like you want to be able to lock people out of the admin altogether. That's not so difficult. Try this: function my_awesome_admin_lockout(){ if( is_admin() && !current_user_can( 'manage_options' ) ) { wp_redirect( home_url() ); die(); } } add_action( 'init', 'my_awesome_admin_lockout' ); Basically, that locks everybody but admins out of the admin area.
stackexchange-wordpress
{ "answer_score": 3, "question_score": 3, "tags": "wp admin, security, htaccess" }
Contact Form in sidebar I have a Contact Form 7 form as a page on my site. I'd like to place the contact form on the sidebar. How can I do this?
Have you tried the options suggested in this WordPress Support thread? They range from copying the generated code in a Text Widget to parsing the shortcode yourself in your template (`<?php echo do_shortcode('[contact-form 1 "Contact form 1"]'); ?>`).
stackexchange-wordpress
{ "answer_score": 3, "question_score": 2, "tags": "widgets, sidebar, plugin contact form 7" }
Combining multiple javascript and css files Is there any plugin which can automatically combine all the javascript and css files that are used on a page? While I can combine them manually I would like to avoid them as some plugins add their scripts and css. Also different scripts might be needed on different pages so I do not want to have one large script on every page. I am not looking for gzipping, minifing or cache-control as I already have them implemented. Thanks.
W3 Cache will do this for you
stackexchange-wordpress
{ "answer_score": 5, "question_score": 1, "tags": "performance, javascript, css" }
Show the First Post from Each of 3 Different Post Types on a Web Page? I have 3 different custom post types: 1.) `"events"`, 2.) `"winners"` and 3.) `"offers"`. How would I go about retrieving the first (latest) post in each of these post types on a single web page (i.e a home page). Would I use `get_posts()` or would I have to manipulate `the_loop()`?
Yes, get_posts is the safest way to use multiple loops. It does not mess up with the original query. Another way would be to create new WP_Query objects: $my_query = new WP_Query($args); while ($my_query->have_posts()) : $my_query->the_post(); Note: Why you should not use query_posts()
stackexchange-wordpress
{ "answer_score": 3, "question_score": 4, "tags": "custom post types, get posts" }
What's the difference between home.php and index.php? If I create a home.php file, it seems that WP will use that instead of index.php, so index.php is never used? What are the differences between these two template files (located in the theme folder)? Do they both behave the same way, the only difference being the priority of home.php?
* `index.php` is universal template, it is what any page (home, archive, single post, etc) will use if no other template is available for it. * `home.php` is a template used for _main page_ (on `is_home()`) condition. See Template Hierarchy for detailed scheme of how templates are applied.
stackexchange-wordpress
{ "answer_score": 18, "question_score": 16, "tags": "theme development, templates" }
List Posts of a Custom Post Types Ordered by Terms of a Custom Taxonomy? I've created a custom post type and custom taxonomy. I can now create a new post and associate it with a custom category. The problem is listing these news post types. This: $loop = new WP_Query( array( 'post_type' => 'sobeedesce' ) ); while ( $loop->have_posts() ) : $loop->the_post(); the_title(); echo "<br />"; endwhile;` lists all custom posts ok. But I want to list them by category, so adding `'cat' => 12` returns nothing. I know my custom category id is `12` and I can confirm that by doing $custom_terms = get_the_terms(0, 'cat_sd'); print_r($loop);` inside the loop. I'm missing something here. Can someone help me? Thanks.
I suppose your custom taxonomy slug is 'cat_sd', right? If so, the right query would be: $loop = new WP_Query( array( 'post_type' => 'sobeedesce', 'cat_sd' => 12 ) );
stackexchange-wordpress
{ "answer_score": 2, "question_score": 2, "tags": "custom post types" }
Blog in multiple languages on WordPress.com? Does wordpress.com support multiple languages at the same time? I know it does support changing the main language, but I can't find anything about how one would go about setting up multiple languages at the same time. Thanks.
No, wordpress.com does not support multilanguage blogs. The solution would be to make one blog per language and link them via the sidebar. Reference: Multi-language blog on wordpress.com
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "wordpress.com hosting, multi language" }
New post email alert I'd like to display a checkbox with the option to subscribe to the site by email I have seen a wordpress blog with the following label next to the said checkbox Subscribe by email to this site The problem is that i cannot see to find the plugin that displays it: i've tried Subscribe2 and Post Notification and Gurken for comment subscriptions. Would you perhaps know what plugin i need to install?
There are often issues with setting up email subscriptions. Hosting providers are very tired of spam and often put harsh restrictions on email rate and volume, especially for cheaper hosting plans. In practice such feature is often implemented with help of external service. FeedBurner is popular for this, because a lot of people use it for feeds anyway and it provides decent email subscription option. See FeedBurner Email Overview and FAQ
stackexchange-wordpress
{ "answer_score": 2, "question_score": 2, "tags": "subscription, notifications" }
List taxonomy terms as links How can I make a list of links of all the taxonomy terms I'm using? For example, I have a taxonomy of Manufacturers with terms of Honda, Ford, etc. I want to list out those terms as links.
My apologies. After some more searching, I found that I could pass the taxonomy as an argument in wp_list_categories. Here is the info via Wordpress Codex.
stackexchange-wordpress
{ "answer_score": 6, "question_score": 3, "tags": "taxonomy" }
How to migrate from Mark Jaquith's Subscribe to Comments plugin to Gurken's new version? Mark Jaquith's Subscribe to Comments plugin has been a staple of my WordPress site since shortly after I launched it. However, it's not really maintained any more (last updated end of 2007) and it lacks some options (email verification, etc.). infogurke extended Mark's plugin and released a different version with enhancements: > * All of the original Subscribe to Comments > * Registration with Double-Opt-In > * Multi-Language (English and German included) > * You can define an own css file for the manager interface > * Fixed many bugs that are still in the original plugin > Is it possible to migrate to infogurke's version and maintain the subscriptions in the database? (Found the new plugin via this question.)
Yes, it's possible (and quite easy) to migrate from Mark Jaquith's Subscribe to Comments plugin to Gurken Subscribe to Comments plugin. The steps: 1. Install Gurken Subscribe to Comments (using either FTP or WordPress's plugin manager) 2. Don't activate Gurken StC yet. First deactivate Mark Jaquith's version. * Activating the new plugin too soon will fail because both plugins define functions with the same names. 3. Activate Gurken StC. 4. Go in via FTP and delete the `/wp-content/plugins/subscribe-to-comments/` folder. * **Don't use WordPress to delete Mark's version!** It might erase your subscription data from the database! (Question and answer inspired by this WordPress Support thread.)
stackexchange-wordpress
{ "answer_score": 1, "question_score": 2, "tags": "plugins, updates, migration" }
Sitemap Plugin for WordPress Network Is there a plugin similar to the Google Sitemap plugin that works for a mutli-site install?
There is Google XML Sitemaps with Multisite support. You can also use the development version of the original Google XML Sitemaps. It seems to be working fine for some people.
stackexchange-wordpress
{ "answer_score": 4, "question_score": 4, "tags": "multisite" }
display different template based on post type Hay, i have a custom post type "Events", however this is basically a post type, so it inherits the post.php template page. Is there anyway to use a different template (i.e events.php) if the content type is an 'event'?
Try `single-events.php`. See Template Hierarchy in Codex for full scheme of templates.
stackexchange-wordpress
{ "answer_score": 18, "question_score": 9, "tags": "custom post types, templates" }
Get term SLUG by term ID I have a hierarchical taxonomy called 'tarefa' I have to display all posts from a child taxonomy. I used get_term_children function function to verify if the taxonomy parent has children. If the taxonomy parent has children I will query posts by taxonomy children. The problem is: I have to query posts by taxonomy slug but the function get_term_children return an array of taxonomy IDS. The question is: How can I return a taxonomy slug by a taxonomy ID?
I have bit of trouble understanding your question. Taxonomy (like `category`) slug or term (like `uncategorized`) slug? `get_term_children()` works with terms so I will stick with that. Try this: $term = get_term( $id, $taxonomy ); $slug = $term->slug;
stackexchange-wordpress
{ "answer_score": 23, "question_score": 12, "tags": "custom taxonomy, get posts" }
User Training Materials Does anybody know of any good publicly-available Wordpress training materials (videos, manuals, etc.) that could be used to give content editors a basic overview of Wordpress. We have a a handful of blogs on a Wordpress server and I'd really like to be able to automate training some more.
Interconnect/Spectacula folks manage free WordPress User Guide for training users.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "documentation" }
Custom WP_Query with no posts to output I have created a custom WP_Query as seen below. The query works well except for when $favorites is empty. When $favorites is empty, the query still outputs posts, which I don´t want. It could seem like it defaults back to the standard WP_Query to output all published posts. Anyone knows what´s going on? $favorites = wpfp_get_users_favorites($user = ''); $favorites_query = new WP_Query(array('post__in' => $favorites)); while ($favorites_query->have_posts() ) : $favorites_query->the_post(); Thanks!
Empty argument here does not equal logical _in nothing_. It equals no value to process and so WP ignores it and goes further as usual. Just wrap your query in `if( !empty( $favorites) )` condition.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "customization" }
Plugin for Android Marketplace downloads? Is anyone aware of any way to show statistics on your WP blog to show android market place downloads? For example, I create an application and host it on the android market place, it gets downloaded/installed 10 times. Is there any plugin I can use to display these figures/links etc on the sidebar in WP?
This plugin will display information from the Android Market, it may be able to be modified to include statistics, but I'm not sure. Otherwise, there are no existing plugins that do what you are asking.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "plugin development, plugins" }
Is a direct or import approach safer for migration into WordPress? We're in the process of migrating a site from an existing CMS system into WordPress. The existing CMS system has no direct integration tools with WordPress. I'm looking into the option of creating my own script/application that will migrate the content between the two systems. Would it be better to migrate directly into the database (inserting the rows myself) or to generate a WXR file (or multiple) and let the WordPress import module handle things for me?
If this is a standard CMS (not something you came up with yourself), I would say that a WXR solution is _the_ way to go. It might take some extra work, but it will be a good learning experience and a nice way to build up your Wordpress skills. The WXR route will be an automated solution that's reliable and repeatable. You might want to consider doing this as an open source project, soliciting help from the community to get it done. The end result will be a useful tool from which others can utilize, improve, and extend. Open source contributions are always nice to list on the resume, too.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 2, "tags": "database, import" }
Where is the robots.txt stored for a WordPress Multisite install? Google Webmaster Tools can see it, but I can't find it. Any idea on how it's generated or where it is the file structure? I don't see the file in my root. My website is at < and the robots.txt file URL is < In the end, Google isn't indexing my site and I am trying to figure out how to edit the robots.txt so that indexing is allowed. I have changed the privacy option to allow indexing, but that hasn't updated the robots.txt.
It's dynamically generated by the function `do_robots()`, which has both an action (`do_robotstxt`) and a filter (`robots_txt`). If you create a `robots.txt` file in your WordPress root, it will (probably) be served up when `/robots.txt` is requested, otherwise processing will fall back on WordPress. Your current file looks like this: User-agent: * Disallow: Sitemap: The first two settings are appropriate for an indexable blog. So, you may just be waiting for Google at this point. Maybe you need to request reconsideration of your site.
stackexchange-wordpress
{ "answer_score": 11, "question_score": 9, "tags": "multisite" }
Plugin to count file download I'm looking for a plugin which will allow me to count how many times a file has been downloaded. I don't need neither a fancy download page nor showing the download count on the page itself, I want it just for me. I'm aware that GA can track them but if the user right-click the link it might not detect it.
You want a plugin (or another piece of software) that tracks the actual server logs. If you don't need WordPress integration there are many options, AWStats is a classic for Apache and other server log formats. I don't know whether there are plugins that integrate nicely with WordPress (normalizing URLs to posts and stuff like that). WP-Alp seems to only display bandwidth usage.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "plugin recommendation, statistics" }
Best way to overide plugin CSS? Currently, I use CSS specificity to override plugin styles. I prefer this for editing the plugin as it makes less headaches when you update. It would be nice if my style sheet loaded after the plugins, so that I only have to be as specific, not more. This would make my stylesheets much prettier.
As you suggest, the most elegant approach is when your CSS overrides are loaded after the CSS injected by the plugins. This is quite easy to achieve - you just need to make sure that your `header.php` calls `wp_head()` before it references your style sheet: <head> <!-- all the usual preamble stuff goes here --> <?php wp_head(); ?> <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" /> </head>
stackexchange-wordpress
{ "answer_score": 21, "question_score": 39, "tags": "plugins, css" }
How to make <!--more--> a button? There is plenty of information on how to make the Read More function display different text in the Codex but what kind of filter would need to be used to make it display `<button class="readmorebtn" onclick(permalink)>Read More</button>`?
The "(more...)" link gets filtered through `the_content_more_link` in `get_the_content()`. You can hook into this function and let it return whatever you want. add_filter('the_content_more_link', 'more_button'); function more_button($more_link) { return '<button class="readmorebtn" onclick="' . esc_attr('window.location="' . get_permalink() . '"') . '">Read more</button>'; }
stackexchange-wordpress
{ "answer_score": 4, "question_score": 1, "tags": "filters, read more" }
How can I exclude specific authors from wp_list_authors I want to have the authors listed like usual from `wp_list_authors()` but I know there are a couple of ones I would like to exclude from the list as well. Is there a way to do that? Thanks
`wp_list_authors()` now does have an `exclude` parameter. So you can exclude the authors you want by their user ID. It accepts: > An array, comma-, or space-separated list of author IDs to include. Default empty. Examples: // exclude just the author with the ID 4 wp_list_authors([ 'exclude' => 4 ]); // exclude the authors with the IDs 4 and 7 wp_list_authors([ 'exclude' => [ 4, 7 ] ]); // or wp_list_authors([ 'exclude' => '4, 7' ]);
stackexchange-wordpress
{ "answer_score": 3, "question_score": 1, "tags": "theme development" }
Menu API not switching menus? I am using the menus API, and I want to switch to a different menu, but it is holding the first one for some reason Here is my code in functions.php add_action( 'init', 'register_my_menus',10 ); function register_my_menus() { register_nav_menu('main-navigation', 'Main Navigation'); } Here is the code in my theme file (header.php) <?php $args = array( 'menu' => 'main-navigation', 'container_id' => 'navigation', 'fallback_cb' => 'wp_page_menu' ); wp_nav_menu($args); ?>
_Menus are somewhat confusing around there. Try this: $args = array( 'theme_location' => 'main-navigation', 'container_id' => 'navigation', 'fallback_cb' => 'wp_page_menu' ); wp_nav_menu($args); `theme_location` tries to display menu that is attached to this location. `menu` tries to display menu by slug/id (not location of menu, but actual menu that you create in admin area). So you are mixing up location with menu slug, it gets confused and just serves first menu it can. See `wp_nav_menu()` documentation for full description of logic behind it.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "menus" }
Add widgets to available widgets section without changing the theme? I have a client that wants to use a particular theme without modification, but will likely want to have more widgets than are available with a given theme. Is there a way to add widgets to the list of those available without modifying the theme? Thanks.
Yes, you can add widgets through plug-ins the same way you add them through themes. So move the widget code from your `functions.php` file and drop it inside a custom plug-in. You'll get the same functionality without the need to modify your theme.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "theme development, widgets" }
I can't view or add comments Hey, there. I just got this site up and going. < It works fine except for the fact I can't seem to see past comments (this blog was imported from blogger) or add comments. I know it's the code not the settings since someone else told me but he didn't help me further. He said it was probably on the index.php Help?
It appears that your posts titles do not link to the single post pages, they link to the archive page. By example, the lastest article "It really is that small" links to " The error should be in your theme index.php file.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 2, "tags": "php" }
Howto force SSL for all requests? Is there a way to force SSL for all requests? Much like the option to use admin ssl, but for all requests, including the ones who are not logged in.
Here is a complete guide - Enable Complete support for SSL on Wordpress
stackexchange-wordpress
{ "answer_score": 1, "question_score": 10, "tags": "ssl" }
Salesforce lead tracking with contact forms plugins I am using Contact Form 7 on my website and would like to integrate Salesforce lead tracking with it. I was able to add a hidden field with my oid as suggested on this site But when I submit the contact form after adding this, it just gets stuck and never actually returns. As soon as I remove the hidden field, it starts working fine. Has anyone been able to integrate the lead tracking system with Wordpress Contact Form plugins? I also tried using cform with the instructions provided here. But this gives a warning that fopen failed. I assume thats because fopen does not allow write operations with HTTP wrappers. Not sure how the author managed to get it working! Would appreciate any help on this! I do not want to use the salesforce Web-to-lead form. Thanks.
I've used the Gravity Forms plugin and its post form-submission hook to fire off a server-side web2lead curl request in wordpress before now. Wasn't too difficult. Essentially your web2lead form submission is purely server-side so the regular gravity forms entry logging (including IP etc...) just carries on working. You get your data in both WP and SF.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "customization, contact, plugin contact form 7" }
Custom page template, not acting as page I have defined several page templates on my site < When I set my pages to use one of these page templates, wordpress seems to stop treating it as a page: * It is not accepted in the is_page() conditional tag * The body class "page" is not present (instead its showing "home"). Only when I use the default page template for my pages they are truly treated as a page by wordpress. Anyone got a clue what´s going on? Thanks! Added: query_posts('meta_key=wpfp_favorites&orderby=meta_value'); if ( have_posts() ) : while ( have_posts() ) : the_post(); $start = get_post_meta($post->ID, '5Start', true); $stop = get_post_meta($post->ID, '6Slutt', true); if(is_active($start, $stop)) { $offer = print_offer($post->ID, $start, $stop); echo $offer; } endwhile; endif;
Thought so... You are using `query_posts()` and this nukes native page's loop and replaces all relevant data with your query. Since your query isn't for page - your page is no longer treated as such. **Always** use `get_posts()` or new `WP_Query` object for secondary loops. See When should you use WP_Query vs query_posts() vs get_posts()?
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "customization" }
Publishing presentations in WordPress? I'm looking for a solution that would enable me to publish a presentation inside WordPress. I do not want to attach a PPT file or embed a Flash plugin for that, I'm looking for a HTML solution. I would be preferable to be able to use PowerPoint to create the presentation but this is not a hard requirement, more important is to output a nice presentation for the users, one with auto-play.
I've run into this problem before with both PPT files and PDF documents. The solution, actually, was quite simple ... There's a plug-in called PDF and PPT Viewer that will uses Google Docs to render your presentation inside the page. Each slide/page is rendered as a image using Google's API rather than Flash or a native file viewer. I'm using this extensively on my portfolio to show PDF files without requiring a file download or browser plug-in. Here's a specific, live example of a press release I did in January: < Note how the plug-in embeds the Google viewer in an iFrame on the page. The file itself is hosted on my own site (I used the WordPress media gallery uploader). **Important:** The plug-in download page claims the system is only tested through WP 2.8.4, however the site I've referenced above is using 3.0.1 ... it _is_ compatible with the latest release of WordPress, the author just hasn't updated the documentation yet!
stackexchange-wordpress
{ "answer_score": 2, "question_score": 4, "tags": "plugin recommendation, media" }
How to add an RSS logo to my blogs header? I have started a new site (here), I want to add the theme a RSS icon/logo on the top right of the theme (like in this theme). What is the best way for doing that? (PHP/CSS wise)
You want some code to be added to the `#title` element. You can do this, as Sorich said, by copying the `header.php` file and just adding it there, but you could also try to add it in the footer and then using Javascript move it to the correct element. This might survive theme upgrades better, but is maybe not so user-friendly (the image appears just after the page has been loaded, giving a strange flash). The code you need is simple, let's take the example you gave: <p> <a href="<?php echo bloginfo('rss2_url'); ?>"> <img style="vertical-align:middle" src=" alt="Subscribe to R-bloggers"> RSS Feed </a> </p> Of course, you would copy the image to your own server and change the path. You can check the styles used on the page, using a good web inspector/debugging tool (like Firebug).
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "css, rss, themes, logo, icon" }
What is true chmod for WordPress? For all the folders and files. Please give some explained answer.
All files should be writable only by your user account. So the correct permissions for files and directories are: * Directories: 755 * Files: 644 You may want to secure some files: * wp-config.php: for maximum security, this file should be made writable by your user only or its group. This means 400 or 440 permission * .htaccess: 666 permission, so that WordPress can automatically generate rewrite rules for you * wp-content/: some plugins and themes may require write access to this directory. you will be prompted when necessary. * wp-content/themes/: 664 permission if you want to use the theme editor References: * Changing File Permissions * Hardening WordPress
stackexchange-wordpress
{ "answer_score": 10, "question_score": 3, "tags": "customization" }
Displaying the Name of the Queried Taxonomy Term on a Term Archive Page? _( **Moderator's note:** post was originally entitled "Taxonomy.php title")_ How can I display the _"Posts classified under:"_ title for the `taxonomy.php` page? For example, this code is used in `tag.php`: printf( __( 'Tag Archives: %s', 'twentyten' ), '<span>' . single_tag_title( '', false ) . '</span>' );
Use: $tax = $wp_query->get_queried_object(); printf( __( 'Posts classified under: %s', 'textdomain' ), '<span>' . $tax->name . '</span>' );
stackexchange-wordpress
{ "answer_score": 6, "question_score": 3, "tags": "custom taxonomy" }
convert from single site to multisite (network) with existing subdomains We currently use wordpress to manage our website under our main domain. We also have a few subdomain under which different applications run. www.example.com // our main website, running wordpress extranet.example.com // a custom-made LAMP application forum.example.com // another LAMP application *.example.com // anything can happen in there. We would like to use the Network feature to create subdomains in which each team can have its own communication tool based on wordpress + buddypress. Question: can i convert our main wordpress installation to Network with subdomain, without removing access to extranet.* and forum.* ? I read the manual, but it doesn't address the specific case where subdomains already exist and i'm afraid to break things up.
This seems possible to me. Most of this is related to server management and not only WordPress, so probably Server Fault also has interesting info on this. On the DNS side, you would create a wildcard to the server with WordPress, and define your other subdomains to the servers that host those (some or all of them can be the same as the WordPress server). Wildcards always have the least priority. For the server side it is useful to know that if a request reaches Apache but it finds no matching `ServerName` or `ServerAlias` in a `<VirtualHost>`, the first virtual host is returned. So you configure the WordPress setup as the first host and the others running on that server after it.
stackexchange-wordpress
{ "answer_score": 3, "question_score": 2, "tags": "multisite" }