INSTRUCTION
stringlengths
11
999
RESPONSE
stringlengths
0
999
SOURCE
stringlengths
16
38
METADATA
dict
How to import WP XML file automatically on installation? I'd like the user to install WP and have the default content loaded automatically but i don't want to have to write in in PHP in the wp_install_defaults(); I'd much rather export an xml file each time i make a change to the default and just bundle that with the install. Thanks.
have a look at the file wp-admin/includes/import.php, you'll find the necessary functions in there.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "installation, customization" }
Replacing the default content created while the site creation How do you replace the default title for first comment? **Mr WordPress on Hello world!** I could not able to locate this in theme's comments.php file I want to edit the title 'Mr wordpress on Hello world' to Admin on -Site Name- * * * How can I replace the default text created with about us page? _This is an example of a WordPress page, you could edit this to put information about yourself or your site so readers know where you are coming from. You can create as many pages like this one or sub-pages as you like and manage all of your content inside of WordPress._ to It is the page about your self.Feel free to edit the page * * * Some times I cannot able to locate certain content(As I mentioned above comment.php and default about us page) in core files when perforimg search .is there any way to find certain content or code overall? * * *
I can only answer your first two questions as I do not know anything about multisites. The default comment and content in the 'About Us" page is not coming from the theme files, but rather the database. They are the default posts/pages/comments accessed by the backend not by the theme files. To get to this content and replace it login to the admin via youraddress.com/wp-admin and locate the about page in pages > about us. The comments are under the "Comments" section. Simply delete the page or replace the content.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 2, "tags": "multisite, comments, customization, core, code" }
How do I create a Custom Post Box that Connects Different Posts Together In WordPress, I'm trying to create a Custom Post Box that will allow one post to be manually connected to another post. The easiest way to illustrate this request was to mockup what I would like the final Post Box to look like. That mockup can be viewed here » < **Requirements:** * The Post Box needs to resemble the "Categories" Post Box, in that it has tabs at the top and checkboxes. * Each tab at the top of this Post Box needs to be a Post Category (as illustrated in the mockup.) If I could manually control this so that the tabs were managed by a Custom Menu (ie. "Post Connections Menu"), that would be ideal. * The checkboxed list of items needs to be posts that have already been categorized to that specific category. Thank you very much for any help / insight you can throw my way!
Hey Mike -- does it need to be connected to _another post_ , or can it be a custom taxonomy or custom field?
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "customization" }
Changing the comments link produced by the get_comments_link() and get_comments_pagenum_link() functions Currently my theme calls upon `get_comments_link()` to create the standard anchor **#comments** to link to the comments below the post, as does the `get_comments_pagenum_link()` function on paginated comments. I would like to replace the **#comments** anchor in these functions with any other string, without of course changing WP's core php files. A simple `add_filter` to completely replace core functions (other than in pluggable.php) doesn't seem to be possible. Are there any other ways of achieving this small change to the output of a core function, that use PHP (rather than say Java)? Is there a way here of using an `add_filter` with `str_replace()` perhaps? This will be useful for foreign language sites, and for redirecting comments to another page with a url request, for example.
So the solution to the `get_comments_pagenum_link()` function is straightforward enough: add_filter('get_comments_pagenum_link' , 'new_get_comments_pagenum_link'); function new_get_comments_pagenum_link($content) { $content = str_ireplace('#comments' , '#other', $content); return $content; } Which filters the output of `get_comments_pagenum_link()` to replace **#content** with **#other** , or any other string you might choose. For the `get_comments_link()` function, which can't be filtered, I have simply discovered that my WordPress theme uses it already within its own comments link function, and so have filtered this theme function instead, using the same method shown above.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "comments, links, pluggable, core" }
What is the difference between feeds served by my WordPress install vs feeds served by FeedBurner? What is the difference between feeds served by my WordPress install vs feeds served by FeedBurner? How to disable hosted Wiordpress feed completely and use feedburner?
Here are some reasons I think FB does well: * feed statistics: subscribers, item view and clicks * email subscription: control email template, subscribers * sharing posts on social networks with FeedFlare * monitize with Google Adsense * reduces CPU usage on your host. Some of above features you can do with plugins, but it costs CPU usage and sometimes host space. With FB, you let FB do all of these stuff without any prices. FB has its own plugin that redirects WP feed to FB automatically, you can find it in FB.
stackexchange-wordpress
{ "answer_score": 3, "question_score": 3, "tags": "plugin recommendation, customization, feed, feedburner" }
Transient RSS feeds in wp_options not removed automatically? I just noticed 55.000 entries(!) in my wp_options table. I had not been there for a while. So I ran: delete from `wp_options` where `option_name` like '_transient_timeout_rss%' delete from `wp_options` where `option_name` like '_transient_rss_%' And... it is now back to 645 entries... How can I have these older RSS entries removed automatically since transient seems to be eternal. Could It be that on my webhost cron is not working?
Yep, this does seem like a cron issue. Core Control plugin is good to diagnose cron tasks (among other things). I am still unsure what is the reason of you getting overrun with feed transients. However I had written some code that might help with automatic cleanup.
stackexchange-wordpress
{ "answer_score": 4, "question_score": 3, "tags": "database, cron, options" }
Editing theme files and access to the Code pages only to super-admin? When I deal with Multisite installation.Some themes like mystique and aparatus provide the widget areas with in the theme-settings page to enter Advertising codes in the form of HTML or java script .But I want the 'Ad code Boxes' to access only by super admin(Me on my Multisite) and not by Normal admins .Can I make that boxes available only to me?
If that is custom functionality in theme options page then it is highly specific to that theme. Likely you will need to edit theme files and/or create child theme. Plus option pages can be simply in WordPress API but just as well can be built with help of theme framework or other kind of third party code. I think your first stop should be developers of themes and information on how to best work with their option pages.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 3, "tags": "themes, multisite, plugin recommendation, customization" }
Does WordPress Allow Blank/Empty Comment Submissions In WordPress? I've got a great Comment Form and Threaded Comments setup by using the native WordPress functions: `comment_form` and `wp_list_comments`. However, I'm trying to also create a custom Contest Comment template for certain posts. I call `comments_template('/contest-comments.php', true);` conditionally based on whether a certain custom field exists or not. It works great. I'm trying to make it look along the lines of < I only want to show the person's name wrapped in a link and their avatar. Therefore, I want my comment form to only show the Name, Email, and URL fields. The text area should be hidden. For the Comment Form, I am passing an empty value for the `comment_field` key in the `$args` array I'm passing into `comment_form`. This makes the comment form look okay, but when someone submits a comment, they get a warning from WordPress saying that their message was blank. Any solutions on how to solve this? Thanks!
Short answer: It doesn't, but you can get around this: add_filter('comment_form_field_comment', 'my_comment_form_field_comment'); function my_comment_form_field_comment($default){ return false; } add_action('pre_comment_on_post', 'my_pre_comment_on_post'); function my_pre_comment_on_post($post_id){ $some_random_value = rand(0, 384534); $_POST['comment'] = "Default comment. Some random value to avoid duplicate comment warning: {$some_random_value}"; } If you want this only for certain pages, then you should create a custom page template, for eg "boo.php", and in the code I posted above, only add these filters if the current page template is boo (use `$post->page_template` to get the current page template when doing the check). Related questions: * Removing the "Website" Field from Comments and Replies? * Comment form validation
stackexchange-wordpress
{ "answer_score": 7, "question_score": 3, "tags": "comments, customization, comment form" }
query users by role I have a custom plugin which queries users and usermeta, but I now need to filter admins out of the results. A very simplified version of my sql query is: SELECT * FROM usermeta LEFT JOIN users ON users.ID = user_id WHERE meta_key = 'last_name' AND user_role != 'admin' ORDER BY meta_value ASC LIMIT 0, 25 `user_role` is not a field, and i saw how it is stored as a config string, but i don't see how to make an equivalent query to this. Am i missing something? Thanks.
You can use this function: // get users with specified roles function getUsersWithRole( $roles ) { global $wpdb; if ( ! is_array( $roles ) ) $roles = array_walk( explode( ",", $roles ), 'trim' ); $sql = ' SELECT ID, display_name FROM ' . $wpdb->users . ' INNER JOIN ' . $wpdb->usermeta . ' ON ' . $wpdb->users . '.ID = ' . $wpdb->usermeta . '.user_id WHERE ' . $wpdb->usermeta . '.meta_key = \'' . $wpdb->prefix . 'capabilities\' AND ( '; $i = 1; foreach ( $roles as $role ) { $sql .= ' ' . $wpdb->usermeta . '.meta_value LIKE \'%"' . $role . '"%\' '; if ( $i < count( $roles ) ) $sql .= ' OR '; $i++; } $sql .= ' ) '; $sql .= ' ORDER BY display_name '; $userIDs = $wpdb->get_col( $sql ); return $userIDs; }
stackexchange-wordpress
{ "answer_score": 5, "question_score": 1, "tags": "plugin development, mysql, user roles" }
Filter WP_Query for posts having a certain meta-value How to filter WP_Query for posts having a certain meta-value, without using a Custom Select Query? I have a custom posttype with meta-key: "open", and meta-value options: "yes" or "no". I would like to show posts only with meta_value = yes, for meta_key = "open". function filter_where($where = '') { $open = "yes"; //$where .= " AND post_date > '" . date('Y-m-d', strtotime('-2 days')) . "'"; return $where; } add_filter('posts_where', 'filter_where');
I am not sure from your wording if you hadn't tried it with query argument or it didn't work? $the_query = new WP_Query(array( 'meta_key' => 'open', 'meta_value' => 'yes' )); Custom Field Parameters in Codex.
stackexchange-wordpress
{ "answer_score": 13, "question_score": 7, "tags": "custom field, filters, wp query" }
How to list posts from a plugin taxonomy? I would like to query posts from a taxonomy created by a plugin (WP Business Directory Manager). How would I do this? I want the query to create html listing of the posts and allow me to list a certain amount, show the associated image to the posts, and a small excerpt. Some examples on wp stack exchange seem like they would help, but might be different in my case. Thanks a lot.
To query by taxonomy you need to know its `query_var` that is used in its `register_taxonomy()` call. It defaults to taxonomy name so usually equal to that. Then you use that info in query argument: query_posts( array( 'query_var' => 'term' ) ); See Querying by taxonomy in Codex. It is hard to suggest more without specifics of your taxonomy and where you need it done (template, standalone function, etc).
stackexchange-wordpress
{ "answer_score": 3, "question_score": 0, "tags": "php, query posts, functions" }
Default admin color scheme as "blue" I don't like the grey one and i'd rather not change each user. Thanks.
I don't see easy way to change default so far, `fresh` color scheme seems to be hardcoded in plenty of places. If you just need to force some specific scheme for all users it can be done with this: add_filter('get_user_option_admin_color','change_admin_color'); function change_admin_color($result) { return 'classic'; }
stackexchange-wordpress
{ "answer_score": 3, "question_score": 1, "tags": "admin" }
How to use widget in a widget-less WordPress theme? I have a widget-less WordPress theme to which I want to add Subscribe by Email functionality. Unfortunatly the plugin only comes in the form of a widget. How can I use the widget functionality without widget support.
It is a little bulky for complex widgets, but you can call any widget in any place (no sidebar required) with `the_widget()` function.
stackexchange-wordpress
{ "answer_score": 4, "question_score": 0, "tags": "theme development, widgets" }
Help with WP Business Directory Manager Plugin? I'm using the WP Business Directory Manager plugin and I'm having some problems. The developer hasn't been supporting the plugin lately, so here I am. * I need to change the field order. Currently the option is there, but it doesn't work. * I need to target the field for CSS purposes, with custom classes/ids * And I need to be able to query the post from certain categories from its directory. I would want to post different list on throughout the site and Im not sure how to do that. The plugin is very useful, I just need some help with these issues...PLEASE. Thanks for any help that can be provided.
To change the field order, you can delete all the fields and then add them again in the order of your choosing. Sucks to have to do it that way, but whatever. It's a free program.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "plugins, php, functions" }
How can i initialize a widgetized sidebar (with widgets) I have a WordPress multisite installation. The client wants an email update form on the sidebar of every blog. I want to use a widget there so I need to assign it to the sidebar. Is there any way to do that on the theme install ?
yes. preset widgets: Possible to preset a widget's contents via a plugin script? post your widget code here if you need specific instructions
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "theme development, widgets" }
Run functions only in the admin area? I'd like this code to only run inside the admin area as it is resorting the items on the public side admin bar too. /* Reorder Admin Menu to put "Pages" at the top */ function menu_order_filter($menu) { $content_menu = array('edit.php?post_type=page'); array_splice($menu, 2, 0, $content_menu); return array_unique($menu); } add_filter('custom_menu_order', create_function('', 'return true;')); add_filter('menu_order', 'menu_order_filter');
There is very little overhead to assigning couple of filters on hooks that simply won't fire on front end. In general it would be something like this: add_action('init', 'admin_only'); function admin_only() { if( !is_admin() ) return; // filter assignemnts and such go here } Also `create_function()` is not recommended for performance and some other reasons. It is better to use more modern Anonymous Functions, but for cases like this WordPress provides ready-made `__return_true()` function.
stackexchange-wordpress
{ "answer_score": 6, "question_score": 6, "tags": "functions, admin menu" }
How to add categories to wp_list_pages() What (if any) is the hook or method for including named categories into the wp_list_pages function? The end result would be that the categories are added onto the end of the list of pages (along with any child categories that exist, with proper ul/li nesting for drop down css to act on)... Home | About | Contact | Category 1 | Category 2
Wouldn't it be even easier to call `wp_nav_menu()` and customize your menu as you please from the admin menu?
stackexchange-wordpress
{ "answer_score": 4, "question_score": 1, "tags": "theme development, navigation" }
What does exactly GPL license mean for my WordPress theme? To put it like this: I have created a WordPress theme for myself which consists of the following: * PHP code - GPL v2 licensed like WordPress * CSS files - All rights reserved * JS files - All rights reserved * image files required for the theme - All rights reserved As far as I understand I can copyright all non PHP files in the theme, so my question is: 1. Does this licensing scheme (for file groups) violates the WordPress license? 2. Do I have to publish the PHP code of the theme so it is available to everyone? 3. If I were to make a WordPress powered website with my theme (with the same licenses as above) for someone else (who pays for the service), do I have to publish the PHP code of the theme so it is available to everyone, just the buyer, or anything else?
> Does this licensing scheme (for file groups) violates the WordPress license? No, only the PHP code needs to be GPL'd. A popular example is Thesis: < < > Do I have to publish the PHP code of the theme so it is available to everyone? You don't have to publish it if your intention is to use the theme only for yourself. The GPL licence applies only when you distribute the theme to others. > do I have to publish the PHP code of the theme so it is available to everyone, just the buyer, or anything else? Just the buyer.
stackexchange-wordpress
{ "answer_score": 13, "question_score": 13, "tags": "themes, licensing" }
Display text if current user has written 1 or more posts in a custom post type I am trying to display different things to new users that have not created a post versus users who have created a post. I tried this, but it did not work for custom post types (only normal posts) and it does not account for drafts or pending posts: <?php if (count_user_posts(1)>=1) { blah blah blah } else {Welcome, blah blah blah }; ?>
Hi **@Carson:** A simple function to address what you are asking for might be the function `yoursite_user_has_posts()` which leverages the built in `WP_Query` class: function yoursite_user_has_posts($user_id) { $result = new WP_Query(array( 'author'=>$user_id, 'post_type'=>'any', 'post_status'=>'publish', 'posts_per_page'=>1, )); return (count($result->posts)!=0); } You can then call it from your theme like this: <?php $user = wp_get_current_user(); if ($user->ID) if (yoursite_user_has_posts($user->ID)) echo 'Thank you for writing!'; else echo 'Get Writing!'; ?>
stackexchange-wordpress
{ "answer_score": 8, "question_score": 3, "tags": "custom post types" }
Best way to pass arguments to another page in Wordpress What is the best way to pass arguments to another page in wordpress. I did it this way : <a href="get_permalinka(id_of_page).'/&i=2&j=3&k=4'">Link/a> I get this arguments with $_GET['i'],$_GET['j'],$_GET['k'],problem is : this works just with default permalinks,but when I change it to some other permalink type,it does not work any more.Note - I'm passing these arguments from homepage to another page(template page). Thank you for your time.
Use add_query_arg() to do this. Here's a useful function if you need to get the current page URL (when get_permalink is inaccesible, like on Archives): function get_current_page_url() { $request = esc_url($_SERVER["REQUEST_URI"]); $pageURL = (is_ssl() ? 'https' : 'http').'://'; if ($_SERVER["SERVER_PORT"] != "80") $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$request; else $pageURL .= $_SERVER["SERVER_NAME"].$request; if (false === strpos(get_option('home'), '://www.')) $pageURL = str_replace('://www.', '://', $pageURL); if (false !== strpos(get_option('home'), '://www.') && false === strpos($pageURL, '://www.')) $pageURL = str_replace('://', '://www.', $pageURL); return $pageURL; }
stackexchange-wordpress
{ "answer_score": 3, "question_score": 2, "tags": "customization, functions" }
How do I change the logo on the login page? Right now, my login page shows the Wordpress logo. How do I change it to my logo?
Here is a pretty simple approach to changing the logo. Mark Jaquith of WordPress released a plugin that allows you to upload an image which will be shown on the login page instead of the WP logo. Customize the WordPress Login Screen Logo
stackexchange-wordpress
{ "answer_score": 3, "question_score": 5, "tags": "login" }
Best practices for securing a Buddypress installation? A client of mine runs a Buddypress-based site (BP 1.2.6 on WP 3.0.2). We'd like to give users the ability to publish blogs of their own, but we don't want them to be able to execute PHP code (we make extensive use of the Exec-PHP plugin on the site), activate/deactivate plugins, or basically anything but use the site and publish blogs. How can we lock things down such that only users with "admin" level privileges and higher can execute PHP code, activate/deactivate plugins, manage users, and the like?
Kit, I'd say that if you make extensive use of Exec-PHP what you really need is a developer that can make stuff happen without it. In reality, that plugin is a crutch that is easily replaced with proper widgets, plugins and template code. So, the best advice I can give you about securing that plugin is to remove it.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "buddypress, security" }
How to get the post editor and media library to respect HTTPS administration mode? I have a site with FORCE_SSL_ADMIN turned on. When I'm editing a post with an embedded image, or when I'm viewing images through the media library, they are loaded using the http:// protocol rather than https. This causes a mixed-content warning in IE, which clients kind of freak out about. Does anyone have a recommended approach for finding/replacing these non-secure image URLs while viewing them through the admin? The frontend loads over regular http, so I don't want to do any replacing in the DB that will force images to load over https outside of the admin. I figure this has to be a common problem, so I'd appreciate any advice, even if it's "you can't do that".
You can't right now. This needs to be fixed in wordpress core. Probably this can be temporarily circumvented for a fraction of the problems with a plugin, but it's much more valuable to invest the time developing something in an actual fix of wordpress.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 4, "tags": "wp admin, media library, ssl" }
Wordpress 3.0 Media Upload Directory I am using Wordpress 3.0 and would like to organize the directory where uploads are made. Is there any way to change where the files get uploaded or is the only real organization the Media tag plugin? What would be ideal is when a user uploads a file, they can specify a sub directory where to dump the file (or default to date). So a user could say "flowers" and the file would go in uploads/flowers. Thanks!
Please see if Custom Upload Dir (Wordpress Plugin) does the job for you. With that plugin you can configure the upload path based on numerous settings.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 2, "tags": "media, directory, media library" }
Plugin options table,is the data serialized I am planning on building a plugin and i need to know if the data stored in the options table i will create for the plugin will be serialized or it will be in the ordinary sql format.
It totally depends on what data is being stored in the option, `maybe_serialize` will determine in the option is holding a singular static value, such as `true/false`, `0/1`, `empty string`, whatever(it's called when an option is created or updated).. it will serialize when dealing with objects and arrays, singular values are not serialized. The `get_option` function is equipped to deal with this however and will unserialize(or not) as necessary for you(using `maybe_unserialize`) when it's called, which basically does the inverse of `maybe_serialize`. Hope that helps.. **EDIT:** _Confirmed - checked source, above information is correct regarding serialization._
stackexchange-wordpress
{ "answer_score": 3, "question_score": 1, "tags": "plugin development" }
How can I create a multisite global tag cloud? I have a WordPress multisite installation. I need to create a sitewide tagcloud on the main blog. How can I do that ?
Use this plugin < and this tutorial < It says wpmu, but it is exactly the same.
stackexchange-wordpress
{ "answer_score": 4, "question_score": 2, "tags": "multisite, tags" }
How to highlight the right item in the navbar In my site i have a navbar which is created by using the new feature of wordpress 3 - "the menus ".In my site this navbar conatins both categories and pages. When I'm in a single post / sub-page , the navbar doesn't give the parent category /page the class of "current-menu-item" and therefore that item in the navbar is not highlighted. I found this but it really doesn't help me because the menu is not built on category_ID like a regualr navbar created by wp_categories_list(), but on item_ID , which I don't understand how is generated. I would like to know either how the item_ID is generated, and/or how to highlight the right item in the navbar Here is a printscreen of my navbar's HTML !alt text and here is a printscreen of navbar created by wp_categories_list() !alt text thanks!!
The filter you need is **nav_menu_css_classes**. You should be able to test for *in_category* on single post and archive pages, and add the appropriate class there.
stackexchange-wordpress
{ "answer_score": 3, "question_score": 3, "tags": "menus, navigation" }
Fatal error: Call to undefined function is_multisite() My theme has a "function_exists" wrapper around the is_multisite() call as seen below... if(function_exists(is_multisite())) { //do something } However, I'm still getting this error on theme install... Fatal error: Call to undefined function is_multisite() What am I missing?
the quotes: `if(function_exists('is_multisite'))`
stackexchange-wordpress
{ "answer_score": 3, "question_score": 1, "tags": "errors" }
Auto block ALL IP's indicated by Akismet? I'm thinking of blocking all IP adresses indicated by Akismet as containing spam. Something like cronning select distinct wp_comments.comment_author_IP FROM `wp_commentmeta` JOIN `wp_comments` WHERE wp_commentmeta.comment_id = wp_comments.comment_id AND wp_commentmeta.meta_value='true' ORDER BY wp_comments.comment_author_IP and then adding the IP's automatically to .htaccess. Even better, I would like to post the current list of 524 IP's to a webservice to be sure hundreds of other people are also blocking the same IP. Is that smart? **update** now checking with < . Interesting e.g. 109.105.192.194 is listed with one of the spam database but not others. So I probably need to write a plugin that auto blocks the IP and then refer them to DSNBL if they want to unblock themselves. IS there already a DSNBL plugin? **update** apparantly (ofcourse) there is : <
Personally I highly recommend to not use IP blocks at .htaccess level. There are simply too many false positives possibilities for that to work reliably. I had encountered WP blogs (luckily wave of those seem to have faded) that just shut me out, accusing my IP of belonging to evil spamer... Static IP that belonged to me for years. I especially don't recommend to use Akismet as source of data. Your mileage may differ, but as commenter I had experienced so many false positives with Akismet that I will never touch it as blogger. What I do recommend: * use spam filtering methods or sources you are 100% confident will not produce excessive amounts of false positives; * do not block out by IP, send matched IP to spam and display informational message about why it was blocked and your means of contact.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "spam, akismet" }
Domain redirect in Wordpress multisite I have two domains `www.domain1.com` and `www.domain2.com`, both pointing to the same host. What I want to do is redirect `www.domain2.com` to `www.domain1.com/domain2`. I got this code for a .`htaccess` from the hosting provider but is giving me a error "500 Internal Server Error" when I install it. What is the problem? RewriteEngine On RewriteCond% {HTTP_HOST} ^ [www.] domain1.com $ [NC] RewriteCond% {REQUEST_URI}! ^ / domain2 / .* ^(.*) RewriteRule / index / $ 1 [L]
> `What I want to do is redirect www.domain2.com to www.domain1.com/domain2.` Then you don't want to do it via `htaccess`. You need to use the **WordPress MU Domain Mapping** plugin. > Map any blog/site on a WordPressMU or WordPress 3.X network to an external domain. * * * Also see: **WordPress 3.0: Multisite Domain Mapping Tutorial** > The other day, Klint Finley wrote a very good walkthrough of using the new Multisite functionality of WordPress 3.0. In the comments, a lot of people wanted to know how to use your own domain names. Since I’m doing that now, here’s a quick walkthrough/how-to guide.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 2, "tags": "multisite, redirect, htaccess" }
Why isn't my Twitter widget working in my theme? I have Twitter's own widget set to load on my website, which works just fine. However, on my WP-powered blog the script is included but not rendered. I call it inside an empty `div` like this: > > <?php include $_SERVER['DOCUMENT_ROOT'].'/twtr-widget.html' ?> > But it appears in the page source as HTML (I'm putting '...' to save room): > > <script src=" > <script> > new TWTR.Widget({... > ...</script> > In other words, the script is not being executed. Why is this? EDIT: The blog is located here.
It is hard to say for sure with those floating sidebars, CSS is huge pain to work through. On the outer layer whole `div` that holds your widget has `display: none;` property applied and there are couple more places with same property applied to parts of twitter widget. Overall this seems like a huge CSS conflict.
stackexchange-wordpress
{ "answer_score": 1, "question_score": -1, "tags": "twitter" }
Custom Taxonomy Term Caching? I have two Custom Post Types, "event", and "opportunity". They share a custom hierarchal taxonomy, "location". My client had added a handful of terms (United States (parent), then a few States (children)). I decided to save them time by adding the rest of the States via wp_insert_term. This worked great! Or, so it seemed. The terms showed up fine for me as an admin. When logging into a "Contributor" account, I can go and create a new "Opportunity", and all the terms show as expected. When going to create a new "Event", the only terms that show up are the ones that were created by hand. You can _add_ a new term on the spot via "Event" and it shows up just fine in the location manager. Its as if WordPress is caching the older terms. Any ideas what might be causing this or where I should look? Details: WordPress 3.0.3 Role Scoper 1.3.20
There are some bugs related to hierarchical term caching, indeed: < <
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "custom taxonomy, customization, terms" }
using multiple meta_key and meta_value in query_posts how can i use multiple meta_key and meta_value in query_posts? For example, I want to find multiple content with two different meta_key and meta_value. How do I do this? i using this code but not effective: query_posts('meta_key=test2&meta_value=hello&meta_key=test2&meta_value=bye'); please help me...
This is not currently possible with query arguments alone (realm of filtering raw SQL query and such). If your task is not time-critical then I suggest to wait for upcoming WP 3.1 release. It will feature much more flexible querying capabilities for custom fields. See Advanced Metadata Queries for post on upcoming improvements.
stackexchange-wordpress
{ "answer_score": 3, "question_score": 1, "tags": "custom field, query posts, post meta" }
Inserting code to HTML view from a pop up initiated from visual view I am trying to insert html into the HTML view.What i have done is to have tinymce advanced(a wordpress plugin) button that throws a popup and in it is all the necessary things to insert the html.The tinymce buttons are however only visible on the visual view. Question 1: Is it a plugin or hack that can allow one to parse html inside the visual view Question 2: Is it possible to insert html code to the html view from a popup initiated from the visual view
> Question 1: Is it a plugin or hack that can allow one to parse html inside the visual view Neither of both. The visual view is the visual view and not the HTML view. If you want to paste HTML, use the HTML view. > Question 2: Is it possible to insert html code to the html view from a popup initiated from the visual view Technically this should be possible, but it would mean that you need to create a plugin with javascript for that first. In case "hack" from your first question is about writing a plugin, then well, this could be done for visual view as well. The TinyMCE API is a good start for doing that stuff. This answer to the "Want to have the Post editor remembering the last editing position" question might be helpful as well.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 1, "tags": "plugin development, javascript, tinymce, wysiwyg" }
different class (css) for sidebar widgets I want to add different class (css) in widgets in site sidebar . For example: First widget in Sidebar -> class=sidebar-top1 Second widget in Sidebar -> class=sidebar-top2 third widget in Sidebar -> class=sidebar-top3 i want to add class in <div> tag. how i can to do?
Check out this post I wrote on the wordpress.org board... it has some functioning code you can work from: <
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "widgets, sidebar, css" }
BLOG_ID_CURRENT_SITE vs. SITE_ID_CURRENT_SITE in WordPress Multisite? I've been trying to figure out why we have the constants `BLOG_ID_CURRENT_SITE` and `SITE_ID_CURRENT_SITE` _(vs. hardcoding them to be equal to`1`)_, what exactly the differences are, and when either of them will not equal 1? Any insight will be appreciated. Thanks in advance.
I addressed a similar question on StackOverflow last month. In MultiSite, "blog" is a reference to an individual website. "Site" is a reference to a network of "blogs." In the future, there's the likelihood that WordPress will be able to power multiple networks ("site"s) in addition to its current state of multiple "blog"s. * * * **Update** I've done some more digging, and discovered a plug-in that easily allows you to split your multi-site installation into a multi-network one: WP Multi Network.
stackexchange-wordpress
{ "answer_score": 8, "question_score": 5, "tags": "multisite, constants" }
Is there a way to create invisible pages? I'd like to add a page that does not appear anywhere on the site (especially not in the header or wherever your pages are listed) unless the URL is typed in directly. Additionally, the page/post should be password-protected. I know how to add a password, but I found no way to remove the page from being listed.
Hi **@mafutrct:** There are a lot of ways to do this; picking one is actually the challenge! I'm going to suggest a few options and let you explore _(the ones at the top look most promising)_ : * **Page Protection Plugin** * **Password Protect enhancement Plugin** * **Better Protected Pages** * **Simply Exclude Plugin** (Article) * **Hide Pages Plugin** * **Creating ‘hidden’ pages in wordpress which don’t appear in the navigation menu** I'm assuming your are using `wp_list_pages()` for your menus? If so consider moving to the new menus in v3.0 where you'll get full control of what appears in those menus: * **Everything you wanted to know about WordPress 3.0 Menu Management**
stackexchange-wordpress
{ "answer_score": 5, "question_score": 2, "tags": "customization" }
using add_role function to make some users to create a selected type post how are you ? I have in my site (post_type called = books).. I need to make some users for example (Library) to create a books (post_type = books) .. this is the code to add rols (called = library) .. $library = add_role('library', 'library', array( 'read' => true, 'edit_posts' => true, 'delete_posts' => false, )); The library Role can create (any type of post) , I want it to create books (post_type) .. I wish you understand me .. thank you very much ^_^
You can add your own capabilities for custom post types. The default behvaiour for a post type is to inherit capabilities from the default post post-type. See the capabilities parameter in register_post_type (Wordpress Codex), that has more information about how that can be done.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 2, "tags": "custom post types, user roles" }
How to delete the Hello Dolly plugin automatically? I'm planing to create a plugin called Goodbye Dolly. Once installed, it will take care for the installation to remove the auto-installing Hello Dolly (Wordpress Plugin) shipping with wordpress. This is due to popular request. Some folks have asked for it. I like the idea. I never cared so far because I removed it manually. But I like the idea to save the hassles and have this removal automated for the future. I wanted to just delete the file when it exists basically. But I'm unsure a bit about file system abstraction. And I would like to do this on install / update already, so this does not needs to be checked for all the time. So which hooks are to be considered? Any best practice ideas? **Update:** * Homepage: < * Repository: <
While I appreciate the idea, isn't this just replacing one plugin with another? Rarst's link already has the answer -- it just needs to be reworked a bit to check for the plugin periodically, like so: function goodbye_dolly() { if (file_exists(WP_PLUGIN_DIR.'/hello.php')) { require_once(ABSPATH.'wp-admin/includes/plugin.php'); require_once(ABSPATH.'wp-admin/includes/file.php'); delete_plugins(array('hello.php')); } } add_action('admin_init','goodbye_dolly'); Slap that into your functions.php file (in a child theme if you aren't already using a custom theme) and you should be good to go.
stackexchange-wordpress
{ "answer_score": 7, "question_score": 5, "tags": "plugins, automation, customization" }
Copying post thumbnail to custom field I've just moved to another theme, and it uses the custom field `bigimage` for associating an image with a post, instead of using WordPress's post thumbnails. How do I copy the URLs of all existing post-thumnails to their corresponding post's `bigimage` custom field? Could we possibly write a bunch of MySQL statements to achieve this?
I wouldn't bother doing that. I'd just find the places in your theme files that call the custom field (probably something like "echo get_post_meta('bigimage')" or something) and replace those with a the_post_thumbnail() tag. This saves you the trouble of messing with the data, and it makes administration much, much simpler going forward--which is kind of the point of post thumbnails. And it'll probably take less time than rigging some SQL to copy all that data.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "themes, images, mysql, posts" }
Crossposting from WP to Blogger with comments I know that there is a way to crosspost from WP to Blogger but I am curious if there is a way to essentially mirror WP blog on Blogger completely, in other words crosspost both posts and comments?
Hi **@Alex:** Your client wants to mirror on Blogger this _"In case WordPress fails?!?"_ OMG!!!! Do they not understand how WordPress works? Set him up a second WordPress site on a different web host or on WordPress.com! Don't put up with Blogger. A simple solution would be to use Windows Live Writer or Qumana to write the posts and then just having them submit to both sites using those programs. A programming solution would be to monitor RSS feeds on a psuedo-cron task and then import them with `wp_insert_post()`: * Import and Display RSS Feeds in WordPress * Pseudo Cron Jobs with WordPress * Function Reference/wp_insert_post But whatever you do get them to stick with WordPress on the multiple sites; doing anything else is madness!
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "comments, posts" }
Two-tone menu items wp_list_pages seems to print out menus ok, but is there a way to alter the functionality so that i can display the menu in two colors..? So, if the titles of 3 actual pages are: Big Cinema * Monaco Theatre * San Franciso Sport * Berlin (each page really has two titles, the asterisk used to separate them. another character could be used..... or is there a way of entering two titles?) When these are displayed you would get the two titles for each page displayed a little differently: _Big Cinema_ Monaco _Theatre_ San Franciso _Sport_ Berlin (the italics above representing blue, the rest green) Is there a way to alter the wp_list_pages behaviour, or is there a better technique to do this?
Hi **@cannyboy:** Unless I misunderstand, I think what you need is to use `'the_title'` filter. If you simplly enter _"Title 1 * Title2"_ into your title field, this code I've written for this hook should wrap your Title2 in a `<span class="title2">` which will allow you to style it with CSS. You can put the following code into your theme's `functions.php` file: add_filter('the_title','yoursite_the_title'); function yoursite_the_title($title) { $titles = explode('*',$title); $title = trim($title[0]); if (isset($title[1])) $title .= ' * <span class="title2">' . trim($title[1]) . '</span>'; return $title; } Of course this will wrap your second title everywhere so you might have some places it does it that you don't want it to do it which case you'll need to figure out how to tell the function not run for only those cases.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "menus" }
Creating a custom Admin panel I'm building a Wordpress Plugin and it has two tables and some data. Right now, for displaying and changing the data, I'm using the wpdb function and manually creating the user interface (mimicking the Default one). However, I see that other plugins have a more consistent style with their tables and the same features (like the bulk button). I'm getting suspicious about Wordpress Taxonomies. I read, but so far, taxonomies seems to be related to posts in a way or the other. My data doesn't relate to posts, it's completely independent. Can I still use Wordpress Taxonomies? Can the taxonomy help me build a consistent interface?
check **this** out, I believe this might be what you're looking for. it helped me a lot.
stackexchange-wordpress
{ "answer_score": 5, "question_score": 1, "tags": "custom taxonomy, customization" }
Is it possible to use a forgot password url filter? i recently found that a login url filter is available but i can't find a solution for the forgot password as well, for the login url i use this: function custom_login_url($login_url) { return ''.get_option('siteurl'). '/login'; } add_filter('login_url','custom_login_url'); is it possible to do the same for the forgot password? thanks a lot, Philip
Yes it's also possible for the password, by running a filter on `lostpassword_url`, which is basically the password equivalent of the login url.. # Example Basically the same as before, just changed the function and hook names. add_filter( 'lostpassword_url', 'custom_lostpass_url' ); function custom_lostpass_url( $lostpassword_url ) { return get_option('siteurl'). '/lostpass'; }
stackexchange-wordpress
{ "answer_score": 7, "question_score": 3, "tags": "functions, filters, login, urls, password" }
inserting uploads into subdomain I have my wordpress blog in the root of my website (example.org) and would like to store uploaded files in a subdomain depending on type of file, for example I currently have static.example.org/images, static.example.org/video and static.example.org/audio and was trying to find a way to put uploaded files in the subdomain through the Wordpress Interface. I've found a plugin which is quite dynamic in storing files, but it won't pass to subdomians, can anybody help or suggest anything?
Try changing the upload path by referring to following tutorial, then use the plugin again. <
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "customization" }
Restrict post to user_id I only want a post to be viewable by the administrator and one user. (So I would have a post for each user) I am thinking of using the Members plugin and meta-data/custom fields to restrict the content. This would effectively make the post private to only those with access and any one else would not even see the post and if they get the url, they will be denied. So would using the Members plugin be the best choice or should I try a different method? and how?
I am not expert on users, simplest way as for me would be to store ID (or IDs) of user in custom field and check for it if user is not admin. Some example code (not tested): if(current_user_can('administrator') || in_array(get_current_user_id(), get_post_meta(get_the_id(), 'allowed_users', true))) { the_content(); } else { echo 'Post restricted'; }
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "user access, plugin members" }
Get a button for <hr> in the Editor Somehow the WordPress editor doesn't have a button to insert a horizontal line (`<hr />` in html). Is there a plugin that adds this button? Or an easy way to add such a button myself?
There's an easy way. Open functions.php and add this code. It works for many html entities // got this form function enable_more_buttons($buttons) { $buttons[] = 'hr'; /* Repeat with any other buttons you want to add, e.g. $buttons[] = 'fontselect'; $buttons[] = 'sup'; */ return $buttons; } add_filter("mce_buttons", "enable_more_buttons"); //add_filter("mce_buttons_2", "enable_more_buttons"); // add to second row //add_filter("mce_buttons_3", "enable_more_buttons"); // add to third row
stackexchange-wordpress
{ "answer_score": 7, "question_score": 5, "tags": "plugins, customization, editor" }
How can I add/append content to the_content on the home page via a plugin? As a proof of concept, I'd like to create a simple plugin that loads some content, say "hello world" just after the_content on the home page only. How can I do this from a plugin?
You mean a filter and a check for `is_home()`? add_filter( 'the_content', 'wpse6034_the_content' ); function wpse6034_the_content( $content ) { if ( is_home() ) { $content .= '<p>Hello World!</p>'; } return $content; }
stackexchange-wordpress
{ "answer_score": 7, "question_score": 2, "tags": "plugin development" }
Query custom taxonomy by term id? I made a custom post type and a custom taxonomy, but I have a problem. When I access the url ` it works well. But when I access the url ` it returns a 404 page. `galaxy-s` is the taxonomy term slug, but I want to access it by `term_id`, like you can with a category: `cat=1`. I prefer `cat=1`. What can I do?
This is not supported by default, but you can convert the numeric terms back to slugs with the `pre_get_posts` hook. I tested this with WP 3.0.1, but in 3.1 the taxonomy query handling changed, so I don't know whether this will work by default or if there is a better way to do it. add_action( 'pre_get_posts', 'wpse6066_pre_get_posts' ); function wpse6066_pre_get_posts( &$wp_query ) { if ( $wp_query->is_tax ) { if ( is_numeric( $wp_query->get( 'term' ) ) ) { // Convert numberic terms to term slugs $term = get_term_by( 'term_id', $wp_query->get( 'term' ), $wp_query->get( 'taxonomy' ) ); if ( $term ) { $wp_query->set( 'term', $term->slug ); } } } } Bizarre that you prefer the numeric version, many would choose the term slug for SEO reasons.
stackexchange-wordpress
{ "answer_score": 3, "question_score": 0, "tags": "custom taxonomy, permalinks, wp query, url rewriting" }
how to setup content on a static frontpage with css and xhtml I'm currently working on a website that has a static frontpage and couple of pages that is going to contain portfolio and things alike on the other pages. The thing I want to do is to hardcode content on the frontpage in css and xhtml. Is this possible and where do I do this? I thought it should be done in **index.php** in between: "<?php get_header(); ?>" and "<?php get_footer(); ?>" calling the content with if and else statement on: is_front_page()
I would set up a new page template (see < create a new page (Pages > New) and set it to use that template, and then set WordPress to use that page as the homepage (Settings > Reading). Then you can fill the custom page template with whatever content you want in between wp_head() and wp_footer().
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "css, html, static website" }
Add additional data to a specific taxonomy term when used in a post If I'm using a custom post type for a Movie or a TV show episode, I may use a taxonomy for "actors" and assign all the actors related to the work to it, but I'm not sure how, besides of that, I can also add **the character the actor is playing in said work**. The characters themselves may or may be not a taxonomy, as sometimes one also needs extra space for adding notes, like "John Doe (voice)" or "John Smith (via stock footage). I can figure something like a metabox with columns for each thing, yet I'm not sure how to make it harmonious (or do it at all).
You could simply use the **"pods"-plugin** (for WordPress) from Matt Gibs and Scott Kingsley Clark. It's exactly what you searching for. Take a look at the doku and look specificaly at "pick columns". Aside from that it has a nice and ajax driven interface and builds it's database tables next to wordpress and doesn't make use of the default tables (there's nothing wrong with adding new tables). It **really** converts Wordpress to a full CMS system. I tried it in some projects and was easily able to achieve **everything** i wanted. A big plus is the irc-chat where you find a nice, friendly and helpful croud and the developers. An here goes another plus: When you feel comfortable with pods, then add pods UI to your weaponary. :) Wish you best!
stackexchange-wordpress
{ "answer_score": 1, "question_score": 3, "tags": "taxonomy, metabox" }
How can i show all categories using wp query? <?php $recent = new WP_Query(); ?> <?php $recent->query('cat=1&showposts=2'); ?> With what can i replace cat=1 to show posts from all the categories?
You should be able to remove that category from the query so you would have`<?php $recent->query('showposts=2'); ?>` you can also take a look at completely custom queries here. `
stackexchange-wordpress
{ "answer_score": 4, "question_score": 0, "tags": "query" }
Change labels on 'Nickname' and 'Biographical Info' in user-edit.php For a project I'm working on, I want to change the labels of the 'Nickname' and 'Biographical Info' fields on edit profile (user-edit.php) page in the dashboard. I still want to use those fields as they are, I only want to change the labels. Anyone know of a function that can do this?
Every string goes through `translate()`, which uses the `gettext` filter. This mean you can try something like this: add_filter( 'gettext', 'wpse6096_gettext', 10, 2 ); function wpse6096_gettext( $translation, $original ) { if ( 'Nickname' == $original ) { return 'Funny name'; } if ( 'Biographical Info' == $original ) { return 'Resume'; } return $translation; } It's probably even more efficient if you only call the `add_filter` when you are on the `user-edit.php` page (see the `admin_head-user-edit.php` hook or something like that).
stackexchange-wordpress
{ "answer_score": 9, "question_score": 1, "tags": "functions, users, dashboard" }
Is there a way to use regular categories with custom post types? Is there a way to use regular categories with custom post types? It seems like there is better functionality and options with regular categories (such as permalink options, etc.).
No problem, the categories and tags are also registered as taxonomies that you can pass to the `taxonomies` argument when you call `register_post_type()`. Categories are `category` and tags are `post_tag`. You can also do this later with `register_taxonomy_for_object_type()`: add_action( 'init', 'wpse6098_init', 100 ); // 100 so the post type has been registered function wpse6098_init() { register_taxonomy_for_object_type( 'category', 'your_custom_post_type' ); }
stackexchange-wordpress
{ "answer_score": 6, "question_score": 4, "tags": "custom post types, categories, custom taxonomy, permalinks" }
How can I create a permalink with two categories, with the order based on the parent category? Basically, I'd like to create a category permalink like example.com/books/adventure without having to make adventure a child-category because it will apply to other categories as well. So the end result is: example.com/books/adventure example.com/movies/adventure example.com/toys/adventure The order is based on the two parent categories, with "items" going first, and "genre" going second. And you could also search the categories separately to see all of the books, or all of the adventure items. How can I do this? Thanks!
David, welcome to wordpress answers. The answer is: Switch to some other platform. Wordpress can not with what's currently in core produce such a result easily. Technically spoken it's possible, but folks hate me here to say how (well Apache + PHP) in concrete, so I don't tell it because I fear the negative karma this give on this site. Just switch to something else if you seriously want to do such stuff and more. Like symfony2 with a database layer. After about one to three month as a single developer you can achieve much more then you can imagine with wordpress. And the best thing is: You can even add a wordpress blog later on. ;)
stackexchange-wordpress
{ "answer_score": 3, "question_score": 0, "tags": "customization, categories, permalinks" }
importing users where password is provided as md5 + much metadata I have a spreadsheet that was provided to me of users to import to a new site I have built. I was provided with the password in MD5 hash form. I suspect if I insert this into the password field in the database, since it is MD5 it will still match their password when the user tries to login on the new system. Is this a correct assumption? I also have a large amount of metadata for each user that needs to be inserted. Because I want to insert the md5 string, and not the password text and the extra custom meta fields, I don't think I can use wp_insert_user. Does anybody have experience with this type of thing? I am thinking I will just do something directly in mysql, rather than hack up a WP plugin, any suggestions would be appreciated though.
WordPress used MD5 for password hash in the past, but had since moved on to more secure phpass. The good thing is that it retains backwards compatibility - if user had old MD5 hash then it will be checked as such and automatically re-hashed and re-saved using current algorithm, see `wp_check_password()`. You are correct that you cannot use `wp_insert_user()` because it expect plain text password.
stackexchange-wordpress
{ "answer_score": 4, "question_score": 3, "tags": "users, mysql" }
Custom Post Type, Custom Taxonomy Template: How to get current taxonomy name? Ok so i have a custom post type called 'profile' with a custom taxonomy called 'company'. The site has many profiles and companies defined, with profiles being associated with companies as necessary. I have created a taxonomy-company.php template and have the correct profiles being displayed, but i don't know how to get the name of the company being displayed so that i can put it at the top of the template. Is there a quick way, perhaps a variable or function call that gets me that? Thanks.
`$wp_query->get_queried_object()` will give you the taxonomy term you're currently displaying. It works in many other situations too, like categories, authors, ...
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "custom post types, templates" }
Custom post type, permalinks & pagination, going wrong i have a site (< with a custom post type 'fotolog' as you can see on the right side. The posts and pagination of the blog (central column) work fine. But when it comes to the posts and pagination of my CPT it goes wrong. If i dont use **the flush_rewrite_rules( false );** function after my register_post_type() call in functions.php, i can see the posts but the pagination doesnt work. If a use the function it's the oposite, i can't see the posts (404) but i get the pagination! I've been trying lots of times to switch the permalinks structure for tests, i checked my .htaccess file and its permissions, i tryed to "play" with the 'rewrite' parameter of the register_post_type() function, i've read and tryed the solution written here, here and also here... So far no luck, or am i missing something super obvious? I'd really be grateful for some help.
Make sure your query has paged in it like so: query_posts('post_type=fotolog' . '&paged=' . get_query_var('paged')); Check to be sure that you don't have page and a post type with the same permalink /foflog and /fotolog/your-post-name-here
stackexchange-wordpress
{ "answer_score": 3, "question_score": 1, "tags": "custom post types, permalinks, pagination" }
How can I troubleshoot why TinyMCE won't load custom plugins in the visual editor? **Edit:** Found that the theme options panel set up (using a class) was causing the problem. Still not sure why - would still love know how to find out what the problem is - e.g. is it a JS or PHP issue. Going to try a different method of creating the theme options panel to see if it fixes the problem. * * * I am able to add extra TinyMCE buttons that are bundled (e.g. HR, anchor), but am unable to add custom plugins of my own. I have also noticed that other plugins (WP-Table Reloaded, cForms, TinyMCE Advanced) are also unable to load custom plugins. Disabling all other plugins does not solve the issue. What could be causing this, and/or how can I find the problem? When viewing source of an edit post screen, mceInit options do not list any plugins besides those defined as WP default. Altering the $initArray does work, but of course does not point to the correct location of added plugins.
You should read this: < It's pretty straightforward if you already know how to program a TinyMCE plugin (which it sounds like you do).
stackexchange-wordpress
{ "answer_score": 1, "question_score": 2, "tags": "tinymce" }
Get list of all registered sidebars I am registering sidebars automatically for each category (a separate widget space per category). The technique I'm using is **here**. In the admin side I have an options page where I need to display a dropdown of all registered sidebars... Is there are way to dynamically get this list of registered sidebars? since they're being registered in functions.php I assume they're in memory, not in the database. I could keep track of the sidebars I register in some global variable, but just in case plugins register their own sidebars, I'd like to account for them too. I'll dig through the core if I have to, but thought someone might know off-hand:) Thanks
Hmm... I'm not sure if this is the best way to do it but it's simple: I looked in `register_sidebar()` and found that new sidebars are simply tacked onto an array:`$wp_registered_sidebars` And I guess that's that. If they ever change the name of the variable, I guess I'd be screwed.
stackexchange-wordpress
{ "answer_score": 22, "question_score": 17, "tags": "sidebar, register sidebar" }
Query posts with double taxonomy So I have a custom type called "vendors" and two custom taxonomies for it. One is "state" and the other is "type". I am trying to list all the vendors from a certain state on one page. I'm using the file called "taxonomy-state.php" which works perfectly. It displays all the vendors in the state. Now what I want to do is specify the types of vendors in order. So the page will look something like this: Vendors in "STATE": Vendor Type #1: Vendor #1 Vendor #2 Vendor #3 Vendor Type #2: Vendor #1 Vendor #2 Vendor #3 I got it to display vendors by state. But I need to display them in the above layout. I have an idea of how to do it. But I need to be able to make a query that can get a vendor from a certain state and certain vendor type. Thanks in advanced, Alain
Hopefully someone else will flesh out this answer, I don't have the time to write out a full solution right now... If you're using WordPress 3.1, look at the `tax_query` parameter that you can pass to `query_posts`. It can handle multiple taxonomies and relationships between them. Otto's post WordPress 3.1: Advanced Taxonomy Queries is the best explanation I've seen of what tax queries can do, and how to use them... In older versions of WP, you're stuck using a plugin like this one, or rolling your own fairly complex SQL queries.
stackexchange-wordpress
{ "answer_score": 5, "question_score": 0, "tags": "custom post types, custom taxonomy, terms" }
More posts from the current author On a multi author WordPress blog I need to show a list with more posts from the current author. The list is inside the Loop, so I can use `<?php the_author_meta('first_name'); ?> <?php the_author_meta('last_name'); ?>` and `<?php the_author_meta('description'); ?>`, but how to retrieve the user's posts?
This will retrieve the posts of current author when used in the loop. Put the following in your theme functions.php: function my_get_display_author_posts() { global $authordata, $post; $authors_posts = get_posts( array( 'author' => $authordata->ID, 'post__not_in' => array( $post->ID ) ) ); $output = '<ul>'; foreach ( $authors_posts as $authors_post ) { $output .= '<li><a href="' . get_permalink( $authors_post->ID ) . '">' . apply_filters( 'the_title', $authors_post->post_title, $authors_post->ID ) . '</a></li>'; } $output .= '</ul>'; return $output; } And add `echo my_get_display_author_posts();` in your template file, within the loop where you want the posts displayed.
stackexchange-wordpress
{ "answer_score": 3, "question_score": 2, "tags": "author, get posts" }
When does wordpress process &lt;!--nextpage--&gt; when does <!--nextpage--> get processed by wordpress filtering. i am adding multiple paged posts in post content on the content_save_pre and this is good for rendering my shortcodes, but <!--nextpage--> doesnt get processed and shows up as an html comment
I am not sure what you mean by rendering shortcodes at that stage, they are usually rendered when content is retrieved for display. _nextpage_ tag is processed in `setup_postdata()` ( source ), which is called by `the_post()`. In other words - during Loop.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "filters" }
Administration Pages Styling I am adding administration pages using `add_menu_page()` function. But it wont look good. Check the image below. !alt text I would like to have it as separated and in between Appearance and Plugins section with rounded borders.
This will put one separator right after 'Appearance' and one right before 'Plugins'. Just make sure to give your menu position 62 or 63. You can just add it to whatever file is adding the admin page to begin with. This should be called after everything else has been added. function jpb_menu_isolator(){ global $menu; $menu[61] = array('', 'read', 'separator3', '', 'wp-menu-separator'); $menu[64] = array('', 'read', 'separator3', '', 'wp-menu-separator'); uksort($menu,'strnatcasecmp'); } add_action( 'admin_menu', 'jpb_menu_isolator', 1000 );
stackexchange-wordpress
{ "answer_score": 4, "question_score": 1, "tags": "theme development, admin, admin menu" }
Explanation of the "posts_join" and "posts_fields" filter hooks? I'm new to the "posts_" filter hooks and wanted to know a few things from those in the know: In this question, someone posted an answer using `posts_join` that took a second parameter of `$query`: add_filter('posts_join',array(&$this,'posts_join'),10,2); ... function posts_join($join,$query) { } Is this an instance of wp_query or something similar? Same example: How would I determine the post type so that I can do custom joins for each custom post type I have on the admin side What does the `posts_fields` filter hook do? from the example I've seen, it looks like it replaces the columns in the `SELECT` clause of an `SQL` call. Am I correct in that assumption, and does it too have more parameters that can be called?? I find some examples but I can't get any solid documentation anywhere.
When you use one of the methods to query for posts (`query_posts()`, `get_posts()` or `WP_Query` object) arguments you provide are processed and turned into SQL query. This happens in `WP_Query->&get_posts()` method. Since arguments are not omnipotent there are a lot of hooks in there that allow to modify or override parts of resulting SQL query. * `posts_join` is part of query that handles SQL JOINs - adding additional tables to the mix, for example tables related to taxonomies when they are needed. * `posts_fields` seem to control which database fields will be returned in query, it seems to default to all fields from `posts` table.
stackexchange-wordpress
{ "answer_score": 11, "question_score": 4, "tags": "plugin development, filters, hooks" }
Wordpress Plugin for Maps of specific Tweets? Is there a Wordpress Plugin that you can give it a list of old tweets (specified by url or tweet number (for example: < and put them on a map, which will slowly move between them (in demo mode) and then allow the user to click on those tweets? (Just figured I'd check before implementing one) P.S. Can someone please tag this post with "Google Maps" or "Maps" please.
I'm not entirely sure if this will help in EXACTLY the way you are looking for, but when it comes to map integration into posts, I love to use MapPress. It supports a pretty robust API which allows you to hook into the plugin to do some custom things, and I'm sure with a little work you could get to where you want to be with your project. I don't usually like the pay-for plugins but I highly recommend buying his MapPress Pro, it works very very well, is highly versatile, and he is always keeping it updated.
stackexchange-wordpress
{ "answer_score": 1, "question_score": -1, "tags": "plugins, plugin recommendation, twitter, geo data, map" }
Is there a specific term for Plugins that are specified in a Wordpress Post using Comments? What are plugins that are added to a post or page using comments...for instance I am aware of the `<!--nextpage-->` tag, (it's part of Wordpress not a plugin...) but I'm assuming that there may be plugins out there with functionality that is placed in a post in a similar manner. What is the name of plugins that operate in this manner?
There's a similar concept for plugins called shortcodes (as andrewk said). The syntax for these is slightly different than the more tag (which does look a lot like an html comment). Shortcodes are wrapped in square braces like so: [myshortcode arg1="something" arg2="something else"] Shortocde is the term for the technique, but plugins that implement shortcodes don't have any special name or anything. They're just plugins that use the shortcodes API. Similarly, plugins that use the widget API (or any other WP functionality) don't have special names. They're all just plugins. As far as I know, there is no built-in API for implementing "html comment-style" tags like the more tag. And I don't think the technique is in popular use by plugin developers since the shortcode API became available. At least, I don't see it very often.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "plugins, comments" }
WP Super Cache separate cache for mobile I'm using the WP Super Cache plugin and inside my theme I have code that executes differently if the site is viewed on a mobile device (iOS, Android) than a desktop browser. How do make WP Super Cache create a separate cache for each, most likely via the user agent? Right now, I have use mod_rewrite to serve cache, which I believe WP Super Cache will cache the pages as html files to be served. Since the cache is saved from the desktop browser, the mobile browser is seeing that as well. I'd like WP Super Cache to generate two separate caches, one of mobile devices and another for desktop browser. Is this something WP Super Cache can handle or is there a better cache plugin I should be using to make this work? Thanks!
There are several ways to handle mobile devices and doing it inside of single theme is builky and hard to maintain (as for me at least). More commonly this seems to be accomplished with separate templates or separate mobile-specific theme. I don't know about WP Super Cache specifics because I hadn't used it extensively. Plugin I currently use is W3 Total Cache. It allows you to create groups of user agents strings, for which visitors can be redirected to another theme or domain and (as I understand from description of settings) will have separate versions of cached pages.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 3, "tags": "customization, cache, mobile" }
How to use str_replace() outside the loop? Is there any way to use `str_replace()` in Wordpress outside the loop? I want to change my html markup which starts before the loop. I need something like this: function content_magic($content) { str_replace('<div id="content">','<div id="new_content">',$content); return $content; } add_filter('the_content','content_magic'); But this works only for markup within the loop. Please help me!
Filters don't really affect resulting markup. More precisely they affect anything that is passed through them, in this specific case output of `the_content()` function is passed through `the_content` filter and you are able to modify it. If markup you want to change is not generated by function and not passed through filter then most likely you will need to edit theme's template file that markup belongs to. It is also good practice to create and use child theme to retain compatibility with theme updates and such if you are going to edit template.
stackexchange-wordpress
{ "answer_score": 3, "question_score": -2, "tags": "content" }
Total number of posts in last year How can i echo total number of posts in last year ? I‚m writing article with stats, and want to get number of posts i published last year. There is something here, but not for last year < It displays only total number of all posts
All you need to do is modify the SQL query. Using the code you linked as a base: $numposts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = 'publish' AND year(post_date) = 2010"); if (0 < $numposts) $numposts = number_format($numposts); The 'AND' I added basically gives you all the posts of 2010. Change the year accordingly
stackexchange-wordpress
{ "answer_score": 4, "question_score": 1, "tags": "statistics, sql" }
Which are the hooks run before/after when a category's deletion? What are the actions that a plugin can hook on to for processing when the user deletes a category?
`wp_delete_category()` is a small wrapper around `wp_delete_term()` ( source ). It has number of hooks, the one that comes right before delete is: do_action( 'delete_term_taxonomy', $tt_id ); Hooks after delete: do_action( 'deleted_term_taxonomy', $tt_id ); do_action('delete_term', $term, $tt_id, $taxonomy); do_action("delete_$taxonomy", $term, $tt_id); There are also few earlier hooks that deal with remapping children terms.
stackexchange-wordpress
{ "answer_score": 3, "question_score": 1, "tags": "plugin development, categories, hooks, actions" }
Why no images on a fresh Wordpress installation? I've just installed Wordpress here at arun.sanspace.in But, don't know why, it doesn't display any images. I want to know why? I have another Wordpress installation on the same server which works great. What exactly is the problem here? Am I doing something wrong? While I copy the image location from the placeholder and open it alone, it displays the picture. It happens on IE and FF both.
I've figured it out. I had enabled hotlink protection. I installed the new blog in a new subdomain which was not added to the hotlink protection. So, it prevented the image requests. Now I added to the list and everything's fine. Silly me. :-(
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "images" }
get_template_part inside get_template_part? Ever tried this? // template file do_action( 'my_hook' ); // ex. functions.php function my_hooked_template_part() { get_template_part( 'my_loop_part_file', 'default' ); } add_action( 'my_hook', 'my_hooked_template_part' ); // my_loop_part_file-default.php get_template_part( 'query', 'default' ); if ( have_posts() ) { while ( have_posts() ) : the_post(); etc. // query-default.php get_posts( array( 'whatever' => 'and_so_on', ) ); Maybe it's my setup, but it won't load the file. Could it be that it's too late for loading some other file inside? Can anyone confirm or this just a drawback of using the get_template_part() function (only one file - no nesting)?
If your comments in the code above reflect the file names then it's a dash vs. underscore mistake. Name of the second included file should be query-default.php
stackexchange-wordpress
{ "answer_score": 1, "question_score": 4, "tags": "get template part" }
How to embed form data within the 'Add new post' I want users to be able to use a car template in new posts. The template will include items such as a photograph of a car, make, model, number of doors, colour of car, etc. Users will not want to use the template in every one of their posts. How should I do this? My idea is to: **Create a new widget within the 'Add new post' page. This would contain a form in which the user can upload a photograph and enter data (in text input fields).** **Once the user has completed the form (within the widget), they could press a button (either in the widget or in the 'Add new post' toolbar) which will embed the form data into the new post.** Please can you tell me if this would be a good/best approach, or if I should do it another way.
IMO this ia a good approach. However one thing I would focus is instead of embedding the data into the post body, you may insert custom fields in that post. This may help you sorting posts based on color, make etc or what ever your fields are.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "custom post types, widgets, posts, forms" }
Can't get blog entry to format properly using wp-load I'm setting up a blog that I'm trying to integrate the posts of into old site pages. The $id = $_GET['article_id']; $post = get_post($id); setup_postdata($post); echo $post->post_content; However, when I echo the blog post from `$post->post_content`, it seems that the html has been stripped out. The lines all run together. There are line breaks in the source, but there are no html `<BR>`s or `<p>`s. However, the post looks fine when I view it through the actual WordPress page. I have to use `<pre>` to get it to display properly, but then on the page, lines don't wrap and it defaults to that typewriter font. What am I doing wrong?
Post content, stored in database, is not equal to what gets displayed. It should be displayed with template tag function or at least run through `the_content` filter. Try: the_content(); Or: echo apply_filters( 'the_content', $post->post_content );
stackexchange-wordpress
{ "answer_score": 1, "question_score": -2, "tags": "formatting" }
Can I turn off write-in tags/taxonomies? One of the big problems my site staff has had with tags is the overwhelming number of similar or duplicate tags, due to the write-in ability. I'm about to add new custom taxonomies to my site for them to use, but I'd like to avoid the problem we had with tags. I'm curious to know if I can turn off write-ins, so they can only be added manually through that taxonomy's part of the admin area. It's non-hierarchical, so they can still type in and the system will auto-complete and search for tags they might be looking for, which is great. I just don't want them to be able to create new tags from the post screen. Is this possible? I was looking at the Taxonomies and register_taxonomy() pages in the Codex, and thought maybe the "rewrite" function might be what I'm looking for, but I don't think it is now.
Here is what I came up with, seems to work: add_filter( 'pre_post_tags_input', 'no_tags_input_create' ); add_filter( 'pre_post_tax_input', 'no_tax_input_create' ); function no_tags_input_create($tags_input) { $output = array(); foreach( $tags_input as $tag ) if( term_exists( $tag, 'post_tag') ) $output[] = $tag; return $output; } function no_tax_input_create($tax_input) { if( !isset($tax_input['post_tag']) ) return $tax_input; $output = array(); $tags = explode(',', $tax_input['post_tag']); foreach( $tags as $tag ) if( term_exists( $tag, 'post_tag') ) $output[] = $tag; $tax_input['post_tag'] = implode(',',$output); return $tax_input; } This is for tags, you can easily extend second function to handle custom taxonomies.
stackexchange-wordpress
{ "answer_score": 6, "question_score": 5, "tags": "custom taxonomy, tags, functions" }
A spam bot loves me, what can I do? I'm receiving many many spam comments using the same username and I guess it is a bot that keeps on submitting comments. In one week I get around 100 such comments (which is quite a lot for my small blog). I want to have a look at all comments that are marked as spam (just in case Akismet is too strict on a certain legit comment), but this is really annoying. Therefore I have two small questions: * How can I tell WP to trash all comments that come from a certain username? * What do you generally do in situations like this?
You actually want to keep these comments marked as spam--not trashed. Akismet checks against your spam list while deciding what to do with a new comment. So having a large database of spam comments actually helps Akismet work. I get what your issue is, but what you're essentially asking for is a spam filter for your spam filter. If you're having trouble with a particular user, you might consider disabling their account somehow. This is pretty easily done by changing their username and password in the DB to something unguessable. This ensures that they can't sign in, and can't create another account using the same email address.
stackexchange-wordpress
{ "answer_score": 3, "question_score": 6, "tags": "spam, akismet" }
How to provide support for [gallery] shortcode? I'm developing a new custom theme - and noticed that if a post contains the shortcode [gallery] it gets ignored ( _edit_ : I mean that the HTML delivered to the browser does not include [gallery], nor anything in its place... I think there's a blank line or two) My Theme is 1. grabbing post contents via `the_content('&rarr;')`; 2. also removing the standard `<p></p>` wrapper via `remove_filter('the_content', 'wpautop');` The Codex does not list this as one of the features you explicitly have to add support for \- but we know the codex can be outdated/incomplete at times. Anyways, what is it needed for a theme to recognize [gallery] (and/or other such standard shortcodes) ?
Have you added any images to the page in which you are using the gallery? The [gallery] shortcode won't work without there actually being attachments on said post.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "theme development, shortcode, gallery" }
Scanning Database for malicious Data After a site of a friend has been hacked I told him he should just clean up the mess and restart from scratch so he know that no file has been altered. I could scan the site for him with tools like grep an so on (For a start: Grep and Friends) but what I wondered about is, how to scan the database? What if some hacker has placed payload inside the database. Can be something simple like XSS or even PHP code in case there is some eval'ing still going on in core (or was at the time of the hack). Any suggestions? I thought about using SQL-Queries with the LIKE comparison function or there is even some REGEX possible. But maybe someone has already done this or wants to do this an has some ideas to share.
I've read that dumping the database as text and searching in it is a good way to go. You can search with phpmyadmin, but it's limited. Depends on the size of the database and a good text editor, but you can delete post/page revisions before dumping the database to bring it down in size. Or dump a few tables at a time.
stackexchange-wordpress
{ "answer_score": 6, "question_score": 5, "tags": "mysql, sql, hacked, verification" }
Specific and Different Ads for each Post? I am working with a magazine client who sells adversiting offline in their magazine and now has a WordPress online magazine. Each of their stories is broken into different posts, and they are using the Wootheme Spectrum. They want the ads in the magazine to correspond to the ads online. So if Story B has Ad Z, then online, Post B should have Ad Z in the sidebar. However, Story A and C might have differents ads. What's the best way to accomplish this? * Custom plugin? * Plugin? * Adsense? Thank you.
Hi **@ewakened:** The simplest solution would be to have them upload the ads as photos using the media features in WordPress and then to have them add custom field called _"Advertisement"_ with the URL to the ad copied from the media module, and a custom field called and _"Ad URL"_ to link to the advertiser's site. Then in the theme use the following to retrieve the add's URL: <a href="<?php echo get_post_meta($post->ID,'Ad URL',true); ?>"> <img src="<?php echo get_post_meta($post->ID,'Advertisement',true); ?>" /> </a> Beyond that is would be very possible to create a custom metabox plugin that would allow them to upload one of more ads directly into the post edit screen but that would require more programming.
stackexchange-wordpress
{ "answer_score": 4, "question_score": 2, "tags": "sidebar, ads" }
How to remove commenters ability to add hyperlinks to comments? I'd like to be able to filter out a commenters ability to add hyperlinks in their comment text. I removed the "websites" field from the mix to reduce the amount of spammage already (see: Removing the "Website" Field from Comments and Replies?") which has helped a lot. By default, they can use the '< a '> tag to do so in the comment box text, which allows spammers to embed hyperlinks to their sites. Is there a way to filter out that capability in the wysiwyg editor for comment fields?
WP runs so many prettifying filters on this stuff that it's easy to get lost. Here is what I ended up with: remove_filter('comment_text', 'make_clickable', 9); add_filter('pre_comment_content', 'strip_comment_links'); function strip_comment_links($content) { global $allowedtags; $tags = $allowedtags; unset($tags['a']); $content = addslashes(wp_kses(stripslashes($content), $tags)); return $content; } This scrubs out clearly defined links and removes filter that turns plain text links into properly tagged ones.
stackexchange-wordpress
{ "answer_score": 9, "question_score": 3, "tags": "comments, wysiwyg, filters" }
Quick and Easy way to Add Search to the P2 Theme? Out of the box the P2 Theme does not have search. Is there a quick and easy way to add it?
Native search widget? Google Custom Search Element is also quite easy to implement, but won't fit private site.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "search, theme p2" }
A good way to add a different background image for each page? I'm working an a Thematic child theme wherein I need to have a unique image decorating each of the site's main pages, from a pre-defined set of permanent images. It would also be ideal to have one of these same images randomly selected to appear on all other pages. Using a sidebar widget to load the images seems like a good option, but I don't know how to create my own widgets yet, and haven't had any luck finding a plugin which provides the simple functionality I'm looking for. I also don't want to clutter up the admin panel with plugins and options that the client shouldn't be fiddling with. I think it will probably be most ideal to put something into my `functions.php` which adds some generated markup to a Thematic hook based on the page ID, but I'm not quite sure what I'm doing, so I thought I should ask to see if someone already has a great solution.
Looking at their demo source, the easiest way to do this is by styling page classes like `pageid-69` or `slug-example-page`: body.slug-example-page{ background: url(...); } If it has to be random image, add your styles in the header template so you can use PHP to generate dynamic css.
stackexchange-wordpress
{ "answer_score": 4, "question_score": 2, "tags": "hooks, widgets, post thumbnails, pages, child theme" }
Subscribe to this Blog for a Private P2 Themed Site? What's the easiest way to get a **subscribe to this blog** for a private P2-Themed Site? I want to have an obvious link on the page without having to modify the theme so that everyone using the site can easily see the link. Ideally I'd also be able to see who is subscribed and if possible subscribe them myself _(it's the team members for the project I want to make sure are subscribed.)_ Suggestion for the best plugin for this?
I use a combination of Subscribe to Comments and Subscribe2, but it's not pretty.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "plugin recommendation, email, subscription, theme p2" }
How to install "Wordpress for ios" on Apple's SDK's iPhone/iPad simulator? How to install Wordpress for ios on Apple's SDK's iPhone/iPad simulator? and what are other ways to make Wordpress Admin compatible with iphone?
This seems to be answered on Stack Overflow. The accepted answer refers to a thread on the MacRumors forum.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "iphone" }
Best Way to Merge a Dev and Live Site to Become a Staging Site? I have two Wordpress installs, both with a little bit of different data. I have a LIVE site and I have a DEV Site. I need to merge the content of these two databases together to make a STAGING Site. I need to merge the new Posts/Pages/Comments/Categories from DEV to a LIVE database backup, and then make that database become STAGING. What is best, easiest, and least time consuming way of tackling this? NOTE: XML Importer will not work for this task as the amount of data is too large.
> NOTE: XML Importer will not work for this task as the amount of data is too large. This tool is by far the simplest solution if there's any way you can get it to work. Is it absolutely "too large" for the importer, or just limited by file upload / PHP execution time limits? If I were doing this, I'd crank up the limits on my development environment to process a really big XML file. If that won't work, I'd probably guess that you have some mucking around in SQL to do. :-P
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "sql, deployment, merging" }
How to add meta boxes to the 'Add new post' screen? I want the user to fill in a form (when they create a new blog post). The results of the form should be embedded within the new blog post. So I am trying to think of the best way of coding this. Meta boxes might be the best way? **Edit, the original question changed a little. The old one was:** How can I add a Dashboard Widget into a custom Plugin Options Page? I have followed the example here < to create a custom Dashboard Widget, but cannot see how to add it into my custom plugin options page (which is found under the 'Settings' sidebar in the Control Panel).
Dashboard widgets only go on the dashboard. You can't put 'em on any other pages, as far as I know. For a primer on plugin options, see the codex article on creating plugin options pages. Is there any reason you need to add a widget-style meta box in your settings page? Are you after the drag-and-drop functionality, or the expand-collapse functionality? If so, you might modify your question to ask for those things specifically. **EDIT** What you're looking for (based on your comments) are called meta boxes, not widgets (it takes a while to learn all the WordPress-specific terminology). There are some easy-to-use WordPress functions for adding meta boxes to the post creation/editing page--you don't need to create a separate admin page for them. To actually save the information entered into these boxes, you'll want to hook into the save_post action. This is all explained (including a copy/paste example you can play with) in the codex article on the add_meta_box function.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "plugin development, plugins, metabox" }
Accessing variable from admin panel? I've created my own admin page in wp-admin folder using add_theme_page() function. How to pass variables from there to my blog? I mean what's the easiest way without arrays etc. I've tried using "globals" but failed. Thanks a lot.
Read the codex page on creating options pages, and let us know if you run into any specific issues. It has a complete copy/paste example you can monkey with. If you're trying to avoid learning WordPress' options mechanisms in favor of a more generic custom php solution, I understand where you're coming from, but recommend learning to do it the right way. It'll be a couple hours investment, but it'll pay off over time. For reals.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "admin, options" }
How to search and replace text in all posts of a wordpress.com blog (NOT wordpress.org one)? I have some texts that need to be replaced in every posts in my blog. Is it possible to do that? ps (I need to tag this question as `search-and-replace` but not enough reputation to do that. Please add the tag if you can. Thank you!)
You have at least three different ways: 1) Edit directly in the database. The content of the post is stored in post_content column of wp_posts table. Since you are running your own WordPress, you should have full access to that. Just use SQL to do search and replace. Remember, the table content is sort-of HTML, so may have tags and/or escaped characters 2) Export your blog into XML, do search/replace in any UNICODE ready editor and import it back in after deleting original content. I would practice this a couple of times first though, especially checking what happens with images, etc. 3) Use WordPress remote access API to iterate through posts and update them that way. Good for programmers and/or more flexible way of doing things, such as content-specific updates.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 2, "tags": "wordpress.com hosting, search, text" }
How to control manual excerpt length? I have a website in which I need to control the displayed excerpt length. Some of the posts might have manual excerpt so I can't use the `excerpt_length` filter. I can, of course, use some kind of `substr()`, but was looking for a more elegant solution (if such exists).
Take a look on my answer here: Best Collection of Code for your functions.php file If I understood your question correctly, it does what you are looking for. Place this in `functions.php`: function excerpt($num) { $limit = $num+1; $excerpt = explode(' ', get_the_excerpt(), $limit); array_pop($excerpt); $excerpt = implode(" ",$excerpt)."... (<a href='" .get_permalink($post->ID) ." '>Read more</a>)"; echo $excerpt; } Then, in your theme, use the code `<?php excerpt('22'); ?>` to limit the excerpt to 22 characters. :)
stackexchange-wordpress
{ "answer_score": 6, "question_score": 6, "tags": "excerpt" }
How to check if an admin (sub)menu already exists? The title says it all. I'm using WP 3.0.4
Something like this should work. `$handle` should be the menu's slug; set `$sub` to true to search submenus (defaults to top level menus): function find_my_menu_item( $handle, $sub = false; ){ if( !is_admin() || (defined('DOING_AJAX') && DOING_AJAX) ) return false; global $menu, $submenu; $check_menu = $sub ? $submenu : $menu; if( empty( $check_menu ) ) return false; foreach( $check_menu as $k => $item ){ if( $sub ){ foreach( $item as $sm ){ if($handle == $sm[2]) return true; } } else { if( $handle == $item[2] ) return true; } } return false; } One last quick note: this should not be used before the menu is set. `'admin_init'` is a safe bet for the earliest time to use this. I also added some code to leave gracefully if the menus aren't set.
stackexchange-wordpress
{ "answer_score": 5, "question_score": 3, "tags": "admin menu" }
Adding class "current_page_item" for custom post type menu I am using the following to help display a list of posts created in a custom post type. $args = array( 'post_type'=>'portfolio', 'title_li'=> __('Portfolio') ); wp_list_pages( $args ); However a class is not being added to the list item of the current page (`current_page_item`). Any ideas of how I could make this happen?
Found this and it works perfectly! Dynamic navigation for custom post type (pages)
stackexchange-wordpress
{ "answer_score": 1, "question_score": 2, "tags": "custom post types" }
Can I set a default dashboard layout for all users? I'm creating a multi-author blog, and have recently added the "Dashboard Notepads" plugin. This allows me to add 1 to 3 dashboard widgets which I can write custom notes in, like news or notices. Is there a way I can set that widget to appear at the top by default? I had a look but could only find a plugin which works up to 2.8. Using version 3.0.4. I would much rather do this without the need to change code, although I would consider it as a last resort option. Thanks in advance.
Hi **@Relequestual:** I think what you want is here: * **Dashboard Widgets API / Advanced: Forcing your widget to the top** It doesn't require you to change code per se, just to add the code like shown in the WordPress Codex to your theme's `functions.php` file which is a standard way to customize and/or extend WordPress: To find out the values you need use, just add a `print_r($wp_meta_boxes);` line then an `exit;` immediately below the `global $wp_meta_boxes;` line like this: global $wp_meta_boxes; print_r($wp_meta_boxes); exit; // Stop execution here so you can see it. You may need to actually view source to make sense of it all. -Mike
stackexchange-wordpress
{ "answer_score": 6, "question_score": 4, "tags": "admin, dashboard, author" }
How to change sidebar per page? I am new to theming with wordpress. I have a theme layout with one sidebar at the right side of the website. Now on my homepage and one other page i dont want to have the sidebar. On all other pages it needs to stay. How can i do this. Any help would be appreciated. Thanks.
> ... on my homepage **and one other page** i dont want to have the sidebar. You can tell WordPress to **do not generate** sidebar on specific page(s) with simple condition in your **page.php** file (or other relevant template file). For example the following piece of code will disable sidebar on 'About Me' page. <?php if (!is_page('about-me')) get_sidebar(); ?> *Note: you can use numeric ID or slug of your page inside the is_page() function.*
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "themes" }
How deactivate the http-api give it an tipp or solution for deactivate the method request() in class WP_Http_Streams? I use WordPress also on offline-servers and have wp_debug true for development and tests. But i have many warnings from functions to use the http-class; as example the functions to read the feeds in dashboard. Current i have deactivate all hooks for update themes, plugins, core and the crons; see my small plugin for this: < Thanks for a reply
Try this in `wp-config.php`: define( 'WP_HTTP_BLOCK_EXTERNAL', true );
stackexchange-wordpress
{ "answer_score": 3, "question_score": 1, "tags": "multisite, http api, offline" }
Are plugins like WP Robot considered as spammy by the community? WP Robot looks like a very powerful plugin, but one which could be used for all sorts of spammy websites. Just wondering what the general community opinion is of these plugins? Are they useful or damaging to a website?
I am not sure what answer you are looking for. Plugins are not something that you directly see when you look at site. Not something site's reputation is based on. I hadn't looked into this specific plugin, but as any of this kind it likely can be used both for perfectly legit and absolutely spammy purposes.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "automation" }
Setting WP Admin passwords to expire I'm aware it's not a feature of Wordpress, but I was wondering if there was a way or a plug-in (haven't found one from searching) that allows me to force a user to change their password after a defined number of days.
I was busy writing up a plugin for this without even checking of one already existed. So I did a little research and found out that it does indeed already exist and that the path I was going down was the right one. Well, there's no need to reinvent the wheel here, so here's the link to the existing plugin. < Does what you need - I tested it myself.
stackexchange-wordpress
{ "answer_score": 4, "question_score": 3, "tags": "users, security, password" }
Post Thumbnails multiple sizes I am working on a theme that shows 200/200px post thumbnail on the home page and 500/300px image on the category page. Here is what I have in fuctions.php but it doesn't seem to work (only the homepage thumbnail works) add_theme_support( 'post-thumbnails' ); set_post_thumbnail_size( 200, 200, true ); add_image_size( 'homepage', 200, 200, true ); add_image_size( 'category', 500, 300, true );
Simply naming the size in the functions file is not enough to get the sizes to work: To call a custom size that you added do this: <?php the_post_thumbnail('category'); ?> I see you `set_post_thumbnail_size(200, 200, true)` which you don't need to do if you're also naming a post thumnail size the same sizes for homepage. Perhaps this line is messing up your other sizes. Also, the_post_thumbnail **doesn't** usually work on images already uploaded. To test if the sizes truly aren't working upload a new file after adding the new thumbnail size/calling it in your theme file.
stackexchange-wordpress
{ "answer_score": 4, "question_score": 1, "tags": "post thumbnails" }
Query for custom post type? I have installed the Custom Post Type UI plugin. After activation of this plugin I have created a custom post type called `portfolio`. Now I want to use this on the portfolio page in the front-end. How do I fetch _all post that are of custom post type`portfolio`_?
query_posts( array( 'post_type' => array('post', 'portfolio') ) ); which shows both normal posts and posts inside `portfolio` type or query_posts('post_type=portfolio'); for only `portfolio`. Use as normal WP Query - read the Codex: < and < <?php query_posts(array( 'post_type' => 'portfolio', 'showposts' => 10 ) ); ?> <?php while (have_posts()) : the_post(); ?> <h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2> <p><?php echo get_the_excerpt(); ?></p> <?php endwhile;?>
stackexchange-wordpress
{ "answer_score": 24, "question_score": 18, "tags": "get posts, custom post types" }
permalink changed, now getting 404 for every pages i have my website with permalink, till now everything was fine, but few days before i changed my permalink, now everything is going wrong, now each and every page i am getting 404, even my about-us and contact us pages, they are giving me 404 page if i come to my site from google or any search engines, then also it gives me 404 i have 1000+ posts on my website, for each post & page from google i get 404 page, but within the website except pages i get no 404 page **my previous permalink:** `%postname%/%category%/` now i added custom taxonomy to my permalink, **so now it is:**`%location%/%courses%/%postname%` I asked this question first also, but it was into wrong section i guess, thats why asking again and in detail. **Related Question:** custom taxonomies on permalink
< check this plugin, I've used it on a couple of sites and it works great.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 2, "tags": "permalinks, 404 error" }