INSTRUCTION
stringlengths
11
999
RESPONSE
stringlengths
0
999
SOURCE
stringlengths
16
38
METADATA
dict
How do you check if a WordPress template file exist? Is there a native function to check if a theme a template file. For instance, if a theme is not using the 'home.php' file, then execute some code...
So I would add to the Answer the following: function foo_function() { $located = locate_template( 'home.php' ); if ( !empty( $located ) ) { // 'home.php' found in Theme, do something } } add_action('init', 'foo_function'); // remember to change both of the parameters above, first one for where you want the // action to happen and the second one the name of the function declared As @Chip Bennett, said it will check both `TEMPLATEPATH` and `STYLESHEETPATH`, but I would append the code to a hook instead of just putting it in the `functions.php` file. But's up to you.
stackexchange-wordpress
{ "answer_score": 11, "question_score": 4, "tags": "templates" }
Featured image for links and categories Is there a ready plugin or solution for implementing Featured Image function to Categories and Links? At Pages and Posts I use the feature image as a background image, using the full size original image, and I'd like to achieve the same, meaning I'd like to have featured full size image for categories. With Links, I'd like to attach an upload image to them, probably with auto-resize ability with different size to the default media size. Are there solutions already done to achieve these? Thanks, cadeyrn
Finally, I managed to use two plugins: Link Image Gallery and Category Meta plugin although I had to tweak one of them. They both use the media gallery to select picture, but if both very active, Link Image Gallery disabled the return function of Category Meta plugin, so I added a check in Link Image Gallery's main function: "if (strsrt($_SERVER['PHP_SELF'],'links.php'))", and now they both work.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "categories, links, media library, post thumbnails" }
WP HTTP Error: couldn't connect to host for RSS feeds on same domain I'm having trouble reading RSS feeds created by WP3 on the same domain. When I do a print_r($rss); at the part of my plugin where it does the RSS parsing, I get the following output: WP_Error Object ( [errors] => Array ( [simplepie-error] => Array ( [0] => WP HTTP Error: couldn't connect to host ) ) [error_data] => Array ( ) ) The RSS feed address being supplied validates and everything, btw. It seems to me the issue has something to do with the webserver being unable to grab its own RSS feeds. This is all very confusing. There's a blog post that seems to identify the issue at: < ...Alas, it does not contain any solutions. Any ideas for a workaround would be much appreciated.
Anyone with a similar issue: First off, try the following after connecting to your webhost via SSH: `ping <yourwebsite>` If you get a "cannot connect to host" issue, there's a firewall or NAT problem blocking traffic for RSS. Contact your server admin.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "rss, simplepie" }
Classes and functions involved in serialization and unserialization I want to know all the classes and functions(individual .php files) in a wordpress installation that handle serialization and unserialization.
WordPress uses `maybe_serialize()` and `maybe_unserialize()`. Both of them use PHP's native `serialize()` and `unserialize()` functions. See: < < Both of those functions make use of the function `is_serialized()`, which checks if the variable is serialized yet. See: <
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "options" }
Showing RSS feed via fetch_feed. How to show the site title of the feed? Question is simple. Can i get the title and main url of the site from where the posts are loading? Actually i want to linked to the main site. The url can be found by wordpress function esc_url(); function but what about site title? The page is here: < Thanks!
$feed = fetch_feed($feedurl); $channel = $feed->channel; $blog_title = $channel["title"]; Note - I haven't tested this, am relying on my (faulty) memory.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "rss, title, feed" }
Plugins not showing in dashboard->plugins section About 60% of plugins that I install don't show up in my plugins section. When I install them it says they're installed, and when I click "activate plugin" it says theres no valid header for the plugin. Navigating to the main plugin section in the dashboard the plugin doesn't show up at all, so I can't activate it from the main plugin page either. What's wrong here. I'm not using the multi-site wordpress, just a standard wordpress installation with buddypress on top. Thanks Tom
Download the plugin as a zip, extract and manually upload the folder that immediately parents all the .php files (i.e not a folder that has another folder as its child) into you plugin folder. Sometimes dev's can zip things within an extra folder, which confuses wordpress.
stackexchange-wordpress
{ "answer_score": 6, "question_score": 6, "tags": "plugins" }
How to build a PDF repository in WordPress I'm seeking advice on the best way to construct a PDF repository. Basically, there will be an uploader in the administrator section and in the front end. The user should be allowed to add tags to the files. So I guess I need: * Front-end uploader * Backend-uploader * Custom-post type? * Security to check the PDF files and not just upload anything. What else am I missing?
Right now, the support for tagging media is pretty disappointing. You can add tags or categories to the attachment post type, but you'll find the UI is unacceptably bad (it's a text box where you enter terms separated by commas). There's a plugin Media Tags that is decent though, so you might look into that. GravityForms is nice for front-end uploading, but make sure you're thinking through security if you have a front-end upload system. Alternatively, you might be able to create a special role that only has access to upload and manage their own media items. You can write your own custom role or use something like Members or User Role Editor to do that. Once you've setup all that, it's just a matter of building out some nice taxonomy and attachment archive pages.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "page template, pdf" }
Links to my uploads went crazy First things firs.... up until now (before I experimented with some plugins - many) my blog was behaving properly.... 1\. I write the post 2\. Import the media from my computer 3\. Insert the media into my post 4\. When I click on media link ... it fires up the pdf file (for example) Now when I do everything same from 1 to 3 and when I try to open up the pdf file, my blog leads me from post url (/?p=1491 in the url) first to attachemtn URL (/?attachment_id=1927) which is WRONG. On that page there is a link to the pdf file. How can I bypas this extra step and go directly to pdf? |help|please|
In the Add Media window, click the "File URL" button, not "Post URL" before inserting it into the post.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "attachments" }
More than one WordPress site using the same database - how to disable plugin for one site? I am going to have two WordPress websites running off the same database, so that they both have the same products set (each post is a product) but they have different homepages, about us pages, etc. thanks to the themes of each site. (Note: NOT using MU). But there is once concern: `<title>` and `<meta>` tags on the site. I want the mini-site to have completely separate tags, as it has a different identity. So I will use custom fields in the posts to set the tags for each domain but herein lies the problem: I already have an SEO plugin installed and loads of custom tags, so how do I disable that plugin for the new site _only_? I assume that if I just omit the files for that plugin on one of the installs then WordPress will detect that it is not there, and disable it in the DB, so it will disable for both sites. Does anyone know the answer?
Hm... In more pure sense of the question I suppose you could filter `active_plugins` option on retrieval via `option_active_plugins` filter and throw plugin out for one of the sites. But I won't try to predict what this can cause to active/inactive state in your situation. :) I think more practical solution would be to figure out functions and hooks that SEO plugin uses and unhook them. Hopefully plugin you use is coded decently enough for that to be possible without much trouble. One more idea - dump plugin in `mu-plugins` for one of the sites so it is forcefully active for it.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "plugins, database" }
How can I get the last posts by user role? I have a custom post type ("News"), and a custum user role ("Friends"). How can I get the last "News" written by "Friends" ?
I would try the following (not tested) <?php $friends = get_users( array( 'role' => 'friends' ) ); $friend_ids = array(); foreach( $friends as $friend ) $friend_ids[] = $friend->ID; $news = new WP_Query( array( 'author' => implode( ',', $friend_ids ), 'post_type' => 'news', 'paged' => get_query_var('paged') ) ); ?> Note: 'friends' is the role ID, not the nice name. Then use the loop as normal : <?php if ( $news->have_posts() ) : while ( $news->have_posts() ) : $news->the_post(); ?> ... <?php endwhile; endif; ?> <?php wp_reset_postdata(); ?> Hopefully that will work :)
stackexchange-wordpress
{ "answer_score": 4, "question_score": 0, "tags": "custom post types, users, user roles" }
Split a database will improve performance? Hi to all I'm running a Wordpress MS installation and I would like to move a couple of heavy "sub" blogs on a different DB, will it encrease my performances? Actually I'm on a dedicated server with quadcore 2.5 Ghz, 6GB ram and a few nice stuff like Lightspeed eaccelerator and so on. I'm a "self made webmaster" so I need an easy to follow guide that can teach me how to split safely my DB and improve my performance. Thank you very much for this! (just read: Split WP install between 2 databases? is this the only solution available or there is an easier one?)
WPMUdev has a Multi-DB plugin but you won't see any performance gains from splitting your database up unless you have a very high volume of sites with thousands of tables. From the plugin instructions: > Step 1: Decide how many databases you want (16, 256, 4096) > > So, how do you know that this plugin is necessary for your install? Well, there are several factors to consider beyond the scope of this walkthrough, but as a basic guideline: > > 1-5,000 blogs/sites you should be fine with your WordPress default database > > 5,000 - 50,000 blogs/sites - go with 16 databases > > 50,000 - 100,000 blogs/sites - use 256 databases > > 100,000+ blogs/sites - use 4096 databases
stackexchange-wordpress
{ "answer_score": 2, "question_score": 2, "tags": "multisite, database, mysql, split" }
Prevent users from adding taxonomy terms I'm trying to prevent people from adding terms to some, but not all of my taxonomies. There are four taxonomies in a certain post type. I need to prevent people from adding to two of those. I used jQuery to prevent people from adding them on the taxonomy page, but I'm having trouble with the new post/edit post page. I can't just hide the box, because I need them to be able to search and select from existing items. I don't know if jQuery will do the trick, because I'd like that input box to still be available for searching for existing terms. So, does anyone know if this is possible?
For these situations build your own metabox for the tax terms and use radio or select. My fork of Jared Atchison's Custom Meta Box class supports custom taxonomy metaboxes. After you get the metabox directory uploaded use this to create your meta box. $prefix = 'xxx_'; //Add your own unique prefix. $meta_boxes = array(); $meta_boxes[] = array( 'id' => 'test_metabox', 'title' => 'Test Metabox', 'pages' => array('page'), // post type 'context' => 'normal', 'priority' => 'high', 'show_names' => true, // Show field names on the left 'fields' => array( array( 'name' => 'Test Taxonomy Radio', 'desc' => 'Description Goes Here', 'id' => $prefix.'text_taxonomy_radio', 'taxonomy' => '', //Enter Taxonomy Slug 'type' => 'taxonomy-radio', ), ); require_once('metabox/init.php');
stackexchange-wordpress
{ "answer_score": 0, "question_score": 1, "tags": "custom taxonomy, jquery" }
Moving a blog from Tumblr to Wordpress I want to move all my content, posts and pics from Tumblr to Wordpress ..! What would be the best way to do this???
Try the Tumblr Importer. :) < Let me know if you have any problems with it, we're actively trying to improve it.
stackexchange-wordpress
{ "answer_score": 3, "question_score": 1, "tags": "import, tumblr" }
site_url is not honoring scheme I'm using site_url() for my href for anchors. I want to control what when I send the user to a secure page or non secure page. I thought I could do that with site_url('/foo', 'http') and site_url('/bar', 'https') but the scheme is not changing. If I'm on a secure page and site_url('/foo', 'http') is set, the clicked page is still secure instead of non-secure.
What is original link? var_dump( get_option('siteurl') ); If I am interpreting code right then for `http` protocol argument action is to **not change** the link. So if you have set up URL to be secure by default then function doesn't override that.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "functions, site url" }
Media upload - choose only one file It is possible to restrict the upload process to choose only one file. Now a person can select various files from pc, Im trying to find a way to restrict this feature just to one file. Thanks in advance.
WordPress contains 2 media up-loaders. The Flash uploader allows the selection of multiple files while the browser uploader only allows 1 file at a time. To disable the Flash uploader add the following filter to functions.php add_filter('flash_uploader', create_function('$flash', 'return false;')); ### EDIT ### After further investigation it's probably not a great idea to use create_function. A beter way to remove the filter would be: function disable_flash_uplaoder() { return $flash = false; } add_filter( 'flash_uploader', 'disable_flash_uploader', 7 );
stackexchange-wordpress
{ "answer_score": 1, "question_score": 2, "tags": "uploads" }
Add filter 'wpautop' to meta box textarea I'm using -this tutorial\- to add simple meta boxes to a custom post type. But the textarea meta boxes are spitting out content all as one big paragraph, with no `<p>` formatting applied. What code would add the -wpautop filter\- to the meta box textarea? Thanks for any help.
Add a function that grabs your meta data, applies wpautop and echoes it out, or otherwise run it through when you output it in your template. $my_meta = get_post_meta($post->ID,'_my_meta',TRUE); echo $my_meta['name']; echo wpautop( $my_meta['description'], 1 );
stackexchange-wordpress
{ "answer_score": 4, "question_score": 3, "tags": "metabox, wp autop" }
Prevent custom post type from showing up in custom menus How do I do that? Any custom post type I register shows up as a meta box on the menu page... !enter image description here
It's really simple, when registering the Custom Post Type use: register_post_type( 'post_type_name', array ( ... 'show_in_nav_menus' => FALSE ... ) );
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "custom post types, menus, metabox" }
How to do Domain Mapping to Subdirectories? Does Wordpress MU not allow domain mapping to subdirectories, such as example.com/blog? Wordpress.com doesn't allow this. I couldn't find an option to do this in WordPress MU Domain Mapping plugin.
Domain mapping works for both subdomains and subfolders (AKA subdirectories). It used to not be available for subfolder installs via the WordPress MU Domain Mapping plugin, but that's no longer the case for a long time. With that being said, it's for a self-hosted blog (WordPress.org install) and not for WordPress.com.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 2, "tags": "multisite, domain mapping, directory" }
How to get blog name, when using Wordpress Multisite I have a wordpress multisite installtion with 5 sites within, the multisite is called **Lifestyle** 1. Homes 2. Cars 3. Architecture 4. Holidays 5. Communities I am trying to get the **blog** name, for each blog when viewing in my theme, every function I use returns 'Lifestyle'. I have tried; get_bloginfo('name'); get_bloginfo(); global $current_site; var_dump(get_current_site_name($current_site)); get_current_blog(); none of the strings or objects returned contain the blog name, they all contain the site name "Lifestyle" can anyone offer any advice...
This is what you need: global $blog_id; $current_blog_details = get_blog_details( array( 'blog_id' => $blog_id ) ); echo $current_blog_details->blogname; Have a nice multisite! :)
stackexchange-wordpress
{ "answer_score": 25, "question_score": 10, "tags": "multisite" }
if plugin is active? check if plugin is enabled or not? I'm using the mingle plugin and the mingle-forum plugin. I want to show a certain part on my site only if those two plugins are active. How can I solve this? <?php if ( is_plugin_active('mingle-forum') ) { ?> <div id="login"><?php include (TEMPLATEPATH . '/inc/userlogin.php' ); ?></div> <?php } ?> This throws a php error. Call to undefined function is_plugin_active Any idea what I'm doing wrong? update: <?php if ( plugin_active('plugin-directory/mingle-forum/wpf-main.php') ) { ?> <div id="login"><?php include (TEMPLATEPATH . '/inc/userlogin.php' ); ?></div> <?php } ?>
This function exists in `wp-admin/includes/plugin.php` so I'm assuming it doesn't get included by the theme. You can either `require` it, or just create your own version of it - see here: < UPDATED: Please check `is_plugin_active`
stackexchange-wordpress
{ "answer_score": 6, "question_score": 4, "tags": "plugins, php, functions" }
Remove the "View" Link in Post Admin I have a custom post type that I'm just using just to keep data in but I sometimes share it with others, and I don't want any confusion when the "view" link appears in the admin column. Is there a way of removing that?
add_filter( 'post_row_actions', 'remove_row_actions', 10, 1 ); function remove_row_actions( $actions ) { if( get_post_type() === 'my_cpt' ) unset( $actions['view'] ); return $actions; } Should see you through :) The $actions array consists of the following: $actions['edit'] $actions['inline hide-if-no-js'] $actions['trash'] $actions['view'] To modify users grid view '`user_row_actions`' filter can be used. For future reference.
stackexchange-wordpress
{ "answer_score": 24, "question_score": 9, "tags": "custom post types, admin" }
How wp_enqueue_script works? I am trying to get scripts via `wp_enqueue_script();`. I have tried this in header but WordPress is not importing any script. I am using like this `wp_enqueue_script('jquery');` < Is any other step needed for importing script via WordPress?
In simple case you need to enqueue script before header scripts are printed, which happens in `wp_head` hook. Basic approach would be this in `functions.php` of your theme: add_action('wp_enqueue_scripts', 'my_enqueue_scripts'); function my_enqueue_scripts() { wp_enqueue_script('jquery'); }
stackexchange-wordpress
{ "answer_score": 6, "question_score": 2, "tags": "jquery, javascript, wp enqueue script" }
wordpress theme backend admin only Does anyone know of a theme that completely removes all uses and aspects of the frontend. So the sole use of the site will be in the admin section. to use as a portal for something like a school or internal government uses.
There are three things (if i understood your needs correctly): * Adjust the admin menu items @MikeSchinkel Gist * The Backpress project * ...or simply `wp_redirect();` on login and offer only a login screen in your index.php template.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "plugins, theme development, themes" }
Default Permalink Structure for Pages I'm trying to figure out a permalink structure for my pages (not posts) in Wordpress. Right now, I can add a "Category Base" for posts... so, something like www.mysite.com/categorybase/post1/ or www.mysite.com/categorybase/post2/ But, if I wanted to do something similar for pages, how would I do that? For example, www.mysite.com/pagebase/page1/ or www.mysite.com/pagebase/page2/ Anyone tried this before?
For the example you're using (ie www.mysite.com/pagebase/page1) you can: * create a page called pagebase * create a page called page1 and make pagebase the parent page - the url for this page will be www.mysite.com/pagepage/page1 This does mean that www.mysite.com/pagebase also exists as a browsable page, but I generally use that as a section description and section index page.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "permalinks, pages" }
How to exclude content (and other returned values) from WP_query()? Does a method exist that can return a simple array of the pages in the site that are published? I only want the name and the slug returned, not the full content or other default values. I've tried WP_query(), get_posts(), get_pages() and query_posts() but they all return the post/page content. I'm only looking to get the post name and slug returned. If there's no lighter method, I can use one of these. Just want to make sure. Any help, much appreciated.
Like a commented the only way to do it is with a custom sql query so: global $wpdb; $mypages = $wpdb->get_results( "SELECT post_title, post_name FROM $wpdb->posts WHERE post_type = 'page' AND post_status = 'publish' AND parent = '0'"); if (count($mypages) > 0){ foreach ($mypages as $page){ //do you stuff //$page['post_title'] for title //$page['post_name'] for slug } }
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "plugin development" }
Custom Nav Menu items default to 'menu-item-type' => 'custom'. How to make a "page" menu item? I'm using the code below to create custom menu items on the fly. Its working great, except all menus are created as "Custom". In the code below, setting the menu-item-type to 'page' appears to have no effect. foreach($thePages as $page){ wp_update_nav_menu_item($menu->term_id, 0, array( 'menu-item-title' => $page->post_title, 'menu-item-type' => 'page', 'menu-item-status' => 'publish') ); } wp-includes/nav-menu.php shows that the value is hard coded to "Custom". However, if I manually add a page to the menu, using the WP Menus manager, it lists it as "Page", not "Custom". What can I do to set the menu type to "Page"?
There's a filter: function wpse15368_update_menu_item_type( $args ) { return $args['menu-item-type'] = 'page'; } add_action( 'wp_update_nav_menu_item', 'wpse15368_update_menu_item_type' );
stackexchange-wordpress
{ "answer_score": 1, "question_score": 4, "tags": "plugin development" }
Passing error/warning messages from a meta box to "admin_notices" I have a simple meta box that updates the post custom fields (using `update_post_meta()`). How can I send a error or warning message to the next page after the user publishes/updates the post and doesn't fill one of the meta box fields (or fills them with invalid data) ?
You can do this by hand, but WP natively does it like this for settings errors: 1. `add_settings_error()` to create message. 2. Then `set_transient('settings_errors', get_settings_errors(), 30);` 3. `settings_errors()` in `admin_notices` hook to display (will need to hook for non-settings screens).
stackexchange-wordpress
{ "answer_score": 10, "question_score": 22, "tags": "metabox, post meta, save post" }
Allow html tags in WordPress Custom Menus Description Field I added descriptions to my menus using this post, Menu items description? Custom Walker for wp_nav_menu(). However I need to be able to use html tags and WordPress is stripping them out. Can anyone help?
You can remove the filter by adding this to your functions.php file: remove_filter('nav_menu_description', 'strip_tags');
stackexchange-wordpress
{ "answer_score": 3, "question_score": 4, "tags": "menus, filters" }
WP_Query - Adding "offset" posts to the end of the loop I'm trying to create two queries. In the first query, I will, for example, display 6 posts, in a given order. In the second query, I want to display the _same_ 6 posts, but "offset" the first 3 and then have those same 3 appear at the end. For example, Query #1 would return: 1 2 3 4 5 6 Then, Query #2 would return: 4 5 6 1 2 3 Any ideas on how I might pull this off??
No need to have two queries, you can just reuse the same post data by resetting the current post position and running the loop again: `$wp_query->current_post = 2;` you'd have to do this twice to achieve what you're asking, and stop it the second time at the third post.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "wp query, loop, offsets" }
How to fork a plugin? I want to start giving back to the community, but writing a plugin from scratch is currently slightly beyond my skill level and creativity level (meaning, I don't know what kind of problem I can solve with a plugin! every time I think of something, I find a plugin or 6 that have already been written!). However, I have recently identified a very simple plugin that looks to be abandoned since WP 2.8, and I think I can modify it to be 3.1 compatible. I've asked, and it seems that the best way to update this plugin may be to simply fork it. So now my question: how do I do that? I'm new to SVN, so I'm totally uncertain as to where to go, how to start, etc etc. Can anyone guide me? :)
there are several guides in the Codex that can help, * Set up your plugin for submission * Submit your plugin * Keep it up to date I also think it's a great idea to "fix" older useful plugins :) **Steps** : < **Submit** : < **How to Use Subversion** : < **Promotion and additional info** : < Using subversion depends on your OS, for windows I recommend tortoise SVN < For Mac check out "Versions", < or you can use the command line. Also a lot of IDE's now have subversion support built right in.
stackexchange-wordpress
{ "answer_score": 12, "question_score": 14, "tags": "plugin development" }
what is __return_false in filters I was thinking of removing/hiding admin-bar from my wordpress (3.1.1) installation. I visited following link: < I was surprised to see only a single line to remove/hide admin-bar add_filter( 'show_admin_bar', '__return_false' ); My question is what is **__return_false** means? why __ and _?
### WordPress contains built in functions for quickly returning values. They are intended to be used as a quick built in function that returns a common value to a filter hook such as true, false, or an empty array. * `__return_false` — Returns the Boolean value of `false`. * `__return_true` — Returns the Boolean value of `true`. * `__return_empty_array` — Returns an empty PHP `array`. * `__return_zero` — Returns the integer `0`. * `__return_null` — Returns `NULL`. * `__return_empty_string` — Returns `''`.
stackexchange-wordpress
{ "answer_score": 47, "question_score": 20, "tags": "filters, admin bar" }
LEFT JOIN, INNER OUTER JOIN, LEFT OUTER JOIN is driving me crazy. Please help? fellow coders! I an having a hard time JOIN(ing) tables. I have a a lot of users on my site and many of them have the same last names. I am trying to get their emails by their last name. WP stores emails in the users table and user names in the usermeta and I have been trying to use JOIN to get what I want, but I don't understand how it works and I am about to give up for the day. This is what i have after 4.5 hours. $usersemails = $wpdb->get_results("SELECT users.user_email, usermeta.meta_value FROM $wpdb->users LEFT JOIN $wpdb->usermeta ON $wpdb->users.ID = $wpdb->usermeta.user_id WHERE user_status = '0' AND meta_value = 'Smith'"); Any help is appreciated, so can you please help? Thanks.
Hi **@Holidaymaine** : Not sure where you are doing wrong, but try the following instead which is a self contained `test.php` file you can drop into the root of your website and load in your browser with ` _(assuming you replace`yoursite.com` with your site's domain! Also, note how I adding in a `WHERE {$wpdb->usermeta}.meta_key = 'last_name'` to ensure you did not get records you were not expecting):_ <?php /* Filename: test.php */ include('wp-load.php'); $sql =<<<SQL SELECT {$wpdb->users}.user_email, {$wpdb->usermeta}.meta_value FROM {$wpdb->users} LEFT JOIN {$wpdb->usermeta} ON {$wpdb->users}.ID = {$wpdb->usermeta}.user_id WHERE 1=1 AND {$wpdb->users}.user_status = '0' AND {$wpdb->usermeta}.meta_key = 'last_name' AND {$wpdb->usermeta}.meta_value = 'Smith' SQL; $usersemails = $wpdb->get_results($sql); header('Content-type:text/plain'); print_r($usersemails);
stackexchange-wordpress
{ "answer_score": 3, "question_score": 3, "tags": "users, wpdb, user meta" }
get_term_by with a variable I have a Custom template with a custom query. I want to use additional information about the current taxonomy > description and name (and use it in the HEAD, desc, keywords, etc...) <?php $productvariable = $_GET['product']; $term = get_term_by('slug', $productvariable, 'mytaxonomy'); $mytitle = $term->name; $mydesc = $term->description; ?> * How do i make the variable safe from url to get_term_by ($value)? * And what if there is no match is it possible to use ELSE? * Is it possible to use the values inside HEAD (header.php)? > Is there a security issue when using a GET variable from url with get_term_by?
you can look at line 874 in /wp-includes/taxonomy.php for the function itself. the value has `stripslashes` applied and then it's used in a prepared statement, so I'd say it's safe. but there's nothing stopping you from checking the value yourself first if you know what parameters it will always fall within, like `ctype_alnum` or something. then check if(empty($term)), to see if anything matched and print something else if not.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "taxonomy, slug, variables" }
Clear Cart with Wordpress E-commerce plugin I added a Merchant to the Wordpress E-commerce plugin. I want on the submit, after doing my curl() call, to clear the cart How do I do that? (link to plugin page)
according to their docs: `$wpsc_cart->empty_cart();`
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "e commerce" }
Using the_excerpt() some posts are truncated and some are not I have a template that pulls three posts query_posts() loop. Two of the posts and are truncated to 10 words like I have it set in a filter. The third decided to ignore the filter and is spitting out 33 words. I can't see a difference between the posts. Does anybody know why this would happen? while (have_posts()) : the_post(); $img = get_post_meta($post->ID, 'Featured Thumbnail', true); ?> <div style="width:237px; float:left; margin-right:20px;" <?php post_class(); ?> id="post-<?php the_ID(); ?>"> <div class="entry"> <img style="margin-bottom:10px;" src="<?php echo $img; ?>"/><br /> <div style="margin-bottom:5px;"> <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title('<h3>', '</h3>'); ?></a></div> <?php the_excerpt(); ?> </div> </div> <?php endwhile; ?>
Does that post have an excerpt manually entered? the filter only works on excerpts when they're pulled from the post content.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "posts, excerpt" }
Functions file mods and CPU Will adding code similar to what I've pasted below to the functions.php theme file slow down a Wordpress site or effect CPU? (Thank You) function remove_menu_items() { global $menu; $restricted = array(__('Links'), __('Comments'), __('Media'), __('Plugins'), __('Tools'), __('Users')); end ($menu); while (prev($menu)){ $value = explode(' ',$menu[key($menu)][0]); if(in_array($value[0] != NULL?$value[0]:"" , $restricted)){ unset($menu[key($menu)]);} } }
Nope or Not really or Not noticeably.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "functions, database" }
BuddyPress - Search members by name and also by username Im trying to find a way to set the members search by name and also by username. Now it seems to search only by name. Thanks in advance.
Somebody on the BuddyPress support forums had this to say: > I don’t recommend to change the core files of buddypress. The best way to do it is to write a custom code (I don’t know how to guide you). So if you don’t mind changing the core files, here is a quick way. > > Open `/buddypress/bp-core/bp-core-classes.php` and change the > > > $sql['where_searchterms'] = “AND pd.value LIKE ‘%%$search_terms%%’”; > > > to > > > $sql['where_searchterms'] = “AND (pd.value LIKE ‘%%$search_terms%%’ OR > u.user_login LIKE’%%$search_terms%%’)” ; > > > If someone can guide us how to do it in `bp-custom.php`, it would be great.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "search" }
How to get custom post type menu_name? I'd like to show the post type of a post, you can do that with get_post_type(), but in my case the names are not pretty (for ex : p_project_plans). So instead I thought I'd show the asociated "menu_name" (as declared with register_post_type), which looks much nicer (for ex : Project plans). Is there a way to do that ?
Hi **@mike23:** This code shows you how to get both singular and plural names _(assuming you specified them as such in your`register_post_type()`)_. Note that the code example is presented as a standalone file you can save as `test.php` file in the root of your website and load in your browser with ` _(assuming you replace`yoursite.com` with your site's domain!):_ <?php /* Filename: test.php */ include( '../wp-load.php' ); header( 'Content-type:text/plain' ); $post_type_object = get_post_type_object('p_project_plans'); echo "Singular: {$post_type_object->labels->singular_name}\n"; echo "Plural: {$post_type_object->labels->name}\n";
stackexchange-wordpress
{ "answer_score": 2, "question_score": 2, "tags": "custom post types, menus" }
Does WP Super Cache really compress my pages? I enabled the compression option on WP Super Cache (off by default!) on my blog. After that, Website Optimization started identifying my pages as being compressed (before, it didn't). All seemed well with the world, but then I double checked with Page Speed Firefox plugin, and and sniffed the traffic with Wireshark, and according to both these measures my page is not compressed. Are my pages being compressed or not? Could it be some proxy my ISP is running, that does not support compression? (that would explain some of the horrible internet experience I'm getting). Here are the HTTP headers I'm seeing with wireshark.
I'm getting a `Content-Encoding:gzip` header when I visit your site... Cache-Control:max-age=300, must-revalidate Connection:Keep-Alive Content-Encoding:gzip Content-Type:text/html; charset=UTF-8 Date:Sat, 23 Apr 2011 15:27:48 GMT Keep-Alive:timeout=15, max=100 Server:Apache Transfer-Encoding:Identity Vary:Accept-Encoding,Cookie Also, you have a jQuery reference error in the wp-minify plugin :)
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "optimization" }
WYSIWYG clear:both How to clear floats in WYSIWYG editor? Not everyone know how to add `<div style="clear:both>"` in HTML mode. Is there any way to add extra button to WYSIWYG or plugin. TineMCE doesn't have that option.
Write a simple shortcode to add a `<div style="clear: both;">&nbsp;</div>` Detailed Explanation: <
stackexchange-wordpress
{ "answer_score": 1, "question_score": 2, "tags": "plugin recommendation" }
Automatic Wordpress Backup Plugin works, but says it's not I just installed Automatic Wordpress Backup on a fresh install of wordpress, with no other plugins installed, nothing else has changed from the default install. The plugin is saying zip is not found, I verified with my host that it is, and updated the path for it in automatic-wordpress-backup.php. I also have debug turned on, and am about to have to turn it off due to the number of warnings and notices displayed. It appears to be mostly Notices about deprecated arguments and Warning: Cannot modify header information. It also causes me to just get a blank page after updating info, for example I just changed the permalinks, after I hit save it takes me to a blank page, it made & saved the changes, but I can't tell my client that it's just going to work that way. Is this normal? Any suggestions?
The plugin's description in repository says following: > Important caveat: this plugin currently has to be run on a linux server. Also, the wp-content/uploads folder has to be server-writable or it won't be able to create the zips for backup. ...which makes me think that developer was not too interested in making plugin use proper WP APIs to work robustly across different hosting server configurations. If this plugin alone generates enough debug output to break things I'd seriously consider looking for alternative.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "plugins, backup" }
Warn me about 'uncategorized' posts I always want new posts to have a category, but sometimes I forget. How can I make Wordpress warn me when I'm about something 'uncategorized'?
Category Reminder plugin
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "categories" }
remove missing image attachments Best way to programatically remove attachments that are missing images? I ask because after using a caching plugin, I have images that have been input in the database as attachments that don't actually exist. These usually take the form of xxxx.1jpg, where xxxx.jpg is a valid. Sometimes this number is a 2 or a 21. !bonus image attachment I guess it would be better to just remove "duplicate" bad images. I think it might be good to have other types of missing images remain, so they could be corrected. Ideas?
Try this: $imgs = get_posts("post_type=attachment&numberposts=-1"); foreach($imgs as $img){ $file = get_attached_file($img->ID); if(!file_exists($file)){ wp_delete_post( $img->ID, false ); } }
stackexchange-wordpress
{ "answer_score": 8, "question_score": 3, "tags": "database, attachments, images, post duplication" }
Wordpress comments title This code: <?php comments_template( '', true ); ?> Outputs: <h3 id="comments-title"> <h2> 12 Responses to My Post. </h2> </h3> (comments template) I don't know where this h2 tag comes from. I want to get rid of that. And customize my comments-title (so there will be h4 instead of h3 and "comments" instead of "Responses". How to achieve that?
Comment markup - both the comments list and the comment reply form, will be in the `comments.php` template file. The contents of this file are entirely Theme-dependent, so any more-specific help will require the content of `comments.php`.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "theme development, comments" }
Something is generating spam pages on my site The site is Videos-de-musica.com it is a simple wordpress blog with music videos. Somehow the subdomain stats.videos-de-musica.com filled up with spam, I remember setting the domain for pwiki stats, but then uninstalled it and I don't remember what happened to it. This is an example spam page stats.videos-de-musica.com/aal-0exe.htm When you search PRINTABLE SUPERMAN EMBLEM BATMAN on Google that is the first result, and when you access it you are redirected to a "Google has found malicious software may be installed onto your computer if you proceed" scam site. I have tried disabling all the plugins with no change. Does anybody know what happened and how to remove this? I am downloading all the site directory to search for any clues. Thanks.
You probably downloaded a theme or plugin that added a _"backdoor."_ Otto has a good post on the subject: * **How to find a backdoor in a hacked WordPress**
stackexchange-wordpress
{ "answer_score": 2, "question_score": 2, "tags": "plugins, spam" }
Symbolic Links on dev box with plugins and stylesheets I'm using mac os x 10.6 with xampp. ` is the url to where I have WordPress installed. The physical path is `/Users/myUserName/Sites/wp3.1/` I do not install plugins or themes in the "natural" way. I have created a directory named "git" which is located in `/Users/myUserName/git/`. This is where all my git repositories live. When I want to install a plugin, I just create a symbolic link in `/Users/myUserName/Sites/wp3.1/wp-content/plugins/`. This works great for simple plugins, but if the plugin enqueue's a style sheet or script, the url displays as: ` How do I fix this?
Symbolic links are … risky in WordPress. It is easier to use a separate domain for plugins per wp-config.php: define( 'WP_PLUGIN_DIR', '/local/path/to/plugin/directory' ); define( 'WP_PLUGIN_URL', ' See Strategy On Building Plugin Using Eclipse as an example for IDE configuration with such a setup.
stackexchange-wordpress
{ "answer_score": 10, "question_score": 11, "tags": "plugin development, urls, wp config, paths" }
How to put Stack Exchange Flair as widget? I want to put my flair in as a widget in the top of my sidebar in my blog. There was a similar question asked here but the only answer links to the flair page and suggests copying and pasting the html into the theme. I don't want to edit my theme, I want to be able to add is as a widget. Is this possible?
## You can add the flair code to a text widget. !enter image description here ## Then go to your WordPress dashboard Appearance - > Widgets !enter image description here ## Your flair in the sidebar!enter image description here
stackexchange-wordpress
{ "answer_score": 7, "question_score": 1, "tags": "widgets, images" }
my blog crashes ie7? weird problem. My blog theme works fine in ie8, ie9 and all other major browsers... however ie7 doesn't even render it? in ie7 it seems like my blog even has serverside problems? !enter image description here any idea what could cause that? In my programming history i've encountered ie7 styling issues and stuff but never something like this that the webpage doesn't even get rendered? Sometimes the page is kind of loaded in ie7, however the browser does crash anyway. any idea what could cause that? If sometimes the page gets loaded in ie7 the bar at the bottom says: "loaded but with errors" ... I do not have a single error if I validate the page!
You have a javascript error on line 451: ReferenceError: Can't find variable: jQuery. and then Failed to load resource: the server responded with a status of 403 (Forbidden): axx1cxj-b.css. The second one looks like s stylesheet that typekit is trying to load.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "themes, errors, debug" }
Options for logging events in WordPress I am building a custom app in WordPress, so I need some means of logging my events. I searched and found this plugin - < which looks very convenient to use. It uses database to store logs and can display them in the backend itself. Another option for me is to learn WP filesystem (something which I haven't tried yet) and use it to write logs to file on disk. What do you think would be best considering the tradeoff between performance & convenience? Database write is equal to `I/O write` \+ some extra work. Thoughts?
I would prefer to use _WP-Logs_ plugin because its code looks pretty well and you will not waste so much time writing something completely from the scratch. I also store data in the database more likely because I think database could be scaled more efficiently when needed. The another reason why I would prefer database is that the data could be accessed more easily by other plugins/APIs. From my point of view it's more secure too (for me it's easier to secure the database then the files on the FTP or in case when you need to access it from the external source...).
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "plugin recommendation" }
Excerpt textarea missing on post editing page in admin panel Why is that? It's a new installation. EDIT: I don't have plugins installed and I tried to restore default theme to Twenty Ten, but it didn't change anything.
Upper right corner in posts editing page > "Screen Options"...there you have to check "Excerpt" ;)
stackexchange-wordpress
{ "answer_score": 8, "question_score": 3, "tags": "wp admin, excerpt" }
WordPress Featured Post Slider Alright, I have almost finished up a clients project in WordPress, but I have hit a wall. I am not really great with jQuery (and I have yet to find a plugin to achieve what they are looking for). The client wants an automatic slider on the homepage that pulls in featured posts out of their five categories. I have scoured the net for plugins to achieve the "look" they want, but to no avail. The look in question can be seen here. Does anyone know how to go about this?
This is one of those things you probably have to do yourself, even though there are some slider plugins, they are difficult to customize. Using a jquery slider is pretty straightforward, they are usually just controlled with ID's and CLASS's, so you can wrap any WordPress code, for instance a wp_query (for featured posts). toscho's answer pretty much covers it, I tend to use Jquery Tools a lot since it has great docs and tons of functionality, <
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "jquery, slideshow" }
Is there a good plugin for social bookmarking on site for WordPress I want to add a onsite social bookmarking system to a WordPress installation. is there any thing like this available?
I think SexyBookmarks is the best < There are some others * Bookmark Me * Simple Social Bookmarks
stackexchange-wordpress
{ "answer_score": 3, "question_score": 2, "tags": "plugins, plugin recommendation" }
How is a student directory best handled in WordPress? I am doing a WordPress site for a school. One of the pages would have a list of 20 or so students, which would include their name, photo and small blurb. How is this type of thing handled in Wordpress? I would like the user of the CMS to be able to manage this page effectively - adding/removing students etc. I know Wordpress is being used in e-commerce sites, so people who run these site must be in the same situation on their pages of products. Should I be using plugins? Custom fields? thanks in advance
You could create a custom post type 'student', with post thumbnails for the images. The post title would be their name, post content would be the blurb. If the code scares you, there are plugins to assist. Taxonomies are also available to you, which operate like categories and tags, but can be any set of attributes or means of grouping.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 2, "tags": "directory" }
Undefined variable _POST Using 3.1.1 with debug on, I am getting following notice. Notice: Undefined variable: _POST in <filepath> on line 1000 Code at line 1000 is $data = $_POST Why am I getting this notice? How can I remove this particular notice?
First check if it is a non-empty POST request: if ( 'POST' == $_SERVER['REQUEST_METHOD'] and ! empty ( $_POST ) { // don't forget to sanitize these data! $data = $_POST; } else { return FALSE; }
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "plugins, plugin development, php, forms" }
WordPress Multisite. Can domain be used instead of subdomain? i am new to multisite. It is a simple question. I know WordPress multisite can be setup for subdomains. Is it possible to use domains along with subdomains? I have searched google but have not had really good results. Perhaps I have used the wrong keywords. **so i can use a single wordpress installation for:** domain.com sub1.domain.com sub2.domain.com example.com example2.com sub1.example2com Hope you get it. Thanks in advance!
"example2.com sub1.example2com" Actually for subsites off of mapped sites, you want a multi network plugin. Free - < Paid - <
stackexchange-wordpress
{ "answer_score": 5, "question_score": 4, "tags": "multisite, domain, subdomains" }
SQL query to delete comments older than 90 days? I'm working on a site that has 150,000 comments with an obvious hit in performance; is there an SQL query that can delete all comments older than say 90 days? They're not spam comments, and they are all approved; they're just too numerous. And: what about bulk changing all posts older than 90 days to untick "Allow comments" and "Allow trackbacks and pingbacks"? So they don't get re-commented?
Regarding comments- what about the case where a comment older than 90 days has child replies younger than 90 days? for comment and pingback status, this should do it: `UPDATE wp_posts SET comment_status = 'closed', ping_status = 'closed' WHERE post_date < DATE_SUB(NOW(), INTERVAL 3 MONTH) AND post_status = 'publish';`
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "comments, mysql, date time" }
Automatically email daily archive Is it possible to automatically email the daily archive.php page as an html email newsletter? For example, at 4am every weekday WordPress would send an email of the 2011/04/25/ page. Any input is greatly appreciated!
I do not think this is built into WordPress currently. This would probably need to be custom-built. It would be some php code that is attached to a cron job. Set the cron job to run every day, and have your php script email out the page. These resources may help: < (via <
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "email, automation, newsletter" }
Automatic image renaming based on title Is there a plugin or a "hack" that can help me do this? I have spent hours try to figure this out so I would greatly appreciate nay help. I have WP 3.1 running php5 Thanks! eg.: **postitle_image-ID.jpg**
Hook into the filter `'sanitize_file_name'`. See my plugin Germanix URL for a working example. A plugin doing this is Rename Media.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 3, "tags": "customization, attachments, file manager" }
Where to store PHP files created by plugin / themes There are cases in which a plugin or theme needs to create a php file somewhere that can later include it. For example a captcha plugin, or some kind of a templating system like twig/smarty (In my situation it's simple template engine for a collection of widgets). Where should be this file created? The only place I can think of is `wp-content/uploads/`, but that just doesn't sound right :) So is there a safe place where you can create files, and not worry about them being deleted on WordPress/plugin/theme update ? One solution could be to create a child theme / directory in the themes / plugins directory...
The appropriate place IMHO would be a custom folder that you create inside the wp-content directory Read this before creating files: <
stackexchange-wordpress
{ "answer_score": 10, "question_score": 13, "tags": "plugin development, theme development, php, filesystem" }
Menu page with minimum capability as 'Subscriber' doesn't allow 'Admin' to access it? I've added a separate menu page (an object page) with minimum access level required as 'Subscriber'. I'm doing this because I'm registering new users and they'll be 'Subscribers' with an extra capability to edit a section that my plugin creates. So I want them to be able to see this menu as well. I created my menu page as follows: `add_object_page('Personal Section', 'Personal Section', 'subscriber', 'personal-section', 'personal_section_fn');` Now when I log in with the subscriber credentials, I'm able to see this menu, but I'm not able to see it when logged in as Admin. Am I doing something wrong here? Thanks in advance!
`subscriber` is a role, not a capability. Use a capability to manage access, e.g. `read`. To understand the difference better install Justin Tadlock’s plugin Members. For the **subscriber** role you get a list of capabilities like this: !enter image description here The **administrator** role in contrast: !enter image description here
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "plugin development, menus, user roles, capabilities" }
How To create ajaxed wp-pagenavi? I'm using WordPress as a Facebook platform and have a page that shows posts from 2 different categories. Each category has it's own pagination using wp-pagenavi. In order to stay in Facebook I need the pagination links to load using ajax. I've seen this article which gives a nice clue about it, but would love to know if anyone had already solved this and has any leads. My main issue here (and this is stupid), I get that I need to call an ajax function with jQuery and pass it the specific category and the desired page number. I have no idea how to get the page number. But once again, if you have an already made solution - it will be much appreciated Currently I tried using this tutorial, the tab code can be seen here. as you can see pagination affects both categories :-(
Take a look at this tutorial: <
stackexchange-wordpress
{ "answer_score": 3, "question_score": 4, "tags": "pagination, ajax, plugin wp pagenavi" }
$wpdb->query() multiple query support Just bump into the issue that I can't execute multiple sql queries using the `$wpdb->query()`. Generated queries work fine directly in phpmyadmin so its something will the ezSQL class only. By design perhaps? I found this < which also says its by design. Can anyone confirm? ezSQL docs dont say anything about multiple queries support. If you have to do a bunch of queries mainly (INSERT/UPDATE/DELETE), any better way of doing them other than doing them one by one using `$wpdb->insert()` and like functions?
Using PHP 5.3.5, I was unable to make this syntax work even after setting the 5th parameter of `mysql_connect()` to 65536 (`CLIENT_MULTI_STATEMENTS`). Looks like it's not possible to concatenate multiple queries into one statement as long as the old-school MySQL API is running the show. I assume you're familiar with the MySQL multiple row INSERT syntax, but I mention it just in case.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 3, "tags": "wpdb" }
Popular Post With Thumbnail? Is there any plugin that allows you to use a custom field as the thumbnail to display the most popular post within the last day (24 hours)? I have found several plugins but none seem to have the capabilities that would allow me to add a custom field as the image or even a thumbnail at all.
If you know the $Post->ID of the "most popular post", why not just use `get_the_post_thumbnail()` (Codex ref): <?php echo get_the_post_thumbnail( $id, $size ); ?>
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "plugins" }
Random category URLs not working I have been having problems with a custom taxonomy not working with a url. For example mysite.com/testcat/test1 will 404 but mysite.com/make/ford will work. More troubling is that mysite.com/?make=ford&testcat=test1 will bring up my test page (both taxonomies where included). Here is a clipping of the functions.php register_taxonomy( 'testcat', 'videos', array( 'hierarchical' => True, 'label' => 'testcat', 'query_var' => true, 'rewrite' => true ) ); Any ideas of what i'm doing wrong?
Did you flush your rewrite rules after you created the taxonomy? I tested your code (only changing `'videos'` to `'post'`) by adding to my functions PHP (TwentyEleven Theme WordPress 3.2 Trunk) then flushed my rewrite rules and created a post and gave it the testcat of test1 and the URL worked. add_action( 'init', 'c3m_wp_stackx'); function c3m_wp_stackx() { register_taxonomy( 'testcat', 'post', array( 'hierarchical' => True, 'label' => 'testcat', 'query_var' => true, 'rewrite' => true ) ); } Screenshot: !enter image description here
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "custom taxonomy" }
Math notation on WordPress.com? I am a new user with WordPress, and I would like to use mathematical formulas. I have been reading the mathjax pages for hours, such as this one and quite a few others. This may be a bad question, but can someone please help me? All I want to do is enable Latex, and I am hopelessly lost. My most recent attempts have been trying to find the "header file" so that I can copy and paste in <script type="text/javascript" src=" </script> I have tried looking for it, and looked over a whole bunch of forum posts about where to find this header file, but I just do not understand. A step by step explanation of how to make mathjax work in the simplest way possible would be extremely appreciated!! (Also, don't worry about leaving in too many steps!)
If you have a blog that is hosted on WordPress.com, you can't install extra plugins or modify the theme files yourself \- this is only possible with a self-hosted version. However, WordPress.com has enabled LaTeX support for everyone. Just write `$latex your-latex-code$` and it will be rendered as images.
stackexchange-wordpress
{ "answer_score": 4, "question_score": 7, "tags": "wordpress.com hosting, headers, latex" }
A reliable AdSense plugin. Does it exist? I've tried a bunch of AdSense plugins but I can't seem to make any work. Can someone recommend something that is known to work? My requirements are simple: display an ad under the header.
If your requirements end at "display an ad under the header" then just open up your theme's header.php file and paste your adsense code there directly and avoid using a plugin all together.
stackexchange-wordpress
{ "answer_score": 4, "question_score": 2, "tags": "plugins, plugin recommendation, adsense" }
Simple Amazon Affiliate Plugin I am looking for a plugin that will embed my amazon affiliate id in outbound amazon links on my blog. I've tried a couple of top plugins (e.g. sorted by popularity) and most are a huge overkill (e.g. providing image popups, search lists, products lists, price integration, etc...) Can someone recommend a plugin that does what I am looking for?
I've been using the plugin called **WordPress-Amazon-Associate**. It was easy to setup and has been working fine. For more information: * link to the author's home page * link to the official WP plugin page
stackexchange-wordpress
{ "answer_score": 1, "question_score": -1, "tags": "plugins, plugin recommendation, links" }
wp_query orderby title and meta key value (WP3.1) I have a taxonomy wp_query and i would like to order the list by **title and** by **meta** value (numeric value) * Have a meta value Interesting = 1 or 0 in the posts * Not so interesting posts would be at the bottom of the query **GOAL - OUTPUT LIKE THIS:** (is this possible with WP_QUERY and WP3.1) **A** ( META KEY interesting = **1** ) **B** ( META KEY interesting = **1** ) **C** ( META KEY interesting = **1** ) **A** ( META KEY interesting = **0** ) **B** ( META KEY interesting = **0** )
You can filter the `orderby` part of the query to get what you want (trying to pass it via the `orderby` parameter will not work, it will be filtered out). This simple example adds the `meta_value` sort order before the standard title sort order. add_filter( 'posts_orderby', 'wpse15168_posts_orderby' ); $query = new WP_Query( array( 'meta_key' => 'interesting', 'orderby' => 'title', 'order' => 'ASC', ) ); remove_filter( 'posts_orderby', 'wpse15168_posts_orderby' ); function wpse15168_posts_orderby( $orderby ) { global $wpdb; $orderby = $wpdb->postmeta . '.meta_value DESC, ' . $orderby; return $orderby; }
stackexchange-wordpress
{ "answer_score": 5, "question_score": 1, "tags": "custom taxonomy, wp query, query" }
Custom Field Query - Meta Value is Array I'm using a custom field query (or trying to) : $args = array( 'post_type' => 'pf_cookbook', 'meta_query' => array( 'key' => 'pf_cookbook_recipes', 'value' => '5', 'compare' => 'NOT IN', 'type' => 'NUMERIC' ) ); However, the meta value to be compared is an array. The idea here is I am querying the DB to get the cookbooks which don't contain a certain recipe. The Recipes & Cookbooks are Custom Post Types. The Cookbooks have a meta key 'pf_cookbook_recipes' which I am storing an array of recipe IDs. Maybe I am missing something?
`meta_query` needs to be an array of arrays - have a look at the code sample in the Codex again. So, for your example: $args = array( 'post_type' => 'pf_cookbook', 'meta_query' => array( array( 'key' => 'pf_cookbook_recipes', 'value' => '5', 'compare' => 'NOT IN', 'type' => 'NUMERIC' ) ) ); );
stackexchange-wordpress
{ "answer_score": 4, "question_score": 1, "tags": "wp query" }
Add box with custom per-page properties Hey, I'm stuck trying to add a box with settings for all pages (the ones users create/edit). What I'm attempting to do is add 6, 7 check boxes and an input field for all pages that alters the rendering of it; for example: _"Display a contact form at the bottom yes/no?"_. How do you do this without, of course, editing any Wordpress core files?
In WordPress these boxes are called "meta box" and to add one to your new/edit page screen you can use add_meta_box() function (look at the example at the bottom for the examples), you can also use **this class** which is nicely documented and does most of the job for you. Or you can use a plugin like Verve Meta Boxes which does all of the job for you and you just add the options you want form its UI.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "post meta, metabox" }
WordPress Page Id I have a client (same for my previous post about the slider) who believes that the url structure needs to include a "google page id" to be compliant with google news. Therefore, they want the url structure set up like: < . I think they want just a unique 3+ number id associated with every post. Does anyone know how to go about this? I am quite good with design and front-end dev, but when it comes to WordPress loops or settings sometimes I am just clueless.
Go to the Permalink page (in Settings), and choose custom structure, and use something like this: /%year%/%monthnum%/%day%/%postname%/00%post_id%
stackexchange-wordpress
{ "answer_score": 3, "question_score": 1, "tags": "url rewriting, pages" }
How can I make an htaccess file on a Mac? I'm trying to set-up pretty permalinks for my site. WordPress has a warning that my htaccess files is not writable. It provided some code to copy and put in the htaccess file. I'm on a Mac, my local machine running WordPress 3.1.1. I coped the code WP provided and pasted it into a new new TextEdit file that I named 1.htaccess . I put the file in the root directory Sites/mysite/. Then I tried to re-name the file and remove the "1", but my Mac gave a warning that files starting with "." are system files and wouldn't let me re-name it. How can I make an htaccess file on a Mac? Thank you. -Laxmidi
Open up terminal. Found in Utilities. Type: cd /path/to/htaccess/file/ mv 1.htaccess .htaccess For future edits of the htaccess file I'd recommend learning to use vi in the terminal. cd /path/to/htaccess/file/ vi .htaccess
stackexchange-wordpress
{ "answer_score": 3, "question_score": 1, "tags": "htaccess" }
How can I redirect user after entering wrong password? I'm using `wp_login_form()` to display login form in a jQuery dialog window. If user enters wrong password, the user is taken to the backend. I don't want that. Is there a way to notify user that he entered wrong password and still remain on the same page? Before `wp_login_form()` came I was using a plugin. I'm kind of hoping I can avoid using a plugin for this. My code: wp_login_form( array( 'label_remember' => __( 'Remember me' ), 'label_log_in' => __( 'Login' ) ) );
`wp_login_form()` creates a form with an action attribute of `site_url/wp-login.php`, which means that when you click the submit button the form is posted to `site_url/wp-login.php` which ignores redirect_to on errors (like wrong password) so in your case either go back to using a plugin or recreate the whole login process and that way you will have control on errors, take a look at Check for correct username on custom login form which is very similar question.
stackexchange-wordpress
{ "answer_score": 6, "question_score": 23, "tags": "login, wp login form" }
Time limited file download upon form submit The basic of what I need; A public page where the visitor have to fill out a form in order to be able to download a large file (the one and the same file for all downloads/users). The file should only be available trough something like a temporary url for a specific amount of time from when the form was submitted. In other words, time limited access to the file for a specific user. To create and setup the form is no problem, but making the file accessible for a limited amount of time to the user whom submitted the form is a completely different story. I have no good ideas on how to create time limited access. Don't know where to start. Any ideas on how to create this with WordPress? Plugin suggestions are welcome too.
a simple way would be to set a cookie with a timestamp when they submit the form, then check for the cookie and valid timestamp when they hit the url to download the file. a more complicated process would be to generate a unique url key for each user, put that in a db table with a timestamp, then look up the url, check the time and then delete when they hit it for download.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "filesystem" }
Who owns the content posted on .wordpress.com blogs? If I sign up for a Wordpress blog that is hosted for free by Wordpress here, who will own the content I post, and how much storage will I have? I know I could ask their customer support, but I don't trust companies (their lawyers specifically).
From the TOS: > By submitting Content to Automattic for inclusion on your Website, you grant Automattic a world-wide, royalty-free, and non-exclusive license to reproduce, modify, adapt and publish the Content solely for the purpose of displaying, distributing and promoting your blog. If you delete Content, Automattic will use reasonable efforts to remove it from the Website, but you acknowledge that caching or references to the Content may not be made immediately unavailable. It means that you own it but they have full rights.
stackexchange-wordpress
{ "answer_score": 6, "question_score": 3, "tags": "wordpress.com hosting" }
How to enable %postname% permalinks on Mac? I'm using Mac OS X's built in Apache + PHP with MySQL. Everything works perfectly, except for my pretty %postname% permalinks — they just won't work. I have obviously enabled mod_rewrite and set the AllowOverride setting to All on my httpd.conf file. In case there's anything I can do (I really don't want to run MAMP), is there any programmatic way to use default permalinks on localhost using the very same template files?
Your /etc/users/{username}.conf should look like this: <Directory "/Users/username/Sites/"> Options Indexes MultiViews FollowSymLinks AllowOverride All AuthConfig Order allow,deny Allow from all </Directory> You also have to change the name Apache runs under to be able to save the .htaccess rules and use the media uploader etc... <IfModule !mpm_netware_module> <IfModule !mpm_winnt_module> User chris Group admin #or you can use staff </IfModule> </IfModule> The AllowOverride is listed a couple of times in httpd.conf make sure you changed the right one or both. One is the default setting and the other is for Library/WebServer/Documents which you should change to whatever server document root your using. Apache has to be restarted for any changes to take affect. `sudo apachectl restart` Also see How to Install Apache and PHP on Mac OSX for more details.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "permalinks, apache, localhost" }
Slideshow/Gallery plugin based on WP Core Gallery Looking for a plugin that I can hardcode into my custom post type template that pulls the images from gallery images added into the standard WP gallery. Thoughts?
See the code in my answer to a similar question. It strips out and reworks the gallery shortcode to use with jQuery Gallerific.
stackexchange-wordpress
{ "answer_score": 1, "question_score": -1, "tags": "custom post types, customization, gallery" }
Add a Jquery Datepicker to custom field in post edit I would like to add a custom field that is set by a jquery datepicker ui in the post edit panel. Im new to wordpress, so Im not sure how to go about adding something like this. I haven't had much luck with plugins, so I would like to know how one would go about adding something like this manually. I am familiar with PHP.
Since you are new to WordPress I would suggest using **Meta Box Script for WordPress** which provides an easy way of adding your custom fields to the post edit panel and its main features are: * Support various field types, including: text, textarea, checkbox, checkbox list, radio box, select, wysiwyg, file, image, date, time, color. Developers can easily add more types by extending the script. * Allow to create multiple meta boxes. * Written in OOP, allow developers easily extend the script. * Work with custom post types. Each meta box can be defined for many custom post types.
stackexchange-wordpress
{ "answer_score": 6, "question_score": 6, "tags": "custom field, php, jquery, datepicker" }
Missed scheduled WordPress I am currently in version 3.1 of WordPress and I have a problem with planning my post. In fact, whenever I plan a post, it is written: "Scheduled missed. Could you help me please.
Due to your server configuration, you may need to use the alternate cron method, which uses redirect rather than http loopback. Try adding the following to your `wp-config.php` file: // Alternate cron method define( 'ALTERNATE_WP_CRON', true );
stackexchange-wordpress
{ "answer_score": 5, "question_score": 4, "tags": "wp cron, scheduled posts" }
Memory consumption in w3-total-cache vs wp-super-cache? I've been suggested by my hosting to move from w3-total-cache to wp-super-cache since the later is supposed to be using less memory then the first. Is there any knowledge about this comparison? Is there a way to test it on my own site? (I am on a managed VPS) Thanks.
If you're using a memory cache like APC or memcached, their respective admin pages will have the total memory you're using (my Wordpress installs are using 80MB with W3 Total Cache). You could then install wp-super-cache and see what it does to your memory usage.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "plugin w3 total cache, memory, plugin wp supercache" }
Suggestions for allowing basic users to view their own posts? I have a client that needs to give access to her clients certain documents. She wants the ability to give them user name and password, so once they log in, they go directly to their page or post which will list the documents available for download. Plugins don't seem to help here and some are way too complicated. I have read many articles and tried several concepts but can't get it right. It's almost a membership to access info, but it's free and members can only be allowed to see what was written for them. This is a tough one for me. Any suggestions?
Well, in short, I had our in-house programmer build me a 3rd party system which we integrated into Wordpress. WP is awesome, but not quite there yet with these kinds of features built in. To the future!
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "user access, membership, page specific settings" }
Cannot publish posts, but can create new pages I am building a site on WordPress. I can't publish posts: when I attempt to do so, the site just hangs and then I get a time out page. However, I can add new pages without a problem. I have tried: * Upgrading the WP build. * Switching my theme to Twenty Ten. I still cannot publish posts. * Deleting all plugins and the plugin folder. None of this has resolved the issue. Should I contact my host or is this a WP issue? Thank you for any help, Jeff
Considering all the content generated by WordPress websites, it seems rather far-fetched that this would be a WordPress problem. I'd contact your host.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "posts, pages" }
Wordpress Hook for user account activation in normal Wp (not MU) what is the action hook, if a user activates his profile? For the profile update, it is: profile_update for example. My goal is, to execute a function, if a user activates his profile. Something like this: add_action( 'user_activate','my_function');
Well there you go Register Plus Redux is the plugin which is adding your new user verification, and by looking at its code there are no filters or hooks which is said because if you make changes to it they will be lost the next time you update, so i would suggest to contact the plugin developer and ask him to add it. But a quick fix for you would be to add do_action('3cees_user_activate',$user_id); after line 2938 at register-plus-redux.php and you can then call it like this: add_action( '3cees_user_activate','your_function'); and your function will run when a user is activated and $user_id will be passed to it.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 2, "tags": "plugin development" }
Unclickable Menu Item Label in Custom Menu with Clickable Children I need some help with a custom menu. I'm using WP 3.1.1. I need to create an unclickable placeholder in the nav menu. So, the children will be clickable, but the "title" in the nav bar is not. For example, let's say I have a Shovel Page, Trowel Page, and a Spade Page and I want them all to be accessible under the Tools section in the Custom Menu. In the menu, "Tools" isn't clickable, only the children are. I tried the solution outlined here: non-clickable placeholder in the menul . But, if I click the placeholder I get an Alert. Also, his opened Custom Link box looks different than mine. I only have options for URL, Navigation Label, and Title Attribute. I don't know if that has anything to do with why it doesn't work. Any suggestions? Thank you. -Laxmidi
HERE´S YOUR ANSWER < CHEERS
stackexchange-wordpress
{ "answer_score": 1, "question_score": 2, "tags": "menus" }
Blog statistics I run small wordpress blog with 3-5 users. People add/edit/remove and read content all the time... What I want is to be able to see some sort of statistics.... which posts/pages are most popular, most updated, commented... which external links are the ones clicked most times... etc.... is there a plugin (not external service) to achieve that?
Piwik is similar to Google Analytics, but you install on your own server. Also- I've seen a private internal intranet site that was tracked on Google Analytics. It was certainly not publicly or search engine accessible, so it is possible to at least use GA on a private site if you're curious to investigate further.
stackexchange-wordpress
{ "answer_score": 4, "question_score": 3, "tags": "statistics" }
Where do I save widget code for wordpress? Pretty simple, I've written a widget and I can't find out for the life of me where to save it?! Using the most recent version of wordpress. Thanks, John.
you can make it a plugin and put it in the plugins folder, or you can make it part of a theme and put it in the theme's functions.php file.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 1, "tags": "widgets, filesystem" }
How to add a user defined hyperlink to the "Featured Image" and the_post_thumbnail() I've enabled my theme with the ability to display the "Featured Image" for the post. However, I'm trying now to determine (1) How to assign a hyperlink to the image and (2) How to call the_post_thumbnail() so that it wraps the hyperlink around the image. I can't find where this is supported in the current release of WP, but I'm thinking that I must just be missing something. <div class="entry"> <?php if(has_post_thumbnail() && get_option('theme_show_featured_image')) the_post_thumbnail('large', array( 'class' => 'alignleft', 'style' => 'margin:0 10px 10px 0;')); ?> <?php the_content('<p class="serif">Read the rest of this page &raquo;</p>'); ?>
I assume you want this to be output inside of `the_content()`? You would probably have to define a shortcode that will output `the_post_thumbnail()`. You could either define the shortcode to accept a URL as an argument, or else wrap the shortcode with HTML anchor tags. EDIT: Assuming you're already outputting `the_post_thumbnail()` inside of `the_content()`, you could add a custom field into which the user enters a URL, and then, if the URL is present, output anchor tags around the call to `the_post_thumbnail()`.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "theme development" }
Custom post type or just use custom fields I am turning a restaurants website into a wordpress website to allow for the customer to take over content changes. The restaurant has a menu that has categories like Baskets with different types. For instance under the Basket type there is Fish which has a Title, Description, and Price. So what I want to do is to be able to have the customer create or delete Menu categories and have the ability to create,delete, update menu types. Then the entire menu is shown on one page. You can view the page at www.tailfinstogo.com/menu.html.
You can really do it either way. I would personally make a custom post type of "Menu Item" then use a custom taxonomy for type of food (e.g., 'Baskets', 'Poboys', 'Soups', etc.). I would then have a custom fields for sizes and price so you could enter something like '4pc' and '10pc' and '7.99'. One of things I've learned with doing WP sites for clients is that training for the client is often overlooked. Just because you do a great job designing and developing the site does not mean the client will know how to use it. I would recommend taking the time to train your client how to use the site after you implement whatever solution you decide on. Good luck!
stackexchange-wordpress
{ "answer_score": 2, "question_score": 3, "tags": "custom post types, custom field, database" }
Dashboard - get status and position of metaboxes and pass them to ajax method I'm wondering if it's possible to get status and position of metaboxes added to a dashboard-like page. The main page of my plugin has several metaboxes laying in a two-columns page and a "table of content" box on top (with internal links, like a wikipedia page). However, since you can order/hide/reveal a metabox, the TOC box should be updated accordingly via an ajax method. Is it possible to trigger a method like that, passing all parameters i need to accomplish the ordering (position and status of all metaboxes)? tnx in advance, Gabriele
You can hook into the `sortstop` event of the `sortable` metaboxes, and read the current state: jQuery( function( $ ) { $( '.meta-box-sortables' ).bind( 'sortstop', function( event, ui ) { var sortData = {}; $('.meta-box-sortables').each( function() { sortData[this.id.split('-')[0]] = $(this).sortable( 'toArray' ); } ); console.log( sortData ); } ); } ); You can also hook into the events that hide or reveal metaboxes, but this requires some more work on your side, since WordPress does not provide nice events for this. See the `postbox.js` script for more details. There are other answers on this site that deal with the Ajax part.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 1, "tags": "plugin development, metabox, ajax, dashboard" }
Is it safe to pass directory path to plugins_url()? `plugins_url()` function accepts plugin slug or file path to build URL for. I have following directory structure: /wp-content/mu-plugins/someplugin/css/file.css /wp-content/mu-plugins/someplugin/includes/file.php I need to build URL to `file.css` in `file.php`. I can't pass `__FILE__` because that will be one level too deep. plugins_url('css/file.css', __FILE__ ) I can pass `__DIR__` to get correct level and it seems to work, but it's not documented as allowed and I am not sure there isn't something to bite me later with this. plugins_url('css/file.css', __DIR__ ) So, is this adequate? Any better way to build URL for these conditions?
`__DIR__` is rather new and not always supported. Use `dirname( __FILE__ )`. `plugins_url()` is using … $folder = dirname(plugin_basename($plugin)); … so yes, it is safe. Just use `plugins_url( 'subfolder/file.css', dirname( __FILE__ ) )`
stackexchange-wordpress
{ "answer_score": 4, "question_score": 4, "tags": "plugins url" }
GUID field in wp_posts - relevance for attachments? How significant is the guid field in wp_posts? I'm doing a migration and adding a lot of images to the table (via `wp_insert_attachment, wp_generate_attachment_metadata and wp_update_attachment_metadata`), but the guid field isn't filled by default. Should i correct this?
If you want to offer an ATOM feed for your attachments you should pass a GUID to `wp_insert_attachment()` or add a filter for `'get_the_guid'` that handles empty values. In most (all?) other cases I wouldn’t care about it.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "attachments, guids" }
How to prepend route with /blog for blog listing page only My permalink settings is simply `/%postname%/` (yes I read from the codex that this is bad performance practice). The result is: * a page url might look like `site.com/pagename` * a blog post looks like `site.com/post-title` * a portfolio (custom post type) post will look like `site.com/portfolio/item-1` I would like my blog post page (`single.php`) to have a URL like `site.com/blog/post-title`. How might I do that?
Change your permalink structure to `/blog/%postname%/`. ## EDIT To get your custom post type to leave out the `/blog` part, in its registration arguments array, set the rewrite argument like this: 'rewrite' => array( 'slug' => 'portfolio', 'with_front' => false )
stackexchange-wordpress
{ "answer_score": 3, "question_score": 1, "tags": "url rewriting" }
where is images/image.jpg? I am being forced to use a SOAP service on a site, and for some of the UI elements it is calling images that I have to put in place. I can't point them to a theme folder, as I have no control over the HTML, and I am reluctant to use javascript. the code points to `<img src="images/image.jpg" >`, I have tried adding an images folder to the root of my WP installation, to no avail. So my question is where should I put the image so that the HTML can find it?
The plugin is search for an 'images' folder inside the current working directory. For example if you are in `/blogs/`, a file looking for `images/image.jpg` is actually looking for `/blogs/images/image.jpg`. This can obviously get _very_ messy when re-writing URLs with stuff like `/2010/03/blog-title` so actually put an image in the specific location is impossible, you will need to edit HTML or at least .htaccass to resolve it. Look up: `<base>` tag, mod-rewrites, javascript or editing whatever plugin is creating that HTML (str_replace on the output?). Personally I think you need to look into filtering the HTML you're receiving from the SOAP service to clear that up.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "images, html, directory" }
Hosting alternatives to WordPress.com I've been hosting my blog on WordPress.com for a few years now, but am starting to feel a bit constrained by some of the limitations. The most troublesome in priority order are inability to include JavaScript in my posts, the requirement to pay an ongoing fee for customized CSS, and inability to install my own WP plugins. I've thought about self-hosting, but the last thing I need is another side project of managing the blogging software. It's tough enough finding time to keep posting new content on the blog. I'm not interested in installing upgrades, doing backups, etc. Long story short, I am wondering if there is another Wordpress hosting provider out there that offers the benefits of the virtually maintenance free hosting of WordPress.com, but without the restriction on CSS and Javasscript. Any suggestions?
Have a look at * page.ly * WP Engine I'm sure there are plenty of others. I'm specifically discounting hosts that provide 1-click installs because even they require some administration.
stackexchange-wordpress
{ "answer_score": 6, "question_score": 6, "tags": "hosting" }
Can you add the visual editor to the description field for custom taxonomies? Can you add the visual editor to the description field for custom taxonomies? It would be nice to have this option available when you edit an entry for a taxonomy be it core or custom.
Just wrote the function. It'll display the tinymce editor in every custom taxonomy description right now. Surely you can edit to show it for only some specific taxonomy. /** * Display advanced TinyMCE editor in taxonomy page */ function wpse_7156_enqueue_category() { global $pagenow, $current_screen; if( $pagenow == 'edit-tags.php' ) { require_once(ABSPATH . 'wp-admin/includes/post.php'); require_once(ABSPATH . 'wp-admin/includes/template.php'); wp_tiny_mce( false, array( 'editor_selector' => 'description', 'elements' => 'description', 'mode' => 'exact' )); } } add_action( 'init', 'wpse_7156_enqueue_category' ); You can provide the first argument in `wp_tiny_mce` as `true` if you want a stripped version of tinyMCE
stackexchange-wordpress
{ "answer_score": 11, "question_score": 9, "tags": "custom taxonomy, taxonomy, tinymce, visual editor" }
Change the default data installed when setting up WordPress Is there documentation somewhere on how to change the default data that is entered into the WordPress database when setting up a new database? I want to change the default category and add a couple others. Change the default post. Set a different theme, activate a couple plugins all by default. All of this to make it easy for setting up multiple sites that are all similar.
See Initialization Script for “Standard” Aspects of a WordPress Website? and my plugin WordPress Basic Settings for details. You may also use a custom `install.php` but that’s somewhat tricky for multi-site setups.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 0, "tags": "database" }
Custom post type functions.php if statement on action I am using developing a child theme for Woothemes' Canvas. I am trying to use functions.php in the child theme to only use actions on my custom post type. This code doesn't seem to be working: add_action( 'woo_post_inside_after', 'my_geo_mashup' ); function my_geo_mashup() { echo GeoMashup::map(); if ($post->post_type == 'listings') { //My function } } add_action( 'woo_post_inside_before', 'listings_nivo' ); function listings_nivo() { echo do_shortcode('[nivo source="current-post" ]'); if ($post->post_type == 'listings') { //My function } } So, I'm unsure how to get the above to work properly and only show these items on the custom post type, or only for the custom post type template single-listings.php (as I only want the map and slider to show on the actual post, not on the blog page (archive.php)
you need a `global $post;` within that function before trying to access the contents of $post.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 0, "tags": "custom post types, functions, customization, actions" }
"Leave a comment" link even when you can't On < I disabled comments for "USDCAD options vs CADUSD options arbitrage?", but it still has a "Leave a Comment" link. Clicking the link takes you to < where it, of course, shows that you can't leave a comment. The timeline page correctly does not show the 'comment' link: < How to fix?
In the `loop.php` template file, you will find this line: <span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span> If you don't want "leave a comment" to display if comments are closed, you can wrap the call to `comments_popup_link()` in a `if ( comments_open() )` conditional, like such: <span class="comments-link"><?php if ( comments_open() ) comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span> Note: you may also want to check the other `loop-foobar.php` template files.
stackexchange-wordpress
{ "answer_score": 2, "question_score": 2, "tags": "comments" }
Is it possible to have two different previews of a post (ie. two templates for one post)? I'm looking for a way to allow post editors to see two different previews of the posts they are writing. On the front, the same post can appear it two different sections of the website (each shows a different amount of custom fields). How can I create two preview links (for ex : "Preview with template 1" and "Preview with template 2") ?
The easiest way to solve this is to create a special template file for previews, that will show the post twice in the different layouts. The following code will use the `single-preview.php` template file if it exists: add_filter( 'single_template', 'wpse15770_single_template' ); function wpse15770_single_template( $templates ) { if ( is_preview() ) { $templates = locate_template( array( 'single-preview.php', $templates ) ); } return $templates; } If you want to show the same post twice you must remember to add `rewind_posts()` in your `single-preview.php` template file, otherwise you can't loop over the posts again.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 2, "tags": "posts, templates, customization" }
WP as an HTML editor Is WP a good HTML editor? A friend of mine wants to create HTML pages, but doesn't know HTML. Can WP become a WYSIWIG HTML editor via the appropriate plugin? He'll be formatting images, wanting to place text in specific locations, etc. Nothing too fancy, but not just text either.
WordPress is a CMS (Content Management System) and not an editor. That being said WordPress does have a simple WYSIWIG style editor built into it for formatting the content that you want to post.
stackexchange-wordpress
{ "answer_score": 0, "question_score": 1, "tags": "visual editor" }