question
stringlengths
0
34.8k
answer
stringlengths
0
28.3k
title
stringlengths
7
150
forum_tag
stringclasses
12 values
If I add the C++ tag, when updating the post it gets converted to C#. If I add the ++ tag, there's no conversion. Encoding for pages and feeds is UTF-8. Wordpress version 3.0.1
I can duplicate this behavior. Probably a bug. Only alphanumeric characters and dashes are allowed in tag slugs, so my slugs for C++ and C# were created as "c" and "c-2," respectively. Adding these tags to a new post by name rather than slug lumped them all into C#. (Or was it C++? Either way, they evaluated to the same.) Manually updating the slugs to "cpp" and "csharp" worked around the bug in my install. Have you customized your tag slugs, or are they "c" and "c-2?" Update : taxonomy.php does check that the slug matches before checking the full tag name, and they both evaluate to the same slug ("c"), hence the incorrect match.
Why 'C++' tag is converted to 'C# '?
wordpress
I launched mobile version of my site some days ago. It was looking fine. I used <code> mobilepress </code> for the same. But i found that <code> shortcodes </code> are being displayed as simple text. is there any other plugin to build efficient mobile version including short code translation
You can use WordPress Mobile Edition or WordPress Mobile Pack .
Mobilepress fails to translate short codes
wordpress
I've launched quite a big site the other day and I'd like to incorporate a caching plugin. The setup is single-site with some Buddypress features mixed in (for user registration, maps with gpress, having a profile) running on a shared host. My questions are: 1. Which plugin you consider best for caching given this setup and why (if possible)? 2. What are the best practices and steps I should take/consider during the setup to make sure all is working? 3. Are <code> transients </code> which I've added myself can still be used or should I remove them and leave the plugin do it's thing? will they clash if not removed? Thanks! ADDITION: 'Power' plan on http://www.inmotionhosting.com/hostingplans.html
On shared hosting plans your caching options are limited. You will only be able to statically cache the html output from your pages. This is the fastest way to serve pages but you loose the dynamic aspects of WordPress like making comments and seeing the latest comments on posts. There are disk caching options available for objects and database but unless your host is running fast drives you won't get much gain from this and it could also cause a drop in performance. All the caching plugins have an option to not serve cached pages to logged in users or any user with a comment cookie. Logged in users + known users = no cache Unknown users get served a cached page. Transients Transients are small pieces of data that are meant to expire at some time. WordPress stores transients as a cache in the database. If you had the option to use Memcache WordPress would keep the transient data in memory. Transients are good because they reduce database look ups. They are also good to use for social networking like displaying your latest tweets. This prevents making a call to the twitter api on every page load. The plugin that uses the most High Performance Websites best practices is W3 Total Cache. W3 Total Cache does more than just cache W3 Total does: page caching object caching database caching minify browser caching CDN integration For your shared hosting set you should enable page cache, minify, browser cache, and the self hosted CDN option. Page Cache Settings Check all the options for page cache Cache Preload Turn this on and set the update interval at what ever is appropriate for your site. This will rebuild the page cache at the given interval. Minify Settings Select Rewrite url structure and if your going to use the CDN check the auto upload so newly minified files will automatically get uploaded to the CDN. Minify HTML Enable and check remove line breaks, inline js and css minification. If your using adsense or another service that uses comment stems enter them here to avoid having them minified. CSS and JS Minify Settings In the file management choose your theme and add any css files you want combined and minified. There is also a help wizard that will search all your templates and add the suggested files for you. Using The Help Wizard W3 Total includes a tool that goes through your theme templates and finds Javascript and CSS files that are used and provides recommended settings. First try theses settings and problems are encountered go back and modify as needed. Any files highlighted in red are files you have already included to be minified. The same option section is available for js files and you have the option of having the files placed after <code> &lt;head&gt; </code> , after <code> &lt;body&gt; </code> , and before <code> &lt;/body&gt; </code> . It is best to put as many as you can before <code> &lt;body&gt; </code> . If any plugins add inline js you wont't be able to use before <code> &lt;/body&gt; </code> for jquery or the plugins js because it will need to load before any inline <code> &lt;script&gt; </code> tags. You can include any combinations of files in each location and for each template. For instance you can set your comment-reply.js to only load on single.php Browser Cache Settings This is the most important one to get right. If you properly cache your static content in your users browsers you can drastically reduce page load times. "do not process 404 errors for static objects" browser cache settings is a big win for shared hosting because invoking PHP and returning 404 pages to bots etc is a big drain on resources and this feature prevents that General Check everything CSS and JS Files Check everything and set our expires header lifetime to far future. 31536000 seconds is 1 year and what yslow recommends. If you make changes to your css or javascript you have to change the file names to prevent users from using the old version. If your using minify you won't have to worry about serving outdated content because every time the minify cache is rebuilt is generates a new file name. Set your cache Control policy to cache with max age There are two more browser cache setting sections. HTMl and Images. For Images use the same settings as CSS and JS. You can increase the expires time on the images if you want. For HTML don't set expires unless your site is mainly static. You can use short lifetimes if you want (180 seconds) but I wouldn't go higher. Enable gzip and you can check the set W3 Headers so you can check the response headers to make sure they are working. CDN Settings W3 Total has built in support for popular origin pull and origin push CDN's and a robust self hosted option that requires you to set up subdomains and cnames. Self hosted CDN will let you take advantage of pipelining. Browser can only download a few files at once, only 4 in some cases. Pipelining is a technique whereby aliases (subdomains for example) of your server are used to allow your browser to increase the practical limit of files that can be downloaded in parallel. Doing so maximizes the throughput of the your internet connection and allows the browser to render a page faster. W3TC takes care of managing these files transparently once DNS CNAMEs (aliases) and subdomains are properly configured. Check all the options then click the upload buttons to upload all the content to the CDN. If using self hosted there is another setting page to put in ftp information. For origin push CDN it's configured based on what provider you are using. For origin pull you don't upload any files and only set your cname to the url the provider gives you. Note: Don't select force override unless new files are not working. Force override will constantly upload files to the cdn even if they already exist and this wastes bandwidth and resources. Testing You should always test your results and tweak your settings accordingly. I like to use WebPageTest.org. To compare my results and identify any potential problems. How much can you increase your performance using W3 Total Cache on WordPress with shared hosting? These are the before and after results for a WordPress blog that we added W3 Total to. Before: After I hope this helps.
What are the best practices for using a caching plugin on a shared host?
wordpress
I've just launched a site that has a RESOURCES section in it, listing of school, documents etc. now the client asks to add an 'Alphabetical Sorter' that will enable the users to see in each specific category the post/resources according to their first letter. This wouldn't be to hard (theoretically), the problems are that those are custom-post-types with nested categories and I already manipulate the request (on the <code> request </code> filter) to get what I want and not a 404. The structure is <code> domain.com/resources/parent-category/child-category/post-name </code> and I'd like to have pretty permalink look so <code> domain.com/resources/parent-category/child-category/A-Z </code> and not using a <code> index=A-Z </code> . This should also work (show the correct posts in a-z order) when the user deletes part of the url, i.e. <code> domain.com/resources/parent-category/A-Z </code> or <code> domain.com/resources/A-Z </code> . What would be the best approach for that, considering we can't go back and add 'category per letter', taxonomy, custom field etc.? Is there a way to maybe hook into the raw SQL and edit it like here http://wordpress.org/support/topic/first-letter-posts ? Thanks!
My recommendation would be to use <code> query_posts() </code> to modify your query such that <code> orderby=title </code> and <code> order=ASC </code> ... this will return the same results as your first query, but with the posts ordered alphabetically by title .
What's the best approach for showing posts by A-> Z order?
wordpress
I've got a WordPress CPT that I've had running for a couple weeks. There weren't any problems with it. In the last couple days, it's been going haywire. Every few minutes, WordPress forgets that the page exists and returns a 404 error. This can be fixed by flushing the permalink rules in the admin panel, but a few minutes later the same things happens and it has to be fixed again. Does anyone know what could be causing this, or how to fix it? Errors: Some of these: <code> [Fri Sep 24 04:11:17 2010] [error] [client 150.254.160.253] Invalid method in request \\n\\n </code> More of these (tv2 is the slug for the CPT): <code> [Fri Sep 24 03:25:15 2010] [error] [client 67.142.166.25] File does not exist: /var/www/vhosts/default/htdocs/tv2 </code> And a ton of these: <code> [Fri Sep 24 03:58:36 2010] [error] [client ::1] Directory index forbidden by Options directive: /var/www/html/ </code>
I do not know the specific path layout on your webserver, but the entries from the error log do not look to me that it is specifically wordpress related: Invalid method in request \\n\\n This error is caused by an invalid HTTP request. Each HTTP request has a method. Most certainly it was missing in the request that resulted in the log entry. File does not exist: /var/www/vhosts/default/htdocs/tv2 A File does not exists message isn't normally created when a PHP script returns 404 response headers. So most certainly, this error was not reported by Wordpress but by the server itself. Probably the mod_rewrite configuration for your wordpress blog was unavailable. Directory index forbidden by Options directive: /var/www/html/ This looks the same to me. If <code> /var/www/html/ </code> is the webroot of your blog, then this shows that index.php has not been found or wasn't looked for as directory index by your webserver. So in the end this looks very much like a webserver configuration issue to me. Permanently rebuilding permalinks wouldn't help here either then. If you are unsure, you can make use of the Permafrost (Wordpress Plugin) . A related question regaring 404 errors and permalinks is: stackexchange-url ("single-type.php not working, delivering 404.")
Wordpress Custom Post Type Repeated 404 Errors
wordpress
What are the best things that I can do to get my Wordpress blog out there? What are good plugins that I can use to get listed in Googles search? Is there anything/anywhere else I can register my Wordpress blog to attract more visitors?
Provide content that people crave to find, consume and share. There is no technical solution to make site popular. If there was one - everyone would use it and field will be leveled again. There are a lot of minor tweaks to implement (heading structure, social buttons, etc), but none of those will automagically bring in traffic and none of those work exactly same across different blogs with different content. The best you can do on technical side is too keep an eye that your blog is reasonably fast and markup makes sense.
What is/are the best thing(s) I can do to make my WordPress blog more popular?
wordpress
I remember seeing a plugin that helps with the translation of other plugins. Anyone remember the name of that plugin? Thanks.
Over years I tried and used lots of wordpress multilanguge solutions and at this moment the WordPress MultiLanguage plugin (WPML) seams to be the best. One of the features supported is the translations of the plugins.
Is there a plugin to help with translation of other plugins?
wordpress
What are the major pros/cons that can help in deciding which of the two to choose: WAMP vs XAMPP for running a local testing server for WordPress? p.s: I now see stackexchange-url ("stackoverflow had a discussion") about it.
Biggest difference - WAMP runs on Windows, XAMPP is multi-platform. Aside from that it's a matter of personal preference. They both provide you with an Apache-MySQL-PHP environment that runs pretty much the same under both systems.
WAMP vs XAMPP pros/cons - for running a local testing server?
wordpress
I'm working on a theme that includes some functionality I've developed as separate plugins (as I'm hoping to release them independently). I'd like to include these plugins as part of the theme core and I've noticed that some developers include plugins as files or subdirectories along with their theme, but over time that can ultimately lead to maintaining two versions of the same plugin - one for the plugin repository, one for the theme - but I'd like to avoid that, if possible. What's the best practice for including plugins as part of a theme?
If you plan to release them independently, then release them independently and try to get them both hosted in the WP repository. This will allow you to update the systems remotely and keep people using the most up-to-date system possible. Then, in your theme, use <code> is_plugin_active() </code> to filter your commands. If you have a theme feature that requires a plugin, use <code> is_plugin_active() </code> to dynamically switch between using the feature or nagging the user to install the plugin. The important thing to keep in mind is that your theme should still work if the plugins aren't installed. It doesn't have to have the same rich feature set, but it also shouldn't break if they decide to remove or deactivate one of the other plugins. Alternatively, if you know that a certain plugin isn't going to change for a very long time (I use a few plugins that only add/remove specific WP filters) you can drop the <code> PHP </code> file into a <code> /library </code> directory with your theme and <code> include() </code> the file in <code> functions.php </code> . Then the functionality is enabled by default - tradeoff is that you're now maintaining two versions of the plugin (as you mentioned in your original question).
Best practice for including plugins as part of a theme?
wordpress
A faculty member is having difficulties with a instructional wordpress install. Fixing individual permission problems has been hit and miss, and have become a perennial pain, so I'll ask here. What can I do to make WP Just Work? The kinds of errors they get: Installing Plugin: Lightbox 2 2.9.2 Downloading install package from http://downloads.wordpress.org/plugin/lightbox-2.2.9.2.zip … Unpacking the package… Could not create directory. /home/CIM140/public_html/wordpress/wp-content/upgrade/lightbox-2.tmp When I su as www-data (the user apache runs as in Ubuntu), I can make that directory just fine. My test wp instance installs this plugin just fine, so I'm at a loss as to why it fails for them.
@pwnguin, I had the same problems running mod_php with WordPress and I finally figured it out. <code> # chown www-data:www-data /home/CIM140/public_html/wordpress/ -R </code> As long as YOU control the box this won't cause any security issues. EDIT: You might also need to change your umask to 022 so new directories created by WordPress will have 755 permissions and files will have 644 permissions. Another option is to override default file permissions in wp-config.php: <code> define('FS_CHMOD_DIR', (0755 &amp; ~ umask())); define('FS_CHMOD_FILE', (0644 &amp; ~ umask())); </code> You can also force the filesystem method for updates. (Primary Preference) "Direct" forces it to use Direct File I/O requests from within PHP, this is fraught with opening up security issues on poorly configured hosts, This is chosen automatically when appropriate. (Secondary Preference) "ssh" is to force the usage of the SSH PHP Extension. (3rd Preference) "ftpext" is to force the usage of the FTP PHP Extension for FTP Access, and finally (4th Preference) "ftpsockets" utilises the PHP Sockets Class for FTP Access. These can be defined in wp-config.php with: <code> define('FS_METHOD', 'ftpext'); </code> You can get all the currently defined constants by executing the <code> print_r(@get_defined_constants()); </code> command in php.
Can't install new plugins because of the error "Could not create directory"
wordpress
I need to create a page in my site that I am able to access via url, but that won't be included in any of the navigation menus which are generated using <code> wp_list_pages() </code> on my site. How can I accomplish this?
There is a good plugin that adds a meta check box under all pages that indicates whether you want the page to show up in menus. Exclude Pages Plugin The other option is to convert from wp_list_pages to the new custom menus. When using custom menus only pages you add to the menu will be included.
How to create a page that isn't accessible via menus?
wordpress
A quick Google search shows a number of different options for comment plugins: Is there a "best" way to handle comments? I realize it will vary from site to site, but I'm looking for the best way to handle them on a "typical" site - no special requirements here. Is it worth using something like Disqus or another plugin or third party service, or should I stick with the built in comment handling?
I've personally stayed away from any external or 3rd party system. Many times commenters are apprehensive about using "another" account or service, esp with recent privacy issues with Facebook, etc. Also, many add bloat and delay page load to run their own scripts, etc and can be harder to style to fit within an existing theme. I would look to use the existing WP comment function, plus Askimet and some .htaccess rules to block out spam.
What is the best method for handling comments?
wordpress
Is there any way to have more post statuses other than just draft or published? For example, if you write a lot of posts, you may wish to type up all the content, and set the status of these posts as "Content - Drafted" Then you can re-style them, make text bold, add code highlighting etc, and set to "Styled - Drafted" Then as a final review you could set status to "Reviewed" Then finally, publish them Is it possible in the current wordpress version 3 to achieve such scenarios?
I found this plugin called EditFlow that says it allows you to add custom statuses. Apparently it's designed for use in a newsroom. (FYI, I searched the WordPress plugins directory for "custom post status.")
Is it possible to have more "levels" of draft/published statuses?
wordpress
What's a surefire way to check/set cookies before the php headers are sent? Is there an action or filter that would be the best place to hook a <code> setcookie() </code> function?
Depends on whether or not you need to check against WordPress' user authentication. If you need to know whether they're a logged in user, hook onto <code> 'init' </code> . Otherwise, the sooner the better. If it's something that should fire on every page load, and only checks for existence of the cookie and doesn't need to tap into any of WP's APIs, I'd put it into a custom MU-plugin named <code> 0000a.php </code> to ensure that it fires before any non-core files could accidentally send headers.
How to set custom cookies before output
wordpress
i am running http://article-stack.com . I want to create a separate blog say help.article-stack.com. Again, it should have 2 portion. One for discussion and another for information. I am planning to install wordpress in 2 more direcotries. Both will have separate database. Tell me is you have some better solution It will be helpful if you can suggest me some free theme for discussion. I am aware with twitter like theme p2. But it is not suitable for me. I want stackexchange type of site. So if someone helps others they must get their credit. It helps to motivate them and others. Thanks in advance
Since version 3.0 capabilities to run multiple site on single installation had been included in WordPress core. See Create A Network in documentation. I have nothing to suggest on theme and I advise to split that part in separate question.
i want multiple blog, themes and database
wordpress
I have PHP errors redirected to log file. Only for WP installation so this definitely doesn't come from somewhere else. This is what started to come up recently (this is all of them, not cut): <code> [22-Sep-2010 14:30:41] junk after document element at line 2, column 0 [22-Sep-2010 16:17:08] junk after document element at line 2, column 0 [22-Sep-2010 17:19:42] junk after document element at line 2, column 0 [22-Sep-2010 18:30:19] junk after document element at line 2, column 0 [22-Sep-2010 20:19:23] junk after document element at line 2, column 0 [23-Sep-2010 14:51:40] junk after document element at line 2, column 0 [23-Sep-2010 15:54:33] junk after document element at line 2, column 0 [23-Sep-2010 17:23:02] junk after document element at line 2, column 0 </code> This doesn't really look like PHP error ( function blah-blah failed at line x ), they are very infrequent and don't seem to be tied to page loads (maybe to some cron event?) and there hadn't been any major configuration changes in months other than keeping plugins up to date and one or two new ones (days before this started). Googling results are mostly about XML parsing... Of which WP probably does plenty (feeds, updates, what else?..) but how to pinpoint what is going wrong? This has me really puzzled.
A quick Google search confirmed your suspicion ... this is likely an XML parsing error. Furthermore, some discussion on the forums suggests it's caused by script insertion after a closing <code> &lt;/rss&gt; </code> tag. If it is an inserted script, this is likely the result of a hack or an attack on your site or host. Another possibility is stackexchange-url ("a PHP error in the RSS-generation script"). PHP would return the error in-line, and the error message, being non-XML, would be read as "junk" by the XML parser. This could also be the result of a feed your site is trying to read (i.e. on the admin dashboard), not necessarily a feed you're generating.
What might cause "junk after document element" error?
wordpress
I need to know solutions for the question above. There are cases, when we need post meta information outside the loop. Let's say, I'm developing theme that will display ads from certain vendor on that page (everywhere on that particular page) based on post meta information. Because, I've bilingual blog and I will use different vendor for each language (for CTR reason). So, do you guys have a solutions for this kind of problem?
Do you mean meta like in custom fields or information from post in general? Basically as long as you have post id you can get anything you want, not tied to the Loop. For custom fields there is <code> get_post_meta() </code> . For general information (like title or content) there is number of functions (many template tags can be explicitly passed post id, they just default to current Loop item) and there is <code> get_post_field($field, $post); </code> (can't find in documentation, but self-explaining).
Strategy to get post meta for use outside the loop
wordpress
The free wordpress blogs (those hosted at wordpress.com) have a build in code formatting plugin Is it possible to get this on private installs of wordpress? I've copied all my posts across but the code formatting feature doesn't work out of the box I'm primarily looking for Java syntax highlighting
This is the plugin used on WordPress.com: http://wordpress.org/extend/plugins/syntaxhighlighter/
Code markup plugin like the .wordpress.com blogs offer?
wordpress
Thanks to some help on here, I've managed to add a custom search box to my main menu... by adding this to my theme's functions.php <code> add_filter('wp_nav_menu_items','search_box_function'); function search_box_function ($nav){ return $nav."&lt;li class='menu-header-search'&gt;&lt;form action='http://example.com/' id='searchform' method='get'&gt;&lt;input type='text' name='s' id='s' placeholder='Search'&gt;&lt;/form&gt;&lt;/li&gt;"; } </code> However, I've now added another menu to put in the footer, but the search box gets added to this one too. How would I add the search box to the primary menu only? My code for registering the menus is: <code> register_nav_menus( array( 'primary' =&gt; __( 'Primary Navigation', 'twentyten' ), 'secondary'=&gt;__('Secondary Menu', 'twentyten' ), ) ); </code> ..and the code to display the secondary menu is: <code> wp_nav_menu( array( 'container_class' =&gt; 'menu-header', 'theme_location' =&gt; 'secondary' ) ); </code>
To only add the custom search box to the main menu you could pass the second parameter provided by the wp_nav_menu_items filter and check if the theme_location is the primary location <code> add_filter('wp_nav_menu_items','search_box_function', 10, 2); function search_box_function( $nav, $args ) { if( $args-&gt;theme_location == 'primary' ) return $nav."&lt;li class='menu-header-search'&gt;&lt;form action='http://example.com/' id='searchform' method='get'&gt;&lt;input type='text' name='s' id='s' placeholder='Search'&gt;&lt;/form&gt;&lt;/li&gt;"; return $nav; } </code>
Customizing Only a Specific Menu using the "wp_nav_menu_items" Hook?
wordpress
I'm having difficulty in creating a big post since the editor box is quite small. I want to make it bigger. Can I?
You have a couple of options. First, you can always click on the bottom right corner of the post edit box and drag to resize: However, you can also make it so that the post box is larger by default. Go to Settings > Writing, and change the value for size of the post box:
Making the Post/Page Content Editor Box Bigger?
wordpress
How can I change the format of attachment page urls from <code> /[post-url]/[attachment-name]/ </code> to <code> /media/[attachment-name]/ </code> ? I understand that I can override the output of <code> get_attachment_link </code> via the <code> attachment_link </code> filter, but I guess I need to change the redirect structure so WordPress knows how to handle these urls?
You can do the following: <code> /* add new rewrite rule */ function attachment_rewrite( $wp_rewrite ) { $rule = array( 'media/(.+)' =&gt; 'index.php?attachment=' . $wp_rewrite-&gt;preg_index(1) ); $wp_rewrite-&gt;rules = $rule + $wp_rewrite-&gt;rules; } add_filter( 'generate_rewrite_rules', 'attachment_rewrite' ); /* redirect standard wordpress attachments urls to new format */ function redirect_old_attachment() { global $wp; if( !preg_match( '/^media\/(.*)/', $wp-&gt;request ) &amp;&amp; isset( $wp-&gt;query_vars['attachment'] ) ) { wp_redirect( site_url( '/media/' . $wp-&gt;query_vars['attachment'] ) , 301 ); } } add_filter( 'template_redirect', 'redirect_old_attachment' ); </code>
Changing attachment urls?
wordpress
Been reading this site and Wordpress Codex and I see there is a function to enable custom type of pages in Wordpress. How can I do the same to enable for Pages ? Or at least get the options for the posts to appear for placing the posts under Pages ?
you question is not so clear for understand. Anyway i try to respond... You can use 'hierarchical' => true when you declarate you new custom post type. For placing this new menu in some other position in your admin are use the proprety 'menu_position' => 5,. Example (to add in your functions.php file): <code> add_action( 'init', 'create_my_post_types' ); function create_my_post_types() { register_post_type( 'mycustompages', array( 'labels' =&gt; array( 'name' =&gt; __( 'My custom pages' ), 'singular_name' =&gt; __( 'My custom page' ) ), 'public' =&gt; true, 'hierarchical' =&gt; true, 'show_ui' =&gt; true, 'publicly_queryable' =&gt; true, 'exclude_from_search' =&gt; false, 'menu_position' =&gt; 5, 'supports' =&gt; array( 'title', 'editor', 'comments', 'trackbacks', 'author', 'excerpt', 'custom-fields', 'thumbnail' ), 'rewrite' =&gt; array( 'slug' =&gt; 'mypage', 'with_front' =&gt; false ), ) ); } </code>
register_post_type for Pages?
wordpress
I have a problem with WP database synchronization between development and production and I am wondering how other people solving it. I am aware about stackexchange-url ("this question") but it doesn't really cover the nastier and more realistic use case. Say I have a life WP website. I took a dump of everything, replicating it on our dev environment. I started making changes. 1 week later I am ready to deploy my updates. In the meantime production has changed(new posts, new comments, etc.). How do I synchronize changes between production and development during the rollout and is it possible to automate(somewhat at least) this process?
There may be a better way that I am missing but I am going to give you 2 options: 1.Use XML Export to export your new posts and comments. Then use the WordPress Importer to import the new posts and comments back into the dev database It's best to import into dev then move the database over to production because when you import it will download all the new media files from production. In the meantime production has changed(new posts, new comments, etc.) This would solve your problem of bringing in any changed content. 2. Use the INSERT IGNORE INTO MySql command to add the new tables from dev. or the REPLACE command to overwrite duplicate rows in the same table. Before using MySql make a backup of both databases and move the gz database to the production server and upload the dump (change the name of dev if it's the same as production. <code> INSERT IGNORE INTO `_wp_production_db`.`wp_cool_plugin_options` SELECT * FROM `_wp_dev_db`.`wp_cool_plugin_options` </code> I'm not comfortable with MySql commands so I would go with option 1.
Database synchronization between dev/staging and production
wordpress
On the free version of wordpress, ie the one you setup for free and get hosted at "myblog.wordpress.com", it has a very nice module on the dashboard for tracking statistics. It displays a nice hit-counter graph and shows search engine terms used etc, without any clutter Is it possible to get this for a self hosted install of wordpress? I can't see it installed by default
Not installed by default, but available as plugin from repository: WordPress.com Stats
How to get the "stats" plugin that comes with a .wordpress.com blog?
wordpress
Internet Explorer will have errors with VB script files en-queued using wp_enqueue_script. This is probably because the output of enqueue script set the script type to 'language/javascript'. Are there any solutions besides manually including the VB script with the theme?
<code> WP_Script </code> always adds <code> text/javascript </code> to the <code> &lt;script&gt; </code> tag, and applies no filter before it returns, there is not much you can do there. You could try to create a subclass of <code> WP_Scripts </code> that has this functionality. If you change the global <code> $wp_scripts </code> to your new class, this might work.
How do you enqueue a Visual Basic script using wp_enqueue_script?
wordpress
I wish to implement the wordpress 3 menus API in a client site, but the designs has restraint on the width of the top level menu items. How can I be sure the client won't exceed that limit?
The easiest way to accomplish this would be to filter <code> wp_nav_menu_items </code> or more precisely <code> wp_nav_menu_{$menu-&gt;slug}_items </code> and cut extra items from output. It would probably me more pretty and proper to limit/warn user in admin area, but at moment I have no remote idea where to start with that. I should learn up on admin side some time. :)
Is there a way to limit the number of top level items in a custom menu?
wordpress
I was wondering whether there's a common way of customising the aspect of the admin panel. I know you can play with the css and js files but what I was looking for is some kind of "admin theme" like with drupal. I´m asking so that you can personalize the admin panel while keeping your WP easily updateable. Thanks in advance.
There is currently no way to create admin themes like Drupal. Here are some tips which cover most of the basic admin panel customization needs: http://www.cmurrayconsulting.com/wordpress-tips/customizing-wordpress-admin/
Any official way to create an admin theme?
wordpress
I have a category that ends with -2, and there's no way I can change it back to the plain word. I know there are problems with numeric slugs, but this is just a word. I also know that a common answer is to look in the trash, but there's no trash for categories as far as I'm aware
You probably have a tag with the same slug. You can't have any taxonomies with duplicate slugs. Either delete that other taxonomy, rename/change its slug, or change/rename this category. EDIT Ok, it turns out you can do this, if you don't mind programming the fix or directly executing the SQL or messing with PHPMyAdmin. What you need to do is add a new row in <code> wp_term_taxonomy </code> that uses the term with the slug you want to use as the <code> term_id </code> and the new taxonomy (category in this case) as the <code> taxonomy </code> . This is necessary because, if the slug already exists, WP creates a new term rather than using the same term with a different term_taxonomy relationship.
Removing the number in a category slug
wordpress
I run a site with over 100 specific redirects in the htaccess for legacy html files that were subsequently brought into WP. There are also rules for pages within a date range to redirect to the home page, and all sorts of other nasties. Given that WP handles redirects and permalinks internally, and without using a plugin, what would be the best way to programatically redirect these links and keep my .htaccess file clean?
The best way to "programatically redirect these links and keep [your] .htaccess file clean" would actually be with a plugin. I know you stated "without using a plugin," but you'll get the same functionality from a plugin that you would if you wrote the code yourself. And, considering how non-user-friendly the WP rewrite scripts are, I strongly suggest you don't try to write it yourself (I'm an experienced WP developer and I still have trouble with the clanky rewrite engine). So if you're willing to go with a plugin, I recommend Redirection . Redirection has a very intuitive UI that allows you to create, display, and manipulate all of your custom redirects. It also keeps track of any 404 errors your site generates by mistake. I use Redirection on my site to redirect legacy links from my ancient static site to the new dynamic WordPress links. I've also used it on several client sites after helping them migrate to WordPress.
Using WP rather than .htaccess to redirect pages/posts
wordpress
is it possible to use the thumbnail mechanic twice? I find the thumbnail API really useful for allowing users to place in there own graphics, so that I can control size and position easily. All they have to do is remember to click featured image. I would like two such mechanisms on my page, any idea how I could do this? Preferably hand coding.
Checkout the multiple post thumbnails plugin . It will allow you to define multiple post thumbnails for specific post types.
Double thumbnails?
wordpress
I have a version 3 installation of wordpress on my hosting package that I installed myself Everything else so far seems ok such as posting etc, but I'm unable to install any new themes I have tried to install a theme from clicking one of the "featured" themes, and have tried to upload a ZIP from the wordpress themes website, but each time it just hangs on "Unpacking" or "downloading" and nothing ever happens, I don't get any errors I've noticed that under <code> /wp-content/uploads </code> I can see a zip I select for upload, its filesize seems ok Any ideas?
This problem most notably occurs on systems running PHP4. If you can, upgrade your server to PHP5 (if you're on a hosted server, there's usually a setting in cPanel or whatever administrative tool you have to switch from PHP4 to PHP5).
Unable to upload/install any WordPress themes
wordpress
I am creating a custom theme with a theme options page. I would like to style the options page and do not want to include inline styles. Is there any way to include an external stylesheet from say <code> TEMPLATEPATH . '/css/admin.css' </code> I have also found this chunk of code and it seems to work - link <code> function admin_register_head() { $siteurl = get_option('siteurl'); $url = $siteurl . '/wp-content/plugins/' . basename(dirname(__FILE__)) . '/yourstyle.css'; echo "&lt;link rel='stylesheet' type='text/css' href='$url' /&gt;\n"; } add_action('admin_head', 'admin_register_head'); </code> What is the best way?
If you create an admin theme plugin from the Codex steps, you will notice it says not to insert stylesheets as per above - although the above will work. If you place the following inside your admin theme file, it will serve the same purpose, but uses the wp_enqueue_styles approach: <code> function add_admin_theme_styles() { wp_register_style($handle = 'mytheme-theme-admin-styles', $src = plugins_url('wp-admin.css', __FILE__), $deps = array(), $ver = '1.0.0', $media = 'all'); wp_enqueue_style('mytheme-theme-admin-styles');} add_action('admin_print_styles', 'add_admin_theme_styles'); </code>
Including CSS and JS on Admin Screen of Custom Theme Options
wordpress
I am not sure how many of you have experimented with the new custom header image functionality of wordpress 3.0 but its actually very cool (enabled by adding the function to your functions.php file). One of the key things which I find to be extremely useful is that it allows you to upload an image and on step 2 it actually places the image on the admin page and shows you a crop box based upon the header image width/height which was defined in your functions.php file. You now have the ability to move the box around or proportionally increase/decrease the size of the area you want to use. The problem that I am having here is that I would like to utilize this functionality with my own custom post type. More specifically, I am just looking for the ability to include the upload functionality, defining the width/height and the select/cropping functionality once the image was uploaded. My thoughts are that if someone can show this can be done then I can create all the other functionality I am looking for by adding this to a custom post type and associating custom metaboxes. Can anyone provide a solution here?
Take a look into <code> /wp-admin/custom-header.php </code> . You may extend the class <code> Custom_Image_Header </code> and adjust it to your needs.
Using Default WordPress Custom Header Image Crop Feature in a Post Type / MetaBox
wordpress
I have recently imported an image gallery to a clean WP install as I am deploying the site to a live domain. I have imported the posts but the images use the medium size for attachements. I would like to get these all to revert to the settings I had set up in the development install. Does anyone have a idea on how to change the size on already imported image attachements? Thanks in advance, J
You can use this plugin: http://wordpress.org/extend/plugins/regenerate-thumbnails/ .
Importing media medium setting image gallery / image attachments
wordpress
When creating custom page templates, how do I get the value of a custom field of the displayed page?
Use the get_post_meta function.
How do I read the value of a custom field of the page?
wordpress
Currently, I have a blog that runs atop Tumblr, which is relatively young (3 months old or so, maybe 25 posts altogehter) that I want to migrate to a self-hosted Wordpress installation. I've installed and configured Wordpress many, many times, but I've never been able to figure this out. Here's what I'd like to do, ideally: First, keep the existing blog up and active during the entire process Install Wordpress somewhere public and migrate the content either by hand or using an import tool of some kind Install whichever theme I end up using, customize the crap out of it Switch the DNS for my domain so that users gradually begin to see the fully built and migrated Wordpress site instead of the Tumblr site. Here are the problems with this as I understand them: I won't be able to install the Wordpress blog within the domain in which it will ultimately live because that domain points somewhere else. For this reason, I'll need to install it on a different domain (test.realdomain.com or something) and do all of the import and theme dev stuff there. The bad part here is that Wordpress uses the post's full URL as it's GUID, so I'll have to hand-edit the database so that each post, page and media asset lives at realdomain.com instead of test.realdomain.com. I'm wondering if, in all of my Wordpress travels, I've somehow missed a super easy solution to this problem. For a product as mature as Wordpress, I find it hard to believe that there's no easy way to, say, build a site in a staging environment and deploy it to production without have to manually edit database tables. Any assistance offered would be greatly appreciated, and feel free to let me know if I've left out any details that would help clarify anything. Thanks!
As others have already mentioned, this can be a long process. But it can also be relatively straightforward, and I've done this to migrate other non-WP sites to WordPress in the past. Export your site First things first, you'll need to export your site from Tumblr into a format WordPress can work with. There are a few tutorials out there on how to do this, but also one great tool built specifically for this purpose called Tumblr2WordPress. You'll also want to make backup copies of any images you're using, just in case they're lost during the export/import process. Set up WordPress on a temporary domain Most hosting packages allow you to access your site from a temporary domain while in development. Use this feature to set up your WordPress site and tweak all of the settings to be just the way you want them. Then ... Import your Tumblr site Once WordPress is up-and-running, import your old site and make sure everything is working the way you want it to. Change the site URL Now that WordPress is running, we want to tell it the correct domain name to use. So log in to your dashboard and go to Settings &raquo; General. Change both the site URL and blog URL to the values you want to use and click "Save." This will temporarily break your site!!! You will not be able to log back in until following the next steps!!! Edit your <code> hosts </code> file On Windows, you can edit your <code> hosts </code> file to redirect domains to different locations. This will make it so, on your machine only , your site will appear at <code> http://mysite.com </code> even though it's actually at <code> http://temporarysubdomain.myhost.com </code> . Here's a quick tutorial good through Windows XP. Here's another Flush your DNS From the command prompt (i.e. DOS), run the command <code> ipconfig /flushdns </code> . This will flush your DNS resolver cache and speed things along a bit. Log back in to WordPress If you've done things correctly, you should now be able to access your site at <code> http://mysite.com </code> from the computer with the edited <code> hosts </code> file . Log in and make sure the site is still displaying as it should. Take a few minutes to edit any image URLs that broke in the transition and get things looking snazzy. Point your domain Now that WordPress is installed, configured to work with your domain, and displaying your migrated Tumblr content, it's time to actually point the domain at WordPress. Go back to your host and move the domain so it's pointing at the right location. Reset your <code> hosts </code> file Now that the domain is pointed, go back and un-do the changes you made to your <code> hosts </code> file ... otherwise there's no way to know when the transition has been made (your system will always be pointing to the right site, even if the rest of the world isn't). Crack open a beer and watch a football game Seriously. DNS updates can take a while to propagate over the Internet, so don't expect your re-pointed domain to work immediately. It might take 12 minutes. It might take 12 hours. This depends on your host and your ISP. Go to your site domain Check in from time-to-time during the football game you're watching to see if it's been pointed correctly (I recommend commercials and time outs ... they're boring anyway). Now that you're running with the default <code> hosts </code> file, you should see the new site immediately when the DNS finally pushes through. Viola! You're done If you've done all of the above steps correctly, you should be done. The entire process can take anywhere from 15 minutes to several hours depending on how long it takes for your ISP's DNS cache to refresh. I've used this process more than a dozen times on client sites and it works every time. Some quick notes ... When your images are imported, they'll likely be stored with the URL <code> http://temporarysubdomain.myhost.com </code> rather than <code> http://mysite.com </code> . You'll either need to create a server-side redirect to fix this, or manually edit your images. Since you only have 25 posts this isn't a huge deal to do by hand, but there are ways to automate the process with SQL search-and-replace statements if you're looking for a shortcut. Do not touch the GUID! I can't stress this enough. The GUID stored in the database is a "Globally Unique Identifier" ... meaning it's unique for that specific page or asset, despite the domain you're on. Yes, WordPress uses the site's URL to generate the GUID, but that doesn't actually mean anything. It's just a static string that's not supposed to be used for anything except to identify the post as unique from others in the database. Even though your imported posts will have your test domain as part of the GUID, do not change this . As always, if you have any questions, feel free to ask.
How can I migrate from another platform to WordPress (using the same domain) and launch when ready?
wordpress
I've a series of custom fields attached to certain pages. These fields are named slide1, slide2, side3, slide4, slide5, slide6. These are images which are going to be used as a slideshow (I'm using jflow slider for this - http://net.tutsplus.com/articles/news/using-the-wonderful-jflow-plugin-screencast/ ) (I don't want to call them all 'slide' and put them in an custom field array because there may be captions for each slide, and when both slides and captions are custom field arrays, the order may not match up) Now, sometimes there will be only 3 slides entered (slide1 to slide3), and sometimes all 6 slides (slide1 to slide6). Not being very PHP savvy, I wonder what the best way best way to stick these custom fields into a PHP array, and then iterate thru them to print out the code, which looks a bit like the below? <code> &lt;div id="slides"&gt; &lt;div&gt;&lt;img src="qwerty.jpg"&gt; &lt;/div&gt; &lt;div&gt;&lt;img src="foo.jpg"&gt; &lt;/div&gt; &lt;div&gt;&lt;img src="test.jpg"&gt; &lt;/div&gt; &lt;/div&gt; </code> The code to print, for instance slide1's image, would be something like: <code> &lt;img src="&lt;?php echo wp_get_attachment_url($slide1); ?&gt;"&gt; </code>
This way of wokring with slides seems to be as popular as it is terrible... :) I coded something very much like this recently. Basic idea, adjust as needed: <code> $id = get_the_ID(); $slides = array(); $i = 1; foreach( get_post_custom_keys( $id ) as $key ) if ( false !== strpos( $key, 'slide' ) ) $slides[$key] = get_post_meta( $id, $key, true); while( isset( $slides["slide{$i}"] ) ) { echo '&lt;img src="' . wp_get_attachment_url( $slides["slide{$i}"] ). '" /&gt;'; $i++; } </code>
Best way of getting a a series of custom fields into an array?
wordpress
Does word press show me if I'm logged in in another location? Related: stackexchange-url ("Limiting sessions to one IP at a time")
When WordPress logs you in, it creates a cookie on your system to keep you logged in if you want. However, being logged in from another location doesn't have much meaning in this context. When you go back to your WP site, WordPress will check for the existence of this authentication cookie on your system. If it's there and valid, you'll be logged in. If it's missing or invalid, you'll have to log in again. However, WordPress doesn't track if you're logged in on one machine versus another at the same time. You could probably set up a plug-in of some sort to track which users are logged in using sessions or transients ... but this isn't WordPress' default behavior.
Does WP show me if I'm logged in from multiple locations?
wordpress
Are there any known privilege escalation bugs in WP 2.9 to be careful for?
There are no known security vulnerabilities in 2.9.2 If any new vulnerabilities are discovered the fix will be packported. (This has not happened but if it did we would get a version 2.9.3) WordPress does not have a backport policy that goes further than the previous major release so it is unknown when the 2.9 branch will stop being supported. WordPress does not maintain lts versions. Matt likes to call them Long Term Suckage and most in the community agree that there is really no reason to keep running out dated versions.
Privilege escalation bugs in 2.9?
wordpress
Why is the visual editor in Wordpress is limiting the width by wrapping the content? I found this behavior in the editor at least annoying, it does prevent me from using my screen real estate.
Hazarding a guess at what you really mean, I suppose you mean something like this is happening: If that is what you're referring to, that's because your theme has an <code> editor-style.css </code> stylesheet that's getting used in the visual editor. Somewhere inside that stylesheet is something like this: <code> html .mceContentBody { max-width:640px; } </code> Removing that or modifying the <code> max-width </code> value will let you customize that. The other option is to remove the stylesheet altogether. To do that, find this line of code in your theme (probably in <code> functions.php </code> ): <code> add_editor_style(); </code> and remove it. If this was not at all your problem, I apologize and would love some clarification. EDIT Since it looks like WordPress loads your stylesheet before it loads the template stylesheet, there are two ways to override styles. First (and easiest): make your style important: <code> html .mceContentBody { max-width: none !important; } </code> To stop the editor from loading the parent styles at all, you could add this to your theme's functions.php file: <code> function get_rid_of_editor_styles(){ global $editor_styles; if(is_array($editor_styles)) foreach($editor_styles as $e) $e = 'editor-style.css' == $e ? '' : $e; } add_action('init','get_rid_of_editor_styles'); function add_my_own_editor_styles(){ add_editor_style( 'custom-editor-style.css' ); } add_action('after_setup_theme','add_my_own_editor_styles'); </code> Then in your child theme, use <code> custom-editor-style.css </code> as your child theme's editor stylesheet instead of <code> editor-style.css </code> . Please note, this last part of the answer would not be the best solution for everybody. I'm only offering it because I know that you are using a child theme using twentyten as the template.
Why is the visual editor in WordPress limiting the width by wrapping the content?
wordpress
I have a fair amount of content in wordpress pages that gradually gets out of date over time. I can have an 'offline' process to set reminders in my calendar to remind me to review particular pages and bring them up to date. However I was wondering if there is a way (with a plugin perhaps) to have WordPress put the pages into a 'needs review' state a certain amount of time after it was last edited. This would keep the page live, but prompts me to review the content.
I tend to look for simple solutions so my suggestion is to query pages, sort by modified day and display in Dashboard widget. <code> add_action( 'wp_dashboard_setup', 'add_old_pages_widget' ); function add_old_pages_widget() { wp_add_dashboard_widget( 'oldpages', 'Oldest Pages', 'old_pages' ); } function old_pages() { $pages = get_pages( array( 'sort_column' =&gt; 'post_modified' ) ); echo '&lt;ul&gt;'; foreach ( $pages as $page) { $edited = human_time_diff( strtotime($page-&gt;post_modified) ); $link = get_edit_post_link( $page-&gt;ID ); echo "&lt;li&gt;&lt;a href='{$link}'&gt;{$page-&gt;post_title}&lt;/a&gt; ( edited {$edited} ago )&lt;/li&gt;"; } echo '&lt;/ul&gt;'; } </code> Can be modified to hide if no pages old enough, etc, etc.
Prompting for review / reapproval of page content
wordpress
The idea here is to have a site (any site) which somehow has the user's WordPress user-name and login (maybe as part of a sister site) to allow him to write a post on his own blog. The idea I have now is basically a simple form sent (perhaps with curl or socket) to the user's blog admin_ajax.php, even though it is strictly not an AJAX call. Are there any other methods which I could try or is there something built into WordPress itself already?
WordPress supports XML-RPC protocol for such things. That is how desktop blogging clients work. Alternatively you can try to set it up via post by email .
Allowing a user to write a post from another website?
wordpress
I've got a blog hosted on .wordpress.com, ie the free version. I'm thinking of re-activating my hosting package so I can have my own WP installation, and therefore have more customisation options open to me etc. I'm getting traffic from search engines, how can I redirect this traffic to my new location? Once I have the new one setup, I would prefer people to view that instead of my old site, what can I do to achieve this, whilst retaining my position in search engines?
Didn't try this myself (self-hosted from the start), but this seems fitting guide for your situation: How to Migrate your Blog from WordPress.com to a Personal Domain ( Digital Inspiration )
Redirecting traffic from old ".WordPress.com" blog to privately hosted WordPress blog?
wordpress
Hi to all I made a wordpress plugin amtythumb post. All previous versions are reflected at worpress SVN within some hours. But this time 5.5 version of my plugin is not being reflected on wordpress plugin site even after 3-4 days. just check wordpress plugin site wordpress.org/extend/plugins/amty-thumb-recent-post/ And SVN for confirmation, http://plugins.svn.wordpress.org/amty-thumb-recent-post/amty-thumb-recent-post/tags/ . Please let me know what to do...
@articlestack According to the trac revision log you added a new directory under your root with the same name as the plugin. It looks like your whole root directory got copied to the new directory because it contains all the tagged versions and trunk. The plugin bot will not be able to find your newly tagged version unless it's in trunk or the new version is tagged in root/tags. You can fix it by moving 5.5 back into the root tags dir. <code> my-local-dir/$ svn cp amty-thumb-recent-post/trunk tags/5.5 </code> then delete the extra dir <code> my-local-dir/$ svn del ampty-thumb-recent-post </code> and check it back in <code> my-local-dir/$ svn ci -m "tagging version 5.5" </code>
My new WordPress plugin version is not showing up in the plugin directory. It's been 4 days what could the problem be?
wordpress
Many users with strange names, register on my blog, but don't leave comments. Should I be afraid, that this might be attack of some sort. Maybe someone found some sort of bug in Wordpress which allows to penetrate security? Are there any actions I should take?
Spam bots will always try to register. They basically just input data into any form they can find in hopes it will pull their URL on to your page so they can build trackbacks and score higher in Google rankings. There are a couple of things you can do to prevent this: If you don't need people to register for your site (most don't) just turn off new user registration. Install a captcha plugin for your registration form. It won't catch everything, but it should decrease the number of bogus registrations you're seeing. A good one I've heard of is Sabre. You might also want to read this good article by Lorelle discussing anti-spam techniques with WordPress. It's from 2007, but the tools and tips are still very relevant. First things first, though, would be to delete these bogus users from your database. All they are is clutter ... if they're not real people, they don't need to be there in the first place.
Many users with strange names register, but don't leave comments. Should I be afraid?
wordpress
I want to turn the comments off by default with pages and custom post-types Initially I simply used conditionals in the comments display function to avoid displaying the block on these pages, but I need the user to be able to turn the comments back on as required.
From what I understand, you want to set pages and some custom post types to have commenting 'off' by default, while posts will still use the default option (i.e. commenting 'on'). If this is the case, the following function will do it. <code> function default_comments_off( $data ) { if( $data['post_type'] == 'page' &amp;&amp; $data['post_status'] == 'auto-draft' ) { $data['comment_status'] = 0; } return $data; } add_filter( 'wp_insert_post_data', 'default_comments_off' ); </code>
setting comments off as default for pages and custom post types?
wordpress
I'm looking to create a simple directory, something similar but not so powerful as SOBI2 for Joomla . Is there something like this for Wordpress? I want to store informations like: Name URL Address (country, region) Details (text) People should be able to browse or search such a simple directory. Is there something like this available for WordPress?
Hi @Sorin Sbarnea : Sounds like what you want is to use Custom Post Types with custom fields to create your own directory. Here's an answer I wrote about exactly that: <a href="stackexchange-url Tips for using WordPress as a CMS? <a href="stackexchange-url Implementing a CrunchBase.com Clone using WordPress? Also, take a look at the SimpleFields plugin for WordPress which can help you create these custom fields: SimpleFields Plugin
How to create a mini directory in WordPress?
wordpress
About a year ago I remember seeing a plugin or some code which allowed you to add an author dropdown menu to the post "publishing" metabox instead of it being on its own. I can't seem to find this code anymore and was wondering if anyone knows how to easily do this? In an ideal situation I would like to essentially add an additional row under the "Visibility:" row within the Publish metabox stating "Author:" along with the current authors name and an edit link after the name. Upon clicking on the edit link a drop down would show up with the same information as is available in author metabox. In any case, I would greatly appreciate to know how this can be done.
I somewhat suck with admin stuff so test this carefully. I had some issues with users not coming up in dropdown, but it fails with default meta box as well - probably because of my messed up test stack. <code> add_action( 'admin_menu', 'remove_author_box' ); add_action( 'post_submitbox_misc_actions', 'author_in_publish' ); function remove_author_box() { remove_meta_box( 'authordiv', 'post', 'normal' ); } function author_in_publish() { global $post_ID; $post = get_post( $post_ID ); echo '&lt;div class="misc-pub-section"&gt;Author: '; post_author_meta_box( $post ); echo '&lt;/div&gt;'; } </code>
How to Move the Author Metabox into the "Publish" metabox?
wordpress
I'm looking to reuse some small portions of html inside several pages/post but I don't know how to obtain this on WordPress. It would be nice if I could have a helper in the editor to include them, but this is only a nice to have feature, for the moment I need a solution for this.
So far I found the Shortcoder plugin that allows me to add 20 shortcodes. For the moment this is enough and I hope the developer will solve this limiation soon. For some reason this plugin does not appear when I search by its name on Wordpress website. Also, I'm open to accept new suggestions/alternatives.
How do I add my own custom shortcodes?
wordpress
Here is an interesting question. I have recently noticed that if you utilize the code <code> remove_meta_box('slugdiv', 'post', 'normal'); </code> you are actually unable to modify the slug when you click on the url slug under the page title. To clarify, when you use remove_meta_box for the slugdiv, the metabox and the screen options get removed however you are still able to click on the url under the post title to edit it... However, when you go to update/publish the post whatever modification you made does not take. My objective is to remove the same metabox from the post edit screen AND remove it from the screen options page BUT I want to ensure that when you edit the slug under the post title that this still works. Can anyone provide a solution to this problem? Thanks in advance.
I ended up just adding the following CSS to a css file I was calling in my functions.php file for the admin area: <code> [for="slugdiv-hide"] { display: none; } #slugdiv { display: none; } </code> This removed both the screen options and the metabox while still allowing me to edit the url under the title. UPDATED Based on the answer provided by FXFUTURE I modified his code by extending it and including the css values for screen options and the slug metabox while ensuring that the code only gets included on the post-new.php and post.php page. <code> // HIDE THE SLUG METABOX AND SLUG SCREEN OPTIONS function hide_slug_options() { global $post; global $pagenow; $hide_slugs = "&lt;style type=\"text/css\"&gt;#slugdiv, #edit-slug-box, [for=\"slugdiv-hide\"] { display: none; }&lt;/style&gt;\n"; if (is_admin() &amp;&amp; $pagenow=='post-new.php' OR $pagenow=='post.php') print($hide_slugs); } add_action( 'admin_head', 'hide_slug_options' ); </code>
Removing Metabox for "Slug" without removing functionality
wordpress
In the codex it lists the parameter $context for the add_meta_box as having the following options: normal advanced side What does "advanced" do? I don't see any difference between it and "normal".
The difference between normal and advanced is that normal will be placed on the page before advanced. For example the following will display "One" before "Two" <code> function admin_init_test() { add_meta_box('one', __('One'), 'test_one', 'post', 'advanced'); add_meta_box('two', __('Two'), 'test_two', 'post', 'normal'); } add_action('admin_init', 'admin_init_test'); function test_two() { echo "&lt;p&gt;test_two&lt;/p&gt;"; } function test_one() { echo "&lt;p&gt;test_one&lt;/p&gt;"; } </code> If you switch the context parameter around, then "Two" will display before "One" on the edit page: <code> add_meta_box('one', __('One'), 'test_one', 'post', 'normal'); add_meta_box('two', __('Two'), 'test_two', 'post', 'advanced'); </code> Also if you reorder the meta boxes yourself by dragging them around then that order is saved and seems to take precedence over the 'normal' and 'advanced' contexts.
What is the "Advanced" $context in add_meta_box?
wordpress
Long time lurker, but first time poster. I've searched Google extensively and just can't seem to come up with an answer on this problem. I use Justin Tadlock's excellent 'Members' plugin for roles and permissions on several client installations of WP. I've recently deployed a theme where the client should only have access to the Appearance -> Menus item, but none of the others sub-items in the Appearance menu of the admin. When enabled, the role 'edit_theme_options' enables the user to access 'Themes', 'Widgets', and 'Menus'. How would I go about filtering the submenu so that if the role 'edit_custom_menus' is assigned, the 'Menus' link will show?
Upon further searching and after discovering the $submenu global variable, I've managed to find a helpful tutorial on removing sub-menus from the WordPress admin . I'll post with code when I get a full solution implemented and integrated with the plugin.
Applying roles to an admin sub-menu (eg Appearance -> Menus)
wordpress
I am asking since I am trying to understand if this widget is causing my server to overuse CPU or memory. But either way - it's interesting to know.
RSS widget uses <code> fetch_feed() </code> function, which is setting default cache lifetime to 43200 seconds (12 hours). Since this value is filtered it can be overridden (as can feed cache overall). I did encounter plugin once, whose developer citing performance reasons completely disabled feed caching for all feeds.
How often does the RSS widget get updates?
wordpress
I need a plugin which can do horizontal scrolling of RSS feeds in wordpress, I have got a vertical scrolling RSS feeds but cannot find a horizontal one
Things that present headlines in a horizontal scroll tend to be called tickers. (Probably due to there resemblance to old-school ticker tape printers.) Anyway, try these: http://wordpress.org/extend/plugins/news-ticker/ http://wordpress.org/extend/plugins/wordpress-news-ticker-plugin/ (may not do RSS) http://wordpress.org/extend/plugins/accessible-news-ticker/ They should all do pretty much the same thing, but they will differ in their appearance. If you don't mind about the appearance, I would recommend the first due to the ease of management.
Which plugin can do horizontal scrolling of RSS feeds in WordPress
wordpress
I saw this message today when accessing my plugin page: So, how do I create this if I want to update my own plugins that's hosted on wordpress?
This message is created by <code> W3_Total_Cache-&gt;in_plugin_update_message() </code> hooked to <code> "in_plugin_update_message-$file" </code> in <code> wp_plugin_update_row() </code> . It does some nifties to parse readme and display info from changelog, but overall you can just echo some stuff as with any other hook.
How to create custom message on plugin update
wordpress
I need a plugin like google tasks, in which we can add in to do tasks on the wordpress page
I don’t know Google Tasks. But a Task Manager I use on nearly every blog is Cleverness To-Do List . You can order tasks by custom categories and by priority, assign tasks to specific users and set the progress for each task. Really useful, saves me hundreds of mails from my clients. ;)
I need a plugin in wordpress like google tasks
wordpress
We were using WPMU version 2.9.1, in which we had a plugin - Fimii WPMU Stats mu-plugin - that showed us last updated blogs, and newest blogs. We now upgraded to Wodpress 3.0, and the commands for the plugin don't work anymore. Does anyone know of a replacement for that plugin? Or something else that will show the data?
We found 2 plugins that work: http://wordpress.org/extend/plugins/multisite-recent-posts-widget/ and http://wordpress.org/extend/plugins/multisite-recent-posts-widget/
How to get last_updated and newest_blogs in WP 3.0
wordpress
In a site I have using Wordpress 3.0, when I'm in a single post, the navbar showing the categories doesn't give the parent category the class of "current_cat" and therefore that category is not highlighted. How can I make Wordpress give the parent category that class in single_post mode?
I found the answer here. Add to functions.php the following function and hook: <code> function sgr_show_current_cat_on_single($output) { global $post; if( is_single() ) { $categories = wp_get_post_categories($post-&gt;ID); foreach( $categories as $catid ) { $cat = get_category($catid); // Find cat-item-ID in the string if(preg_match('#cat-item-' . $cat-&gt;cat_ID . '#', $output)) { $output = str_replace('cat-item-'.$cat-&gt;cat_ID, 'cat-item-'.$cat-&gt;cat_ID . ' current-cat', $output); } } } return $output; } add_filter('wp_list_categories', 'sgr_show_current_cat_on_single'); </code>
How to get current_cat in navbar, in single post
wordpress
One my widget bar, I have an image which is hyperlinked. The problem is that CSS underlines it. How do I remove the underline? Update: Just noticed that this is what is causing the underline: <code> } .entry a, .secondaryColumn a, #commentsContainer h3 a, .commentlist .comment-author a { border-bottom: 1px solid #ddd; color: #3c6c92; font-weight: bold; } .entry a:hover, .secondaryColumn a:hover, #commentsContainer h3 a:hover, .commentlist .comment-author a:hover, .commentlist .comment-meta a:hover { color: #3c6c92; border-bottom: 1px solid #3c6c92; } </code> changing the border-bottom to 0px does the trick, but then it takes off the border across all widgets. I use Grid-focus with a wee bit of customization @ thunderror.com
By definition it isn't really hyperlinked image. It is hyperlink tag <code> a </code> that contains image tag <code> img </code> . Most probably it is a link that is really underlined, image is just inside it. You need to create new CSS rule that matches your link with image and specifies no underline (it could also be border-bottom property by the way, some recommend it over underline for better typography looks). If possible please give link to the site. CSS in theory is even worse than PHP in theory. :) I assume it's about twitter image at top of sidebar? Try this: <code> .textwidget a, .textwidget a:hover { border-bottom: none; } </code> But this will affect all text widgets. It is probably better to assign individual class to link like <code> &lt;a href="http://thunderror.com/" class="twitter-link"&gt; </code> and style it.
Stop underlining image links
wordpress
I have a post ID and I'm just trying to find a function ( I was thinking of something similar to wp_update_post() ) where I can just pass a post ID and maybe a category ID or slug and have it associate the post to the category. Does that exist or have you seen a plugin doing that where I can peek at what they did?
<code> wp_set_object_terms() </code> is native function that assigns term from taxonomy to post.
Any built-in function to associate a post to category through a plugin?
wordpress
All plugins I've tried makes the page go blank. I tried so far: Smart Archives Reloaded Clean Archives Reloaded Better Extended Live Archives Thanks. Tal
@Tag, To answer your question directly, Smart Archives Reloaded works with W3 Total Cache. I have thoroughly tested it on my test bed and it works fine with W3 Total. I was even able to easily add the js to my minify settings. Version 2.0 removed the caching from the plugin. Have you tried it with the latest version? No more buggy caching Older versions of the plugin stored the generated HTML in a text file, instead of generating it on each page load. Unfortunately, this relied on two rather unreliable things: file permissions and wp-cron. Thus, it was the biggest source of problems for users. So I decided to remove file caching completely. If you want caching back, the best solution is to use a dedicated plugin, such as WP Super Cache. It will make your entire site load much faster. It seems that some of the other archive plugins use some sort of caching mechanism which might cause a conflict with a dedicated caching plugin like W3 Total.
What archive plugin works with W3 total cache?
wordpress
I'm trying to speed up my site a bit. How can I add Expire headers to images I upload? Must this be done with Apache configuration, or is there a setting or plugin to do the job?
This can be done with Apache configuration, I have used this snippet in the past in .htaccess: <code> ExpiresActive On ExpiresByType image/gif "access plus 1 month" ExpiresByType image/png "access plus 1 month" ExpiresByType image/jpeg "access plus 1 month" </code> Can be set up with plugin as well. W3 Total Cache (which I currently use) can do that among other things. Overall this is not a huge performance factor. Modern browsers are smart enough about caching images even without expires set.
How can I add Expire headers to images?
wordpress
I'm using Wordpress 3.0.1 with the Twenty Ten theme. I'm trying to change the way the posts in the Category view are displayed (i.e. by going to a url like mywebsite.com/category/mycategory). Currently the posts in the Category view just show the first part of a post, but I'd like to change that so it shows the whole thing. In the Category Template (category.php) file, there are a few lines of code that look like they are responsible for generating the category data: <code> /* Run the loop for the category page to output the posts. * If you want to overload this in a child theme then include a file * called loop-category.php and that will be used instead. */ get_template_part( 'loop', 'category' ); ?&gt; </code> Since the comments mention setting up a child theme, I went ahead and followed these instructions (via stackexchange-url ("this answer")) to set up a child theme so I could add my custom functionality. I see from the comments that I'm supposed to create a file called loop-category.php with my custom implementation, but I don't know what code I need to put in that file. What do I need to add to loop-category.php to get Category views to show up with full blog posts? NOTE: While I've been using Wordpress for quite a while, this is my first dive into theme customization. Any help would be much appreciated.
@Ben, If you look at line 132 of loop.php in Twentyten you will find the conditional statement that is telling WordPress to only display the_excerpt on category archives. Right below that after <code> &lt;?php else : ?&gt; </code> is how all posts that are not on an archive page, in the asides category or in the gallery category will be displayed. (The asides and gallery categories are targeted at the beginning of loop.php) <code> &lt;?php if ( is_archive() || is_search() ) : // Only display excerpts for archives and search. ?&gt; &lt;div class="entry-summary"&gt; &lt;?php the_excerpt(); ?&gt; &lt;/div&gt;&lt;!-- .entry-summary --&gt; &lt;?php else : ?&gt; &lt;div class="entry-content"&gt; &lt;?php the_content( __( 'Continue reading &lt;span class="meta-nav"&gt;&amp;rarr;&lt;/span&gt;', 'twentyten' ) ); ?&gt; &lt;?php wp_link_pages( array( 'before' =&gt; '&lt;div class="page-link"&gt;' . __( 'Pages:', 'twentyten' ), 'after' =&gt; '&lt;/div&gt;' ) ); ?&gt; &lt;/div&gt;&lt;!-- .entry-content --&gt; &lt;?php endif; ?&gt; </code> In your loop-category.php file the easiest thing to do would be copy and paste the whole loop.php file and change the section of code above to: <code> &lt;?php if ( is_search() ) : // Only display excerpts for archives and search. ?&gt; &lt;div class="entry-summary"&gt; &lt;?php the_excerpt(); ?&gt; &lt;/div&gt;&lt;!-- .entry-summary --&gt; &lt;?php else : ?&gt; &lt;div class="entry-content"&gt; &lt;?php the_content( __( 'Continue reading &lt;span class="meta-nav"&gt;&amp;rarr;&lt;/span&gt;', 'twentyten' ) ); ?&gt; &lt;?php wp_link_pages( array( 'before' =&gt; '&lt;div class="page-link"&gt;' . __( 'Pages:', 'twentyten' ), 'after' =&gt; '&lt;/div&gt;' ) ); ?&gt; &lt;/div&gt;&lt;!-- .entry-content --&gt; &lt;?php endif; ?&gt; </code> You will notice that we only removed <code> is_archive </code> from the conditional statement so now category archives will displayed using the code after the else statement which contains <code> the_content </code> as opposed to <code> the_excerpt </code> .
How do I make the category template display full posts instead of partial posts?
wordpress
If you were to turn your blog into a Facebook app, what features would it have? What would the UI look like? What are the significant dealbreakers you'd need to satisfy to extend your blog to a social networking platform? I'm marking this as a community wiki because I'm not looking for one answer, but for an array of "best practices" that developers should consider when taking their blog online through a social network. One feature/UI element/dealbreaking necessity per answer please.
My number 1 feature would be to have the ability to use WordPress to manage a fan page. It would have to have the ability to use a WordPress page to create a Facebook page application tab. Published posts would auto publish to the Facebook wall and comments would sync between WordPress and Facebook.
If your blog was an app on Facebook
wordpress
Can I replace the WYSIWYG editor with a markdown editor? If so, what plugin can I use?
I'm not sure about the version of Markdown, but here's some plugins I use markdown-for-wordpress-and-bbpress to get wordpress to render posts and comments in markdown format. For editors, I prefer markdown-quicktags. It has a bunch of auto-complete features, and seems to be the most actively updated markdown editor plugin. You might also try wmd-admin for the wmd editor (Same markdown editor as the stackexchange) or wp-markitup (not markdown specific)
Create posts using markdown?
wordpress
I keep getting the same error, any ideas? I have generated a key without a password using <code> ssh-keygen </code> I set permissions on the keys to 600 I have successfully logged in using <code> ssh -i /root/.ssh/id_rsa 1**.**.*8.128 </code> I have tried changing hostname to <code> localhost </code> and <code> 127.0.0.1 </code> The server is running CentOS 5.4.
This Question was answered on ServerFault by the asker. I am adding his answer here as a community wiki. Here is the full solution, thanks to michaelmior for his help, it got me half way. Run this command to generate keys: <code> ssh-keygen </code> You'll get this output: <code> Generating public/private rsa key pair. Enter file in which to save the key (/home/user1/.ssh/id_rsa): Created directory ‘/home/user1/.ssh’. Enter passphrase (empty for no passphrase): (just hit enter, no need for a password) Enter same passphrase again: (same thing, hit enter again) Your identification has been saved in /home/user1/.ssh/id_rsa. Your public key has been saved in /home/user1/.ssh/id_rsa.pub. The key fingerprint is: xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx user1@server1.example.com </code> Add the public key to your <code> authorized_keys </code> file Move the <code> id_rsa </code> and <code> id_rsa.pub </code> to <code> /usr/local </code> <code> chown </code> the files to the same user as your webserver (in my case apache) <code> chmod </code> the files to 600: <code> chmod 600 id_rsa* </code> This should now work. However, my installation kept hanging, a quick look at the httpd error_log file show me: <code> PHP Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 2966269 bytes) in /var/www/sites/.... </code> Adding this code to the Wordpress <code> wp-config.php </code> file to temporally increase the amount of memory available: <code> define('WP_MEMORY_LIMIT', '64M'); </code>
SSH Upgrade Problem
wordpress
I am using a slick little piece of code which I have included within my functions file which automatically takes any information entered into the title of a new post and create a slug with specific stop words automatically removed (code included below). The problem is that sometimes after this slug is automatically created I wanted to click on the slug (under the title) and modify it directly. My question to the community is... what would I need to change in the code below so that when I click on the slug (under the title) and modify it that whatever I enter there is used without the function below preventing that from happening. Here is the code: <code> // AUTOMATICALLY SANITIZE PAGE/POST SEO SLUG FROM SHORT WORDS // SOURCE: http://www.vretoolbar.com/news/seo-slugs-wordpress-plugin add_filter('name_save_pre', 'seo_slugs', 0); function seo_slugs($slug) { // We don't want to change an existing slug if ($slug) return $slug; global $wpdb; $seo_slug = strtolower(stripslashes($_POST['post_title'])); $seo_slug = preg_replace('/&amp;.+?;/', '', $seo_slug); // kill HTML entities // kill anything that is not a letter, digit, space or apostrophe $seo_slug = preg_replace ("/[^a-zA-Z0-9 ']/", "", $seo_slug); // Turn it to an array and strip common words by comparing against c.w. array $seo_slug_array = array_diff (split(" ", $seo_slug), seo_slugs_stop_words()); // Turn the sanitized array into a string $seo_slug = join("-", $seo_slug_array); return $seo_slug; } function seo_slugs_stop_words () { return array ("a", "able", "about", "above", "abroad", "according", "accordingly", "across", "actually", "adj", "after", "afterwards", "again", "against", "ago", "ahead", "ain't", "all", "allow", "allows", "almost", "alone", "along", "alongside", "already", "also", "although", "always", "am", "amid", "amidst", "among", "amongst", "an", "and", "another", "any", "anybody", "anyhow", "anyone", "anything", "anyway", "anyways", "anywhere", "apart", "appear", "appreciate", "appropriate", "are", "aren't", "around", "as", "a's", "aside", "ask", "asking", "associated", "at", "available", "away", "awfully", "b", "back", "backward", "backwards", "be", "became", "because", "become", "becomes", "becoming", "been", "before", "beforehand", "begin", "behind", "being", "believe", "below", "beside", "besides", "best", "better", "between", "beyond", "both", "brief", "but", "by", "c", "came", "can", "cannot", "cant", "can't", "caption", "cause", "causes", "certain", "certainly", "changes", "clearly", "c'mon", "co", "co.", "com", "come", "comes", "concerning", "consequently", "consider", "considering", "contain", "containing", "contains", "corresponding", "could", "couldn't", "course", "c's", "currently", "d", "dare", "daren't", "definitely", "described", "despite", "did", "didn't", "different", "directly", "do", "does", "doesn't", "doing", "done", "don't", "down", "downwards", "during", "e", "each", "edu", "eg", "eight", "eighty", "either", "else", "elsewhere", "end", "ending", "enough", "entirely", "especially", "et", "etc", "even", "ever", "evermore", "every", "everybody", "everyone", "everything", "everywhere", "ex", "exactly", "example", "except", "f", "fairly", "far", "farther", "few", "fewer", "fifth", "first", "five", "followed", "following", "follows", "for", "forever", "former", "formerly", "forth", "forward", "found", "four", "from", "further", "furthermore", "g", "get", "gets", "getting", "given", "gives", "go", "goes", "going", "gone", "got", "gotten", "greetings", "h", "had", "hadn't", "half", "happens", "hardly", "has", "hasn't", "have", "haven't", "having", "he", "he'd", "he'll", "hello", "help", "hence", "her", "here", "hereafter", "hereby", "herein", "here's", "hereupon", "hers", "herself", "he's", "hi", "him", "himself", "his", "hither", "hopefully", "how", "howbeit", "however", "hundred", "i", "i'd", "ie", "if", "ignored", "i'll", "i'm", "immediate", "in", "inasmuch", "inc", "inc.", "indeed", "indicate", "indicated", "indicates", "inner", "inside", "insofar", "instead", "into", "inward", "is", "isn't", "it", "it'd", "it'll", "its", "it's", "itself", "i've", "j", "just", "k", "keep", "keeps", "kept", "know", "known", "knows", "l", "last", "lately", "later", "latter", "latterly", "least", "less", "lest", "let", "let's", "like", "liked", "likely", "likewise", "little", "look", "looking", "looks", "low", "lower", "ltd", "m", "made", "mainly", "make", "makes", "many", "may", "maybe", "mayn't", "me", "mean", "meantime", "meanwhile", "merely", "might", "mightn't", "mine", "minus", "miss", "more", "moreover", "most", "mostly", "mr", "mrs", "much", "must", "mustn't", "my", "myself", "n", "name", "namely", "nd", "near", "nearly", "necessary", "need", "needn't", "needs", "neither", "never", "neverf", "neverless", "nevertheless", "new", "next", "nine", "ninety", "no", "nobody", "non", "none", "nonetheless", "noone", "no-one", "nor", "normally", "not", "nothing", "notwithstanding", "novel", "now", "nowhere", "o", "obviously", "of", "off", "often", "oh", "ok", "okay", "old", "on", "once", "one", "ones", "one's", "only", "onto", "opposite", "or", "other", "others", "otherwise", "ought", "oughtn't", "our", "ours", "ourselves", "out", "outside", "over", "overall", "own", "p", "particular", "particularly", "past", "per", "perhaps", "placed", "please", "plus", "possible", "presumably", "probably", "provided", "provides", "q", "que", "quite", "qv", "r", "rather", "rd", "re", "really", "reasonably", "recent", "recently", "regarding", "regardless", "regards", "relatively", "respectively", "right", "round", "s", "said", "same", "saw", "say", "saying", "says", "second", "secondly", "see", "seeing", "seem", "seemed", "seeming", "seems", "seen", "self", "selves", "sensible", "sent", "serious", "seriously", "seven", "several", "shall", "shan't", "she", "she'd", "she'll", "she's", "should", "shouldn't", "since", "six", "so", "some", "somebody", "someday", "somehow", "someone", "something", "sometime", "sometimes", "somewhat", "somewhere", "soon", "sorry", "specified", "specify", "specifying", "still", "sub", "such", "sup", "sure", "t", "take", "taken", "taking", "tell", "tends", "th", "than", "thank", "thanks", "thanx", "that", "that'll", "thats", "that's", "that've", "the", "their", "theirs", "them", "themselves", "then", "thence", "there", "thereafter", "thereby", "there'd", "therefore", "therein", "there'll", "there're", "theres", "there's", "thereupon", "there've", "these", "they", "they'd", "they'll", "they're", "they've", "thing", "things", "think", "third", "thirty", "this", "thorough", "thoroughly", "those", "though", "three", "through", "throughout", "thru", "thus", "till", "to", "together", "too", "took", "toward", "towards", "tried", "tries", "truly", "try", "trying", "t's", "twice", "two", "u", "un", "under", "underneath", "undoing", "unfortunately", "unless", "unlike", "unlikely", "until", "unto", "up", "upon", "upwards", "us", "use", "used", "useful", "uses", "using", "usually", "v", "value", "various", "versus", "very", "via", "viz", "vs", "w", "want", "wants", "was", "wasn't", "way", "we", "we'd", "welcome", "well", "we'll", "went", "were", "we're", "weren't", "we've", "what", "whatever", "what'll", "what's", "what've", "when", "whence", "whenever", "where", "whereafter", "whereas", "whereby", "wherein", "where's", "whereupon", "wherever", "whether", "which", "whichever", "while", "whilst", "whither", "who", "who'd", "whoever", "whole", "who'll", "whom", "whomever", "who's", "whose", "why", "will", "willing", "wish", "with", "within", "without", "wonder", "won't", "would", "wouldn't", "x", "y", "yes", "yet", "you", "you'd", "you'll", "your", "you're", "yours", "yourself", "yourselves", "you've", "z", "zero"); } </code>
I ended up using the following code within my functions.php file to get the desired functionality: <code> // AUTOMATICALLY SANITIZE PAGE/POST SEO SLUG FROM SHORT WORDS // SOURCE: http://www.vretoolbar.com/news/seo-slugs-wordpress-plugin add_filter('name_save_pre', 'seo_slugs', 0); function seo_slugs($slug) { // We don't want to change an existing slug if ($slug) return $slug; global $wpdb; $seo_slug = strtolower(stripslashes($_POST['post_title'])); $seo_slug = preg_replace('/&amp;.+?;/', '', $seo_slug); // kill HTML entities // kill anything that is not a letter, digit, space or apostrophe $seo_slug = preg_replace ("/[^a-zA-Z0-9 ']/", "", $seo_slug); // Turn it to an array and strip common words by comparing against c.w. array $seo_slug_array = array_diff (split(" ", $seo_slug), seo_slugs_stop_words()); // Turn the sanitized array into a string $seo_slug = join("-", $seo_slug_array); return $seo_slug; } function seo_slugs_stop_words () { return array ("a", "able", "about", "above", "abroad", "according", "accordingly", "across", "actually", "adj", "after", "afterwards", "again", "against", "ago", "ahead", "ain't", "all", "allow", "allows", "almost", "alone", "along", "alongside", "already", "also", "although", "always", "am", "amid", "amidst", "among", "amongst", "an", "and", "another", "any", "anybody", "anyhow", "anyone", "anything", "anyway", "anyways", "anywhere", "apart", "appear", "appreciate", "appropriate", "are", "aren't", "around", "as", "a's", "aside", "ask", "asking", "associated", "at", "available", "away", "awfully", "b", "back", "backward", "backwards", "be", "became", "because", "become", "becomes", "becoming", "been", "before", "beforehand", "begin", "behind", "being", "believe", "below", "beside", "besides", "best", "better", "between", "beyond", "both", "brief", "but", "by", "c", "came", "can", "cannot", "cant", "can't", "caption", "cause", "causes", "certain", "certainly", "changes", "clearly", "c'mon", "co", "co.", "com", "come", "comes", "concerning", "consequently", "consider", "considering", "contain", "containing", "contains", "corresponding", "could", "couldn't", "course", "c's", "currently", "d", "dare", "daren't", "definitely", "described", "despite", "did", "didn't", "different", "directly", "do", "does", "doesn't", "doing", "done", "don't", "down", "downwards", "during", "e", "each", "edu", "eg", "eight", "eighty", "either", "else", "elsewhere", "end", "ending", "enough", "entirely", "especially", "et", "etc", "even", "ever", "evermore", "every", "everybody", "everyone", "everything", "everywhere", "ex", "exactly", "example", "except", "f", "fairly", "far", "farther", "few", "fewer", "fifth", "first", "five", "followed", "following", "follows", "for", "forever", "former", "formerly", "forth", "forward", "found", "four", "from", "further", "furthermore", "g", "get", "gets", "getting", "given", "gives", "go", "goes", "going", "gone", "got", "gotten", "greetings", "h", "had", "hadn't", "half", "happens", "hardly", "has", "hasn't", "have", "haven't", "having", "he", "he'd", "he'll", "hello", "help", "hence", "her", "here", "hereafter", "hereby", "herein", "here's", "hereupon", "hers", "herself", "he's", "hi", "him", "himself", "his", "hither", "hopefully", "how", "howbeit", "however", "hundred", "i", "i'd", "ie", "if", "ignored", "i'll", "i'm", "immediate", "in", "inasmuch", "inc", "inc.", "indeed", "indicate", "indicated", "indicates", "inner", "inside", "insofar", "instead", "into", "inward", "is", "isn't", "it", "it'd", "it'll", "its", "it's", "itself", "i've", "j", "just", "k", "keep", "keeps", "kept", "know", "known", "knows", "l", "last", "lately", "later", "latter", "latterly", "least", "less", "lest", "let", "let's", "like", "liked", "likely", "likewise", "little", "look", "looking", "looks", "low", "lower", "ltd", "m", "made", "mainly", "make", "makes", "many", "may", "maybe", "mayn't", "me", "mean", "meantime", "meanwhile", "merely", "might", "mightn't", "mine", "minus", "miss", "more", "moreover", "most", "mostly", "mr", "mrs", "much", "must", "mustn't", "my", "myself", "n", "name", "namely", "nd", "near", "nearly", "necessary", "need", "needn't", "needs", "neither", "never", "neverf", "neverless", "nevertheless", "new", "next", "nine", "ninety", "no", "nobody", "non", "none", "nonetheless", "noone", "no-one", "nor", "normally", "not", "nothing", "notwithstanding", "novel", "now", "nowhere", "o", "obviously", "of", "off", "often", "oh", "ok", "okay", "old", "on", "once", "one", "ones", "one's", "only", "onto", "opposite", "or", "other", "others", "otherwise", "ought", "oughtn't", "our", "ours", "ourselves", "out", "outside", "over", "overall", "own", "p", "particular", "particularly", "past", "per", "perhaps", "placed", "please", "plus", "possible", "presumably", "probably", "provided", "provides", "q", "que", "quite", "qv", "r", "rather", "rd", "re", "really", "reasonably", "recent", "recently", "regarding", "regardless", "regards", "relatively", "respectively", "right", "round", "s", "said", "same", "saw", "say", "saying", "says", "second", "secondly", "see", "seeing", "seem", "seemed", "seeming", "seems", "seen", "self", "selves", "sensible", "sent", "serious", "seriously", "seven", "several", "shall", "shan't", "she", "she'd", "she'll", "she's", "should", "shouldn't", "since", "six", "so", "some", "somebody", "someday", "somehow", "someone", "something", "sometime", "sometimes", "somewhat", "somewhere", "soon", "sorry", "specified", "specify", "specifying", "still", "sub", "such", "sup", "sure", "t", "take", "taken", "taking", "tell", "tends", "th", "than", "thank", "thanks", "thanx", "that", "that'll", "thats", "that's", "that've", "the", "their", "theirs", "them", "themselves", "then", "thence", "there", "thereafter", "thereby", "there'd", "therefore", "therein", "there'll", "there're", "theres", "there's", "thereupon", "there've", "these", "they", "they'd", "they'll", "they're", "they've", "thing", "things", "think", "third", "thirty", "this", "thorough", "thoroughly", "those", "though", "three", "through", "throughout", "thru", "thus", "till", "to", "together", "too", "took", "toward", "towards", "tried", "tries", "truly", "try", "trying", "t's", "twice", "two", "u", "un", "under", "underneath", "undoing", "unfortunately", "unless", "unlike", "unlikely", "until", "unto", "up", "upon", "upwards", "us", "use", "used", "useful", "uses", "using", "usually", "v", "value", "various", "versus", "very", "via", "viz", "vs", "w", "want", "wants", "was", "wasn't", "way", "we", "we'd", "welcome", "well", "we'll", "went", "were", "we're", "weren't", "we've", "what", "whatever", "what'll", "what's", "what've", "when", "whence", "whenever", "where", "whereafter", "whereas", "whereby", "wherein", "where's", "whereupon", "wherever", "whether", "which", "whichever", "while", "whilst", "whither", "who", "who'd", "whoever", "whole", "who'll", "whom", "whomever", "who's", "whose", "why", "will", "willing", "wish", "with", "within", "without", "wonder", "won't", "would", "wouldn't", "x", "y", "yes", "yet", "you", "you'd", "you'll", "your", "you're", "yours", "yourself", "yourselves", "you've", "z", "zero"); } </code> Also note that you NEED to have SLUG Metaboxes enabled for this to work. As I did not want the screen options or the actual metabox to show I added the following to an admin style sheet to remove them: <code> [for="slugdiv-hide"] { display: none; } #slugdiv { display: none; } </code>
How to customize this automatic slug shortener with an overrwrite function
wordpress
Question - How can one utilize the wordpress 3.0 Menu system to automatically have new pages from a custom post type included within the menu (I am referring to the Menu Management area of wordpress for the public website). I believe this currently works for the regular "pages" if you check the automatically incude box but is there a way to also hard code it to work for pages from a custom post type?
This is accomplished by <code> _wp_auto_add_pages_to_menu() </code> (in <code> \wp-includes\nav-menu.php </code> ) function that is hooked to <code> transition_post_status </code> hook. Unfortunately it is hardcoded for <code> page </code> post type and is not easy to extend. On other hand since it works through generic hook it isn't hard (relatively, menus internal code is pain) to engineer analogue for custom post type.
Menu with Automatic Pages Included from Custom Post Type
wordpress
Would there be any negative SEO effects for having a wordpress website at example.com and having another website at example.com/anothersite? Would the site "anothersite" be indexed in search engines (assuming I did all the seo strategies for them)? Any negative effects for either site? Thanks in advance
Yes Whatever negative means to you. I tend to say not more then with a single site. The search engine will basically spoken not differ between one or more sites. The spider is just indexing pages not sites. So this can have positive effects while the content of one site pulls / pushes the URLs of contents of the other one. So the arrangement of the sites in URLs on that domain (URL Layout) and it's contents will have the SE influence, not the number of sites you run on the domain.
SEO - Two WordPress websites on same domain name
wordpress
In WP theme building, if a sidebar is not active, can I turn it on? Also, if the sidebar is active, and doesn't contain any widgets, can I add some? I'm a theme and plugin developer, but this is something I haven't learned to do yet.
@Volomike, When you register a sidebar in your themes functions it will be active in the dashboard. If no widgets are added to your sidebars WordPress will add the default widgets. You can prevent WordPress from adding the default widgets by unregistering them: <code> // Remove WP default Widgets // WP 2.8 function using $widget_class if (function_exists('unregister_widget')) { unregister_widget('WP_Widget_Meta'); unregister_widget('WP_Widget_Search'); unregister_widget(''); // pre WP 2.8 function using $id } else { unregister_widget_control('meta'); unregister_widget_control('search'); } </code> You can also preset your own widgets. <code> // The following code sample is from The Thematic Theme which is licensed under the GPLv2 register_sidebar_widget(__('Search', 'thematic'), 'widget_thematic_search', null, 'search'); unregister_widget_control('search'); register_sidebar_widget(__('Meta', 'thematic'), 'widget_thematic_meta', null, 'meta'); unregister_widget_control('meta'); register_sidebar_widget(array(__('RSS Links', 'thematic'), 'widgets'), 'widget_thematic_rsslinks'); register_widget_control(array(__('RSS Links', 'thematic'), 'widgets'), 'widget_thematic_rsslinks_control', 300, 90); // Pre-set Widgets $preset_widgets = array ( 'primary-aside' =&gt; array( 'search', 'pages', 'categories', 'archives' ), 'secondary-aside' =&gt; array( 'links', 'rss-links', 'meta' ) ); if ( isset( $_GET['activated'] ) ) { update_option( 'sidebars_widgets', apply_filters('thematic_preset_widgets',$preset_widgets )); } </code> Themati c is actually a great example of all the things that can be done with widgets. Take a look at widgets.php and widgets-extensions.php
Enabling Widgets By Default in Custom Theme Development
wordpress
I have an interesting problem which I am sure someone here can solve. I have gone through a bunch of different plugins and code snippets in search for the perfect code to extract a primary image to be associated with a post . If the new WP 3.0 featured image element is used then there is of course no issue but there are a bunch of situations where a post may not have a "featured image" assigned. In these situations if you were to use the standard code of: <code> &lt;?php echo the_post_thumbnail( array(200,200) ); ?&gt; </code> in your template... nothing is going to be displayed. For these type of situations I am looking for the perfect solution. Essentially, what I need is the ability to have a type of "failover" when the_post_thumbnail does not exist but I also still need the ability to set the image size just like I can with the code from the_post_thumbnail. This "failover" I believe should have two steps to it: Check the "Media Gallery" for this post and locate the image with the highest sort order (or added post parent as shown in the plugin below) If no sort order is set or if blank then extract the first image from the post content. The good news is that for the two points above I seem to have found two separate snips of code which take care of these requests individually (copied below for review) however nothing which combines all three of these elements in one. So, to recap: Instead of doing a bunch of if/then calls to check if a post thumbnail exists and then running a check against the code below I was hoping that someone might be able to provide a clean/combined function which would allow me to echo a single function along with size variables which can achieve all three these goals as mentioned above. HERE ARE THE BITS OF CODE MENTIONED ABOVE: FOR #1: Get the First Image based off the order from the Media Gallery: This code works by first looking for any attachments in the wp_posts database table that have a “post_parent” ID that matches the current post and as a second step for posts with multiple image attachments, returning the attachment with its “menu_order” field set to “1″. If no image attachments match the current post ID, the plugin returns “false”. <code> // AUTOMATICALLY EXTRACT IMAGES BASED ON ASSOCIATED GALLERY ORDER // THIS CODE EXTRACTS THE FIRST IMAGE BASED ON THE ORDER IN THE MEDIA GALLERY // PLUGIN FROM: http://mekosh.org/projects/ordered-thumbnails function ordered_thumbnails( $display = 'true', $class='' ) { global $post; // get all image attachments for this post $images = get_children( array( 'post_type' =&gt; 'attachment', 'post_parent' =&gt; $post-&gt;ID, 'post_mime_type' =&gt; 'image', order=&gt;"asc" ) ); // if the post has image attachments if( $images !== false ) { // find the image in position 1 foreach($images as $i) { if ( $i-&gt;menu_order == 1 ) { $img_id = $i-&gt;ID; } } // if the images were unordered if ( $img_id == '' ) { $i = array_slice( $images, 0, 1 ); $img_id = $i[0]-&gt;ID; } // get image data $image = wp_get_attachment_image_src( $img_id, 'thumbnail' ); $result = array( 'url' =&gt; $image[0], 'width' =&gt; $image[1], 'height' =&gt; $image[2] ); // should the image be displayed or should data be returned as an array? if ( $display == 'true' ) { return _e( '&lt;img src="'.$result['url'].'" width="'.$result['width'].'" height="'.$result['height'].'" class="'.$class.'" /&gt;' ); } else { return $result; } } else { // post does not have any image attachments return (bool) false; } } // create template tag "ordered_thumbnails" add_action( 'ordered_thumbnails', 'ordered_thumbnails', 2 ); </code> FOR #2: Extract the first image from the post content <code> // THIS CODE GETS THE FIRST IMAGE EXTRACTED DIRECTLY FROM THE POST CONTENT function bm_extract_string($start, $end, $original) { $original = stristr($original, $start); $trimmed = stristr($original, $end); return substr($original, strlen($start), -strlen($trimmed)); } function getFirstImage() { $content = get_the_content(); $pic_string = bm_extract_string('src="','" ',$content); $imagesize = getimagesize($pic_string); list($width, $height, $type, $attr) = getimagesize($pic_string); $link = get_permalink(); $title = get_the_title($post-&gt;post_title); echo '&lt;a href="'.$link.'" style="background:url('.$pic_string.'); display:block; width:'.$width.'px; height:'.$height.'px;" title="'.$title.'"&gt;&lt;/a&gt;'; } </code>
Here is the solution to my problem for anyone who is interested. Include this in your functions.php file <code> require_once('custom/extract-post-thumbnail.php'); $extract_img = new extract_post_image(); add_filter( 'post_thumbnail_html', array(&amp;$extract_img, 'get_post_image'),1,5 ); </code> Create a new file and name it "extract-post-thumbnail.php", place it into a folder named "custom" and place that within the the same directory that your themes functions.php file is located. Finally, past the code below into this file. <code> &lt;?php class extract_post_image { public $html; public $post_id; public $post_image_id; public $size; public $attr; public function extract_post_image() { } public function get_post_image ($html,$post_id, $post_image_id, $size, $attr) { $this-&gt;html = $html; $this-&gt;post_id = $post_id; $this-&gt;post_image_id = $post_image_id; $this-&gt;size = $size; $this-&gt;attr = $attr; if ($this-&gt;html == '') { $this-&gt;post_image_id = $this-&gt;get_post_image_id (); if ($this-&gt;post_image_id) { do_action( 'begin_fetch_post_thumbnail_html', $this-&gt;post_id, $this-&gt;post_image_id, $this-&gt;size ); $this-&gt;html = wp_get_attachment_image( $this-&gt;post_image_id, $this-&gt;size, false, $this-&gt;attr ); do_action( 'end_fetch_post_thumbnail_html', $this-&gt;post_id, $this-&gt;post_image_id, $this-&gt;size ); } else { $this-&gt;html = $this-&gt;get_image_in_content (); } } return $this-&gt;html; } public function get_post_image_id () { $images = get_children( array( 'post_parent' =&gt; $this-&gt;post_id, 'post_status' =&gt; 'inherit', 'post_type' =&gt; 'attachment', 'post_mime_type' =&gt; 'image', 'order' =&gt; 'ASC', 'orderby' =&gt; 'menu_order', 'numberposts' =&gt; 1 ) ); if ($images) { foreach ($images as $img) { $img_id = $img-&gt;ID; } return $img-&gt;ID; } else { return NULL; } } public function remote_file_exists($image) { if ( @file($image)) { return true; } return false; } public function get_image_in_content () { $my_post = get_post($this-&gt;post_id); preg_match_all( '|&lt;img.*?src=['"](.*?)['"].*?&gt;|i', $my_post-&gt;post_content, $matches ); if ( isset( $matches ) ) { $image = $matches[1][0]; if ( $matches[1][0] &amp;&amp; $this-&gt;remote_file_exists($image) ) { $altpattern = '/alt=(['"])?(.*?)\\1/'; preg_match($altpattern, $matches[0][0], $m); $alt = $m[2]; $default_attr = array( 'src' =&gt; $image, 'class' =&gt; "attachment-$size", 'alt' =&gt; $alt ); $this-&gt;attr = wp_parse_args($this-&gt;attr, $default_attr); $attr = array_map( 'esc_attr', $this-&gt;attr ); $attributes = ''; foreach ( $this-&gt;attr as $name =&gt; $value ) { $attributes .= " $name=" . '"' . $value . '"'; } $imgwh = getimagesize($image); $imgsize = image_constrain_size_for_editor($imgwh[0], $imgwh[1], $this-&gt;size); $wh = image_hwstring($imgsize[0], $imgsize[1]); $this-&gt;html = ' &lt;img '.$attributes.' '.$wh.' /&gt;'; return $this-&gt;html; } } else { return NULL; } } } ?&gt; </code>
Extract & Display the REAL first image attached to a post - extend the_post_thumbnail()
wordpress
I use WordPress a ton, but I'm somewhat new to multisite. Now that 3.0 has brought multisite into the main core, shouldn't there be an easy loop function that allows you to display the most recent posts from across your network, in a loop, for me to output in PHP as I want? Does anybody know if this exists and I'm just missing it?
Wordpress doesn't ( and won't ) support this natively. The alternative is to write your own template with a custom request. (You might even have to drop down into MySQL - I'm not sure the built in Wordpress query system will be capable of this.) Check out this plugin though: WordPress MU Sitewide Tags Pages It might give you an acceptable compromise, or it might give you a starting place when coding your own approach. Good luck!
In WordPress 3.x, I can't access posts from all blogs in the network
wordpress
Code: <code> print_r($wp-&gt;query_vars); echo "&lt;br&gt;&lt;br&gt;".get_query_var('term'); echo "&lt;br&gt;&lt;br&gt;".get_query_var('taxonomy'); $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy') ); echo "&lt;br&gt;&lt;br&gt;$term"; </code> Output: <code> Array ( [titles] =&gt; windows-powershell-v2 [taxonomy] =&gt; titles [term] =&gt; windows-powershell-v2 ) windows-powershell-v2 titles </code> As you can see, the first three lines run fine. The fourth line fails with no error - but it terminates page execution. The specified term does indeed exist in the taxonomy; this is being reached with the URL /titles/windows-powershell-v2/. Any idea what I'm doing wrong?
<code> get_term_by() </code> returns object by default. Which should end up in <code> Catchable fatal error: Object of class stdClass could not be converted to string </code> if you try to echo it. Likely you have errors suppressed. Try <code> var_dump( $term ); </code> instead of <code> echo </code> .
get_term_by seems to be failing
wordpress
I want to make something like iGoogle in WordPress, in which I can drag and drop the widgets. How could that be done in HTML 5?
This is an interesting question. Generally, I agree with EAMann - this would be better suited in a more general discussion. Seeing as you ask it here however, I'm going to give a Wordpress specific approach you may want to use. In the context of Wordpress, "widget" obviously has a specific meaning. The Wordpress sidebar widget system is highly flexible and benefits from being an established system with a large number of widgets available. This makes it a sensible place to start. You could, for example, make a template which contains multiple sidebars arranged next to each other. Styling your widgets should be easy enough. To make them drag-droppable, collapsible, editable, etc. I recommend this tutorial , which demonstrates these techniques with jQuery UI. It now gets a bit tricky. I'm assuming you want each user to be able to configure their own widgets and that these changes should be persistent. (If either of these requirements is unnecessary, it gets much easier.) This is hard - we can't use the Wordpress widget system to store these preferences, but we can go to it for inspiration. If you have PhpMyAdmin (or similar) installed, go to your wordpress database and execute the following: <code> SELECT * FROM `wp_options` WHERE `option_name` REGEXP '^widget_' LIMIT 0 , 30 </code> You should get a whole load of results with stored PHP arrays for the details. If each user were to be able to set their own widgets, you could use this format, but append a user id to the end of the option name. You could write a simple piece of AJAXy javascript to send off the details of the widget arrangement each time it changes. The PHP receiver would then update the database accordingly. So that's one way to save the users data, but how do we retrieve and display it again? Personally, I'd let wordpress serve up the defaults normally at first. (Possibly with a CSS overlay and/or a progress spinner.) Then I'd fire off another AJAX request and load the user specified widgets. Specifically, I'd load the arrangement first, then individually load the data (via AJAX again) into each box. This would speed up the perceived loading time. So there we go. Sorry it's such a high level answer, but it's a pretty far reaching question. I hope I've given you some ideas. Good luck! PS If you get this working, I'd recommend distributing it as a plugin.
Can I create drag and drop widgets like iGoogle in WordPress?
wordpress
When I am trying to login as admin to my site I am redirecting to another unknown page. The login page is pointed to a page-Id2 .I don't understand why it is happened and how to solve it. The links to admin page are redirecting to that page Id-12 . Could any one help me to resolve the issue
The problem has been solved when I deactivated some plugins .
Problem in logging in as admin
wordpress
I am aware of the question stackexchange-url ("What are options are there to implement a multi language site"), but the answers there are focused on multi-language support on the backend as well as the frontend. I am only concerned with offering multi-language viewing of a site's content, not multi-language content creation. Could it be as simple as putting the Google Translate Tools code on my site? I see that there are at least a couple of plugins that offer this functionality - anyone have experience with those?
If your just looking for a way for your site to be viewed in other languages I would defiantly recommend using Google Translate Tools. I just add it to the theme: <code> &lt;div id="google_translate_element"&gt;&lt;span id="trans"&gt;Translate: &lt;/span&gt;&lt;/div&gt; </code> You can hide the Google Logo and funky colors in your css: <code> .goog-logo-link{display:none;} </code> Instead of calling the Google Translate js I just copy the return script and add it to my main js file. Edit Google provides embed code to use on your website: <code> &lt;div id="google_translate_element"&gt;&lt;/div&gt;&lt;script&gt; function googleTranslateElementInit() { new google.translate.TranslateElement({ pageLanguage: 'en', layout: google.translate.TranslateElement.InlineLayout.SIMPLE }, 'google_translate_element'); } &lt;/script&gt;&lt;script src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"&gt;&lt;/script&gt; </code> The first line: <code> &lt;div id="google_translate_element"&gt;&lt;/div&gt; </code> can be placed where you want the translate drop down box to be shown: The section between the first set of <code> &lt;script&gt; </code> tags are the language and layout options. The last set of <code> &lt;script&gt; </code> tags call more javascript which Google inserts inline in your html while the dom is loading. To speed up this process and avoid the extra http request and inline script I remove the last call and add the code returned by Google into a "master" js file I use that contains all my custom javascript combined into one file. The code that Google returns is: <code> (function(){var d=window,e=document;function f(b){var a=e.getElementsByTagName("head")[0];a||(a=e.body.parentNode.appendChild(e.createElement("head")));a.appendChild(b)}function _loadJs(b){var a=e.createElement("script");a.type="text/javascript";a.charset="UTF-8";a.src=b;f(a)}function _loadCss(b){var a=e.createElement("link");a.type="text/css";a.rel="stylesheet";a.charset="UTF-8";a.href=b;f(a)}function _isNS(b){b=b.split(".");for(var a=d,c=0;c&lt;b.length;++c)if(!(a=a[b[c]]))return false;return true} function _setupNS(b){b=b.split(".");for(var a=d,c=0;c&lt;b.length;++c)a=a[b[c]]||(a[b[c]]={});return a}d.addEventListener&amp;&amp;typeof e.readyState=="undefined"&amp;&amp;d.addEventListener("DOMContentLoaded",function(){e.readyState="complete"},false); if (_isNS('google.translate.Element')){return}var c=_setupNS('google.translate._const');c._cl='en';c._cuc='googleTranslateElementInit';c._cac='';c._cam='';var h='translate.googleapis.com';var b=(window.location.protocol=='https:'?'https://':'http://')+h;c._pah=h;c._pbi=b+'/translate_static/img/te_banner_bk.gif';c._pci=b+'/translate_static/img/te_ctrl.gif';c._phf=h+'/translate_static/js/element/hrs.swf';c._pli=b+'/translate_static/img/loading.gif';c._plla=h+'/translate_a/l';c._pmi=b+'/translate_static/img/mini_google.png';c._ps=b+'/translate_static/css/translateelement.css';c._puh='translate.google.com';_loadCss(c._ps);_loadJs(b+'/translate_static/js/element/main.js');})(); </code> This is mainly for performance reasons to avoid the extra request and avoids the website having to communicate with Google unless a language is chosen from the drop down box. The drop down box can be customized using css. For example here is how I display the box on the site I used it on.
How can I make a site viewable in multiple languages?
wordpress
Before I found out about the ability to add a meta box (with custom post meta selections) to the page and post editor, I was (and still am to a degree) using categories to define custom post meta. For example, to make a post nofollow, or noindex, I created a category called nofollow and another called noindex and assigned one or both of those categories to a post or page. Then in my header.php file, I'd do an in_category test in order to write the appropriate meta tags to the page. Example: <code> &lt;?php if (in_category('noindex') &amp;&amp; in_category('nofollow')){?&gt; &lt;meta name="robots" content="noindex, nofollow"&gt; &lt;?php}?&gt; </code> I also have custom categories for things like "Disable Adsense for this page", "Don't Show Image Attachments for this Page", "Hide this page from menus", etc... So now that I've decided to move away from using categories where I should be using custom post meta, The above code in header.php instead becomes... <code> &lt;?php if (get_post_meta( $post-&gt;ID, '_noindex', true ) &amp;&amp; get_post_meta( $post-&gt;ID, '_nofollow', true )){&gt;? &lt;meta name="robots" content="noindex, nofollow"&gt; &lt;?php } ?&gt; </code> So that's my plan, but now I have the problem of upgrading sites that use the old means of defining custom post options via the category assignments. So I need a routing that goes about reassigning the category values to custom post meta values for each post and page in the site I'm upgrading. I'm just looking for some quick advice on how to go about this and possibly some code hints on the neccessary routine. Since this is a theme that can be updated, as part of the update process, I'd like to run a script one time, when the theme is first installed, (or the user clicks my upgrader utility) that runs through the options table and for every instance of one of my custom category assignments, it creates the requisite custom meta assignment for that post or page. For example, if a post currently belongs to the "Hidden" category, it would be assigned to the "_hidden" post meta. Hopefully I've explained this well enough. I appreciate any insights you can provide. Perhaps its as simple as a series of custom SQL statements that run for each possible category assignment?
Basic idea would be to loop through posts and their categories, assigning meta on matches. Something like this (be sure to check on test copy of data, etc, etc): <code> $posts = get_posts( array( 'numberposts' =&gt; -1 ) ); foreach( $posts as $post ) { $categories = get_the_category( $post-&gt;ID ); foreach( $categories as $category ) { if( 'Hidden' == $category-&gt;name ) add_post_meta( $post-&gt;ID, '_hidden', 'yes', true ); } } </code> Forgot to add deleting when done: <code> $category = get_category_by_slug( 'hidden' ); wp_delete_category( $category-&gt;term_id ); </code>
Need advice > converting category assignments to custom post meta values
wordpress
I have a wordpress MU (3.0.1) setup (upgraded from 2.9.2). It runs on 4 instances, load balanced, and all 4 connect to same database. Now, when only one instance is running, it is working fine... When I run multiple instances, I am not able to trash or undo trash or even do any change in settings .. I get this message: Are you sure you want to do this? Please try again. the URL when this occurs is mblogs.com/testblog/wp-admin/post.php?post=9&action=trash&_wpnonce=8f5a697d1e What could be the issue and how to fix it?
Likely this is result of <code> check_admin_referer() </code> function not recognizing your request as coming from admin area. Since your query clearly contains nonce it is likely what is not being recognized. Nonces can be locked down in many ways. They are unique to the WordPress install , to the WordPress user, to the action, to the object of the action, and to the time of the action (24 hour window). That means that if any of these things changes, the nonce is invalid. ( Mark Jaquith ) My theory is that your load-balanced installs don't count as same install for the purpose of generating nonce. If possible try to limit admin area to single server and see if that helps.
Weird Issue with load balanced WP 3.0 setup
wordpress
Is there anyway I can edit my htaccess file without using ftp?
Here are a couple of options: WP htaccess Control - will let you manually edit your <code> .htaccess </code> file All-in-one htaccess Plugin - will let you dynamically create an <code> .htaccess </code> file based on which modules/features you want set up When all else fails, turn to Google ...
Plugin to edit htaccess file
wordpress
A standard WordPress installation has very basic support for posting via e-mail . Is there a plugin that gives the same functionality as WordPress.com (especially attachment handling)? My client is in love with Posterous, and I could set up the XML-RPC bridge so new posts go to WordPress, but I'd rather stay in WordPress so I could add advanced handling of custom post types and taxonomies myself once we get the basics running.
Try Postie. http://wordpress.org/extend/plugins/postie/ It has lots of features (including handling attachments and inline images)
Post-by-mail similar to WordPress.com or Posterous?
wordpress
I've created a custom meta box to handle certain custom post meta fields and I don't want the clutter of having these custom fields duplicated down in the "Custom Fields" area. How can I remove specific custom post meta from the "Custom Fields" fieldset?
To hide a custom field from the "Custom Fields" section, prefix it with an underscore. So <code> add_post_meta($id, 'name', 'value'); </code> becomes <code> add_post_meta($id, '_name', 'value'); </code> . Here's a good reference for backup: How to Hide Your Plugin's Custom Fields
How can I remove specific custom post meta from the "Custom Fields" fieldset?
wordpress
I recently updated the main theme of a production site. Unfortunately, the upgrade process deleted all our custom templates. Is there any way I can prevent this happening again?
Child themes might be your best bet.
Is there a way to upgrade a theme without losing custom templates?
wordpress
My theme has code that places a custom meta box on the Page editor interface for toggling noindex and/or nofollow attributes to the page. Its a simple little deal with two checkboxes, one says noindex, the other says nofollow. These work flawlessly in all versions of WP prior to 3.0.1 I've found that in 3.0.1, the values of the checkboxes are not saved. No matter what I do, they always come up unchecked, and the values are not being passed to the database either (its not just reporting unchecked in the interface, it never sends the values to the db) I'm at a loss at what's different and how to get my code to work with 3.0.1 Does anyone know of what might have changed to make these checkbox values not pass when the page is Updated in WP 3.0.1? <code> // =================== // = POST OPTION BOX = // =================== add_action('admin_menu', 'my_post_options_box'); function my_post_options_box() { if ( function_exists('add_meta_box') ) { add_meta_box('categorydiv', __('Page Index Options'), 'post_categories_meta_box_modified', 'page', 'side', 'high'); } } //adds the custom categories box function post_categories_meta_box_modified($post) { global $post, $noindexCat, $nofollowCat; $noindexCat = get_cat_ID('noindex'); $nofollowCat = get_cat_ID('nofollow'); if(in_category("noindex")){ $noindexChecked = " checked='checked'";} if(in_category("nofollow")){ $nofollowChecked = " checked='checked'";} ?&gt; &lt;div id="categories-all" class="ui-tabs-panel"&gt; &lt;ul id="categorychecklist" class="list:category categorychecklist form-no-clear"&gt; &lt;li id='category-&lt;?php echo $noindexCat ?&gt;' class="popular-category"&gt;&lt;label class="selectit"&gt;&lt;input value="&lt;?php echo $noindexCat ?&gt;" type="checkbox" name="post_category[]" id="in-category-&lt;?php echo $noindexCat ?&gt;"&lt;?php echo $noindexChecked ?&gt; /&gt; noindex&lt;/label&gt;&lt;/li&gt; &lt;li id='category-&lt;?php echo $nofollowCat ?&gt;' class="popular-category"&gt;&lt;label class="selectit"&gt;&lt;input value="&lt;?php echo $nofollowCat ?&gt;" type="checkbox" name="post_category[]" id="in-category-&lt;?php echo $nofollowCat ?&gt;"&lt;?php echo $nofollowChecked ?&gt; /&gt; nofollow&lt;/label&gt;&lt;/li&gt; &lt;li id='category-1' class="popular-category" style="display:none;"&gt;&lt;label class="selectit"&gt;&lt;input value="1" type="checkbox" name="post_category[]" id="in-category-1" checked="checked"/&gt; Uncategorized&lt;/label&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;?php } </code>
First of all, this isn't using custom post meta ... you're trying to retrieve categories and use the presence of those categories to check the boxes. I also don't see any script to save the values once you've clicked them ... When this did work, I assume it was a very hackish solution, so I'm not surprised that it's unstable and has broken. However, you can actually use custom post meta to do what it is you want to do. Use the following script instead: <code> // =================== // = POST OPTION BOX = // =================== add_action('admin_menu', 'my_post_options_box'); function my_post_options_box() { if ( function_exists('add_meta_box') ) { add_meta_box('categorydiv', __('Page Index Options'), 'post_categories_meta_box_modified', 'page', 'side', 'high'); } } //adds the custom categories box function post_categories_meta_box_modified() { global $post; if( get_post_meta($post-&gt;ID, '_noIndex', true) ) $noindexChecked = " checked='checked'"; if( get_post_meta($post-&gt;ID, '_noFollow', true) ) $nofollowChecked = " checked='checked'"; ?&gt; &lt;div id="categories-all" class="ui-tabs-panel"&gt; &lt;ul id="categorychecklist" class="list:category categorychecklist form-no-clear"&gt; &lt;li id='noIndex' class="popular-category"&gt;&lt;label class="selectit"&gt;&lt;input value="noIndex" type="checkbox" name="chk_noIndex" id="chk_noIndex"&lt;?php echo $noindexChecked ?&gt; /&gt; noindex&lt;/label&gt;&lt;/li&gt; &lt;li id='noFollow' class="popular-category"&gt;&lt;label class="selectit"&gt;&lt;input value="noFollow" type="checkbox" name="chk_noFollow" id="chk_noFollow"&lt;?php echo $nofollowChecked ?&gt; /&gt; nofollow&lt;/label&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;?php } function save_post_categories_meta($post_id) { if ( defined('DOING_AUTOSAVE') &amp;&amp; DOING_AUTOSAVE ) return $post_id; $noIndex = $_POST['chk_noIndex']; $noFollow = $_POST['chk_noFollow']; update_post_meta( $post_id, '_noIndex', $noIndex ); update_post_meta( $post_id, '_noFollow', $noFollow ); return $post_id; } add_action('save_post', 'save_post_categories_meta'); </code> This will store Boolean flags in the custom post meta fields "noIndex" and "noFollow", retrieve the values of those fields to use in your custom meta box, and allow you to easily access them elsewhere in your site. Just use <code> get_post_meta( $post-&gt;ID, 'meta-name', true ) </code> to retrieve them.
WordPress 3 botches my Custom Meta Box values on Save
wordpress
Provided you have a 404 page defined in your theme, Wordpress will display a 404 page if "tag" is defined in $wp_query-> query_vars, and there are no posts matching that tag. I'm writing a plugin that displays some information on each page, in addition to posts. I'd like to alter the 404 logic so that the 404 page gets displayed if there are no posts matching a tag and the plugin cannot pull up any data matching that tag. If the plugin can find data, I'd like to show a normal page, regardless of whether there are posts on that page or not ... I've been Googling, reading code, reading the codex, and poking around here, and haven't been able to figure out where Wordpress triggers that 404, and how I can override it. (I have a feeling it might have something to do with status_header() in functions.php, but it's not clear how and when I need to hook into it). Any help/ideas/enlightenment appreciated. Thank you, ~ Patch
After a bit more slogging through code and Googling, I found the answer. It's contained in this thread (see Otto42's post), but for the record, adding the following to your plugin will override the 404 handling for the conditions you specify: <code> add_filter('template_redirect', 'my_404_override' ); function my_404_override() { global $wp_query; if (&lt;some condition is met&gt;) { status_header( 200 ); $wp_query-&gt;is_404=false; } } </code> Note that you need to set "is_404" to false before PHP outputs headers, which is why hooking it in the template_redirect logic is a good idea. ~ Patch
Are there any hooks that alter the 404 logic?
wordpress
i have a setup like <code> function form($instance) { $defaults = array( 'title' =&gt; 'Recent Products', 'number_products' =&gt; 3 ); $instance = wp_parse_args($instance, $defaults); </code> but my title is ok but number_products always does not show. i debuged in netbeans and found that form() is run 2 times and 1st time, variables look like <code> $instance = array(0) // after wp_parse_args, $instance = array('title' =&gt; 'Recent Products', 'number_products' =&gt; 3); </code> on 2nd run of <code> wp_parse_args </code> , i dont know why it runs the 2nd time, <code> $instance = array('title' =&gt; 'Recent Products', 'number_products' =&gt; null); // after wp_parse_args $instance = array('title' =&gt; 'Recent Products', 'number_products' =&gt; null); </code> i dont really know whats happening ... can some1 enlighten me?
i finally found the answer, its actually not a problem with the code i posted. its in the <code> update() </code> function. i have some validation code <code> function update($new_instance, $old_instance) { $instance['title'] = esc_attr(strip_tags($new_instance['title'])); if (is_int($new_instance['number_products'])) { if ($new_instance['number_products'] &gt; 0) $instance['number_products'] = $new_instance['number_products']; else $instance['number_products'] = 1; } else { $instance['number_products'] = $old_instance['number_product']; } return $instance; } </code> the problem is at 2 places. i should be using <code> is_numeric </code> over <code> is_int </code> , the reason is To test if a variable is a number or a numeric string (such as form input, which is always a string), you must use is_numeric(). then, in the else, <code> $old_instance['number_product'] </code> should have be plural <code> $old_instance['number_products'] </code>
Widget instance options not showing correctly
wordpress
I started using Akeeba Remote Control for Joomla and was really impressed with it. When I went to look for something similar for Wordpress, I found these Weblog clients. Which one is the best for backing/restoring up your content? (Existing and content that you add to the blog via the Weblog client)
It is not really direct answer to your question, but I think complete (database plus files) backup/restore is more comprehensive and important. Content backup is only content. Database is all of your blog, which can help you go from nuked database back to normal in no time (speaking from sad practical experience, that would be much more sad without complete database backup). Would you like to keep your question about clients alone or expand it to backup/resotre in general (it's marked as community wiki so I am trying to establish scope) ?
Which Blog Client for Windows/Linux has the best support for backing/restoring your posts?
wordpress
I have an XML data source that updates daily. Is there a plugin that will allow me to create a query and update it daily with the least programming possible and display the data on a page?
XML as in generic XML? I mostly mess with RSS (for which WordPress has SimplePie bundled). Maybe SimpleXML (PHP 5+, not WP specific) will do? Also quick repository search found this: Advanced XML Reader
XML parser plugin
wordpress
I typically schedule posts well in advance before they get published. At times I can have as many as 5-10 scheduled posts set to be published within the coming weeks. Is there a way to show a calendar with all my scheduled posts? Ideally I would like to see them in Google Calendar.
It's not Google Calendar, but the Editorial Calendar plugin works really nicely.
How can I show my scheduled posts in Google Calendar?
wordpress
does anyone know of a plugin for mass editing of settings on a multisite installation? Something like Plugin Commander for Settings?
i think this is what you looking for: http://wordpress.org/extend/plugins/yd-wpmu-sitewide-options/
Plugin for editing options on multisite?
wordpress
How can a widget which of which only one instance can be used?
Simple way would be to set some global variable on first widget run and check for it. Output nothing or informational message if it is already set. Proper way would probably be to work with interface and remove widget from available when you add it to sidebar, but that is way out of my league.
How Can A Widget With Only One Instance Be Defined?
wordpress
Hay, i have a site which has been designed to only have 8 main pages across the main navigation, however these pages can have as many subpages as they want. Is there a way to limit the amount of main pages an admin can create?
Won't it make more sense to limit number of pages that navigation displays? There are many instances when page is not wanted in navigation but still needed somewhere (I have privacy policy set up this way at my blog for example).
Limit the amount of main pages
wordpress
In my WordPress blog I have events I want to order and filter by custom fields. The order should be done by the custom field "event_date_end" which means that every event that is still running should be displayed. To order the events I use a second custom field "event_date_start". So an event, that start on the 10th and ends on the 20th it should be displayed until the 20th but should be order next to all other events starting at the 10th. I use Thematic as a parent theme and so I use the query_posts() function adding both rules as parameters. This is how I use it in the index loop: <code> function my_index_loop($content) { global $query_string; query_posts($query_string // filter by event_date_end ."&amp;meta_key=event_date_end&amp;meta_compare=&gt;=&amp;meta_value=".date('Y-m-d') // order by event_date_start ."&amp;meta_key=event_date_start&amp;orderby=meta_value&amp;order=ASC"); } add_filter('thematic_indexloop', 'my_index_loop'); </code> Now the posts are correctly ordered, but also the filter will be done on the "event_date_start" value. So an event, that has been started yesterday and still going on, will not be displayed. If I switch the order of the "filter" and "order" parts, I will see all events, but an event starting at the 10th and ending at the 20th will be placed to all event on the 20th. I know I can create queries in SQL myself, but will they work with Thematic? And how do I have to write statements for archive, category, tag listing? The solution : After reading the mentioned pages, I found the following solution. I had to use some raw SQL and add them through filters within the specific loop filter. These are the functions I added: <code> function my_loop_where($where){ global $wpdb; $where .= " AND pm_where.meta_value &gt;= '".date('Y-m-d')."'"; return $where; } function my_loop_join($join){ global $wpdb; $join .= " LEFT JOIN " . $wpdb-&gt;postmeta . " AS pm_order ON (" . $wpdb-&gt;posts . ".ID = pm_order.post_id AND pm_order.meta_key = 'event_date_start')"; $join .= " LEFT JOIN " . $wpdb-&gt;postmeta . " AS pm_where ON (" . $wpdb-&gt;posts . ".ID = pm_where.post_id AND pm_where.meta_key = 'event_date_end')"; return $join; } function my_loop_order(){ return 'pm_order.meta_value ASC'; } </code> And than I simply added filter to these functions within the e.g. index loop: <code> function my_index_loop($content) { global $query_string; add_filter('posts_where', 'my_loop_where' ); add_filter('posts_join', 'my_loop_join' ); add_filter('posts_orderby', 'my_loop_order' ); query_posts($query_string . "&amp;meta_key=event_date_end&amp;meta_compare=&gt;=&amp;meta_value=".date('Y-m-d')/*."&amp;meta_key=event_date_start&amp;orderby=meta_value&amp;order=ASC"*/); } add_filter('thematic_indexloop', 'my_index_loop'); </code> Now I can easily use that filter and order on the index and category loops but keep the default "log style" filter and orders on the archive pages.
This is not going to work, because you are setting same <code> meta_key </code> parameter twice with different values and only one will be effective. Rather than building raw queries it is better to use filters to modify WP query. Query Overview documentation has list of hooks where you can insert your mods (as the end under What Plugins can Modify ).
How to order posts by one custom field and filter them by another one?
wordpress
I want to use a category page as the home page of my blog. Is that possible and how can I do it? It tried it with a .htacces rewrite rule but that didn't worked.
Update Eliminating all of the other solutions, there is at least one remaining: <code> template_redirect </code> : <code> function wpse121308_redirect_homepage() { // Check for blog posts index // NOT site front page, // which would be is_front_page() if ( is_home() ) { wp_redirect( get_category_link( $id ) ); exit(); } } add_action( 'template_redirect', 'wpse121308_redirect_homepage' ); </code> You will need to pass the appropriate category <code> $id </code> , of course. The benefit of redirecting at <code> template_redirect </code> is that you only get one template-load taking place, rather than a second redirect after the template loads. Note that you can hook into the process even earlier, such as at <code> pre_get_posts </code> , thereby potentially saving an entire query request: <code> add_action( 'pre_get_posts', 'wpse121308_redirect_homepage' ); </code> Original Answer If all you want to do is display a specific category on the blog posts index, you can accomplish that with a simple filter of the main <code> $wp_query </code> at <code> pre_get_posts </code> : <code> function wpse1862_pre_get_posts( $query ) { // Only modify the main query // on the blog posts index page if ( is_home() &amp;&amp; $query-&gt;is_main_query() ) { $query-&gt;set( 'category_name', 'category-slug-here' ); } } add_action( 'pre_get_posts', 'wpse1862_pre_get_posts' ); </code> If you want to modify the template , then you can do one of two things: Create a <code> home.php </code> with the desired markup Use <code> template_redirect </code> or <code> home_template </code> to force WordPress to include your <code> category.php </code> template. Edit And if you want the blog posts index URL to look like: <code> www.example.com/main </code> Then you can use a Static Front Page , and assign a static page called "main" as your blog posts index. And if this is your objective: I really want the redirect. I want the home page ( <code> http://example.com/ </code> ) to redirect to the category page (which looks like <code> http://example.com/main/ </code> ) ...then the accepted answer is correct for your use case.
How to make a category page the blog home page?
wordpress
Our situation is that we only dabble with Wordpress, however one of our Wordpress customers wishes to add Google Analytics to his site. I'm assuming we can do this manually, relatively easily. And our instincts would be to go down that route. The customer is only small scale and won't need to do anything especially sophisticated, at least at this stage. We want to keep this simple. Is it best to avoid a plugin? Update Thanks for all the great answers- in the end we did use a plug-in. As promised by the experts who answered below it was super straightforward.
I'd suggest either a plug-in or a drop-in section of code in your client's <code> functions.php </code> file. The advantage of a drop-in is that you can add it once and never have to worry about activating or managing the system once it's up-and-running. stackexchange-url ("Here's a quick explanatio")n of how to add the Google tracking code to your theme's <code> functions.php </code> file. The code itself will be automatically added to the footer of every page, archive, and post. This is essentially what a plug-in will do, without requiring you to activate/administer the system within the WordPress UI. Alternatively, you could use Google Analytics for WordPress to do the same thing within the UI. The choice between plug-in or drop-in is entirely up to you. A drop-in takes about 10 seconds to add with copy-paste. A plug-in takes only slightly longer. The actual setup process within Google Analytics to get your tracking code will take longer than either approach.
Add Google Analytics manually, or use a plug-in?
wordpress
I have come across an interesting problem regarding the <code> get_template_part() </code> . I have created a theme options page (named sitewideSettings.php) normally I would include this in functions.php like so: <code> include(TEMPLATEPATH."sitewideSettings.php"); </code> which works fine. But now I am trying to use <code> get_template_part(); </code> <code> get_template_part('sitewideSettings'); </code> which is also working fine except that when clicking 'update' to update the settings I get an error message: "Are you sure you want to do this? Please try again". "Please try again" links back to the theme options page and clicking update takes you back to the error message which takes you back to Theme options and round and round we go. Nothing else has changed other than the use of <code> get_template_part(); </code> Anyone else come across this problem? How did you get around it? I am sure its something simple and obvious, but exactly what it is totally escapes me. (Its not a nonce issue as a nonce is created in both instances)
I know you say it's not a nonce issue, but it clearly is. That notice is the default 'This nonce didn't check out' message. I don't know exactly why the nonce is failing, but that is what is happening. I would double check how your nonces are created and checked. If you're using <code> wp_nonce_field() </code> make sure both action values and argument values are the same. Also, double check spelling of variables, or any scope-related issues that could be causing the nonce to fail. EDIT Following up on your insistence that it's not a nonce issue (which it is. The nonce issue is caused by a scope issue), here's what's probably happened. Included/required files are executed in the scope in which they're included. My guess is you're using a variable to build either the nonce action or the nonce name. Because <code> get_template_part() </code> includes the template file in the scope of that function, it's no longer being executed in the scope of your admin page's display callback. You either need to globalize those variables in all locations, or you need to use constants instead of variables.
Form Submitting Error with get_template_part()
wordpress
I want to create a sub config from some page on admin panel, eg: I've set config menu this way: <code> add_menu_page( 'E+', 'CRE+', 8, 'cr_e_plus_user_config', 'cr_e_plus_user_config'); add_submenu_page( 'cr_e_plus_user_config', 'E+', 'Configurations', 8, 'cr_e_plus_user_config', 'cr_e_plus_user_config'); </code> From <code> Configurations </code> page, I need to load another page when I click certain link. Now, I don't want this new page to be listed on menu, because it will need certain parameter before I can show it.
Admin pages are basically spoken nothing else then a hook to a function, so it is technically not a problem to add your own pages without making use of the menu. I was not aware of an API function that allows you to register own pages with ease, but there is a helper function in Wordpress you can make use of: <code> get_plugin_page_hookname() </code> (undocumented function). Next to that, the hook needs to be registered in a global registry of all page hooks ( <code> $GLOBALS['_registered_pages'] </code> ) so that it's rated valid when the page is requested. I've wrapped that in some sample code, just save it into your <code> /wp-content/mu-plugins </code> folder: admin_page_demo.php (Wordpress MU-Plugin Example) In there you can find a function <code> register_admin_page() </code> that can register any callback you need per the <code> admin_menu </code> hook. That's the important one, compare to Adding Administration Menus (Wordpress Codex) . The function returns the URL of the new admin page. You wrote that you might need to add more parameters, so I thought that might be handy. For the demo page I hardcoded into that example, the URL is: <code> /wp-admin/options-general.php?page=adminpagedemo_demo_page </code> . Keep in mind, that you need to check for security for that page on your own because Wordpress does not. Something like <code> current_user_can( ... ); wp_die( __('You do not have sufficient permissions to access this page.') ); </code> might be a helpful additional hint.
Admin config screen without menu
wordpress
I've created plugin that goes to wordpress plugin repositories. Now, I need to create another plugin (sub plugin or child plugin you may call) that require this certain plugin to be already installed and activated. I know I can use <code> register_activation_hook </code> . However, how do I check using that hook? Or, maybe there's another solution exists?
There is <code> is_plugin_active() </code> function. Other method is to check if functions or classes, specific to required plugin, exist. Some plugins explicitly define their own constants for this, typically with version number and/or other identifying info. There has been some developments to make extension dependence logic more generic, such as Plugin Dependecies , but they hadn't gained widespread adoption so far.
How to check if certain plugin exists and in expected version
wordpress
Is there some way to export/import links from a wordpress.com site to a private site? I have a rather large directory of links. I fetch the opml file and the category levels are there, but when I use the Bloggroller importer, it doesn't create the categories? Help would be appreciated.
If you're going from WP to WP, then you want to use the built-in exporter and importer. Your links should come along with it. I'm not sure about the categories with it, but this might help http://ellejohara.com/blog/making-the-wordpress-opml-tool-slightly-more-useful/
Import and export links from WordPress.com to private site
wordpress
1st question is: is a nonce required for a meta box? i read on the wordpress codex <code> add_meta_box </code> and they have a nonce for the meta box, i'd thought that maybe the add post form will already include a nonce? <code> echo '&lt;input type="hidden" name="myplugin_noncename" id="myplugin_noncename" value="' . wp_create_nonce( plugin_basename(__FILE__) ) . '" /&gt;'; </code> 2nd question is: whats the parameters available for the function that creates the markup of the meta box. from what i read in profesional wordpress looks like <code> function pp_meta($post, $box) </code> how will i know what parameters are available in such functions? and what does <code> box </code> refer to?
Not sure about nonces. As for arguments it is probably their usage of add_meta_box() : $callback_args (array) (optional) Arguments to pass into your callback function. The callback will receive the $post object and whatever parameters are passed through this variable. Default: null So <code> $post </code> is post object and <code> $box </code> is whatever they are passing in <code> $callback_args </code>
Questions about meta box: nonce and parameters available
wordpress
say i have an option <code> update_option('pp_options', $options); </code> when i want to create a form for that, i learnt that i have to create a settings group <code> register_setting('pp_options_group', 'pp_options'); </code> then in the form do <code> settings_fields('pp_options_group') </code> but i dont really what is the settings group actually for? i know its to do with sanitization but why the need to create a group for sanitization?
Sanitization is secondary function. Main is: The register_setting and unregister_setting functions add and remove options from a whitelist of allowed options that the form is able to save. They can also name a sanitize callback function as a security measure to check each option's value. ( Register settings ) Technically <code> $option_group </code> argument is used for: array key in global array of whitelisted options part of filter name to run sanitization callback
What is a settings group actually for?
wordpress