INSTRUCTION
stringlengths
11
999
RESPONSE
stringlengths
0
999
SOURCE
stringlengths
16
38
METADATA
dict
Remove "Comments are closed" Notice from Custom Post Type template I've created a custom post type single template. I noticed that when I turn off comments, I get a notice that says "Comments are closed." Looking at my comments.php, I get this little bit of code: <?php else : // or, if we don't have comments: /* If there are no comments and comments are closed, * let's leave a little note, shall we? * But only on posts! We don't want the note on pages. */ if ( ! comments_open() && ! is_page() ) : ?> <p class="nocomments"><?php _e( 'Comments are closed.', 'dukatheme' ); ?></p> <?php endif; // end ! comments_open() && ! is_page() ?> This code makes it such that the notice is not shown on pages. How can I edit it to make sure it is not shown on pages AND my custom post type? My custom post type is named "duka". Thanks!
Add a post type check to the `if` clause; if ( ! comments_open() && ! is_page() && 'duka' != get_post_type() ) :
stackexchange-wordpress
{ "answer_score": 3, "question_score": 2, "tags": "comments" }
Good tutorial on how to make custom write panels in Wordpress 3? On my last Wordpress 3 projects I successfully used custom post types and taxonomies coding the implementation by myself. As regards to custom write panels, I always used the more fields plugin without any problem. Now I am developing a whole new theme which needs to be totally independent from that plugin therefore I need to add the custom write panels only by coding. I did a lot of searching but I was not able to find a good tutorial about it. Any suggestion? Thank you
I always loved this article mainly for the reason that its about creating a class to use for your metaboxes.
stackexchange-wordpress
{ "answer_score": 3, "question_score": 1, "tags": "editor" }
converting custom field date format I am using the More Fields plugin which gives me the ability to create a date formatted YYYY/mm/dd and I want to convert that to be shown like: February 11, 2011 Is this possible?
Do you have issue with exactly converting or retrieval? Converting is trivial and is plain PHP: date('F j, Y', strtotime($date)); For more complex and WordPress-specific way with localization support see `date_i18n()` function.
stackexchange-wordpress
{ "answer_score": 7, "question_score": 1, "tags": "custom field, date time" }
Correct way to include extra styles & script files? I'm just wondering what is the correct way to do it? Add it in via the theme header? If so, what is the proper way to do it? I see a lot of the other current stuff in there using the bloginfo() function. Thank You!
You could tack it into header.php as you suggested (although this is not really the proper way to do it, it is best to use WPs enqueue function as described here). When do you need these? All the time? You can enqueue scripts and styles to be used all the time, or on an as-needed/per template basis < <
stackexchange-wordpress
{ "answer_score": 4, "question_score": 0, "tags": "javascript, css" }
OEMBED seems to have stopped working I had upgraded from 3.0 to 3.1 and oembed worked normally. All of a sudden I've lost embedding when directly pasting video url into the editor. My embed setting is selected under "media". Any ideas what could be going on? I've changed themes, ultimately to the native 2010 and still no function. I've tried turning the embed setting on and off in the admin as well to no avail.
It appears I've been hoodwinked by my local setup & accidentally stopping connections to vimeo / youtube. This resulted in the video url appearing as only text. Once my setup was restarted everything appears to be working properly. Sorry for the confabulation.
stackexchange-wordpress
{ "answer_score": 4, "question_score": 1, "tags": "oembed" }
Getting a 404 in Debugger for example.com/wp-admin/Array? For some reason when I go to one of my clients WordPress installations, and I install a plugin that I made which has custom TinyMCE buttons, when they click on one of the buttons the popup appears but there's no text. In the JavaScript console of Google Chrome before I even click the buttons, there is the following: `Failed to load resource: the server responded with a status of 404 (Not Found) - Array - < Could that have something to do with my plugin or their installation of WordPress? Thanks for the help.
If I am not mistaken in PHP `Array` commonly comes up when array variable is wrongfully used where string is expected. But from this information I have trouble suggesting where exactly that can go wrong.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "404 error, tinymce" }
Scripts at the end of the page If I wanted to put the scripts that all my plugins use at the end of the page, where would I do this? Using YSlow/Firebug it recommends this tactic.
The hook for registering the script in the footer is: <?php function my_init_method() { wp_register_script( 'myscript', ' wp_enqueue_script( 'jquery' ); } add_action('init', 'my_init_method'); ?> be sure to look at this and this, both are important.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 1, "tags": "plugins, javascript, scripts" }
Using the ABSPATH constant - What files need to be loaded before use? I need to make use of the ABSPATH constant but need to know what WP files I need to include so I can make use of it. Thanks a lot!
It is defined at the very start of `wp-load.php`. However it's value is very primitive - only a path to where file is located, which you could easily get without bothering with including it.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "constants" }
How do I change the permalink structure without getting 404s? after updating the permalinks from the default /?p=N to another setting (e.g. /%year%/%monthnum%/%postname%/) all my old links are broken and also the archive, catgories etc. side bars get 404 errors. How can I avoid this (or redirect) without changing the .htaccess (which I can't access using my hosting package)? Any suggestions or plugins that work with my current version (WP 3.1) are welcome! Thorsten
If you can't modify .htaccess then chances are WordPress can't either. Save your permalinks again and check if it tells you it couldn't save your htaccess file. That's your problem if so. Bigger question: why are you using a host that won't let you modify .htaccess? That's like renting an apartment from a landlord that won't let you use the bathroom. You're paying them for space on that server and you should be allowed to use it in any legal way you see fit. My advice is that you change hosting providers.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "permalinks, 404 error" }
How to allow <video> html5 tag in Wordpress Currently I am running a Wordpress MU blog using the Unfiltered MU plugin. However, when I try to insert an HTML5 tag, it gets stripped away. I believe it may be the WYSIWYG editor cleaning the code. Where can I change settings to allow ? Thanks
Just FYI... WordPress 3.2 includes an updated TinyMCE which allows HTML5 tags. It's still under development but is fairly stable if you want to take the risk of running it now. The alternative is to write any posts requiring the tag with the visual editor turned off. As long as you don't turn the editor on again on that same post the tags will stay there. Just turn the editor on once you have navigated away from that post in admin.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "tags, multisite, wysiwyg, videos, html5" }
Auto-Update Plugin Creating .tmp directory, not overwriting old version I'm using this library to auto-update my plugin, but it's only extracting the new plugin files into a .tmp directory, while the old plugin files stay where they are. Can anybody help me fix this to overwrite the old files or any ideas as to why it would be doing that? Edit: I know that the library above does not actually install the update, but the WP core updater does, so it has something to do with that. Any ideas?
Are you able to update standard WP repo plugins? I am using that library and it seems to work well. What's the exact error that WordPress gives on the admin screen when it tries to run the update? I would take a look at permissions first. What are the permissions on the old plugin directory? Any different than any of your other plugin directories? I would also take a look at the format of the zip file you're feeding it. What software did you use to create the zip? When you unzip it, what does the directory structure look like? It should unzip as a folder with the same name as the plugin you're trying to replace. Did you set the slug attribute in the JSON file? Does that also match the folder name? Hope this helps. I was able to get that library going pretty quickly.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "plugin development, automatic updates" }
How to prevent spam comments? I have NoSpamMX plugin installed. I was not getting spam comments for a long time. But now I am getting a lot of spam comments especially in one post. What is the reason that there is such a lot of spams only to that post?
+1 for akismet < Is also amazing. Akismet is great at catching spam, but adding cookies for comments is awesome. It stops a lot of the auto-posted spam. (Which most of it is) Cookies for comments will stop the comment before it even gets to you. Akismet was catching 50 spams a day for me. But once I added CFC, I only get maybe 1 comment a week for akismet to deal with. The two combined are great
stackexchange-wordpress
{ "answer_score": 5, "question_score": 2, "tags": "plugins, comments" }
How can I convert Posts into Custom type posts? I have a Wordpress site that I just updated to 3.1. I want to make use of custom post types now, my question is how can I assign (transfer?) a post to a newly created custom post type ? For example, all my articles (news, poems, ideas to change the world) are in Posts. Now I have created the custom post types News, Poems, etc. and I want to transfer my old posts to these new custom post types. I hope this is clear enough, anybody ?
It seems that the easiest way is to do it manually in the DB. If you don't have access to the DB, or if you don't want to do it manually, you can install a plugin that will do it one post at a time, or a plugin that will bulk convert a lot of posts at once
stackexchange-wordpress
{ "answer_score": 12, "question_score": 7, "tags": "custom post types, posts" }
enabling custom fields in admin? i've found out that there are custom fields but i'm not able to activate them in the admin panel .. :( i've checked the screen options but there's no custom fields - looks like it depends on the template i'm using. any ideas how to modify it in order to enable custom fields for posts? thx
The visibility of custom fields on the post edit screen is controlled on the post edit page. There's a button called "Screen Options" towards the top of the screen. !Screen Options Button Clicking that button will display all of the available boxes and panels for the edit page. If custom fields is not visible here, then either your theme or a plug-in is disabling the feature. !Screen Options Panel
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "custom field" }
Styling readme.html in plugin? I am making `readme.html` file for a plugin with some detailed setup instruction that need to include screenshots. As rest of UI I want it be consistent with WordPress style and so I looked at its own `readme.html`. It includes stylesheet with relative path: <link rel="stylesheet" href="wp-admin/css/install.css?ver=20100228" type="text/css" /> So for a plugin file I might go with: <link rel="stylesheet" href="/wp-admin/css/install.css" type="text/css" /> But it is good way to include styling? There are really many ways to do it: * link to `install.css`; * bundle copy of `install.css` with plugin; * bundle own CSS file with plugin; * embed style in `readme.html`. I am not aware of any recommendation about providing HTML documentation with plugins. Had you included HTML documentation with plugins (or themes, whatever)? What method had you chosen to style it and what was you reasoning for it?
It would be better to include your own CSS file that way you can: * Use a relative path to your CSS. * Avoid problems getting the path right to the `wp-admin` directory. Not all people put WordPress in the root directory, so your example above would break for them. * Possibly redundancy by reusing the CSS in your HTML & admin pages for your plugin.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 2, "tags": "plugins, css, documentation, readme" }
displaying flv-video attachment in post i've attached a local .flv video to my post (it was uploaded and is inside my mediapool). my question: how can i display it inside my post? (the video player) thanks
The .flv is not a video player in itself, rather just a video file to be played in one. To display it, you'll need to play it from an actual video player. Unlike .wmv and .mp4, .flv files won't play natively in your browser without one. There's a couple great open source options out there. There are also a few plugins that might already have the functionality you're looking for.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "posts, videos" }
Using the title of the post in a shortcode Hi I'm trying to use this plugin: < I am supposed to use the shortcode: `[screenshot url="www.example.com"]` Because I am writing the code in the single.php file I am using: `<?php echo do_shortcode( '[screenshot url="www.example.com"]' ); ?>` But, my problem is that the URL is defined in the title of the post, so I tried: `<?php echo do_shortcode( '[screenshot url="<?php the_title(); ?>"]' ); ?>` with no luck. Is it possible to do a workaround on this?
You're trying to execute PHP inside a string! Instead, concat the string; <?php echo do_shortcode( '[screenshot url="' . get_the_title() . '"]' ); ?>
stackexchange-wordpress
{ "answer_score": 3, "question_score": 0, "tags": "shortcode" }
Is there a plugin that will completely remove the category system? I have no use in categorizing/tagging my posts with anything, at all, and it doesn't look very good to have every post say "filed under: uncategorized." Is there any plugin to do this, or do I need to do some manual editing?
Why hack apart what's already there? If you remove the built in taxonomies, you'll end up **creating hiccups** in core code that expect them to be there! You're **much** better off just editing your theme file(s), or filtering out categories on the front-end (ask if you need help on that). For example, in your theme's `index.php` and `single.php`, you might have something like; filed under: <?php the_category( ', ' ); ?>. Just remove it and you're done!
stackexchange-wordpress
{ "answer_score": 4, "question_score": 2, "tags": "categories" }
Listing all sidebars How to list all existing sidebars? I want to show them all in the drop down list (so each item should have also the right value).
You can only gel list of registered sidebars, from variable **$wp_registered_sidebars**. <?php global $wp_registered_sidebars; echo '<pre>'; print_r($wp_registered_sidebars); echo '</pre>';
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "plugins, widgets, sidebar, list" }
getting video dimensions when attaching videos (eg. .flv) to a post - is it possible to query its dimensions? the problem is - i've got videos in 4:3 and 16:9 format and i need to get this information. any ideas? thanks
php-flvinfo and php-mp4info are php classes for reading flv and mp4 metadata. you could read it on the fly, or it may be possible to hook a save to get this info in the db somewhere.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 3, "tags": "posts, videos" }
adding a #hash to each link in list_pages()? hey guys, is it somehow possible to do the following: `wp_list_pages()` lists each link inside a `<li> <a href="link"...` <?php wp_list_pages('title_li=&depth=0&exclude='); ?> Is it possible to add a #hash to those links? Like `<a href="link#something"`? thank you for your help
I'd wrap it in a function (save it in `functions.php`); function wp_list_pages_with_hash( $hash, $args = '' ) { $add_hash = create_function( '$link', 'return $link . "#' . $hash . '";' ); add_filter( 'page_link', $add_hash ); $result = wp_list_pages( $args ); remove_filter( 'page_link', $add_hash ); return $result; // back compat in case 'echo' was null } Then call it like so! <?php wp_list_pages_with_hash( 'target', 'title_li=&depth=0' ); ?>
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "list, functions" }
Proper way to get page content I have to get specific page content (like page(12)) I used that : <?php $id=47; $post = get_page($id); echo $post->post_content; ?> Work nice execpt for compatibility with qtranslate it return french and english text But the loop is fine, return only the good language version <?php if(have_posts()) : while(have_posts()) : the_post(); ?> <div id="post"> <?php the_content(); ?> </div> <!-- .post --> So the question.... HOW to get a specific page content insite the loop...
Here is the solution i have founs that work fine...the codex should be more specific about the apply_filter ... used it all everytime $id=47; $post = get_page($id); $content = apply_filters('the_content', $post->post_content); echo $content; But i have found a great place to ask question (HERE)! thanks guys !
stackexchange-wordpress
{ "answer_score": 6, "question_score": 8, "tags": "pages, query, post content" }
ShortCode and extra </p> [box id='1' text="some texte"] the shortcode, at one point is outputting text the html result is : `</p> some text </p>` There is an extra closing paragraph in the start and and opening at the end... WHY ? where those come from ?.... any idea ?.. it screw my w3 validation ! ** note i have found that... but look all "patched" to me...any clean solution... wp is dirty ? reference
I discover that it's a know bug, and will be fix in future release Reference here So then, i used this code... not pretty, but do the magic !, thanks $content = do_shortcode( shortcode_unautop( $content ) ); if ( '</p>' == substr( $content, 0, 4 ) and '<p>' == substr( $content, strlen( $content ) - 3 ) ) $content = substr( $content, 4, strlen( $content ) - 7 ); return '<div my stuff>' . $content . '</div>';
stackexchange-wordpress
{ "answer_score": 3, "question_score": 1, "tags": "shortcode, html" }
Having trouble understanding custom post type and taxonomy :/ I am developing a Wordpress site that will have a database of car modifications and an embedded youtube video with the results. For example: search for Honda Civic with a spoiler and exhaust. This would generate several posts. Each post has there own video, attributes, and an adsense ad. I am using the term posts loosely though, I really don't want to post them on the blog of the site. I am struggling to see how (if) this can work with the custom post type and taxonomy features in 3.0. Also I found this $200 theme on WooThemes, I'm not positive it will work and they wont talk to me about technical stuff unless i'm a "member". I would Like to insert youtube videos instead of their dealer listing, but it seems like the theme is a great start. WooThemes - "Listings" Thanks for any help and insight, I am at my wits end try to see if this is do-able.
1. Register a 'car' post type. 2. Register 'spoiler' and 'exhaust' taxonomies to the 'car' post type. 3. Use the Taxonomy Drill-Down plugin to create the "search" you need. The YouTube video URL could be stored as a custom field.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 2, "tags": "custom post types, taxonomy" }
How do I make an HTML table from a database table? is there a built-in wordpress function to make the HTML or should I use plain-old PHP?
Since 3.1 there's a class `WP_List_Table` which makes it a hella lot easier to render tables for an array of data objects. There's very little documentation (read: none) on it yet, but you can check out the source if you're familiar with PHP.
stackexchange-wordpress
{ "answer_score": 10, "question_score": 10, "tags": "php, database, html, wp list table" }
Error "The given object ID is not that of a menu item" on menu with 40+ items When ever I try to add menu items past about 40 I get an error "The given object ID is not that of a menu item" and many of my menu items will disappear from the menu at random. The site I am working on has approx 65 pages in total but I am unable to get them all in because of this. I am referring to the new WordPress menu management interface
The solution I found was to get in touch with my webhost and have them up the PHP memory limit on my account from 64MB to 128MB. The problem went away after that.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 2, "tags": "menus, errors" }
Send automatic mail to Admin when user/member changes/adds profile Is there a way to send the updated/added values from profile, when a member/user updates his/hers data, to the admin of the site or another emailadress? Can this be the first step? /* do something when user edits profile */ add_action('personal_options_update', 'notify_admin_on_update'); function notify_admin_on_update(){ // send a mail with the updated values to [email protected] exit; } What is best pracice to send emails from within WordPress?
you got the first part right about using `personal_options_update` but to be on the safe side add `edit_user_profile_update` also. and as for sending emails within WordPress the best way would be to use **wp_mail**, So something like this: add_action( 'personal_options_update', 'notify_admin_on_update' ); add_action( 'edit_user_profile_update','notify_admin_on_update'); function notify_admin_on_update(){ global $current_user; get_currentuserinfo(); if (!current_user_can( 'administrator' )){// avoid sending emails when admin is updating user profiles $to = '[email protected]'; $subject = 'user updated profile'; $message = "the user : " .$current_user->display_name . " has updated his profile with:\n"; foreach($_POST as $key => $value){ $message .= $key . ": ". $value ."\n"; } wp_mail( $to, $subject, $message); } }
stackexchange-wordpress
{ "answer_score": 12, "question_score": 4, "tags": "admin, email, updates, automation, profiling" }
Editing URL character replacement Whereabouts can I edit which characters in permalinks are replaced? For example apostrophe's are replaced with nothing, and I would like to have them replaced with hyphens instead. Thanks.
You need to filter `'sanitize_title'` and use the second argument, the raw title. See my plugin Germanix for an example.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "permalinks, slug, encoding, localization" }
Multisite: setting theme and options when a new blog is created When a new blog is created in a WP Multisite instance I want to be able to set the default theme and configuration options * create 2 menus (main and secondary) and associate them with the 2 slots provided by the theme * set various theme options as defined on the theme option page What's the best way to go about achieving this? * which hook should i use - I'm going to use this: ('WP_DEFAULT_THEME', 'theme-folder-name' in wp-config.php to set the default theme - unless this prevents a needed hook from firing. * easiest way to programatically create menus and associate them with existing theme menu 'slots'
The best hook I can find is `wpmu_new_blog` (line 1086, `wp-includes/ms-functions.php`, `wpmu_create_blog()`) - it passes 6 arguments like so; do_action( 'wpmu_new_blog', $blog_id, $user_id, $domain, $path, $site_id, $meta ); `$meta` is an array of initial site options, not to be confused with the options generated by `populate_options()`. Programatically creating nav menus may prove to be a little tricky, as there is no 'API' as such - they're a mix of posts, post meta and `nav_menu` terms, coupled with a few available functions such as `is_nav_menu_item()` and `wp_setup_nav_menu_item()`. My best advice would be to check out `wp-admin/nav-menus.php`, as this is where all the core code lies for creating menus. Using `WP_DEFAULT_THEME` should be fine, and is probably the best approach too.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 3, "tags": "themes, options, activation, customization" }
Featured Image meta box shows at the bottom? After using this code: //Set custom featured image metabox function customposttype_image_box() { remove_meta_box('postimagediv', 'eezzyweb-webfolio', 'side'); add_meta_box('website_grid_view', __('Featured Image for grid view'), 'post_thumbnail_meta_box', 'eezzyweb-webfolio', 'side', 'low'); } add_action('do_meta_boxes', 'customposttype_image_box'); and afterwards removing it, the Featured Image metabox is at the bottom, not on the right side anymore... Is there something I need to reset/unregister??? Thank you
The `add_meta_box` code you've posted does certainly register the metabox to the bottom of the side area. If the box is shown in the center then i imagine it's because you've(at some point) moved the metabox, as can be done with any of the metaboxes(all drag and drop). WordPress remembers where you move boxes to, and only adheres to the positioning inside the `add_meta_box` as a default view(when they've not yet been moved). The solution would be to drag and drop the box back to the side area, assuming this is just a case of re-positioning the metabox.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "post thumbnails" }
Query posts without a specific ID How would we query posts as long as the post does not equal the ID 2047? Here is the current query. <?php $args1 = array( 'post_type' => 'options', 'tag_slug__and' => array( $triplevel, $divingtrip, 'accommodation' ), 'posts_per_page' => -1, 'offset' => 1, ); query_posts( $args1 ); while (have_posts()) : the_post(); ?> I tried this... query_posts( $args1 . 'p!=2047' ); ..to no effect. Any ideas? Marvellous
Most of the things you can do with a query are described in the Codex page for WP_Query You need to use the 'post__not_in' parameter eg: $args = array( 'post__not_in' => array('34','54'), // post ids 'post_type' => 'page' );`
stackexchange-wordpress
{ "answer_score": 8, "question_score": 1, "tags": "query posts, posts" }
How do I exclude a custom taxonomy from the post loop Is there a simple or easy way to exclude all posts from a custom taxonomy in the loop? I've been looking high and low, and neither SE, SO or Google seem to have a straight answer. I know it can be done via a WPDB query, but that just seems like massive rope to jump for something that should be fairly simple.
You would want to use the `NOT EXISTS` operator along with passing the taxonomy slug, which tells the query not to include any of a chosen category from your custom taxonomy inside the loop. To exclude all posts that are in the taxonomy "fruit" (regardless of fruit kind), here is the snippet: $args = array( 'post_type' => 'post', 'tax_query' => array( array( 'taxonomy' => 'fruit', 'operator' => 'NOT EXISTS' ) ) ); $query = new WP_Query( $args );
stackexchange-wordpress
{ "answer_score": 19, "question_score": 27, "tags": "custom taxonomy, query posts, wp query, loop" }
one category template for multiple categories i have category-events.php to list my posts tagged 'events' but it wont work for 'events' child categories. ie i have some posts tagged 'events' and one of events' children 'exhibition'. I thought it would use category-events.php automatically but it doesn't. Is this possible as i want to user category-events.php for several of 'events' child categories. hope that makes sense and any pointers welcome. dan.
ah - found it here! Make all subcategories use the template of its category parent? thanks...
stackexchange-wordpress
{ "answer_score": 0, "question_score": 1, "tags": "categories, templates" }
Create a Plugin to Download Files from Web to Server I'm writing a plugin and want to have a feature where, in the Admin area, the user will click on a link and it will download a theme to the /themes directory on their server. How would I do this? Thanks.
Ehm... You are writing the plugin or thinking about it? Could you show us some stuff that you already did? You should check the permissions on the server where you want to upload the files. Then - in case - change chmod, upload and then change chmod back for sec. reasons. Maybe the update class will help you a little further.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "plugin development" }
How to remove "Connection Information" requirement on localhost install of WP on MACOSX I've just installed XAMPP on Mac OSX and when trying to install a theme or plugin in WP admin, I'm getting this screen. I've never gotten this on my _shared_ hosting account. how to get rid of it on localhost? !WordPress challenge when installing new plugin !enter image description here
Have you tried updating the permissions for your WordPress files to 755 or 777? ## UPDATE 1 Thanks to @anu in the comments _(`~/Sites` assumes you put websites are in the Mac's default website directory):_ cd ~/Sites sudo chmod -R 777 * I just checked my `httpd.conf` file, which has the path `/Applications/XAMPP/etc/httpd.conf` and here is what I found starting on line 127 so I think @gabrielk's answer is probably what you need. # running httpd, as with most system services. # User mikeschinkel Group everyone </IfModule> </IfModule> ## UPDATE 2 If you were to decide to use the built-in Apache a tool you should definitely consider getting for the Mac is **VirtualHostX**. It manages all your Apache and your hosts files for setting up local _"domains"_. It's one of my favorite tools on the Mac: ![VirtualHostX Screenshot](
stackexchange-wordpress
{ "answer_score": 4, "question_score": 5, "tags": "security, xampp, local installation, mac" }
Wordpress FLIR (Facelift Image Replacement) plugin clipping off end of text I'm using the FLIR for Wordpress plugin (v0.8.9.2) with FancyFonts enabled. I'm running Wordpress 3.1. The problem I'm having is that it appears the plugin is cutting off a couple pixels off of the end of some of the text that it generates. It doesn't do it for all text, but where it happens, it happens consistently. Here are some examples: !enter image description here !enter image description here !enter image description here In my search for a solution, I've found a number of people with this issue, but never any solutions. Any ideas would be greatly appreciated. Thank you!
Copy & Paste from comment. Seems like the plugin has a bug. The plugin doesn't seem to be actively maintained anyway, but your best bet is to contact the plugin author. The cufon project is pretty similar and production proven. Just google for it. But in times of CSS3 and HTML5 you could simply insert the font via @font-face. Edit: It is totally safe to use @font-face these days. IE actually supports font-face since IE4 via the .eot format. Not as nice as using the .otf like modern browsers do, but far better than any other solution.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "plugins, customization" }
Is there something wrong w/ this code? <?php $rp = new WP_Query(array( 'post_type' => array( 'post','videos','projects' ), 'orderby' => 'date&order=DESC', 'posts_per_page' => 4 )); while ($rp->have_posts()) : $rp->the_post(); ?> I noticed that if I change `date&order=DESC` to `rand`, it makes no difference, meaning the posts don't show up in random order even after multiple refreshes. Is there something wrong w/ this code?
It should be this: WP_Query Order By Parameters <?php $rp = new WP_Query(array( 'post_type' => array( 'post','videos','projects' ), 'orderby' => 'date', 'order' => 'DESC', 'posts_per_page' => 4 )); while ($rp->have_posts()) : $rp->the_post(); ?>
stackexchange-wordpress
{ "answer_score": 5, "question_score": 0, "tags": "wp query" }
And/Or Category Query I'm having a lot of trouble using php query_posts(array('category__and'=>array(1,3))) - it seems to be pulling anything that's in category 1 regardless of whether it's also in category 3 and I only want the posts if they exist in both categories. And ultimately, I need a bunch of OR statements anyway, so is there a better way than query_posts to do this? I want a page of posts that exist in a variety of multiple categories -- i.e: categories 1 AND 3 OR categories 1 AND 5 OR categories 1 AND 6 But not categories 1 AND 4 Any help would be greatly appreciated. Thanks.
Strange, that usage of `category__and` should be working. As for following logic I don't think you can accomplish anything that complex with query parameters. There are several possible ways to deal with it that I can think of: * simplify category structure and/or selection logic; * modify raw SQL with `posts_where` filter; * store selection criteria in post meta.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "categories, query" }
get author of published post I am using the publish_post action to run some checks on a user after their post is published: $author_ID = ???? add_action('publish_post', 'rhb_check_current_user', 10, $author_ID); How can I get the original author's ID?
use `add_action('publish_post', 'rhb_check_current_user');` and in your rhb_check_current_user function check using the global $post: function rhb_check_current_user(){ global $post; $author_id = $post->post_author; ... ... }
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "plugin development, users, author" }
Need help decrypting error and warning messages I'm a relatively new Wordpress user, usually I just code my sites by hand though I'm trying to move to a CMS. I installed Wordpress onto a subforlder (< to test. Every now and again I would get warning messages like below, though starting today I started getting fatal errors. According to my server admin he has PHP 5.2.6 and MySQL 4.1.2 installed. Also it doesn't seem to help on whether I'm using Wordpress 3.1 or Wordpress 2.7 (which had been installed by someone else some time back and seemed to work) !Fatal error screenshot !Warning screenshot
The Health Check plugin is triggering the first error. Is this when you're running 2.7? `get_transient()` was only introduced in 2.8, which would explain it's absence. The second failure is merely a failed HTTP request. This can happen every now and then (mainly due to timeouts). It shouldn't interrupt the normal functioning of WordPress (the HTTP request was made by `wp-cron.php`, which is triggered as a separate request). The obvious advice is; * Upgrade to 3.1 if you're not running it, **now!** * Update any active plugins * Ensure you are using a fairly regularly maintained theme (or if you built it yourself, make sure you're using best practices and have removed calls to any deprecated functions).
stackexchange-wordpress
{ "answer_score": 3, "question_score": 0, "tags": "fatal error, warnings" }
show other images from same gallery suppose you are viewing a single image from the gallery. You have both previous and next links there (for navigation). but is there a way to also show all the other images from the same gallery in the same page (for example i want to show other images from same gallery) if there is a way then can anyone please provide me the simplest code please.
At it's very simplest, add this to your theme's `attachment.php` <?php do_shortcode('[gallery id="' . $post->post_parent . '"]'); ?>
stackexchange-wordpress
{ "answer_score": 2, "question_score": 2, "tags": "gallery" }
Automatic SEO for wordpress I know the ultimate seo plugin for seo optimizing seo. But with more that 250 post, and no seo plugin installed, i like to know if there is a plugin that will 1) make the title of the page, the title of the post 2) make the description based on the first paragraph 3) make the keyword meta by parsing the whole post, retreive all the reveland word that are more that 3% occurence, and fill the meta with them any idea ?
take a look at WordPress SEO by Yoast it will cover : > 1) make the title of the page, the title of the post > > 2) make the description based on the first paragraph as for your #3 > make the keyword meta by parsing the whole post, retrieve all the relevant word that are more that 3% occurrence, and fill the meta with them I highly doubt you will find a plugin that does that for you, but there are a few like * Keyword Density * SEO-Tool - Keyword Density Checker which do chack that , so i guess you can use that to update your keywords.
stackexchange-wordpress
{ "answer_score": 8, "question_score": 0, "tags": "seo" }
Clean up output added via wp_head() I know that `wp_head()` is important, but using it injects so much crap into the header. I'd like to get it out and just add manually the 2-3 line of code that I need. But, there is certain code added by WordPress that I want to keep: <meta name="description" content="" /> <meta name="keywords" content="" /> <link rel='canonical' href=' /> ... <meta http-equiv="Content-Language" content="fr-FR" /> How can this be generated for me? (Something like `bloginfo('name')` will be fine for me.)
You can remove some of the header stuff with the following. // remove unncessary header info function remove_header_info() { remove_action('wp_head', 'rsd_link'); remove_action('wp_head', 'wlwmanifest_link'); remove_action('wp_head', 'wp_generator'); remove_action('wp_head', 'start_post_rel_link'); remove_action('wp_head', 'index_rel_link'); remove_action('wp_head', 'adjacent_posts_rel_link'); } add_action('init', 'remove_header_info'); The default installation does not include stuff like meta keywords, so that is either a theme or plugin that you are using.
stackexchange-wordpress
{ "answer_score": 6, "question_score": 0, "tags": "post meta, seo, headers, functions" }
Default comments file and how to copy it I have a custom theme. There is no comments.php file, Wordpress is using whatever the default is. I need to modify the comments area, but I want to base my changes off of the default template. Where is the default template and how can I copy it into my own theme's comments.php? UPDATE Sorted it out for myself. The following directory contains default fallbacks if a file is not specified in your custom theme - `\wordpress\wp-includes\theme-compat\` I copied the comments.php file from there over to my custom theme and am ready to rock. I was told in a WordPress forum that this file is deprecated though and I should really be building my own.
I got some help from Wordpress forum. As of Wordpress 3.1 a function called `comment_form()` creates the submit comment area. You can override default settings by creating an argument list and passing it in as a parameter. Here is a quick example where I change the default header **Reply** to **Comment** and then remove the **acceptable tags** section at bottom of form. $comments_settings = array( 'title_reply' => 'Comment', 'comment_notes_after' => '' ); comment_form($comments_settings);
stackexchange-wordpress
{ "answer_score": 1, "question_score": 2, "tags": "theme development, comment form" }
Loading a newer version of jQuery within WordPress I've read about the WP enqueue_script() function, but if I wanted to use a newer version of jQuery than what my WP installation is using, can I load it through this & WP will use the latest version? or will it load both? or what will happen? Thanks!
To replace the default jQuery url, do: wp_deregister_script( 'jquery' ); wp_register_script( 'jquery', 'your custom url', ... ); Then call `wp_enqueue_script( 'jquery' );` as usual. Note that various pages in the WP admin might not be compatible with never versions of jQuery, not to mention plugin scripts.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "jquery, wp enqueue script" }
wp_get_object_terms - How can I order the resulting array by hierarchy? I'm returning a custom hierarchal taxonomy via wp_get_object_terms. The trouble is that the results are being ordered by name or count, neither of which are proving reliable. (I'm using a custom taxonomy for "Location" - City, State, Country - sometimes the State appears before the City) Is there a way I can order the resulting array by the custom taxonomy hierarchy? Is there, perhaps, another way I should be looking at this?
Just a rough sketch to get your idea: * countries (hierarchical taxonomy) * * France (country - sub taxonomy) * * * Champagne (state - sub sub taxonomy) * * * * Le Mans (city - term) * * * * Angers (city - term) * * * * Nantes (city - term) And you want to order: $query_results = query( 'country' => 'france', 'orderby' => 'state city', 'order' => 'ASC' ); Did i get this right? If not, feel free to edit my answer or update your Q.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 3, "tags": "custom taxonomy, terms" }
Possible to filter the posts or categories that XML-RPC users see in their mobile application? Is it possible to filter the posts or categories that XML-RPC users see in their mobile application? I have a plugin that hooks into `pre_get_posts` and `list_terms_exclusions` to do what I need it to do. I've had requests to allow the same functionality on their mobile devices.
Okay, so I discovered the answer to my question. It is possible to filter the posts and categories that users see in their XML-RPC application. The `pre_get_posts` and `list_terms_exclusions` filters are called via the blogger.getRecentPosts XML-RPC method. Inside this function, it calls `wp_get_recent_posts` which uses `get_posts`. In other words, there's really nothing special you have to do if you are hooking into the above filters. My problem was that for my plugin, I was only filtering while in the admin: `if ( is_admin()` **SOLUTION** In order to make sure it only fires when requested through an XML-RPC application, all you have to do is check for the XMLRPC_REQUEST constant and hook into the `xmlrpc_call` action. if ( defined ( 'XMLRPC_REQUEST' ) && XMLRPC_REQUEST ) { add_action( 'xmlrpc_call', array( &$this, 'posts' ) ); } Inside your callback, hook into the `pre_get_posts` and `list_terms_exclusions` filters.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 1, "tags": "filters, query, mobile, xml rpc" }
How can I to add upload functionality outside of the admin area? I am looking into updating this template (< which allows logged in subscribers to post (questions). I would like to add an option to upload a file and attach it to the post. I was thinking of using the media-upload functionality, but I do not want to give users full access to the media library. How could this be achieved?
You won't find much on the Codex or the net about this. Media can seem like a pretty dark art, but everything you're looking for is in /wp-admin/includes/media.php. The function you're looking for is `media_handle_sideload()`. You'll have to pass it a `$file_array`, which you'll have to read up on. Basically you just make sure your file information is all up to snuff, pass it into this function and it creates something that acts a lot like a regular post and can be manipulated via the media tools and custom post queries with `post_type=attachment` argument.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "posts, uploads" }
Display list of posts with x tag within a page? What codex/query would I use to call a list of pages with a specific tag from within another page?
Probabbly the easest way to do it is use: Kalin's Post List > Creates a shortcode or PHP snippet for inserting dynamic, highly customizable lists of posts or pages such as related posts or table of contents into your post content or theme. so you can either use a shortcode or edit your theme file.
stackexchange-wordpress
{ "answer_score": 1, "question_score": -1, "tags": "pages, tags" }
Getting Path To Uploaded Attachment Image After Upload After you have uploaded an attachment in Wordpress using the media upload screen, is there a hook or filter I can run after the image has been uploaded where I can get the path to the uploaded image so I can analyse it? I am building a plugin that will analyse an image after it has been uploaded and then tag the image with the average colour it finds in the image. The only problem is I don't know what hook I can use that will fire right after the image has uploaded and then a way I can get the path to the newly uploaded file. Any help would be gratefully appreciated.
Turns out I solved my own question with help from a colleague. The two filters that get called after media is uploaded or when media is being edited are; 'add_attachment' and 'edit_attachment'. Here is the code I am using, I then check to see if the attachment is an image (code omitted from example). function analyse_attachment($attachment_ID) { $attachment = get_attached_file($attachment_ID); // Gets path to attachment update_post_meta($attachment_ID, "image_rgb", $the_colour); } add_action("add_attachment", 'analyse_attachment'); add_action("edit_attachment", 'analyse_attachment'); Obviously I've omitted some stuff that isn't relevant to the question. But that code gets called right after you've uploaded or edited an attachment.
stackexchange-wordpress
{ "answer_score": 9, "question_score": 9, "tags": "plugins, plugin development, attachments" }
Conditional tag affecting taxonomy term and its children? I am wondering how can I write a conditional tag that affects a custom taxonomy slug and its children? Found this in Wordpress Codex: is_tax( 'flavor', 'mild') > When the archive page for the flavor taxonomy with the slug of 'mild' is being displayed. However with this code only 'mild' slug archive page is affected and not it's children taxonomy terms. Thanks!
I have a handy little function that i based on post_is_in_descendant_category function it expends the is_tax to check if its the term or any of his children function is_or_descendant_tax( $terms,$taxonomy){ if (is_tax($taxonomy, $terms)){ return true; } foreach ( (array) $terms as $term ) { // get_term_children() accepts integer ID only $descendants = get_term_children( (int) $term, $taxonomy); if ( $descendants && is_tax($taxonomy, $descendants) ) return true; } return false; } and you use it just the same so instead of: `is_tax('flavor', 'mild');` you put: `is_or_descendant_tax(get_term_by( 'name', 'mild', 'flavor' ), 'flavor');` or if you are using term id instead of name then: `is_or_descendant_tax(12, 'flavor');` and you are set.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 2, "tags": "taxonomy, conditional content" }
Does WordPress's HTTP API use any caching? I'm working on a plugin to will retrieve data from a remote server and display it on the Dashboard. To do this, I'll be using the WordPress HTTP API but I'm not seeing any information on the HTTP API using any form of caching. As I don't want my plugin to cause problems for the admins of the remote server, I was wondering if I missed some documentation about the HTTP API doing caching or if I'll also need to use the Transients API to implement caching for my plugin?
It does not. Some functionality actively uses HTTP API and is cached - feed fetching, updates checking. But caching is always implemented at wrapper's level. Making HTTP request without context is too unspecific to make educated guess about caching needs (one minute or one hour).
stackexchange-wordpress
{ "answer_score": 3, "question_score": 1, "tags": "plugin development, cache, api, http api" }
How to fix 404 page error on theme I am using the MidMo Clean theme and for some reason the 404 error page isn't working. Parse error: syntax error, unexpected T_STRING in /home/wpversec/public_html/UXJobsLA.com/wp-content/themes/clean-home/404.php on line 14 < Short of me disabling all my plugins and re-installing a out of the box version of the theme, anyone have any ideas please? Thanks!
So I think you're problem is the quotes in the href inside your function. Try escaping them like this and it should be fixed. <p><?php _e("Sorry but, you are looking for something that isn't here. <br /><br /> Looking for more web developer jobs, please visit our sister site: <a href=\" 'cleanhome') ;?></p>
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "404 error" }
removing wordpress generated code from the head section? Specifically, I'm talking about the following which gets added automatically: 1) `<script type='text/javascript' src=' 2) `<script type="text/javascript"> //<![CDATA[ var _wpcf7 = { cached: 1 }; //]]> </script>` 3) `<link rel="stylesheet" href=" type="text/css" media="screen" />` 4) <style type='text/css'> #wpadminbar .quicklinks li#wp-admin-bar-stats {height:28px} #wpadminbar .quicklinks li#wp-admin-bar-stats a {height:28px;padding:0} #wpadminbar .quicklinks li#wp-admin-bar-stats a img {padding:4px 11px} </style> Not sure about #1, I know #2 is generated by the Contact Form 7 plugin, #3 is Disqus, and #4 is from the new admin bar in 3.1 and although I added `show_admin_bar( false );` to my functions file, the styles still show up in my head section. Anyway to get rid of all or at least some of these?
1) Normally not (that's the translation mechanism offered for javscript strings), but you can probably de-register that l10n script. But be warned that some plugins and the site might not work as intended any longer. 2) Yes, by uninstalling the contact form 7 plugin. 3) Yes, by removing the disqus plugin. 4) If disabling the admin bar did not work, please report this as a bug in wordpress trac. I assume it left's over a registered hook to be removed, but that's just an assumption.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 1, "tags": "wp head" }
Disable WYSIWYG editor only when creating a page I read several articles about configuring the WordPress editor. For example, this snippet shows how to permanently set the editor to HTML or WYSIWYG _for all contents_. I'm wondering if it's possible to disable the WYSIWYG only when the user is creating a page, leaving it enabled for any other WordPress content type.
The best way to do this is by adding 'user_can_richedit' filter, like so: add_filter( 'user_can_richedit', 'patrick_user_can_richedit'); function patrick_user_can_richedit($c) { global $post_type; if ('page' == $post_type) return false; return $c; } Hope it's useful ;)
stackexchange-wordpress
{ "answer_score": 11, "question_score": 6, "tags": "editor, visual editor" }
Get the Current Page Number In a situation where one has 20 posts per page. I would like to get the current page number in order to make some nice page links at the bottom. How do you get the current page. I tried this <?php echo '(Page '.$page.' of '.$numpages.')'; ?> and it just says page 1 of 1 on every page. Any ideas, Marvellous
When WordPress is using pagination like this, there's a query variable `$paged` that it keys on. So page 1 is `$paged=1` and page 15 is `$paged=15`. You can get the value of this variable with the following code: $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; Getting the total number of pages is a bit trickier. First you have to count all the posts in the database. Then filter by which posts are published (versus which are drafts, scheduled, trash, etc.). _Then_ you have to divide this count by the number of posts you expect to appear on each page: $total_post_count = wp_count_posts(); $published_post_count = $total_post_count->publish; $total_pages = ceil( $published_post_count / $posts_per_page ); I haven't tested this yet, but you might need to fetch `$posts_per_page` the same way you fetched `$paged` (using `get_query_var()`).
stackexchange-wordpress
{ "answer_score": 36, "question_score": 23, "tags": "posts, pages" }
File available but giving 404 in wordpress Hey, im not sure why but php files other then wordpress either redirects to homepage or gives a 404. for example i have a timthumb.php in directory /js/ it was working fine and generating thumnails for me.. but it started to give 404 on even running the direct url. You can take a look here : www.designzzz.com/js/ you will see timthumb.php available, but on clicking or running that file it gives 404 :( . Help is appreciated :) cheers Ayaz
Check the permissions on the JS folder against the folders for the rest of the site.
stackexchange-wordpress
{ "answer_score": 4, "question_score": 1, "tags": "errors, redirect, customization" }
Programmatically get images by URL and save in uploads folder I am involved in a large migration from another CMS to WordPress. We have a copy of the database and have worked out how to extract the content and programmatically create WordPress posts from it using an instantiation of the `wpdb` class. However, there are a couple of thousand images which we would like to pull across automatically, generate the various sizes, and then attach to the posts, to save about a week's work! Is there a way I can get an image from a remote site by URL and save it in my wp-uploads folder? I guess this uses `wp_http` but I'm unfamiliar with that. Once I've got the image and saved it I'm ok as I can then use `wp_generate_attachment_metadata` to create the various sizes and `wp_insert_attachment` to attach it to a post. Thanks Simon
There's actually a great function that will do all three of those things for you: media_sideload_image( $url, $post_id, $description ); The first argument is the remote url of the image you want to download. The second argument is the post id of the post to which you want to attach the image. The third argument is optional, but will be a description if included. I'd suggest finding a way to throttle the downloads so that you don't keep timing out, such as limiting the number of images it pulls in per load and setting the importer to refresh itself between downloads, or using AJAX to do them one at a time asynchronously.
stackexchange-wordpress
{ "answer_score": 32, "question_score": 16, "tags": "images, attachments, post thumbnails, urls, migration" }
On Install, which code sets the 'home' option? I'm just doing some wordpress development and wondered for a brand new install, which code within core is generating the first value that get's filled into the `home` option? I'm looking for the code in core, e.g. the filename and the line where this happens. Does someone remembers from mind?
When the installer runs it calls `wp_install()`, that in turn calls `populate_options()` defined in `wp-admin/includes/schema.php`, which runs the following.. if ( !__get_option('home') ) update_option('home', $guessurl); Prior to that `$guessurl` is defined by.. $guessurl = wp_guess_url(); The guess URL function is defined in `wp-includes/functions.php` and looks like this. function wp_guess_url() { if ( defined('WP_SITEURL') && '' != WP_SITEURL ) { $url = WP_SITEURL; } else { $schema = is_ssl() ? ' : ' $url = preg_replace('|/wp-admin/.*|i', '', $schema . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); } return rtrim($url, '/'); } * wp_install() < * populate_options() < * guess_url() < Hope that's the info you're looking for... :)
stackexchange-wordpress
{ "answer_score": 6, "question_score": 2, "tags": "customization, homepage, options, installation" }
Is there a limit to number of pages displayed for selection in custom menu? I recently started working with a client who has over 400 pages on their WP site (yes, pages, not posts). Their menu needs to be redone, so I decided to go the 'custom menus' route. However, not more than a third of the pages are available to select from the 'Pages' meta box on the Menus page. And 'search' does not seem to work (typing in the page title, even of pages that do show in the box, results in 'No results found' message. In short, some of the pages I need to add to the menu are not available for me to select. What's up with this? And how do I solve it? Also, if I select on-site pages as 'custom links', will WP still add classes to the links to indicate they are 'current page' or 'current page ancestor'?
Upgraded to 3.1 from 3.05 and both problems (inability to see all pages in 'pages' box, and inability to search) went away.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "menus" }
Multi-site: removing /blog from posts I'm deploying a multi-site network, using subfolders. I've found on the main site the permalinks for news posts can only be placed like so: /blog/%year%/%monthnum%/%postname%/ I understand that this prefix is needed to lessen the risk of conflict between the main site and sub-sites. Unfortunately this is a serious website, where the word 'blog' isn't really appropriate. Something like `/pressreleases` would be much more appropriate, and still avoid conflicts. I tried various of the 'tricks' people mention, such as editing the permalink structure from the network admin settings. I also tried using rewrite rules (both Apache and the Redirection plugin) without much luck. WordPress needs to believe the posts are at the location in the address bar, so rewriting results in a 404. I could redirect them back to `/blog`, but that still has the same problem. How can I change the permalinks?
Let see if I remember this correctly. 1. Go to < 2. Find `permalink_structure`. By default, the value should be `/blog/%year%/%monthnum%/%postname%/` 3. Change the value manually to whatever value you like. e.g `/pressreleases/%year%/%monthnum%/%postname%/` or just `/%year%/%monthnum%/%postname%/`. Then Save Changes. 4. Now visit < and **DON'T** click Save Changes. It should flush the rules. If you click Save Changes it will revert back to the default. LOL
stackexchange-wordpress
{ "answer_score": 3, "question_score": 1, "tags": "multisite, permalinks, posts" }
Chat support plugin? I've been looking for a chat support plugin for WP and I haven't been able to find one, does anyone know about one? Free or paid doesn't matter. Thanks in advance.
If you're looking for a "talk with a representative" type chat plugin I found that www.oggchat.com was a reasonable one, and they have a Wordpress plugin to go with it. It supports the rep chatting from either the Oggchat website or via Gtalk, so your rep could be anywhere at any time, with a smartphone and a Gtalk program. If it's a "users on the site can chat together", then Oggchat isn't what you're looking for.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "plugins, support" }
Is there a user-facing interface to edit an attachment's permalink? If you use the `[gallery]` tag at all you know that permalinks for image attachments end up like `blog.com/2011/03/18/post-permalink/attachment-permalink`. The URL extension from the post permalink appears to be based on the attachment's title on first save. To my knowledge, however, this permalink does not update when the image title is edited in the media tools. I cannot find a way to do edit attachment permalinks at all, actually. Is there a user-facing interface I'm missing that will let users edit an attachment's permalink?
This'll add a slug field to the edit attachment page, which'll allow you to independently change it when and how you choose to. Drop it into a plugin or your theme's `functions.php`; function wpse_12405_edit_attachment_name( $fields, $post ) { $fields['post_name'] = array( 'label' => __( 'Slug' ), 'value' => $post->post_name, ); return $fields; } add_filter( 'attachment_fields_to_edit', 'wpse_12405_edit_attachment_name', 10, 2 ); function wpse_12405_save_attachment_name( $attachment, $POST_data ) { if ( ! empty( $POST_data['post_name'] ) ) $attachment['post_name'] = $POST_data['post_name']; return $attachment; } add_filter( 'attachment_fields_to_save', 'wpse_12405_save_attachment_name', 10, 2);
stackexchange-wordpress
{ "answer_score": 13, "question_score": 4, "tags": "permalinks, media, media library" }
Template messed up on viewing posts Take a look at this post: < My images are broke and CSS links are broke. I know the problem is with the permalink, but why would it be broke? I have the same problem with the Twenty Ten theme and the new Twenty Ten Five theme.
Viewing your pagesource and clicking on your first style sheet link brings up this error: <html> <head> <title>Not Found</title> </head> <body> <h1>Apache server with mod_pagespeed</h1> OK <hr> NOT FOUND: wp-content/themes/richardshepherd-TwentyTenFive-a8f2860 /style.css.pagespeed.ce.pAcUzu9T3K.css </body> </html> So it looks like your (cached?) stylesheet isn't where you think it is or your apache module isn't configured correctly.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "themes, theme twenty ten" }
Does WP delete deprecated plugin/theme files on plugin/theme upgrade? Let's say theme 1.0 is installed with 30 files in it. Then two weeks later theme is upgraded to theme 2.0 which contains only 10 files. Do those older 20 files get automatically deleted after upgrade? What I wanted to do is to place a file inside the theme directory, trough which the user can customize the theme. This file would be created after the theme is installed trough the theme settings. But if WP does delete files that do not exist in the official theme package, then this file would be deleted as well...
Yes. Find a theme that support Child Theme. Create a child theme so that your modification doesn't get deleted if you update the parent theme.
stackexchange-wordpress
{ "answer_score": 3, "question_score": 0, "tags": "plugins, themes, upgrade" }
CSS - why does my sidebar drops to the bottom of the page? I spent almost an hour searching why my sidebar here: < Is dropping to the bottom of the page. Could you please advise on how to fix it? Thanks.
Your `#leftcontent` div is not closed out with a closing `</div>` tag after your loop. Edit your index.php, find the Loop, and look for the end of the loop (usually it looks like `endwhile; endif;`. Add a closing `</div>` tag immediately after that (but outside of the `<?php ... ?>` tags).
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "css" }
Modify WP-Admin login fields Hi is it possible to modify the login fields required to login into wp-admin? Say to use the email address instead of the username together with the password to gain access. How would I go about doing that? thanks
There are plugins which help to do this: With < people can use their email address instead of their username to log into you WordPress install. Using < you can have the WordPress login included in your design, and allow users to modify their account information without logging into the backend.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "wp admin, login" }
Custom taxonomy admin description Is it possible to add a short description to a custom taxonomy's admin area? For example, I've added a taxonomy that determines what kind of banners are displayed on a post's page. In the meta box for this taxonomy on the Edit/Add Post page I'd like to add a little blurb explaining how it works.
I don't know of any hooks to add or filter the metabox so you can either create your own metabox to replace the custom taxonomy metabox or in this case just use JQuery `.append()` for example is your taxonomy is named banners and its none - hierarchical (like tags) then: $('.tagsdiv-banners').append('<p>your short description here</p>'); and if its hierarchical (like categories) $('.bannersdiv').append('<p>your short description here</p>'); the only difference is the name of the selector , for none hierarchical taxonomies you use tagsdiv-{$tax_name} and for hierarchical taxonomies you use {$tax_name}div.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "admin, taxonomy, customization, forms" }
How to automatically share posts on facebook? Basically, I would like to know how to make a post appear on facebook (like when you press a facebook share button.) the right instant you click 'Publish'?
There are several plugins you can use. One of such plugin is Wordbook.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "posts, facebook" }
Does the switch_theme action run when you're upgrading a theme? Did anyone test if this action is being executed on theme upgrade? Are there any other actions I could use to attach a theme uninstall function?
My educated guess is that process is implemented in Theme_Upgrader class. It does some stuff with `upgrader_post_install` hook (seems like a good candidate) and it does run `switch_theme()` under some conditions (that I am too lazy to make sense of at moment).
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "theme development, actions" }
Hosting plugin with excanvas (dependency of flot, jqPlot and more) in official repository? Considering using flot for graphs in plugin and a little lost with dependencies and licensing here. 1. WordPress repository demands GPLv2-compatible. 2. flot is under MIT license, which is GPL-compatible. 3. flot uses excanvas (for IE compatibility) under Apache License 2.0 which is compatible to GPLv3, but not v2. So is or is not flot compatible to repository? Aside - I had started wiki-style question if you want to suggest and discuss alternative libraries Graphing libraries for WordPress
As of May 2012 plugin repo rules have been updated, allowing Apache License 2.0 and some other previously incompatible licenses: > The plugin directory’s licensing guidelines have been updated. The guidelines will now allow code that is licensed under (or compatible with) version 3 of the GPL. > > The guidelines still encourage use of “GPLv2 or later,” the same license as WordPress. However, we understand that many open source libraries use other licenses that are nonetheless compatible, such as GPLv2 only, GPLv3, and Apache 2.0. > > Nacin
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "repository, licensing" }
Can't add a class to links in the visual editor since WP 3.1? Did this feature chang in 3.1? I recall that I could change the class of the link in the thickbox popup. !Link dialog in WP 3.0.5 !Link dialog in WP 3.1
The link window was completely redesigned in 3.1 to make it easier to link to other posts in your blog. The "title" and "class" attributes were removed from this window, probably because the UI team thought they were not used as often?
stackexchange-wordpress
{ "answer_score": 1, "question_score": 2, "tags": "links, tinymce" }
Which hook should be used to add an action containing a redirect? I want to build a plugin that grabs certain url params from the query string to build a new query string for the same page. I'm following the excellent the Professional WordPress Plugin Development book, but I'm not sure which hook to use for this action. Here is my action function: add_action( 'init', 'tccl_redirect' ); function tccl_redirect() { header ( "Location: ); ?> Which hooks are suitable for header redirects?
Like kaiser answered `template_redirect` hook is indeed appropriate for redirects. Also you should use `wp_redirect()` function, rather than setting header.
stackexchange-wordpress
{ "answer_score": 16, "question_score": 20, "tags": "plugin development, redirect, hooks, actions, init" }
Limiting Amount of Posts in a Custom Post Type again I've been trying to limit the amount of posts a user can create in a specific custom post type, and I had some help from Bainternet by checking out his plugin. I read over that and then came up with my own, but it doesn't seem to be working. I want to make my code much more lightweight than an entire new plugin so I am just adding it to mine, but what am I doing wrong here? The name of my custom post type will be lets say.. `newpages`. And we'll pretend `$custom = 'Developer';` has been placed before the function. function efpd_limit_posts(){ global $pagenow,$custom; if (is_admin() && $pagenow=='post-new.php?post_type=newpages'){ $theposts = get_posts(array('post_type'=>'newpages')); if (count($theposts) >= '1'){ wp_die('You have reached the maximum amount of 'newpages' you can create.'); } } } add_action('admin_head','efpd_limit_posts');
Your array phrasing is wrong, cange $count_posts = count(get_posts(array('author'=>$current_user->ID,'post_type','newpages'))); To $count_posts = count(get_posts(array('author'=>$current_user->ID,'post_type' => 'newpages')));
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "custom post types, plugin development" }
Where can I find a schema of wordpress plugin core architecture? There are plenty of articles which explain how to create a wordpress plugin. I'm not looking for that, I'm looking for a schema of the core architecture of a wordpress plugin (an UML class diagram and sequence for example). Has somebody seen anything like that somewhere ? Update: I know plugin can be as simple as a function. It's not my question. My question is about the architecture of the CALLER that calls the plugin, that is the architecture of the SYSTEM pertaining to the call of the plugin. At least in which PHP module(s) is it implemented by the Wordpress Core System files ?
There is not much to it, really. 1. During the loading of WordPress engine `wp-settings.php` file is processed. 2. Among other things this files calls `wp_get_active_and_valid_plugins()` function, that gets list of activated (through admin interface) plugins from `active_plugins` option (stored in database). 3. For each active plugin its main file (the one holding plugin header) is `include`d and from there it is up to plugin how it uses Plugins API (more commonly known as hooks) to integrate with WordPress. Basically it is only a thin layer of active/inactive controls on top of straight PHP `include`.
stackexchange-wordpress
{ "answer_score": 7, "question_score": 5, "tags": "plugins, plugin development, settings api" }
Function to get content by ID I'm trying to get text only content of posts by ID. I modified this function as follows, but at the moment it returns nothing. I cannot see what's wrong with it. function get_the_excerpt_id($post_id) { $find = get_posts($post_id); $excerpt = $find->post_content; $excerpt = strip_tags($excerpt); $output = substr($excerpt, 0, 100); return $output; } Any ideas what's missing? Marvellous
Instead of using `get_posts`, which you would use if you wanted to retrieve multiple posts in a loop, you should use `get_post`, which only retrieves one post by an ID. There is also a built-in excerpt so you might want to go with retrieving `post_excerpt`. function get_the_excerpt_id($post_id) { $find = get_post($post_id); $excerpt = $find->post_excerpt; $excerpt = strip_tags($excerpt); $output = substr($excerpt, 0, 100); return $output; }
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "get posts, content, functions" }
Best Practice for re-using API Data in WordPress? I'm using an API which is accessed with ID/Secret, etc. and use it in different widgets. In each widget however, I'm repeating the entire JSON process (i.e. file_get_contents, decode, etc.). I can't help but think this must be slowing the entire process down. What would be the best way of going about only calling this API once and then grabbing various data from it in different widgets, theme components, etc.? Thank you! Noel
Use Transients API - < I would also suggest you to use WordPress HTTP API - < instead of `file_get_contents`
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "api" }
Custom rewrite rules for a $_GET request Assuming I have this URL: ` How can I change it to a nice URL that looks like: ` using WP's URL rewriting system?
First add get to query vars array: function add_query_vars_wpa12572($vars) { $vars[] = 'get' return $vars; } add_filter('query_vars', 'add_query_vars_wp12572'); then add the rewrite rule function author_rewrite_rules_wpa12572( $wp_rewrite ) { $newrules = array(); $new_rules['get_(\d*)$'] = 'index.php?get=$matches[1]'; $wp_rewrite->rules = $new_rules + $wp_rewrite->rules; } add_filter('generate_rewrite_rules','author_rewrite_rules_wpa12572');
stackexchange-wordpress
{ "answer_score": 1, "question_score": 2, "tags": "permalinks, url rewriting" }
Get post ID outside of the loop I am trying to accomplish something somewhat simple I think. I have a menu item at the top of my page that I want to link to the latest post in a certain category. I just need to get the post ID of the latest post in the category so I can pass it to the menu. I want to do this outside of the loop and create a function in functions.php that will return the post ID. Does anyone have any suggestions on how to do this?
here is a function that does just that: function get_lastest_post_of_category($cat){ $args = array( 'posts_per_page' => 1, 'order'=> 'DESC', 'orderby' => 'date', 'category__in' => (array)$cat); $post_is = get_posts( $args ); return $post_is[0]->ID; } Usage: say my category id is 22 then: $last_post_ID = get_lastest_post_of_category(22); you can also pass an array of categories to this function.
stackexchange-wordpress
{ "answer_score": 4, "question_score": 1, "tags": "posts" }
Add popup window to TinyMCE buttons I'm looking for a good tutorial on how to create a popup window with a TinyMce button that would allow the user to select from multiple options, enter text into inputs, etc. I know how to create a button that displays a single prompt window, but that's about it and I've been searching for hours. Anyone know some links? Thanks!
Here is a nice and a fairly new (a year old) tutorial that i've read a few days ago: < He has a great example and you can also download the source files and get a better understanding.
stackexchange-wordpress
{ "answer_score": 9, "question_score": 11, "tags": "tinymce, visual editor, buttons" }
Creating Pages that show specific blog categories How do you: 1) create a page and select "Blog Template" and also choose which category for the Blog's you want. 2) Then create a blog post and choose the category for that page....resulting in a page that shows all the blog posts for that category? Thanks!
Sounds like you are looking for the functionality of WordPress 3.0 Menus Subpanel. In Dashboard go to 'Appearance' then 'Menus' and you can create a page that will show the posts from a specified category.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 2, "tags": "categories" }
WordPress Plugin: Where should I put my cookies for cURL? Currently creating a plugin with cURL and I need a place that will work for most WordPress servers (Unix or Windows) to store my cookie file. Anyone have a suggestion or best practices? I've been googling for a while now and I think I found something about wp_temp_dir, but googling that keyword gives me only a thousand and one results about solving some install error.
Transients seem to be appropriate storage. Just note that if you will generate a lot of this and they will be disposable then you will need to cleanup old transients. As for your cURL/filename issue - it is bad practice to use cURL directly in WordPress. WP provides HTTP API that abstracts remote requests. Unfortunately it is bit poorly documented. As far as I understand you pass cookies in arguments array with `cookies` key to its functions.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "plugins, cookies, curl" }
Faulty restore of the database, encoding issue I messed up the settings with W3 Total Cache (tried to import all the media to my library, didn't work out well, broke all my links to every picture). So I took my latest backup of the database, copy/paste the _post and _postmeta tables inside my phpmyadmin. It brought back the links and pictures as expected, but now all the french characters (à,é,è etc) are not displayed properly. I took the backup from the plugin WP-DBManager, which doesn't seem to handle UTF-8 properly. What's the fastest way to correct the issue ? Thanks Edited for more details: The SQL backup header is DROP TABLE IF EXISTS `hojd_posts`; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; However I have those characters badly encoded coming directly in my sql commands (eg: français for "français")...
You might be able to solve this if you have a text editor with good encoding support. That way, you could switch between the Latin 1 and the UTF-8 encoding until you have the right combination. I use SubEthaEdit which can convert but also reinterpret a file when you change the encoding. The `ç` should be encoded as `c3 a7` in UTF-8 when you view them as bytes. What could be happening here is that the file was interpreted as Latin 1 first, where `c3 a7` means `ç`, and then saved as UTF-8, where `ç` is saved as `c3 83 c2 a7`. You want the `c3 a7` version. The way to get back to a nice `ç` is to open the file as UTF-8, save it as Latin-1, and then open it again as if it was UTF-8. Once you did this, you can import the file into MySQL, but specify it is UTF-8, otherwise MySQL might try to interpret it as Latin 1 and you will still have the `ç` characters.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 2, "tags": "database, backup, encoding" }
How do you modify CSS files via admin panel? All theme styles are in style.css file. Let's say first line looks like: body { background-color: #fff; } Now, I've created an option in admin panel named body_bg. User types #000 there and I want the value in style.css to change. How do I achieve that? The easiest way to me looks like I have to rename style.css to .php, and just do: <?php header("Content-type: text/css"); ?> body { background-color: <?php echo get_option('body_bg');?> ; } And then just link style.php in empty style.css file. It's perfectly valid and works, but I've never seen a theme with style.php file, so how do people modify their stylesheets dynamically?
If you're wanting styles to be dynamic, then you'll have to emit your CSS file as you are suggesting. However, as WordPress often uses styles.css as a theme definition file, renaming styles.php _might_ cause problems. It might be better to collect all the 'dynamic' definitions into a separate file (eg dynamic-styles.php) and import them from your main style.css file via `@import(url)`,
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "wp admin, admin, css" }
How customizable is a self-hosted WordPress blog compared to a Blogger blog? I currently have a **Blogspot** blog and I'm thinking of making the leap to a _self-hosted_ **WordPress** one instead. Everything I've seems to suggest this is the best way to go for the best possible experience, but main concern is customizability. I've messed around with a few Blogspot blogs and I know that you're given pretty much full access in terms of changing the look of your blog. I can get in there pretty "deep" and do whatever I like. When I've read about WordPress, though, a lot of people complain about the lack of customization. Is this true? Are they getting confused with the non-self-hosted version? Just how much visual customization will I get in a _self-hosted_ WP blog? I'd really like to know that I have full control over how things look before I take the plunge! Thanks a for any help.
The front-end customization options in self-hosted WordPress are absolute. You can edit whatever you want in PHP/HTML templates and CSS style sheets. While WordPress comes with single theme ("Twenty Ten" at moment) the availability of third party free and paid themes for it is **huge**. See: * Where can I download WordPress themes from? for good list of sources for ready-made themes; * WordPress frameworks and parent themes if you are more into developing or deeply customizing one yourself.
stackexchange-wordpress
{ "answer_score": 1, "question_score": -2, "tags": "theme development, css, customization, templates, comparison" }
Enable page templates. How? Basic question, but I want to enable page templates. I have one theme which has page templates enabled. I switched to another but there is no option to change the template, even when creating a new page. How do I switch this option on? I've had a root around on the Codex and forum but can't find it.
Chances are that the theme you've switched to has no page templates defined - they exist on a per theme basis. Here's the Codex reference: <
stackexchange-wordpress
{ "answer_score": 9, "question_score": 12, "tags": "templates, options" }
WordPress hosting optimized servers - Is this just a sales gimmick? I have always hosted my own websites on my own hardware, this includes WordPress. I always see on shared hosting sites "WordPress Hosting" which looks to be the exact same as their regular hosting plan. Am I missing something, or is there a difference, and how can I optimize my servers for WordPress?
Of course you can optimize your servers like the hosting companies do, it just depends on how much skill you have and how much effort you want to take on. Here's a community wiki that might give you an idea of what to consider doing: * **Best-of-Breed Features of a High-End WordPress Web Host?** One thing that comes to mind as a great feature is to **use nginx as a caching proxy server**.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "server, hosting, optimization, shared hosting" }
Is it possible to split database tables using HyperDB? I'm looking for an answer from someone who's implemented HyperDB or has knowledge of it. I have a database which has just passed the 100mb mark a week or so ago, the problem is my host only allows databases of 100mb a time. I was looking to implement HyperDB but wanted to find out some information first. My current database is around 100mb alone on the posts table of the database. If I implement HyperDB will this table get split between two databases?
HyperDB lets you split whole tables across different databases but it won't split a single table. You wouldn't want that anyway because that means wordpress would have to query multiple databases to find a single post. However, depending on how your site is set up, you might be able to work around that by creating a multisite wordpress install using subdirectories. That means splitting your site up into subdirectories that are actually separate wordpress installs. Then you can use hyperdb to distribute those tables. Or an easier thing to do is find a web host that doesn't limit your database size :)
stackexchange-wordpress
{ "answer_score": 3, "question_score": 1, "tags": "database, mysql, hyperdb" }
Custom Permalink: /year/month/post-goes-here/? I'm experimenting with adjusting permalinks (for purely educational experimentation). What would I need to place in the "Custom Permalink" option to get my post URLs in the form... /year/month/post-title-goes-here/
`/%year%/%monthnum%/%postname%/`
stackexchange-wordpress
{ "answer_score": 5, "question_score": 3, "tags": "permalinks" }
Any guides on using WP SVN with IDE clients? The documentation for dealing with official WP repository is exclusively about using command line. While I have no bias against that, I do have little experience with VCS and two (or three) different ones I will have to figure out and use in nearest future. So for now I wing it with VCS integration features in IDEs (NetBeans, PHPStorm). Which often leaves me confused on specifics and ways of doing things properly. Are there any good articles/posts/guides on using official SVN repository (or at least SVN in general) with IDEs or other GUI-based tools? Something that focuses on concepts and workflow, rather than typing in arcane lines in console.
I don't use (widely recommended) TortoiseSVN at moment, but turns out it has very extensive manual, available online and for download in multiple languages. In its own words: > This book is written for computer literate folk who want to use Subversion to manage their data, but are uncomfortable using the command line client to do so. ( Preface ) > > This document describes day to day usage of the TortoiseSVN client. It is not an introduction to version control systems, and not an introduction to Subversion (SVN). It is more like a place you may turn to when you know approximately what you want to do, but don't quite remember how to do it. ( Chapter 4. Daily Use Guide ) Pretty much what I was looking for, reading it now.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 8, "tags": "svn, ide" }
Display only one result from "get_the_category_list" I'd like `get_the_category_list` to only display one or two categories instead of **all** the categories associated with the post. Haven't been able to find any results. <?php echo get_the_category_list(); ?> Any help would be appreciated
$categories = get_the_category(); if ( ! empty( $categories ) ) { echo '<a href="' . esc_url( get_category_link( $categories[0]->term_id ) ) . '">' . esc_html( $categories[0]->name ) . '</a>'; }
stackexchange-wordpress
{ "answer_score": 1, "question_score": 2, "tags": "categories, list" }
Experiences with compiling WordPress using Hip Hop? What are you experiences compiling Wordpress using Hip Hop? ( > < ) Specific: * is this maintainable with upgrades? * is the performance increase bigger than using alternatives? update: also interesting: <
Original approach of static compilation in HipHop PHP-to-C++ has been since replaced by HipHop VM just-in-time compilation. Facebook prominently featured WordPress as example application and it no longer requires extensive (barely any by now) core edits. * * * **Old answer** There is quite extensive presentation Rasmus Lerdorf - PHP Performance that uses WP as test subject and covers HipHop among many other things. The summary I can formulate from that presenation is that HipHop: * requires WP core edits * has limited PHP and libraries compatibility * provides (on vanilla WP install at least) very mild performance gain for the effort it takes to implement. In that presentation compiling with HipHop bumped WP from 28.8 transactions per second to 33.6. I think more common performance improving alternatives (like reverse proxy) can easily outperform that without such downsides.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 5, "tags": "php, facebook" }
What params are available with the_content filter? I am looking for what params are passed to my filter function. Where can I find such info in the codex? < didn't provide much info I wanted to know if the post is a child of another
I don't think there are any additional parameters passed, per se, to `the_content`, but global variables like **$post** are accessible. So something like this would work: add_filter( 'the_content', 'check_for_post_parent' ); function check_for_post_parent($content) { global $post; if ($parent_id == $post->post_parent) { //do what you want to $content here, //now that you know $parent_id //... } return $content; }
stackexchange-wordpress
{ "answer_score": 6, "question_score": 3, "tags": "filters, the content" }
Category articles "read more" links not active If I click on a category in my Wordpress blog, it displays an excerpt of all articles in the category, and finishes with a word that says "continue" which has no hyperlink. Example here. How do I fix this?
Open the theme index.php (or other theme template file) and look for something like this: <div id="more_reading"> ... </div> replace with: <?php if ( $wp_query->max_num_pages > 1 ) : ?> <div id="more_reading"> ... </div> <?php endif; ?> or just remove "Continue"
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "categories, read more" }
Deactivate plugin on registration I'd like to check if the server is running PHP5.2. To do this, I use a activation-hook which will be registered with "register_activation_hook". Instead of just returning a warning, i'd like to auto-disable the plugin and redirect to the plugins.php in WP-Dashboard. Unfortunately, this doesn't work. No error or other output. The activation-hook fires correclty, tested with a wp_die(). What I'm doing wrong here? register_activation_hook(__FILE__, 'MyActivationHook'); function MyActivationHook() { if(version_compare(PHP_VERSION, '111.2', '<')) { deactivate_plugins(plugin_basename(__FILE__)); wp_redirect(admin_url('plugins.php')); //wp_die(printf(__('Sorry, you need at least PHP version %1s to use this plugin. Your current PHP version is %2s.', 'textdomain'), '5.2', PHP_VERSION)); } }
You always have to `exit;` after a redirect.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "plugin development, comparison, activation" }
How to make search engine index PDF files? I'm looking for a plugin or a idea so that my WP 3.1 search engine can index PDF files. Has anyone be through that need too ? Thanks !
The standard WordPress search is pretty basic and only search the database, there are some plugins that extend the search functionality to search even more parts of the database like: * Search Everything * Search Unleashed but they do not have the ability to search files. There is one plugin that i know of that claims to support indexing PDF and DOC files * Sphider for WordPress which is a bit outdated and i have tried before so you might want to check it out. But **the best solution** I have used for this kind of "Job" is **Google custom search** that searchs PDFs and DOCs and is fairly easy to set up.
stackexchange-wordpress
{ "answer_score": 7, "question_score": 5, "tags": "plugins, search" }
Plugin or theme that sort posts as 'top this year' and 'top last month"? Is there any free WordPress plugin or theme that sort posts as 'top this year' and 'top last month" or 'top 24 hours' based on voting? I'm using the Vote It Up plugin right now. But it doesn't have the capability of sorting post as a loop. Any suggestions?
Try GD Star Rating - I'm pretty sure it stores vote times and so can be used to do this - you'll probably need to extract the ordering yourself though. <
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "plugin recommendation" }
WPML: getting page title in different language i'm running my web in english and german using the WPML plugin. my question: when in english mode - is it possible getting the page_title() but in german? thanks
Let's say the original language of your site is english, then when visiting a german post you would return the title of the corresponding english post like that : // Get the post ID of original post $original_ID = icl_object_id( $post->ID, 'post', false, 'en' ); // Get original post title $original_title = get_the_title( $original_ID ); Hope that helps, in any case check out the documentation for icl_object_id();
stackexchange-wordpress
{ "answer_score": 4, "question_score": 5, "tags": "multi language, plugin wpml" }
Random and Erroneous Wordpress Redirect Would somebody mind postulating and possible reasons why their is an automated redirect on my homepage that adds /admin to the URL. Please visit www.divethegap.com/update. You will see that it instantly redirects to /admin and does not load the page. There is a folder called admin that is not accessible to a user, but their is no redirect to it anywhere on the site. What is going on. I have removed all recent function additions in the theme and unistalled plugins. There are several include-template-paths that I use but I don't use any redirects. What has caused this. Any ideas? Marvellous HT ACCESS // # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /update/ RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /update/index.php [L] </IfModule> # END WordPress
By a process of elimination we have determined that the error was caused by the plugin REDIRECTION. This plugin has now been removed. I must point out that it was never used and certainly never set up to carry out that action. I can only imagine that somehow the creation of themed files must have had similar names to the plugins files. After checking the plugin file names that is also not the case. This remains a mystery. It was only through trial and error that we determined that it was this plugin causing the problem. If anyone has any theories I would like to hear them. Case closed
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "redirect, homepage" }
How to hide "Comments are disabled" is it possible to hide the string: "Comments are disabled" from everywhere? I mean also from posts list, and post page :) Thanks :) EDIT: sorry, the theme is Journal Cruch by Site5.com However I resolved using if (comments_open()) comments_popup_link(); where the comments are displayed, but I don't like too much this solution :)
Popup link takes five parameters. comments_popup_link('No Comments','One Comment','Many Comments','CSSclass','Comments Disabled'); So you are on to the correct solution. Now just change the above strings to whatever you want them to be for each # of comments. Finally change 'Comments Disabled' to just `''`. Or perhaps `'&nbsp;'` if it requires you to put something in there.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 2, "tags": "comments" }