INSTRUCTION
stringlengths
11
999
RESPONSE
stringlengths
0
999
SOURCE
stringlengths
16
38
METADATA
dict
Script to replace default blogroll with links to my social media URLs I've got a plugin that I ship with my theme whose function is to jumpstart the process of launching site so that its optimized for the theme. It has all my default pages, plugins, settings, etc... For example, I'm using the following script to remove the default blogroll links... $arr_args = array( 'hide_invisible' => 0 ); $arr_links = get_bookmarks( $arr_args ); foreach($arr_links as $obj_link){wp_delete_link($obj_link->link_id);} However, now I want to create replacement links to go in this listing. I want my social media links to go here. Basically, I want to create a list of 4-5 links (YouTube, Facebook, Twitter, LinkedIn, etc) Once I know how to insert bookmark links via script, I can place the css bits in my theme that I need to effect the look. Any ideas or examples for doing this?
Use wp_insert_link().
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "plugin development, blogroll" }
Troubles with making a custom template for posts Is it possible to make a template for all posts in a custom post type? For example I would like to be able to change an adsense ad or some other element on every post by simply editing a custom template. I have been experimenting with templates that are pretty static, but I am stumped on which one to copy/edit for the posts.
Yes it possible, take a look at **Template Hierarchy codex entry** to get a better idea but the simple answer is to create a template for all of you custom post type posts create a template and name it `single-{post_type}.php` so if your post type is named dogs then your template file should be named `single-dogs.php` and automatically this template file will be used to display all of the dogs post type posts and once you edit that file it will effect all of the posts of that type.
stackexchange-wordpress
{ "answer_score": 3, "question_score": 1, "tags": "custom post types, page template" }
Is there a plugin for rating of multiple questions for wordpress? I have developed a site in worpdress. I need to manage a different questions like "How would you rate our customer service", "How satisfied were you with our service" and more questions and rate these questions and have view on the admin. I tried to find the plugin but could not find. Can anyone let me know if that type of plugin exists or do I need to do with my own codes? Thank you in advance
Yes, there is a plugin - GD Star Ratings. I am using it here: < You can customize your questions, type of ratings (thumbs up/down vs stars) and much more. You can also configure it to have the ratings appear in your dashboard.
stackexchange-wordpress
{ "answer_score": 3, "question_score": 1, "tags": "rating" }
Adding custom Field To The Posts Listing Are there plugins or hooks to editing custom fields just from the posts listing in admin panel?
The easiest way is to use a plugin like Custom Field Template. This adds a custom field column to the "Manage Posts" page by default.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "plugins, custom field, plugin recommendation, hooks, admin menu" }
How to forbid users to change their first, last and screen names? I'm using Wordpress 3.1. I need to forbid users to change their first, last and screen names in their profile, but admin must still have this possibility. How can I do that?
Have a look at this question - Preventing users from changing their email address.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "php" }
Allow front end users to add data to a custom post type Hay Guys , I'm currently making a plugin so that the administrator can manage "Subscriptions" to the website. I have made a custom post type and activated it within WordPress and only allowed the title field. This works perfectly on the backend, but now i need a way for front end users to add their email address. How would i implement this, i need to add data to the database, i could easily just write some PHP to manually add the data, but does WordPress have any calls so that i can save data to the database?
Rake a look at wp_insert_post() which handles the insertion of new posts to the database. and there are many example how to create posts from the front end here, here, here, here and here:
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "custom post types, database" }
How can I run code in functions.php when switch_theme() is called? I've got some code inside functions.php which is designed to execute only when the theme is first activated: if ( is_admin() && isset($_GET['activated'] ) && $pagenow == 'themes.php' ) { //this code only runs when the theme is first activated } However, I'm pretty sure this code is not running if the theme is activated outside the normal activation process. For example, if a switch_theme() statement is called from a plugin. In that case, how might I alter my code above to execute on switch_theme()? if ( is_admin() && isset($_GET['activated'] ) && $pagenow == 'themes.php') OR (switch_theme_called() ) ) { //this code only runs when the theme is first activated }
Well, instead of using a $_GET parameter you could store a initiate state in your options-table. E.g. $initialized = get_option('mytheme_initialized'); if ( (false === $initialized) && is_admin() && ($pagenow == 'themes.php') ) { //this code only runs when the theme is first activated update_option('mytheme_initialized', true); } Unfortunately the "register_activation"-hook is only available for plugins -> <
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "theme development" }
A plugin for newsletter registration (not sending, just gathering data)? Most of the plugins I see also send the newsletter, which I don't need. I need a simple, customizable plugin that helps me get user e-mails, name, and other custom fields, and store it in the database. The plugin must also have an unsubscribe option, of course.
Contact Form 7 is pretty flexible. And there's the premium plugin, Gravity Forms, which a lot of people love. Or if you don't really need to keep the subscriber info in your own database, you could always use a service like MailChimp, for which there are WordPress plugins available for subscriber sign-up.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "plugin recommendation, newsletter" }
Where are the options "template" and "current_theme" derived from My theme is in a folder called "mytheme" and the "Theme Name" in the style.css is "My Theme". From that, I'm guessing that the option "template" in the options table is a reference to the folder, not the "Theme Name". I'm asking because I want to be sure that the value I should pass to switch_theme() is a reference to the foldername mytheme, not the theme name "My Theme" ? switch_theme('mytheme', 'style.css')
You'r right. The template-tag is based on your directory name. Same goes for a child-theme, which has a base theme as parent. Check out the search_theme_directories() function for more information.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "theme development" }
str_replace the_title(); blues I have a dilemma, well a new blog which im developing and a few of the posts titles are like this 'Tutorial: Build your first App' or 'Tutorial: Start your business with xensuithia' I have a page called tutorials that display the posts from this category. I need the title to not display the 'Tutorial:' part on this page, I tried: str_replace('Tutorial:',' ', the_title()); However it does not work. It just outputs the full title.
That's because the_title() echoes the title. Use this instead: echo str_replace( 'Tutorial: ', '', get_the_title() );
stackexchange-wordpress
{ "answer_score": 5, "question_score": 1, "tags": "posts, php" }
How to debug WordPress "Cron" wp_schedule_event How can I debug problems with WordPress Cron? I think it will trigger when users go to your site but any errors wont be shown to them, as the jobs are run "asynchronously". So how might I debug errors? I use `wp schedule event`
You can run WP cron manually by calling: ` If you don't want the automatic cron to run while you're debugging, then add this to your `/wp-config.php` file: define('DISABLE_WP_CRON', true); If you're on a development environment and want to output debug information, calling it manually like that will show you your debug output. Alternatively you can use PHP's built-in error_log function to log message strings to the error log for debugging. You'd need to use this in conjunction with WP_DEBUG settings, as mentioned by Rarst.
stackexchange-wordpress
{ "answer_score": 33, "question_score": 26, "tags": "cron" }
How to return the_excerpt (without echo)? Hey all, I see that get_the_excerpt() echoes the post excerpt if it is manually set, but not if it is automatically generated (with just the 55 words, for example). [and its use is deprecated] the_excerpt() on the other hand, echoes directly without giving me a string in return. Is there a function to return the excerpt of a post in Wordpress, including automatic excerpt if not manually defined, without echoing it?
Sure thing my friend, you see, the function "the_excerpt" (located at "WORDPRESSINSTALLDIR/wp-includes/post-template.php") is the one that makes the echo: function the_excerpt() { echo apply_filters('the_excerpt', get_the_excerpt()); } so, what you want is to use the same function "apply_filters" without the echo: $myexcerpt = apply_filters('the_excerpt', get_the_excerpt()); ...and there you have your excerpt.
stackexchange-wordpress
{ "answer_score": 4, "question_score": 3, "tags": "php, excerpt" }
WordPress 404 page returning with default in IIS7 I've installed a number of WordPress sites across many different platforms and I'm finding that when installed on IIS7 I'm getting the nasty default IIS7 404 error. I nuked Window's hold on the 404 and now I'm receiving the standard. > The resource you are looking for has been removed, had its name changed, or is temporarily unavailable. Is there an address I need to redirect to in order to display the WP404? Or does anyone have a better suggestion? Thanks a ton!
This resolved my 404 error. I essentially went into IIS and directed the 404s to a custom URL “/index.php?error=404“ Article that explained how to resolve the error
stackexchange-wordpress
{ "answer_score": 4, "question_score": 1, "tags": "theme development, 404 error, iis" }
How to *remove* a parent theme page template from a child theme? I'm using the TwentyTen theme to create a child theme, but I can't seem to get rid of the 'One column, no sidebar' page template that is in the TwentyTen parent theme. I thought just copying it over and deleting the contents would do the trick, but it seems not. Does anyone know how to do this? I'm sure it's very simple. Thanks osu
Overriding that template would be much easier than getting rid of it. Just the way logic goes. I make no claim it's efficient idea (late here), but this would get it nuked from edit screen: add_action('admin_head-post.php','remove_template'); function remove_template() { global $wp_themes; get_themes(); $templates = &$wp_themes['Twenty Ten']['Template Files']; $template = trailingslashit( TEMPLATEPATH ).'onecolumn-page.php'; $key = array_search($template, $templates); unset( $templates[$key] ); }
stackexchange-wordpress
{ "answer_score": 11, "question_score": 18, "tags": "customization, page template, child theme, parent theme" }
Disable all admin UI access to authors (except to custom post type add, edit and modify) I just created a custom post type named Catalog. Where authors can create as many entries they need. But I need to restrict/deny access to all admin parts: Posts, Profile, Media or other admin parts except their Catalog entries. Do I need to compare against $_SERVER['REQUEST_URI'] or theres a better way? Thanks in advance.
This is more difficult than it needs to be it seems. To code it without using a plugin I would suggest using `global $menu` and `global $submenu` as an array and unset them based on user role or user name. It might get more difficult if you want to define user role permissions outside default values. < You can find the values in wp-admin/menu.php , you must look in here. Or browse them here < For example if you want to unset a menu in a function it would be something along the lines of: function remove_menu() { global $menu; //remove post top level menu for editor role if current_user_can('editor'){ unset($menu[5]); } } add_action('admin_head', 'remove_menu'); // ($menu[5]) is the "Posts" menu You can see a much more detailed example here <
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "user access" }
Sync my svn repositories I use my own svn repositories for all my development. I am looking for an easy way to keep the svn repository wordpress provides for my plugin synced up with my own internal repository. The desired end result being that when I commit a change to my own internal repository it gets duplicated automatically to my repository at plugins.svn.wordpress.org. ANd just to make things fun and interesting, I do not have any access to the server where my svn repositorys are held, I use a svn hosting service.
Maybe the svn switch -- relocate repository option can help you here: svn switch --relocate oldURL newURL . ( < ) But... a lot more options here: <
stackexchange-wordpress
{ "answer_score": 1, "question_score": 4, "tags": "plugins, plugin development, svn" }
WordPress 3.1 removing 'category' from the slug Is there a way to remove 'category' from the slug when viewing posts in a particular category in WordPress 3.1 without it breaking? My client is asking me to remove it, but it seems necessary - I get a Page Not Found error when using this plugin: < He also doesn't want to just change it to another word...very frustrating... Thanks, osu
I didn't test it myself, but maybe this tip could solve your problem: > If you would like yoursite.com/category/projects/projectname/ to appear as yoursite.com/projects/projectname/ > > Simply enter /. as the value for Category base in the permalink settings page.
stackexchange-wordpress
{ "answer_score": 3, "question_score": 2, "tags": "customization, slug" }
Category "same post" retreive and display I have made a multiple category. Each item belong to one or more category. So when display one item, i like to retreive the category of this item, and display all post that have belong to that category. Example. Chair : cat = sit, leather, one person So when display the chair, i like below to display all item that have : sit leather and one person as category Is there a plugsin that do that ?, or in php it's simple to do ?
# according to your example: $categories = array ( 'sit', 'leather', 'one person' ); # get all id's by the category names foreach ($categories as $category_name) { $category = get_term_by( 'name', $category_name , 'category' ); $ids[] = $category->term_id; } # get all posts for the categories query_posts( 'cat='.join(',',$ids) ); Sorry, I cannot test it right now, this is just a guess till tomorrow.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "plugins, categories" }
Add "Page Revised" column to Admin How would I go about adding a column to the Page Admin area that would show the last revision date of all pages? Alongside the Author and Published Date columns? I need to keep an eye on the page edits that other users do, and right now, the Page Admin area will only show the published date for a published page and the last modified date of a draft. So I need to show the revision date by any user of each published page. Possibly complicating things is I have post/page revisions disabled in wp-config.php to keep the database down to size, so an action can't hook into already existing page revision metadata. But the database contains a `post_modified_gmt` metadata column, so can that be grabbed by a direct database query? Not a good idea? And would I use this kind of action? <
Would need some prettifying, but basic code is following: add_filter('manage_pages_columns', 'add_revised_column'); add_action('manage_pages_custom_column', 'echo_revised_column', 10, 2); function add_revised_column($columns) { $columns['revised'] = 'Revised'; return $columns; } function echo_revised_column($column, $id) { if ('revised' == $column) echo get_post_field('post_modified', $id); }
stackexchange-wordpress
{ "answer_score": 4, "question_score": 2, "tags": "wp admin, actions" }
remove inline scripts from the_content() produced by plugins? hey guys, any idea how I could filter all inline javascripts from the content()? thank you
Not tested, but I imagine add_filter('the_content', 'wp_kses_post'); will scrub it good. Might need playing with priority.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "javascript, content, filters" }
What do you think about custom designed plugin/theme options UIs? You probably noticed the trend of making custom designed plugin/theme options UIs, especially in the commercial ones (on CodeCanyon for example - custom boxes, tabs, accordions etc). I personally believe that UI should be unified in the first place and that is really easy in WP to achieve using some core's default HTML structure + CSS classes => following the styling guide. However it is maybe sometimes not enough and that's why why there is that trend. Another reason could be "branding" or just some "coolness effect". What do you think about this? Do you prefer some custom designed UIs or the default one and why? P.S. The main reason I ask this is also because these days I started with plugin development and I trying to make this decision of which path to choose.
Custom UI is great where it improves the experience and makes the task easier. After all, a plugin extends WordPress and therefore a lot of the time is extending the user interface. This might mean a screen that is arranged completely differently to any other screen, but if it is logical and understandable then there's no cause for confusion. Where custom styling is being used to 'brand' a plugin, it's just annoying and naff. Custom UI should respect the colour choice of the admin backend. I much prefer plugins that could be mistaken for being part of the core, and that should pretty much be the goal. So, respect the core UI but don't be restricted by it.
stackexchange-wordpress
{ "answer_score": 8, "question_score": 12, "tags": "plugin development, customization, design, user interface" }
WordPress Hook for user register how can I tell WordPress, that if a user registers, it shall execute my function?
You can use `user_register` action hook which fires after a user has registered and passes `$user_id` as a variable: add_action('user_register','my_function'); function my_function($user_id){ //do your stuff }
stackexchange-wordpress
{ "answer_score": 21, "question_score": 6, "tags": "plugin development, hooks" }
How to remove the Unattached filter on Media Library List? For example, at /wp-admin/upload.php are displayed the following filters by: All (6) | Images (6) | Unattached (6) How can I remove the "Unattached (6)" filter by? Thanks in advance.
As it turns out, with the introduction of the `WP_List_Table` class, view filter are now hookable and specifically you can filter out that detached link like so.. add_filter( 'views_upload', 'upload_views_filterable' ); function upload_views_filterable( $views ) { unset( $views['detached']); return $views; } Bye bye detached link!... :)
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "views" }
My wordpress site gets redirected automatically to the old site any known solution for this? I had recently moved my wp site from a domain to other, but when I type in the new domain's address it gets redirected to the old domain/some_page. Is this any common problem? Is there any known solution to this? I had checked my code and it has no redirects to this page. Can someone give me a hand on this?
This is because the URL settings inside WordPress are still pointing to the old WordPress site. More information is available in the Moving WordPress documentation. If your WordPress admin pages are still working, you can go to Settings → General, and change the WordPress URL and the Site Address to the correct values. If your WordPress site is completely broken, then you can add the following values to `wp-config.php`, which will have the same effect: define('WP_HOME', ' define('WP_SITEURL', ' Note that in most cases, WP_HOME and WP_SITEURL will be the same, apart from exceptional circumstances.
stackexchange-wordpress
{ "answer_score": 21, "question_score": 8, "tags": "wp admin, domain" }
Main menu - get rid of titles? I've got a default main menu: wp_nav_menu(); But it gives a list of links in a form: (...) <a href="link" title="PageName">PageName</a> (...) The very important question is, how to force WP to display it like: (...) <a href="link">PageName</a> (...) I don't like the yellow boxes appearing every time I hover anything in menu. I know it's possible, because I've seen it working, but no idea how? Filters maybe? Any ideas?
The title is an accessibility attribute that helps users with screen readers. It is part of the recommended WC3 standard for navigation items. Just think about that before you decide to eliminate it because you find it annoying. Rather than modifying the PHP code, you could think about removing it after it's loaded. It's very easy to do this with jQuery. First, add this to your `functions.php` file: wp_enqueue_script('jquery'); Next, in your `site.js` file, add this code: <script type="text/javascript" > jQuery(document).ready(function($){ $('.nav li a').removeAttr('title'); } </script> Again, I don't really recommend doing this, but this is how to accomplish it.
stackexchange-wordpress
{ "answer_score": 4, "question_score": 2, "tags": "menus" }
can I 'combine' categories as a menu item? I have custom post type and I want to have a menu where I combine category or categories from default Wordpress post type and from my custom post type. Let's say I have these categories * sport, books, movies, any in default post type * sport, books, school, any in my custom post type can I have a menu link where I would display * **sport** posts from both post types? * **sport, books** posts from default post type and **any** from my custom post type?
What I would suggest in this situation is that you create a "CUSTOM QUERY" to query the posts. Set this custom query into a page, then use Appearance > Menu's to add the page into your menu structure. I hope this helps.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "categories, link category" }
Where do I start from I'm student web developer and I'd like to know the things I should know before venturing into WordPress. Where do I start?
Glad your taking the jump into wordpress, wordpress is an amazing platform for developers and non-developers alike, if you have knowledge of PHP, HTML, CSS (and jQuery in some instances) you will enjoy working with wordpress. A great place to start understanding wordpress would of-course be the wordpress website itself. < I hope this helps, for more specific tutorials and tips / tricks i find myself scouring google every-time i need something.
stackexchange-wordpress
{ "answer_score": 8, "question_score": 4, "tags": "plugin development, theme development" }
PHP nested If statement syntax Hiya Guys! so I need some help with this: <?php $newsposts = new WP_Query('cat=restaurant'); if ( is_front_page()) { echo '<h3 class="member-review">Latest Restaurants</h3> <div id="extra">if ($newsposts->have_posts()) : while ($newsposts->have_posts()) : $newsposts->the_post(); <div class="reslogo"><img src="'echo catch_that_image()' /></div> endwhile, endif; </div>'; } ?> What I'm trying to do here is have an image slider of first post images (from restaurant category) display at the bottom of the page. I use DIVs to control placement/ style but I really need help with my PHP syntax ... I just cant figure it out... Any help would be greatly appreciated! Cheers
you can't run code inside quote since php treats it as string, try this: <?php $newsposts = new WP_Query('cat=restaurant'); if ( is_front_page()) { echo '<h3 class="member-review">Latest Restaurants</h3> <div id="extra">'; if ($newsposts->have_posts()) : while ($newsposts->have_posts()) : $newsposts->the_post(); echo '<div class="reslogo"><img src="'.catch_that_image().'"/></div>'; endwhile, endif; echo '</div>'; } ?>
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "php, code" }
adding a filter to a shortcode? <?php echo do_shortcode('[mingleforum]'); ?> inserts the mingle forum into my content! is it possible to use add_filter() on that?
You can change your code to this: <?php $shortcode = do_shortcode('[mingleforum]'); echo apply_filters('my_new_filter',$shortcode); ?> and then you can interact with that filter add_filter('my_new_filter','my_new_filter_callback'); function my_new_filter_callback($shortcode){ //to stuff here return $shortcode; }
stackexchange-wordpress
{ "answer_score": 2, "question_score": 5, "tags": "php, functions, filters" }
Why doesn't this page query work? This should be easy. I need to query to display one page in a tab. Just pull one page by one query, but I'm doing something (maybe lots) wrong here: **Edit: Hah. I forgot`the_content` It works now.** <?php $the_query = new WP_Query; $the_query->query ('pagename=about' ); while ($the_query->have_posts()) : $the_query->the_post(); ?> <?php the_content(); ?> //forgot this <?php endwhile; ?>
Hah. I forgot `<?php the_content(); ?>`
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "query posts" }
Is there a good Q&A platform to integrate into WordPress? I think my audience is more capable of answers each others' questions than I am. I need a system for them to do that and I'd like it to integrate with WP so I could use their existing usernames and accounts. Do you know of a good solution?
Have you heard of WP Answers? It is a plugin that appears to do exactly what you need. There are also some themes out there that do what you're after; after a quick comparison, the Answers theme by Templatic appears to be one of the nicer ones.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "community" }
Is there any way of copy/pasting, duplicating, or auto-generating posts for fast testing? I always find myself creating posts every time to test layout or design. For example, I create stuff like: > Content 1 > > Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. 6 times. Is there a fast way of copy pasting posts, duplicating them or auto-generating them, perhaps?
I use **Demo Data Creator** plugin with it you can create and set: * Number of users to create * Number of blogs per user (for WPMU/MultiSite) * Whether users must have a blog * Number of categories in each blog * Number of posts in each blog * Number of paragraphs in each blog post * Number of pages in each blog * Number of top-level pages * Number of levels to nest pages * Number of comments per post for each blog * Number of links in blogroll for each blog
stackexchange-wordpress
{ "answer_score": 3, "question_score": 3, "tags": "posts" }
Translate database content using __($message) function I've written a plugin that allows users to add information in the database. It runs well but I can't translate the information using WPML. This is a simple example of the problem: $message = 'test'; // here I get the information of the DB __($message, 'my-plugin'); Is there a way to workaround this problem? I don't know if we can use a variable instead of a string to translate. When I analize the widget in the Admin panel it don't show the string to translate. This example works in WPML because is a string: __('test', 'my-plugin'); Thanks in advance.
If you want to have variables in your text to be translated the usual way would be with string formatting like so: <?php printf(__("text %s text2."), $message); ?> with integers: <?php printf(__("text %d text2."), $count); ?> with more then one placeholders: <?php printf(__("text %1$s text2 %2$S."), $message, $message2); ?> but the variable it self will not be translated in no way. WPML doesn't run the code before `__();` or `_e();` function it only search the files for them, and that is why when you write something like this: $message = 'test'; // here I get the information of the DB __($message, 'my-plugin'); WPML only sees `__($message, 'my-plugin');` where $message is empty.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "plugins, plugin wpml" }
How do i login when i cant access wp-login.php? i have a self hosted wordpress install on a server in a virtbox at home. i was trying out plugins from the wordpress.org site, and after enabling some securtiy plugins, i found i couldnt access the wp-login.php page anymore. i get a function of one of the plugins telling me the site is forbidden and doesnt exist. the problem is, i am not exactly sure which plugin did this. i dont have a login link on the front end of the page also. the plugins i have installed are bulletproof security, lockdown wp-admin, ultimate security checker, and wp security scan. the install is on an ubuntu server with no GUI, host is mac osx, but i can access it from the network. if i just delete the plugins from the wordpress directory, will that work?
Assuming you have shell access to the server (which is sounds like you do), rename the `wp-content/plugins` directory to something else (I often just stick an `x` in front) and see if you can get into your site. Then create a new plugins directory and move the plugins one at a time from `xplugins/` to `plugins/`. You'll soon know who the culprit is.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "plugins, login" }
How to get post author name by its ID inside a function? i'm trying to get the author name using the "`the_author_meta`" function. After doing that I need to pass the value inside an array and return that with "json_encode". Let me show: $autor_id = $post->post_author; $autor_name = the_author_meta('user_nicename', $autor_id); echo $autor_name; The `$autor_name` `echo` works fine but when i do the following code it returns null on my script: ... $results['author'] = $autor_name; $posts[] = $results; } return json_encode($posts); it returns that: `"author":null` How can i make it display the author name like: `"author":admin`?
The echoing is already done by the_author_meta(). `echo $autor_name` does nothing. Correct would be to use get_the_author_meta().
stackexchange-wordpress
{ "answer_score": 8, "question_score": 4, "tags": "author" }
Should we localize custom-made themes / plugins? Does anyone know how much do the localization functions from WordPress affect the speed of a website? Do you think it's worth replacing all strings with gettext inside a theme, even if it will only be used on a single, english website?
If you know that you or the client will NEVER need to be translated there is no need to replace all the strings within your theme with gettext. Regarding the performance issue I found a benchmark **comparing the 3 gettex methods.** It also compared using the default local vs a different local and the differences were negligible which leads me to the conclusion that that you do take a performance hit when replacing all your strings with gettext. ### Benchmarks !enter image description here
stackexchange-wordpress
{ "answer_score": 3, "question_score": 0, "tags": "theme development, customization, translation" }
How to limit the posts I have a new question, how can I limit the amount of posts coming out of this query? I only need 7 <?php $newsposts = new WP_Query('cat=restaurant'); if ( is_front_page()) { echo '<h3 class="member-review">Latest Restaurants</h3> <div id="extra">'; if ($newsposts->have_posts()) : while ($newsposts->have_posts()) : $newsposts->the_post(); echo '<div class="reslogo"><img src="'.catch_that_image().'"/></div>'; endwhile; endif; echo '</div>'; } ?> I tried to put: `('cat=restaurants'.'limit=7')` but she no work. How did i go wrong? any help would be appreciated
It should be: $newsposts = new WP_Query('cat=restaurant&posts_per_page=7'); Another way to write it (helps readability with larger queries) would be: $newsposts = new WP_Query(array( 'cat' => 'restaurant', 'posts_per_page' => 7, )); See `WP_Query` in Codex for description of available parameters. PS would be good practice to add `wp_reset_postdata()` at the end. You are (correctly) not modifying main query, but you do change global `$post` variable with this loop.
stackexchange-wordpress
{ "answer_score": 11, "question_score": 3, "tags": "wp query" }
Why does WordPress append numbers to page slugs sometimes? How to reliably style based on page Why isit that WordPress sometimes add a number to my slug even if I explicitly set it. Like if I set slug to be 'about' I get 'about-2'. I want the slug to be correct so I can style using CSS easily. Or is there a better way?
WordPress appends a number to your slug when the database already contains a duplicate slug. It will append the number even if the duplicate post or page has been moved to the trash. The URL Routing system is one of the weaknesses of WordPress. **Mike Schinkel** made a very good proposal to **evolve the re write engine** on trac but the ticket was closed as "wont fix"
stackexchange-wordpress
{ "answer_score": 3, "question_score": 0, "tags": "theme development" }
How to restrict access to uploaded files? I have a restricted area on a website that can only be accessed by logged in users. For that I created a page template with a 'current_user_can()' condition. My problem is that the documents attached to the restricted pages are still accessible to anyone if you put the complete path into the browsers address bar. Is there a way to restrict the access to uploaded files ? EDIT : I want to clarify, the files should be accessible only to logged in users.
This isn't really a WordPress question - but you can add a rewrite rule to prevent access unless the referrer is your own domain. [Update] You'll need to do 2 things 1. Add a rewrite rule (either directly with .htaccess or by using WP_rewrite (Codex reference). The aim here is to deny requests to your documents that don't have your domain as a referrer - this stops people pasting the link into a browser's address bar 2. Wrap your download links in an `is_user_logged_in` (Codex reference) conditional block - that way they will only show up on the page if the user is logged in A code example is available in a related question: * protect wordpress uploads, if user is not logged in
stackexchange-wordpress
{ "answer_score": 7, "question_score": 9, "tags": "users, uploads, attachments, user access" }
Admin Bar CSS left over after removal I am using the following code to remove the admin bar (client request). add_filter( 'show_admin_bar', '__return_false' ); Trouble is, it leaves some autogenerating CSS, which places a massive white line at the top of my page in its place (via a 28px top margin rule). How can I turn this off as well?
To completely remove the Admin bar deregister the js and css using wp_degregister_script and remove the action. if (!is_admin() && !current_user_can('add_users')){ wp_deregister_script( 'admin-bar' ); wp_deregister_style( 'admin-bar' ); remove_action('wp_footer','wp_admin_bar_render',1000); }
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "admin bar" }
PHPlist & new posts notification? I know there are plugins out there for integrating the user base & sign-up, but are there any for using PHPlist to automatically send out newsletters of new posts? I'm really trying to avoid a from-scratch solution here, though if nothing is 'ready made' I'd appreciate any pointers or head starts ;)
Don't know of a plugin that does that but if you take a look at **WP PHPList plugin** or more specifically the way it **Interacts with phplist** using PHP CURL, it logs in to phplist as admin and save cookie using `CURLOPT_COOKIEFILE` and then simulates a post to subscriber form. So maybe going in that route you can do the same and simulate a post to send mail form. then all that is left is to hook you function to these hooks: add_action('new_to_publish', 'send_new_post_mail'); add_action('draft_to_publish', 'send_new_post_mail'); add_action('pending_to_publish', 'send_new_post_mail'); add_action('private_to_publish', 'send_new_post_mail'); add_action('future_to_publish', 'send_new_post_mail'); I know its not a complete solution but should give you a jump start.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "plugin recommendation" }
Building a Wordpress App I construction of a administrative back office inside the wordpress theme for running our travel company, monitoring users, bookings and payments, it has come to my attention that it might be better served and more secure if such an area were in face a desktop application or offline webpage that connected to the internet inly to get the date. So how would one connect to wordpress from html/php pages sitting on the desktops of relevant computers? And is that a sensible idea or not? Many Thanks,
I'm curious how/where you got the impression that desktop apps are more secure than the WP admin. For better security, you can enable SSL for the normal WP admin web interface, by adding this line to wp-config.php: define('FORCE_SSL_ADMIN', true); More info here: <
stackexchange-wordpress
{ "answer_score": 3, "question_score": 0, "tags": "php, admin" }
Background image in login showing in admin area I have customized my login screen with a logo using html{background:#E2DEAF url(.../images/login_logo.jpg) center top no-repeat;} because it is so wide. Usually would not tie something to the HTML element. works great BUT... it also shows up in the admin area. Anyway to prevent this? I only want it on the login.
Try selecting login body class instead of adding background to html tag. body.login { background:#E2DEAF url(.../images/login_logo.jpg); } You could also play with .page (pages only), .logged-in (logged users) and so forth :) Hope it helps.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "admin, customization" }
FTP file manager AS wordpress site Ok, maybe it a far fetch question, and a question about depersonalisation of something into something else, but let try. One on my client want a easy file bin for his client to go get the public HR file for publicity. The main company have the HR pdf and some newspaper or local advertising need it. Instead of sending those file by email, CD or free FTP like "senduit.com" a site will be created. A bunch of folder, with a bunch of file. Let say **Winter 2010 AD** * french ad 8.5 x 11 * english ad 8.5 x 11 **Summer 2011 AD** * french poster * English poster and so on, understand the concept ? So what will be the best plugin set or system for that... wordpress seem fit to that, but it's sont OUT OF THE BOX as this.. system should be secure, but's that just adding a password page.. that simple... What will be your solution ?
Perhaps WP-Filebase would be a suitable plugin for you.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "ftp, filesystem, file manager" }
How to get the first term for the current taxonomy? I'm using the following code to display the term for a specified taxonomy: $terms = get_terms( "book_review" ); $category = $terms[0]->name; However I want to display the term for whatever the currently displayed taxonomy is, rather than specifying a particular taxonomy. Basically what I'm wanting is a way to replicate the functionality of get_the_category, but for the current taxonomy instead of the current category. I'm trying to display this on a single custom post type page (single-custom_post_type_name.php)
### You can use `get_queried_object` to get the term name. <?php if( is_tax() ) { global $wp_query; $term = $wp_query->get_queried_object(); $title= $term->name; } ?> To display: `<?php echo $title; ?>` If your on a taxonomy archive page you can use: <?php $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); ?> Then to display the term: `<?php echo $term->name; ?>` _**The following properties are available for the $term object:**_ * term_id * name * slug * term_group * term_taxonomy_id * taxonomy * description * parent -count
stackexchange-wordpress
{ "answer_score": 2, "question_score": 2, "tags": "custom post types, custom taxonomy, terms" }
Query for tag given slug How might I query for a tag given the slug?
Hi **@JM at Work:** Like this: $term_slug = 'foo'; $term_object = get_term_by( 'slug', $term_slug, 'post_tag' ); print_r( $term_object );
stackexchange-wordpress
{ "answer_score": 0, "question_score": -1, "tags": "theme development" }
Custom sidebars - get_sidebar() problems I want to have different sidebars on different pages. So firstly I registered a few basic sidebars in functions.php. So they will be always there no matter where I move my theme. Let's name them Standard Sidebar, Special Sidebar, Tiny Sidebar. The next step was creating sidebars metabox below posts and pages. It lists all the sidebars using foreach $GLOBALS['wp_registered_sidebars'] loop and allows user to pick one. Now, here comes the trouble. I don't know how to display my sidebars. I have a meta value but get_sidebar() accepts only names from sidebar.php file. What about registered (not included in sidebar.php) sidebars? I know I could add all my sidebars to sidebar.php/save them as sidebar-name.php, but again, I'm going to use sidebar generator to add addtional sidebars to three basic ones. Any ideas, walk-troughs how to accomplish this? Displaying registered sidebars by name will be a serious breakthrough in my case.
You can call registered sidebars with the dynamic_sidebar() function. Just put the ID of the sidebar in to the call. In the case below the id would be homepage-sidebar. <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('homepage-sidebar') ) : ?><?php endif; ?>
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "sidebar, metabox, register sidebar" }
pre get posts changing the query i need to change the posts in taxonomy.php page. I have a meta_key which i want to compare to meta value. But currently my code is not returning anything. I am sure i am missing something. Please let me know what i am doing wrong! add_action('pre_get_posts', 'add_event_date_criteria'); function add_event_date_criteria(&$query) { // We only want to filter on "public" pages // You can add other selections, like here: // - Only on a term page for our custom taxonomy if (!is_admin() && is_tax('event-tag') || is_tax('event-category')) { $query->set('meta_key', 'start_time'); $query->set('meta_compare', '>='); $query->set('meta_value', time()); $query->set('meta_key', 'start_time'); $query->set('orderby', 'meta_value_num'); $query->set('order', 'ASC'); } }
Try using meta_query parameter : add_action('pre_get_posts', 'add_event_date_criteria'); function add_event_date_criteria(&$query) { // We only want to filter on "public" pages // You can add other selections, like here: // - Only on a term page for our custom taxonomy if (!is_admin() && is_tax('event-tag') || is_tax('event-category')) { $time = time(); $meta = array( array( 'key' => 'start_time', 'value' => $time, 'compare' => '>=' ) ); $query->set('meta_query',$meta ); $query->set('meta_key', 'start_time'); $query->set('orderby', 'meta_value_num'); $query->set('order', 'ASC'); } } also you need to make sure your meta field `start_time` is measured and saved in the number of seconds since the Unix Epoch like time() function.
stackexchange-wordpress
{ "answer_score": 6, "question_score": 2, "tags": "custom post types, custom taxonomy, query posts, actions, pre get posts" }
Suggestions for creative use of post format feature, or themes that use them well I'm looking for themes or examples of sites that use the post format feature in an interesting way. I suppose adding special styling for each post format would be a good start. But if anyone knows of it being used in a cool or creative ways by a premium or free theme feel free to chime in.
Check out this post on WordCast: WordPress Post Format Eye-Candy: Tumblr Style Theme Inspiration Showcase Also Digging into WordPress uses them and just wrote a post about it: Tumblr Links with Post Formats
stackexchange-wordpress
{ "answer_score": 1, "question_score": 3, "tags": "theme development, css" }
What action should I hook into when adding roles and capabilities? I'm going to be using add_role() and $role->add_cap() to set up a new custom role and attach a new capability to existing roles. I'm wondering where the best place to do this is? Obviously I can do it straight inside functions.php and be done with it. But is this the best practice? Do I only need to do this on admin_init? or should I do it on init? I'm not entirely sure what the best practices are around using init action hooks rather than just dropping a direct function call inside functions.php. thanks for your input!
When adding a role and capabilities you only need to run the code once since the roles and capabilities are saved to the database when using `add_role` or `->add_cap` functions so just like Andy said you can use `after_setup_theme` for this kind of action but add some kind of check so it only runs once, like register_activation_hook or using options: add_action('after_setup_theme','my_add_role_function'); function my_add_role_function(){ $roles_set = get_option('my_roles_are_set'); if(!$roles_set){ add_role('my_role', 'my_roleUser', array( 'read' => true, // True allows that capability, False specifically removes it. 'edit_posts' => true, 'delete_posts' => true, 'upload_files' => true )); update_option('my_roles_are_set',true); } }
stackexchange-wordpress
{ "answer_score": 11, "question_score": 12, "tags": "capabilities, actions, user roles" }
current_user_can on WordPress 3.1.1 I just upgraded to WordPress 3.1.1 and suddenly I'm getting the following error: `Fatal error: Call to undefined function wp_get_current_user() in /home/arisehub/arisehub.org/wp-includes/capabilities.php on line 1028` I've narrowed it down to my usage of "current_user_can" Example: ` if ( !current_user_can('manage_options') ) { add_action('admin_init','customize_page_meta_boxes'); }` Removing that reference to current_user_can removes the errors. Any ideas?
You are calling the function too early. The `functions.php` is included before `current_user_can()` is defined. **Never** do anything before the hook `'after_setup_theme'`: ## Example for the functions.php add_action( 'after_setup_theme', array( 'WPSE_14041_Base', 'setup' ) ); class WPSE_14041_Base { public static function setup() { ! isset ( $GLOBALS['content_width'] ) and $GLOBALS['content_width'] = 480; add_theme_support( 'post-thumbnails', array( 'post', 'page' ) ); add_theme_support( 'automatic-feed-links' ); add_theme_support( 'menus' ); add_editor_style(); add_custom_background(); // You may use current_user_can() here. And more. :) } }
stackexchange-wordpress
{ "answer_score": 6, "question_score": 1, "tags": "fatal error" }
Is there a browser plugin or method to find which php template an item is coming from? Is there a browser plugin or method to find which php template an item is coming from?
The Debug Bar together with the Debug-Bar-Extender will show you what template file is being used. !Debug Bar Extender showing the query template
stackexchange-wordpress
{ "answer_score": 5, "question_score": 4, "tags": "php" }
How to hide/redirect the author page I have a website where I let people subscribe. I would like to only show the author page for actual authors who have written a post. I wrote this code that checks for post the problem is I can't use a `wp_redirect` or include a template that uses it because then I get everyones favorite "cannot redifine headers header" message. I could display a "User has no post message but I think redirecting them to the main author page is a better option. if ( is_author() ) : ?> <?php $id = get_query_var( 'author' ); $post_count = get_usernumposts($id); if($post_count <= 0){ //This line could also be wp_redirect include( STYLESHEETPATH .'/author-redirect.php'); exit; } endif;?> Thanks
You can do this at an earlier moment by hooking into the right action, like `template_redirect`, which fires right before the template will be displayed. add_action( 'template_redirect', 'wpse14047_template_redirect' ); function wpse14047_template_redirect() { if ( is_author() ) { $id = get_query_var( 'author' ); // get_usernumposts() is deprecated since 3.0 $post_count = count_user_posts( $id ); if ( $post_count <= 0 ) { //This line could also be wp_redirect include( STYLESHEETPATH .'/author-redirect.php' ); exit; } } }
stackexchange-wordpress
{ "answer_score": 4, "question_score": 3, "tags": "templates, redirect, page template, author, wp redirect" }
Can't call external stylesheet for Wordpress admin (using wp_admin_css)? I tried the following: <?php function my_wp_admin_css() { echo '<link rel="stylesheet" href="/wp-content/plugins/custom-admin-style/wp-admin.css" type="text/css" />'; } add_action('wp_admin_css','my_wp_admin_css'); but nothing is being displayed in the Wordpress admin. What I'm doing wrong?
You need to use `wp_enqueue_style` and hook it into `admin_print_styles` add_action( 'admin_print_styles' , 'my_wp_admin_css' ); function my_wp_admin_css() { wp_enqueue_style('my_admin_style' , WP_PLUGIN_URL . '/myPlugin/stylesheet.css' ); } If you just want the stylesheet on your plugins page you can use: $mypage = add_management_page( 'myplugin', 'myplugin', 9, __FILE__, 'myplugin_admin_page' ); add_action( "admin_print_styles-$mypage", 'myplugin_admin_head' );   function myplugin_admin_head() {     // what your plugin needs in its <head> }
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "wp admin, css" }
Why is save_post hook not running? I am trying to save my meta box, I have something like function xxx_meta_box_callback() { add_meta_box('xxx-meta', 'xxx Details', 'xxx_meta_box', 'xxx-post-type', 'side', 'default'); add_action('save_post', 'xxx_save_meta_box'); error_log('meta box cb'); } function xxx_save_meta_box($post_id, $post) { error_log('running ...'); die('OK!!!'); } I am getting "meta box cb" ok in my error log, but `xxx_save_meta_box()` does not seem to run. Why is that?
Try this in your theme's `functions.php` file, or a `.php` file of a plugin that you may be writing: add_action('save_post', 'xxx_save_meta_box'); function xxx_meta_box_callback() { add_meta_box('xxx-meta','xxx Details','xxx_meta_box','xxx-post-type','side','default'); error_log('meta box cb'); } function xxx_save_meta_box($post_id, $post) { error_log('running ...'); die('OK!!!'); }
stackexchange-wordpress
{ "answer_score": 7, "question_score": 2, "tags": "metabox, hooks, troubleshooting" }
Archive Widget - Show selected Category Post title. Sorted by Year I need to add a widget to the sidebar that shows post titles sorted by year ie: 2011 POST TITLE 1 POST TITLE 2 POST TITLE 3 2010 POST TITLE 1 POST TITLE 2 POST TITLE 3 I was thinking of using the Archive widget to do this, but I dont know how to add the display post title bit and then have the YEAR display as a type of heading for all the posts under that year. This might not be the best way to go... Any thoughts or feedback would be greatly appreciated
Have a look at < Or if you want to code it yourself have a look at wp_get_archives <
stackexchange-wordpress
{ "answer_score": 0, "question_score": -1, "tags": "sidebar, archives, wp get archives" }
How to determine if post has widget content? I've got a registered sidebar called "my-header" that affects the absolute positioning of elements below it in the markup. So I need to execute a query in header.php to determine if the sidebar is present for the current post, and write out a class identifier to my theme's body tag. I'll use this css class to adjust absolute positioning of elements accordingly. Is there a method that can be called, separately from the method that's used to display the sidebar, to determine if the post has widget content for the "my-sidebar" widget? For example, one that just returns true/false? After looking through widgets.php, I tried using is_active_sidebar('my-header') but it returns true for all pages. I need a function that accepts the post as an argument. Otherwise, if none exists, I suppose I'll create my own function.
<?php $bodyclass = ""; // are we on a 'single' page? e.g. a post or page or some other custom post type? if(is_single()){ // is this a post of type 'page'? or is it a blogpost? global $post; if($post->post_type == 'page'){ // good now to check if we have a sidebar with active content if( is_active_sidebar('my-header')){ $bodyclass="wehavesidebarcontentyay"; } } } ?> <body <?php body_class($bodyclass); ?>> Though I'm sure if you have body_class on your body tag then you already have the needed css classes and selectors to do this without the PHP code.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 2, "tags": "theme development, widgets" }
Upgrade to 3.1.1 Fails When doing an automatic upgrade, I get this: Downloading update from < Unpacking the update… Could not create directory.: /public_html Installation Failed All my wp files are in /public_html and the directory already exists. The FTP user I am logging in as owns all the Wordpress files, so it cannot be a chmod problem. Is there any reason why this error is occurring?
I had this problem and the answer was found (a) in enabling ftp to write and (b) at least temporarily setting the directories to 777 although I think the latter permissions can be improved. I run vsftp with chroot'd users. After finding no mention in apache logs, setting the permissions to 777, changing ftp group to www-data, enabling anonymous ftp to write, tearing my hair out, kicking the dog etc etc the penny eventually dropped that ftp was not allowed to write. I also upgraded a multi-site to 3.1.1 and that needs 777 set (well probably less) but returns the files 640. It may be that a changed ftp configuration has tripped you up.
stackexchange-wordpress
{ "answer_score": 0, "question_score": -1, "tags": "customization, upgrade" }
All post ids are the same after this query but rewind_posts() does not seem to work here? I'm executing a query inside of header.php which is apparently resetting the $post object so that all pages are getting the $post->ID of the last element in this loop. $mypostsheader = get_posts(array('cat' => "$cat,-$catHidden",'numberposts' => $cb2_current_count)); $current_page = get_post( $current_page );?> <div class="menu top"> <ul><?php foreach($mypostsheader as $idx=>$post){ if ( $post->ID == $current_page->ID )//do something; } I've tried adding a rewind_posts() at the end of this function and also at the end of header.php but my echo $post->ID inside of page.php still returns the id of the last element in the query. Any ideas?
I found that one solution for this was to place a call to wp_reset_query() just before the close of the function call. I was trying to use rewind_posts() but it would not work. wp_reset_query() did the trick. After doing that, thanks to @goldenapples excellent observation that I was already setting a pointer to the current $post object with my $current_page variable (duh!), I found that I could dump the wp_reset_query() call and instead just add this line in its place... $post = $current_page; The root cause is that I was resetting the $post object in the for loop (as $idx=>$post) and the query had to be reset so that the value of $post was a true reflection of the current $post object for the page in function calls below header.php
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "theme development, loop" }
Added 20 Custom Fields. Only 10 showing in drop down Just like the title states. I've added around 20+ custom fields into my wordpress site and only around 10 are showing in the drop down. The custom fields are all functioning fine on the site side, but they just aren't showing up in the drop down. !enter image description here
There's a limit set inside the function that lists the meta data. < Run a filter on `postmeta_form_limit` to increase to your desired value, eg. add_filter( 'postmeta_form_limit', 'meta_limit_increase' ); function meta_limit_increase( $limit ) { return 50; } Hope that helps.. :)
stackexchange-wordpress
{ "answer_score": 6, "question_score": 3, "tags": "custom field" }
Website fully loads then immediately crashes in Internet Explorer The website I run www.detroitdungeon.com loads perfectly fine in every browser but in IE it crashes after loading. Any help would be appreciated!
When you want to debug any issue, follow these steps: 1. Check Firefox or another browser to make sure it's not a system issue but is, in fact, a browser issue. 2. Use the build-in debugger in IE to diagnose your problems. You've already done step 1. You've pointed out that the site works well everywhere _but_ IE. I did step 2 for you. * * * The site loads fine in IE until you hit the page onLoad event. Then, something fires that replaces your entire page content with the following: <div id="stimuli_overlay" style="display: none;"/> <div id="stimuli_lightbox" style="display: none;"> ... </div> This means your lightbox plugin is malfunctioning in IE. Try disabling it to verify (the site should start working in IE again). If it is the lightbox plugin, you'll need to find an alternative.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "pages" }
WordPress TwentyTen Theme Incompatible with Theme Unit Test I'm trying to test the comments template on a theme that is based on TwentyTen, using the the WP Theme Unit Test XML file, and there is one post that does not display comments properly. The post is called "Comment Test", and it contains 20 comments, including 2 pingbacks. The only thing that displays are the pingbacks. Is that the expected behavior? I can't seem to figure out why it's only displaying the pingbacks. Perhaps there is a setting I missed in the backend. The way to reproduce this, is to create a blog, apply the TwentyTen theme, and import the WP Theme Unit Test file: < Then visit the post called "Comment Test", published on March 3, 2008. You should see it say "20 Responses to Comment Test", and underneath it you should see 2 pingbacks, no comments. Thanks for you help, Dave
**Twenty Ten has beentested by the theme review team and it passes all the unit tests.** You can see how it looks on one of the demo test installs or another install I found. Try doing a fresh install of WordPress with a new database with no plugins.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "themes, comments, theme twenty ten" }
urlencoding of the_title() doesn't work? hey guys, `<?php urlencode(the_title()); ?>`doesn't take effect. this is my entrie line of code: `<li><a href="mailto:?subject=<?php urlencode(the_title()); ?>&amp;body=<?php the_permalink(); ?>">e-mail</a></li>` I don't want to have spaces in the_title(). Why does urlencode not work for me?
The `the_title()` echo the title. You must use `get_the_title()` instead. get_the_title() returns the title as string. Use <? echo urlencode(get_the_title()) ?>
stackexchange-wordpress
{ "answer_score": 7, "question_score": 3, "tags": "php, urls" }
Removing the first 8-10 letters from a post? I have a widget that shows all the post names. All the post names are "Chapter ## - Title" I would like the php in the widget to remove the "Chapter 1 -" or "Chapter 12 -" for example so that just the part after the Chapter is left....
This is a new query loop that I use that shows the latest ten post titles/permalinks in the category mycategoryname and strips the first 15 characters from all of the titles. <?php $my_query = new WP_Query('category_name=mycategoryname&showposts=10'); ?> <?php while ($my_query->have_posts()) : $my_query->the_post(); ?> <a href="<?php the_permalink() ?>" title="Permanent Link to: <?php the_title_attribute(); ?>"> <?php $mytitle = get_the_title(); $mytitle = substr($mytitle,15); echo $mytitle; ?></a> <?php endwhile; ?> If you need to select which posts to strip either 8 or 10 characters, you'd have to select them by some sort of criterea and alternate that character number.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "php" }
CRM and newsletter integration? I already use WordPress to create an online catalog and web presence. Now, a little box tells people to enter their email address, and they will receive an email when a new product is added to the site (which is useful). Now, having entered the email addresses manually or asked people to enter it, I would like to have a little CRM for managing those mails, getting the names, phones, emails, addresses, and references (why they are in the database) - all in WordPress. So when new content is added, or when I would like to send all those people info (mass mailing), I can use the same system as for managing my site. What solutions have you tried and used for this?
Check out Bill Erickson's Twentyten CRM Theme. It's a great theme for using WordPress as a CRM.
stackexchange-wordpress
{ "answer_score": -1, "question_score": 0, "tags": "user meta, plugin recommendation, cms, newsletter, mailing list" }
tinymce "Link" popup throwing error, not working I am unable to access the new lightbox-style link popup window. When I try to open it, I get an "error on page" message, and the popup doesn't appear. I've tried on ffx, ie & chrome, on a pc and a mac. I go to work and all is well, on all those same browsers, pc & mac. I can't find any pattern. I've logged out & back in again, cleaned cache, refresh, yada, yada. Does anyone have any idea what could be causing this and how i might fix it?
The problem turned out to be that I added some custom javascript further down the page hat was somehow ruining the tinymce popup js. I wasn't able to figure out exactly what was causing the problem, I needed to comment it out and it works okay now.
stackexchange-wordpress
{ "answer_score": 0, "question_score": -2, "tags": "links, tinymce, visual editor" }
esc_url removes white space. Can I change that to using '-'? I'm using esc_url to sanitize my url. The only problem is that "my link" becomes "mylink". I wouldreally like it to become "my-link". Is there a way to change this?
$url = esc_url ( str_replace(' ' , '-', $url ) ); Replace the spaces to - chars before activating esc_url function, and your problem is solved.
stackexchange-wordpress
{ "answer_score": 3, "question_score": 4, "tags": "sanitization" }
Wordpress home page doesn't work, but other pages do. How to rectify? < My blog home page is messed up. None of the plugins or sidebar widgets are working. Only the latest post is showed that too partially. However, other pages and posts (accessing through their URL) seems fine. < [page] < [post] I am not sure what exactly the problem is. Could anyone help me with this? Is there anything wrong with the wordpress settings? Else, something needs to be done with my server settings? **update** : I have hosted it with hostso in a shared hosting plan. I did not modify any WP files. My home page is a default WP home which shows the latest post. **update** _ _closed_ _ : The problem was with the json_last_error() method I used in the latest post. Somehow the method is no longer supported by my server it seems. It caused all the problems.
I believe the page is truncated due to a fatal error. Look for an error log file in the wp directory or add the following line to wp-config.php to hopefully see the error text: define( 'WP_DEBUG', true );
stackexchange-wordpress
{ "answer_score": 5, "question_score": 1, "tags": "errors, homepage" }
Pasting images removes class attribute When you paste an image with a `class` attribute in the Wysiwyg editor, the pasted image no longer has this `class` attribute. This makes it harder to copy and paste images that are aligned with the `alignleft` or `alignright` classes. This used to work in WordPress 2.7, but it no longer works in WordPress 2.8 and up. It also works in the "base" version of TinyMCE (tested with 3.2.7 and 3.3.9.3), so it is probably something that is added by WordPress. I tested this in Safari, Firefox 3.6 and Chrome on Mac OS X. This has been mentioned in a Trac ticket but the main item was dismissed as a browser issue - but I think the `class` issue is not. Has anyone else found a way to make this work?
Instead of pasting into the Visual editor, switch to the html editor for pasting any kind of html, or using shortcodes. I'd recommend checking the "disable the visual editor" checkbox in your user profile. Then install Mark Jaquith's _Markdown on Save_ plugin for more readable formatting without the wysiwyg pitfalls.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 3, "tags": "images, visual editor, wysiwyg" }
WordPress as a data-store? I would like to use WordPress to not only run my site, but also to manage users, handle authentication, and read/write content via a client application, but I would like to avoid writing everything from scratch on the PHP-side, as I don't know PHP that well. Is there a "Services" plugin similar to that in Drupal, or something else that can give me easy access to using WordPress as a data-store for a client application? Thanks much in advance for all of your assistance!
WordPress uses an XML-RPC interface in which you can define your own custom methods to it. And if server side coding is not your thing , then there are a few plugins that do most of the job for you: * WordPress Web Service * Extended API * WP RESTful
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "plugins, database" }
Return $post_id when DOING_AUTOSAVE? I see the following pattern over and over, on this site and on other places: add_action( 'save_post', 'wpse14169_save_post' ); function wpse14169_save_post( $post_id ) { if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { return $post_id; } // Other code... } Why should I return `$post_id`? `save_post` is an action, and the return value of an action handler is ignored. The WordPress core itself doesn't do it either. The Codex example does return the `$post_id`, but it would not be the first incorrect (or outdated) line in the Codex. Am I missing something? Do I need to return `$post_id`? Was there a there a time when this was needed?
The `'save_post'` action was added to core in 2.0, and has always been an action. Looking through the current autosave procedures, it doesn't appear to call the `'save_post'` action directly at any time. So the short answer is, no. There is no reason, and has never been any reason, to return any value on this action. Of course, it doesn't hurt at all to do return the post id.
stackexchange-wordpress
{ "answer_score": 5, "question_score": 8, "tags": "code, customization, save post, actions" }
Display navigation menu item conditionally based on user capabilities I have one "branch" of my main site's navigation tree that should only be accessible to a set of registered, logged-in users. I understand how to query a user's role and capabilities. This question is specifically about what is the best way to leverage the build-in nav menu, but just hide an item conditionally. Do I need to overload the built-in default navigation and write a custom query and build the navigation structure manually? I'd love to avoid this if possible. I don't need full code samples, just your ideas and general framework / approach. Appreciate the advice! T
Use your own walker and check the capability before you create an item.
stackexchange-wordpress
{ "answer_score": 5, "question_score": 5, "tags": "navigation, user roles, conditional content" }
Function to get image from media library Is it possible to retreive media image directly into the library... Something like get_media ('all') and it return a array with image url, caption, description etc etc..
Here you go: function get_media_all_wpa14177(){ $args = array( 'post_type' => 'attachment', 'post_mime_type' =>'image', 'post_status' => 'inherit', 'posts_per_page' => -1, ); $query_images = new WP_Query( $args ); $images = array(); foreach ( $query_images->posts as $image) { $images[]= $image->guid; } return $images; } ## Usage: $Images = get_media_all_wpa14177();
stackexchange-wordpress
{ "answer_score": 3, "question_score": 2, "tags": "media library" }
How to change default post type / post to media or attachments Im using wordpress 3.1.1, in frontpage i need to display only the media uploads, now im using this acction: add_action( 'parse_query', 'custom_query' ); function custom_query( &$query ) { $query->set( 'post_type', array('attachment') ); } add_filter( 'pre_get_posts', 'my_get_posts' ); function my_get_posts( &$query ) { if ( is_home() || is_frontpage() ) { $query->set( 'post_status', 'inherit' ); $query->set( 'post_type', 'attachment' ); } return $query; } But doesnt work. Any help is working.
You almost have it right, it should be `attachment` instead of `media` since all media uploads are "called" attachments" in WordPress, so: $query->set( 'post_type', 'attachment' );
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "query posts" }
Delete backgound for ID with conditional if statement how can I delete a background for #main only on my posts. I know that I have to create a conditional `if` statement in my functions.php file with `if (is_post())` but I'm just not sure how to write it.
Take a look at the classes offered by your body_class() function to your `<body>` element. Then overwrite your div with the ID `#main` on your posts page with a higher specifity and set this div to `display: none;`.
stackexchange-wordpress
{ "answer_score": 1, "question_score": -1, "tags": "conditional tags" }
Show widget differently depending on if it's in the sidebar or footer I've made a custom widget which shows thumbs of my latest videos. These thumbs are set to be 300px wide, which is the same width of my sidebar. My problem is that i also want to be able to use it in my footer where the width of widgets are only 220px wide. So basically what i want to do is: if the widget is shown in the sidebar use `<?php the_post_thumbnail('media-thumb-sidebar'); ?>`and if the widget is used in the footer use `<?php the_post_thumbnail('media-thumb-footer'); ?>` Anyone know how i could do this? Thanks :)
you can always get the thumbnail, but size it with CSS as Xavier mentioned.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "widgets, sidebar, footer" }
apache_mod_loaded setting can fubar plugins? I had a user recently who reported an issue with my plugin's options page not loading. They would click on the "settings" link but only got a blank page. There was also an issue with the rich text editor showing up on the category edit screen. I could not figure out why, on almost every other site but their's, the plugins loaded fine. We disabled all plugins except mine and still could not get the plugins to load properly. Some time passed and I got an email from the user that he had resolved the issue (WP 3.1 site) by editing the file wp-admin/includes/misc.php changing... $got_rewrite = apache_mod_loaded('mod_rewrite', true); To... $got_rewrite = true; Anyone have any insights into why the unedited file might cause issues with plugins?
I think it has to do with < > The problem appears to be localized around the use of ob_get_clean in the definition of apache_mod_loaded in the branch that has to parse phpinfo.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "mod rewrite, apache" }
Build page base on category I know how to hardcode that... but i like to have a plugin with shortcode that will make it for me... do you know any... If not, i will have to make it myself Have a page (blank) and build it base on post category. So in page xyz display all the post with category=abc. So the build page will display all the abc post back to back. Framework do that, but i only have a simple theme... how to do that ? And yes, i know that clicking on category will just do that, but it's less managable !
I dont quite understand how it's less easier to manage a category... So you have `Category -> Post` but instead you want `Page -> Category -> Post` It doesn't make sense in what you are trying to do. And and if your trying to link categories into pages just so you can include them in some form of navigation, WP3.0+ has the ability to link categories with `Appearance -> Menus`. And you don't really manage a category you just manage the posts associated to a category.
stackexchange-wordpress
{ "answer_score": 0, "question_score": -1, "tags": "categories" }
How do I list only children of a specific category in a drop-down? Okay, I think I'm pretty close. I have the following going on: $cat_id = get_cat_id('library'); wp_dropdown_categories('hierarchical=1&parent=$cat_id'); However, it doesn't work with $cat_id in there. It does work when I put the category's ID number in there (which I got when I echoed $cat_id), but obviously that presents a problem when I install the site on the real server. What should I try? Thanks!
If you change your single quote marks in to double quote marks it should work : $cat_id = get_cat_id('library'); wp_dropdown_categories("hierarchical=1&parent=$cat_id"); but if you really want to make it more flexible you can phrase your arguments as an array: $args = array( 'hierarchical' => 1, 'parent' => get_cat_id('library')); wp_dropdown_categories($args); and if you want to make it even more flexible to get the current category's children you can use `get_query_var('cat');` assuming that you are in your category.php file, so: $args = array( 'hierarchical' => 1, 'parent' => get_query_var('cat')); wp_dropdown_categories($args);
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "categories" }
Prevent Authors from viewing each others Posts I am setting up a site where there will be multiple users as Author, the owner doesn't want the authors to be able to view each others posts, since there are some meta fields with information he'd rather not have shared between the authors. Is there a way to remove the ability to view other authors posts? Thanks, Chuck To clarify a bit more, this is for the admin side, at the top underneath Posts, there are links for mine, all, and published. I only want Authors to see "mine".
If you want to prevent a user with the "Author" role to view other users' posts in the overview screen (they won't be able to view the details anyway), you can add an extra filter on the author: add_action( 'load-edit.php', 'wpse14230_load_edit' ); function wpse14230_load_edit() { add_action( 'request', 'wpse14230_request' ); } function wpse14230_request( $query_vars ) { if ( ! current_user_can( $GLOBALS['post_type_object']->cap->edit_others_posts ) ) { $query_vars['author'] = get_current_user_id(); } return $query_vars; } The little links above the post table ("Mine", "All", "Drafts") are less useful now, you can also remove them: add_filter( 'views_edit-post', 'wpse14230_views_edit_post' ); function wpse14230_views_edit_post( $views ) { return array(); }
stackexchange-wordpress
{ "answer_score": 14, "question_score": 6, "tags": "posts, author" }
$wpdb->get_row() only returns a single row? Why is it? I tried the same query in the console and it returned multiple rows. Here's the query: `$this->wpdb->get_row("SELECT * FROM ".$this->wpdb->users." WHERE status = 'active'", ARRAY_A);` It keeps returning the same single row when there are several active users. Am I missing something?
Indeed, use `get_row()` only when you expect to get one result, else you can use `get_results()`
stackexchange-wordpress
{ "answer_score": 62, "question_score": 37, "tags": "wpdb" }
Creating custom login errors I want to be able to create custom login errors. For instance if a user visits a restricted area without being logged in then I am redirecting to `wp-login.php?ref=access` and I would like to output `Restricted area, please login to continue.` or something similar. Any idea how to do this. I found that there are filters for `login_errors` but I can't find anywhere else in the code this comes up, except in the login page itself. Lastly, I really don't want to have to change any of the core files to do this either. I've spent a lot of time and energy trying to make sure that the wordpress core is completely untouched so that I can upgrade it. Anyone have any ideas? Thank you Tom
From quick look at the login screen code (ouch): add_action('login_head','ref_access'); function ref_access() { global $error; if( !empty($_GET['ref']) && 'access' == $_GET['ref'] ) $error = 'Restricted area, please login to continue.'; }
stackexchange-wordpress
{ "answer_score": 3, "question_score": 0, "tags": "login, errors" }
Implementing lazy loading in homepage posts instead of pagination I have lots of posts in my website. I have used `default pagination` function for paging the post list in _homepage_. But I wanted to implement `lazy loading` instead of pagination just like in _twitter_. I don't have any idea about it's implementation in _Wordpress_. Please help me with this.
Take a look at **Infinite Scroll** plugin which Automatically append the next page of posts (via AJAX) to your page when a user scrolls to the bottom.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "jquery, javascript" }
get parent fields title, content excerpt etc can't seem to get this but how can i load info in a child's page from its parent? ie, i'm looking at an attachment and i can get the parents ID easy enough but not sure how to get the parents title, excerpt etc. // attachment content above here then want to get and show some parents' content echo $parent = get_post_field('post_parent', $id); echo the_title(); // this still shows the childs title... any help appreciated! Dan
You can try `get_post($post->post_parent)` or `get_page($post->post_parent)` so if you do: $parent = get_post($post->post_parent); You can get the title like this: $parent->post_title; And anything you want, you can `var_dump($parent)` to see all the post info you can use.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "posts, query posts" }
Reason for Lowercase usernames I can see `validate_user()` calls `sanitize_user()` with strict argument as true, which means uppercase letters are not allowed too. In source code, I found this comment // If strict, reduce to ASCII for max portability. if ( $strict ) $username = preg_replace( '|[^a-z0-9 _.\-@]|i', '', $username ); I would like to know how does this affect portability?
Uppercase characters are not blocked in usernames on single site setups. Uppercase characters ARE blocked in usernames on multisite setups. The wpmu_validate_user_signup function forces lowercase a-z and numbers 0-9 only.
stackexchange-wordpress
{ "answer_score": 7, "question_score": 7, "tags": "sanitization" }
User Roles Not Sticking I have added a custom user role of super_poster, basically they make 20 posts and once they hit $postlimit get auto-moved back down to contributer level, the moving down and post counting works ok, my problem is that the wp system adds the user into "none" instead of into contributer role if ($count_posts >= $postlimit) { $current_user->remove_role( 'super_poster' ); $current_user->add_role( 'contributer' ); } contributer is set for new user default on sign-up, so the situation i have is in wp-admin user edit page i can see the newly moved (into contributer from super poster) has still got "additional capabilities of contributer" however user role dropdown says --No role for this site -- wp-admin users page shows the super_poster as in user group "none" what gives?
You might want to use `WP_User::set_role( 'contributor' )` instead. It unsets all current roles and sets the new one (the argument) too. So the above would be if ($count_posts >= $postlimit) { $current_user->set_role( 'contributor' ); }
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "customization, user roles" }
How is my non-published blog getting so much spam? A few weeks ago I created a new WordPress blog. I bought a new domain name for it, and I have not published/linked to the blog yet (because I wanted to get a few articles up first, I only have 2 so far). I have gotten about 10 spam comments already. I am confused how the spammers could be finding me?
What are your privacy settings? Go to **Dashboard -> Settings -> Privacy** If it is set to _I would like my site to be visible to everyone, including search engines (like Google, Bing, Technorati) and archivers_ , then your site is actively being crawled/indexed by search engines, and thus visible to spammers. If it is set to _I would like to block search engines, but allow normal visitors_ , and you're still getting spam comments, then that would be a bit more surprising. In that case, you might want to look at disabling comments, or looking at some anti-spam solutions.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "spam" }
Importing Direct to DB - GUID Question I've got a CSV file of new posts which I'll be importing straight into the database. Is it safe to give a GUID of ` where `[n]` is any number, as long as it's not a duplicate of an existing post?
Short answer: **yes** The GUID field is meant to represent a globally unique identifier for the post. In WordPress we just happen to use the URL. The GUID field should never be thought of as an actual URL, though ... just an identifier for the post. In reality, the GUID field could contain anything that's unique. But if you have two posts that share the same GUID, you might want to consider bumping one or the other. Importing the CSV of posts into an empty blog and using the WordPress Import/Export mechanism would help. Or setting `[n]` to be the ID the post _will_ have after import.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "database, import, guids" }
Change URL for Blog? Using WP 3.1.1 as a CMS, using the Boldy theme. Home page is at < Advantage of using this theme, is that it comes setup with a homepage that has a gallery slider and some homeboxes at the bottom. To get to the blog, I had to dump all my posts into a category called blog. \- The themes docco advises to do this]3. I can then link to this blog category from the top menu. This then passes me to this URL: **I want to know how to retain the home page provided by Boldy, but have the blog on a separate page with the following URL:** _dekho.com.au/blog_
First, you need to change your Front Page settings: 1) Create a _Static Page_ , called "Blog" (and a slug of "blog") 2) Create another _Static Page_ , to serve as your site Front Page 3) Go to Dashboard -> Settings -> Reading 4) Change "Front Page Displays" from "Your latest posts" to "A static Page (select below)" 5) In the "Front Page" dropdown, select the Static Page that you created to serve as your site Front Page 6) In the "Posts Page" dropdown, select the Static Page "Blog" Next, you need to fix your permalinks: 1) Go to Dashboard -> Settings -> Permalinks 2) Select one of the default options ("Month and Name" is usually good) 3) Save settings, to write the rewrite rules to .htaccess Now dekho.com.au/blog should be displaying your blog posts index
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "url rewriting" }
Get terms by taxonomy AND post_type I have 2 custom post types 'bookmarks' and 'snippets' and a shared taxonomy 'tag'. I can generate a list of all terms in the taxonomy with get_terms(), but I can't figure out how to limit the list to the post type. What I'm basically looking for is something like this: get_terms(array('taxonomy' => 'tag', 'post_type' => 'snippet')); Is there a way to achieve this? Ideas are greatly appreciated!! Oh, I'm on WP 3.1.1
Here is another way to do something similar, with one SQL query: static public function get_terms_by_post_type( $taxonomies, $post_types ) { global $wpdb; $query = $wpdb->prepare( "SELECT t.*, COUNT(*) from $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id INNER JOIN $wpdb->term_relationships AS r ON r.term_taxonomy_id = tt.term_taxonomy_id INNER JOIN $wpdb->posts AS p ON p.ID = r.object_id WHERE p.post_type IN('%s') AND tt.taxonomy IN('%s') GROUP BY t.term_id", join( "', '", $post_types ), join( "', '", $taxonomies ) ); $results = $wpdb->get_results( $query ); return $results; }
stackexchange-wordpress
{ "answer_score": 12, "question_score": 18, "tags": "custom post types, custom taxonomy, terms" }
Contact Form 7 - Show image on successful send? I am running Contact 7 form, and looks good for my needs. I have added it to Wordpress, for people to suggest ideas for our product. When users send an idea, they are given a message to say thanks. This message is configurable via the settings for the form in wp-admin !enter image description here Does anyone know how I could get Mr Burns to appear once they have successfully sent an idea? i.e. Make a picture visible, and ideally place the picture to the side of the contact form.
You can customize the "Your message was sent successfully. Thanks." message with-in the the form's edit page at the bottom !enter image description here so add something like this: Your message was sent successfully. Thanks.</p> <p><a href=" width="234" height="369" alt="" src=" class="alignnone"></a></p> **Update:** Just tried and it works with this exact code.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "plugins, plugin contact form 7" }
WP Create User - Preventing repeated information I am using the <?php wp_create_user( $username, $password, $email ); ?> function in a contact form to create a subscriber when the user enters infomation on the contact form, thus in the background adding their email address to the database and giving them an account for site access. Does this way of doing it though not mean that if a user sends 3 messages from the contact form they end up with 3 accounts with the same email address, or will it check to see if the email address or user name already exists. Any ideas?
The function `wp_create_user` calls `‪wp_insert_user‬` which check to see if `$username` and `$email` already exists and if so it returns a new WP_Error so you wont have duplicate users in your database and it wont send the new user email more then once, but i'm not sure if that is the best way to do that.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "users, email" }
Switching From HTML to Visual Editor and Back Completely Strips Page Contents I have a page (not a blog post) I need to embed an iframe on (it's to "integrate" an external service's product catalog). I added the iframe code in the raw HTML editor and saved the page. I viewed the page, everything worked. I went back to the editor and switched from raw HTML to the Visual editor tab, added a line of text, and then remembered I needed to add an attribute to the iframe code. So I switched back to the raw HTML tab. When I did this, the post is completely empty. Everything I'd entered in the editor in raw HTML or not was stripped out and the post is blank, like I'd just created it new. I had to roll back to a revision to recover it. So far the solution has been to disable the Visual editor, but I have a non technical partner and that isn't an ideal long term solution. Is there any way to control this behavior of WordPress? I'm using WordPress 3.1.1 Thanks
I've had this code in a custom local plugin for a while. Or you could just stick it in your theme's `functions.php`: // Allow iframe in TinyMCE function tinymce_add_iframe( $arr = array() ) { $extra = 'iframe[id|class|title|style|align|frameborder|height|longdesc|marginheight|marginwidth|name|scrolling|src|width]'; if ( isset( $arr['extended_valid_elements'] ) ) { // append to existing value $arr['extended_valid_elements'] .= ',' . $extra; } else { // set the value $arr['extended_valid_elements'] = $extra; } return $arr; } add_filter('tiny_mce_before_init','tinymce_add_iframe'); This tells TinyMCE (the visual editor) to allow the `iframe` tag and all of its attributes.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "html, visual editor" }
How can I change the theme of different posts using a plugin? I'd like some posts to look different from others. Wordpress let's me easily switch themes for pages, but not posts. Is there a plugin that will let me do that for posts?
<
stackexchange-wordpress
{ "answer_score": 3, "question_score": 0, "tags": "theme development, themes, theme options" }
Redirect to another page using contact form 7? I'm using CF7 to send some information to my email and everything's working fine, but I need to redirect the users to a different page after the email has been sent, by default the forms are sent to the same page via ajax, I was thinking about setting a hidden field with the page url but since the form submits asynchronously I don't know how to set it in my page template. If the form was submitted normaly I'd do something like: if (isset($_REQUEST['hidden_field_url']) { wp_redirect($_REQUEST['hidden_field_url']); } So is there any way to send the form without ajax? Or maybe do what I need in any other way? Thanks in advance!
Got it, needed to add this to the additional settings option: on_sent_ok: "location = '
stackexchange-wordpress
{ "answer_score": 3, "question_score": 0, "tags": "customization, ajax, forms, plugin contact form 7" }
Passing meta_box string to post__in? Hey Guys, I'm using a meta box to store a bunch of page ID's. When I try to pass the page ID's to the post__in parameter of WP_Query it doesn't work becuase the metabox comes throug as a string, when it needs to be a comma separated integers. So, say the "relatedpages" meta box contains: 55, 33, 22 $relatedpages = get_post_meta($post->ID, 'relatedpages', true); $args = array( 'post_type' => 'page', 'posts_per_page' => -1, 'order' => 'ASC', 'orderby' => 'menu_order', 'post__in' => array($relatedpages) ); $myposts = get_posts($args); echo $myposts; The problem is that $related pages is now "55, 33, 22" rather than 55, 33, 22 How can I overcome this? Is there a way to store just the integers in the meta box, rather than converting them to a string? Thanks, Drew
'post__in' => explode( ',', $relatedpages )
stackexchange-wordpress
{ "answer_score": 3, "question_score": 0, "tags": "custom field, wp query" }
ASCII titles with Yoast SEO plugin I'm finding that SEOmoz is showing page titles with ASCII when indexing my customer's site < I'm concerned that this is how search engines will index the site. I'd love to remove commas and apostrophes but it would change the sentence structure entirely. Is there a way to clear up this formatting? Spokane &amp; Coeur d&#039;Alene&#039;s top fencing installers - Bulldog Fences Inc. !enter image description here
ASCII characters will not cause any issues with search engines and they will be displayed properly. SEOmoz does this to avoid any chance of sql injection via its form fields.
stackexchange-wordpress
{ "answer_score": 4, "question_score": 0, "tags": "seo, title, plugin wp seo yoast" }
Where is the code that set the background image in TwentyTen theme? I am developing a theme for my blog using Twenty Ten as starting point. Now, I am trying to understand how it manages the background image that can be set in theme options but I wasn't able to find the code. Can you help find where is that implementation?
This is native WP feature, it is set up in Twenty Ten with simple `add_custom_background()` call in `functions.php`.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "theme twenty ten" }
Embed a page within WordPress dashboard? We're using Facebook Comments for the comment functionality on our WordPress blog. I thought it'd be nice to embed the page with Facebook Moderation tools on the WP Dashboard. That way, we can immediately see who commented on what when we log in. I've looked for the functionality to embed an html page in a dashboard widget but I haven't managed to find something. Does anybody know if this is possible?
function facebook_setup_function() { add_meta_box( 'facebook_widget', 'Facebook Moderation Tools', 'facebook_widget_function', 'dashboard', 'normal', 'low' ); } function facebook_widget_function() { include ('facebook.php'); } add_action( 'wp_dashboard_setup', 'facebook_setup_function' ); add the above to your functions file and replace the include url with the php file you wish to include into your dashboard. # Setting it up ; Use the facebook.php and add an iframe to it, or ajax call to load the facebook tools, then simply just echo that file into your dashboard page :)
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "comments, facebook, dashboard, moderation, embed" }
How to Check If A Plugin Is Enabled Through API? How to find out if a particular plugin is enabled in a sub-blog in a multisite blog?
Hm, I am not entirely sure about mechanics here. Usual `is_plugin_active()` checks if plugin is in `active_plugins` option. By this logic you could probably retrieve `active_plugins` of specific blog with `get_blog_option()` and check it for plugin.
stackexchange-wordpress
{ "answer_score": 6, "question_score": 4, "tags": "plugins, multisite" }