question
stringlengths 0
34.8k
| answer
stringlengths 0
28.3k
| title
stringlengths 7
150
| forum_tag
stringclasses 12
values |
---|---|---|---|
I have a very large Wordpress image bank (over 600 images, all in use...!) and a new development will mean that i would like to change some of the thumbnail settings. I have at the moment <code> set_post_thumbnail_size( 75, 75, true ); </code> In the functions, which of course means that the thumbnail is cropped to fit. I would like to change this so that the thumbnail is scaled, rather than cropped <code> set_post_thumbnail_size( 75, 75); </code> But will this change the current images i have? If not, is there a way of doing this? Thanks!
|
The Regenerate Thumbnails plugin will go through your media library and re crop all your images.
|
Wordpress thumbnail settings change
|
wordpress
|
As suggested on this site, I am using this code to style an excerpt if no post format is selected/if it is a standard post. <code> <?php $format = get_post_format(); if ( false === $format ) { echo 'This is a default post'; the_excerpt(); } ?> </code> However, it seems there must be a better way to include it with one PHP statement... the rest of which follows this pattern: <code> if ( has_post_format( 'video' )) { ?> A VIDEO POST <?php the_content(); } if ( has_post_format( 'audio' )) { ?> AN AUDIO POST <?php the_content(); } </code> Anybody know how to include the original code in this same if statement? If, then...
|
I'm not sure I understand. Do you just want to join all the if-statements together? If that's the case you could use elseif, like so: <code> <?php $format = get_post_format(); if ( false === $format ) { echo 'This is a default post'; the_excerpt(); } elseif ( has_post_format( 'video' )) { ?> A VIDEO POST <?php the_content(); } elseif ( has_post_format( 'audio' )) { ?> AN AUDIO POST <?php the_content(); } ?> </code>
|
A better code for no post format?
|
wordpress
|
is there a way to add a class to every nth item in a menu using wp_nav_menu? Trying to create columns but need to add a 'last' class to the 3rd item. cheers! Dc
|
got this working like this in the end... <code> function add_nthclass($items, $args){ $scb = get_object_vars($args); switch($scb['menu']) { case 'mainpages': $nth = 2; $items = explode('</li>',$items); $newitems = array(); // loop through the menu items, and add the new link at the right position foreach($items as $index => $item) { if(($index+1) % $nth == 0){ $newitems[] = str_replace('class="', 'class="last ', $item); }else{ $newitems[]= $item; } } // finally put all the menu items back together into a string using the ending <li> tag and return $newitems = implode('</li>',$newitems); case 'footer': // footer menu nth funcs... default: $newitems = $items; } // End switch return $newitems; } add_filter('wp_nav_menu_items', 'add_nthclass', 10, 2); </code>
|
wp_nav_menu, add class to every nth item?
|
wordpress
|
At the risk of sounding completely ridiculous, i'm posting this question here as the nature of my query doesn't seem to help me much from google. My wordpress default rss feeds makes use of post excerpt this feed is accessed via www.mydomain.com/feed I have a requirement to make another RSS feed that is full text. How can create an additional RSS feed (that is private/given to only trusted parties).. preferably using a function but a plugin (as a last resort)?
|
Here is how to create a custom feed: first create a new file in your theme's directory , name it <code> your-custom-feed.php </code> and put this code inside <code> <?php /** * custom RSS feed. * * @package WordPress */ header('Content-Type: ' . feed_content_type('rss-http') . '; charset=' . get_option('blog_charset'), true); $more = 1; echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?> <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" <?php do_action('rss2_ns'); ?> > <channel> <title><?php bloginfo_rss('name'); wp_title_rss(); ?></title> <atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" /> <link><?php bloginfo_rss('url') ?></link> <description><?php bloginfo_rss("description") ?></description> <lastBuildDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?></lastBuildDate> <language><?php echo get_option('rss_language'); ?></language> <sy:updatePeriod><?php echo apply_filters( 'rss_update_period', 'hourly' ); ?></sy:updatePeriod> <sy:updateFrequency><?php echo apply_filters( 'rss_update_frequency', '1' ); ?></sy:updateFrequency> <?php do_action('rss2_head'); ?> <?php while( have_posts()) : the_post(); ?> <item> <title><?php the_title_rss() ?></title> <link><?php the_permalink_rss() ?></link> <comments><?php comments_link_feed(); ?></comments> <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?></pubDate> <dc:creator><?php the_author() ?></dc:creator> <?php the_category_rss('rss2') ?> <guid isPermaLink="false"><?php the_guid(); ?></guid> <description><![CDATA[<?php the_excerpt_rss() ?>]]></description> <?php if ( strlen( $post->post_content ) > 0 ) : ?> <content:encoded><![CDATA[<?php the_content_feed('rss2') ?>]]></content:encoded> <?php else : ?> <content:encoded><![CDATA[<?php the_excerpt_rss() ?>]]></content:encoded> <?php endif; ?> <wfw:commentRss><?php echo esc_url( get_post_comments_feed_link(null, 'rss2') ); ?></wfw:commentRss> <slash:comments><?php echo get_comments_number(); ?></slash:comments> <?php rss_enclosure(); ?> <?php do_action('rss2_item'); ?> </item> <?php endwhile; ?> </channel> </rss> </code> then add a simple function to call that template file using <code> do_feed_$hook </code> <code> //load feed template function create_my_customfeed() { load_template( TEMPLATEPATH . 'your-custom-feed.php'); } add_action('do_feed_mycustomfeed', 'create_my_customfeed', 10, 1); </code> Now when you access <code> http://yoursite.com/?feed=mycustomfeed </code> you will get a full text feed, no mater what you define inside WordPress admin. Bonus if you want to create a rewrite rule for your custom feed so your url could be: <code> http://yoursite.com/mycustomfeed.xml </code> as well as a <code> http://yoursite.com/feed/mycustomfeed/ </code> add this code to your functions.php file: //create feed rewirte rule <code> function custom_feed_rewrite($wp_rewrite) { $feed_rules = array('feed/(.+)' => 'index.php?feed=' . $wp_rewrite->preg_index(1),'(.+).xml' => 'index.php?feed='. $wp_rewrite->preg_index(1)); $wp_rewrite->rules = $feed_rules + $wp_rewrite->rules; } </code>
|
How to create additional full text RSS feeds
|
wordpress
|
Hello I am working with my own template, and also using the post-to-post plugin, I am doing the following, <code> <ul> <?php global $post; global $related; ?> <?php query_posts('post_type=client'); ?> <?php $the_query = new WP_Query( array('post_type' => 'casestudy', 'connected' => $post->ID)); ?> <?php $content = $post->post_content; $link = $post->guid; $id = $post->ID; ?> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <?php $client = get_post_custom($post->ID); ?> <li> <img src="<?php echo $client['upload_image2'][0]; ?>" alt="<?php the_title(); ?>"/> <?php while ($the_query->have_posts()) : $the_query->the_post(); ?> <?php die("!"); ?> <?php $related = get_post_custom($post->ID); ?> <?php if(is_array($related)) : ?> <a href="<?php the_permalink(); ?>" class="case_study"><?php echo $content; ?></a> <?php endif; ?> <?php endwhile; ?> </li> <?php endwhile; endif; ?> <?php wp_reset_postdata(); ?> </ul> </code> However, I do not get into the second while, even though if I print_r $query_post it returns data. However If I then repeat the code again, it all works as I would expect, i.e the code goes into the second while loop, can anyone tell me why this would be happening?
|
did you try this? <code> $custom_query_args = array( 'post_type' => 'casestudy', 'connected' => $post->ID ); $the_query = new WP_Query(); $the_query->query($custom_query_args); </code>
|
problem with the loop
|
wordpress
|
I'm trying to remove the adjacent_posts_rel_link links under WP3.2, i.e. remove these from wp_head: <code> <link rel='prev' title='blah blah' href='http://...' /> <link rel='next' title='blah blah' href='http://...' /> </code> and this function used to work under 3.1: <code> function remove_header_info() { remove_action('wp_head', 'adjacent_posts_rel_link', 10, 0); } add_action('init', 'remove_header_info'); </code> But doesn't under 3.2. Anyone know or know how to find the new action to remove the links? Edit 7/15/11: the change is <code> adjacent_posts_rel_link_wp_head </code>
|
Answer: the change in 3.2 is from <code> adjacent_posts_rel_link </code> to <code> adjacent_posts_rel_link_wp_head </code>
|
Remove adjacent_posts_rel_link under 3.2?
|
wordpress
|
I'd like that my categories having child-categories don't be selectable on the post article page. What I want to do is to remove the checkbox before their label. I've looked the filter documentation but I wasn't able to find any filter that suits my need.
|
I really doubt this is filterable, so jQuery comes to rescue :) The Code <code> add_action( 'admin_footer-post.php', 'wpse_22836_remove_top_categories_checkbox' ); add_action( 'admin_footer-post-new.php', 'wpse_22836_remove_top_categories_checkbox' ); function wpse_22836_remove_top_categories_checkbox() { global $post_type; if ( 'post' != $post_type ) return; ?> <script type="text/javascript"> jQuery("#categorychecklist>li>label input").each(function(){ jQuery(this).remove(); }); </script> <?php } </code> The Result Advanced There's a caveat: whenever selecting a sub-category, it gets out of the hierarchy... So, the following is the code from the excellent plugin by Scribu, Category Checklist Tree , coupled with the previous code. On the post editing screen, after saving a post, you will notice that the checked categories are displayed on top, breaking the category hierarchy. This plugin removes that "feature". Either you use the previous code and install the plugin, or simply drop this in your theme's <code> functions.php </code> or in a custom plugin of yours (preferable, so all your tweaks will be theme independent). <code> /* Based on Category Checklist Tree, by scribu Preserves the category hierarchy on the post editing screen Removes parent categories checkbox selection */ class Category_Checklist { function init() { add_filter( 'wp_terms_checklist_args', array( __CLASS__, 'checklist_args' ) ); } function checklist_args( $args ) { add_action( 'admin_footer', array( __CLASS__, 'script' ) ); $args['checked_ontop'] = false; return $args; } // Scrolls to first checked category function script() { ?> <script type="text/javascript"> jQuery(function(){ jQuery('[id$="-all"] > ul.categorychecklist').each(function() { var $list = jQuery(this); var $firstChecked = $list.find(':checked').first(); if ( !$firstChecked.length ) return; var pos_first = $list.find(':checkbox').position().top; var pos_checked = $firstChecked.position().top; $list.closest('.tabs-panel').scrollTop(pos_checked - pos_first + 5); }); jQuery("#categorychecklist>li>label input").each(function(){ jQuery(this).remove(); }); }); </script> <?php } } Category_Checklist::init(); </code>
|
Make parent categories not selectable
|
wordpress
|
Right now I have pages like "about", "resources", etc and the urls are /about and /resources with a custom permalink structure as /%postname%. For "news" section it's the posts and it's at /news and that's great. The problem is I want the new stories to be /news/the-name-of-the-story not /the-name-of-the-story. Can that be accomplished in the wp admin area? Or is that a custom .htaccess trick? Also, news is in categories and /category/category-name lists the posts in that category and the story for those should be at /category/category-name/the-name-of-the-story. Is this even possible?
|
The custom permalink field on the settings-> permalink screen only applies to Posts. Not to Pages. WordPress Pages always live at the "top" of the URL tree. /about /whatever /etc. Posts live wherever the custom permalink string defines them to be. So, in your case, your permalinks custom structure would be "/news/%postname%/" and would not affect your Pages permalinks of "/about" and "/resources". For instance, to put all Posts under the sub-directory "/blog", your permalinks custom structure would be "/blog/%postname%/".
|
How would I create a different permalink structure for pages and posts?
|
wordpress
|
I'd like to style differently the content before the link, but in single.php. To be more specific, all my posts on the homepage only have a summary, and the rest of the text is cut thanks to the use of the more tag. So when I click on "read more" I see the complete post, starting with the summary we previously seen on the homepage. I'd like to differentiate this summary from the rest of the text, adding it some bold for example, to show to the user what he as already read. Unfortunately I think this is not possible. Is it ?
|
using: http://codex.wordpress.org/Function_Reference/the_content#Overriding_Archive.2FSingle_Page_Behavior and the $strip_teaser parameter: http://codex.wordpress.org/Function_Reference/the_content#Usage in single.php, replace <code> <?php the_content(); ?> </code> with: <code> <?php if( strpos(get_the_content(), '<span id="more-') ) : ?> <div class="before-more"> <?php global $more; $more=0; the_content(''); $more=1; ?> </div> <?php endif; ?> <?php the_content('', true); ?> </code>
|
Style the text before in single.php
|
wordpress
|
I would like to have a separate custom page where the logged in users can post their content. Add post title, add content, add check boxes, image/file uploads, Is there any way to do so?
|
Maybe scribu 's Front end Editor would be an easy way to update your website if your client finds the WP admin to be " confusing and difficult ". But also bare in mind that the admin is customizable through admin themes , as well as various scripts and plugins . To cite only one plugin, try Adminimize , it will allow you to remove a lot of unnecessary stuff from the interface.
|
how to have custom post template including custom write panels for the users to post
|
wordpress
|
To solve this problem i've used this in my js file: <code> var location = String(window.location); //only runs in post.php and post-new.php if(location.search('post.php') != -1 || location.search('post-new.php') != -1 ) { } </code> But it's does not seem like i solid solution. Are there any other way?
|
You can use this in your <code> functions.php </code> : <code> function add_admin_scripts( $hook ) { if ( $hook == 'post-new.php' ) { wp_enqueue_script( 'myscript', get_bloginfo('template_directory').'/js/myscript.js' ); } } add_action('admin_enqueue_scripts','add_admin_scripts',10,1); </code>
|
Execute script only on certain admin pages
|
wordpress
|
I have this code that adds the check box to the 'Edit User' page but when i check it, and refresh the page, the box becomes unchecked... what is wrong? <code> add_action( 'show_user_profile', 'module_user_profile_fields' ); add_action( 'edit_user_profile', 'module_user_profile_fields' ); function module_user_profile_fields( $user ) { ?> <h3>Module Options</h3> <table class="form-table"> <tr> <th><label for="module_activation">Module Activation</label></th> <td> <input id="module_activation" name="module_activation" type="checkbox" value="<?php echo esc_attr( get_the_author_meta( 'module_activation', $user->ID )); ?>" <?php if ( get_the_author_meta( 'module_activation', $user->ID ) == 1 ) echo ' checked="checked"'; ?> /> <span class="description"><?php _e("Please enter your address."); ?></span> </td> </tr> </table> <?php } add_action( 'personal_options_update', 'save_module_user_profile_fields' ); add_action( 'edit_user_profile_update', 'save_module_user_profile_fields' ); function save_module_user_profile_fields( $user_id ) { if ( !current_user_can( 'edit_user', $user_id ) ) { return false; } update_usermeta( $user_id, 'module_activation', $_POST['module_activation'] ); } </code> EDIT Here is what i got to work. <code> add_action( 'show_user_profile', 'module_user_profile_fields' ); add_action( 'edit_user_profile', 'module_user_profile_fields' ); function module_user_profile_fields( $user ) { ?> <h3>Module Options</h3> <table class="form-table"> <tr> <th><label for="module_activation">Module Activation</label></th> <td> <input id="module_activation" name="module_activation" type="checkbox" value="1" <?php if ( get_the_author_meta( 'module_activation', $user->ID ) == 1 ) echo ' checked="checked"'; ?> /> <span class="description"><?php _e("Please enter your address."); ?></span> </td> </tr> </table> <?php } add_action( 'personal_options_update', 'save_module_user_profile_fields' ); add_action( 'edit_user_profile_update', 'save_module_user_profile_fields' ); function save_module_user_profile_fields( $user_id ) { if ( !current_user_can( 'edit_user', $user_id ) ) { return false; } update_usermeta( $user_id, 'module_activation', $_POST['module_activation'] ); } </code>
|
your function never defines a value for that field so when you check if its equal to 1 you never get true. try this: <code> add_action( 'show_user_profile', 'module_user_profile_fields' ); add_action( 'edit_user_profile', 'module_user_profile_fields' ); function module_user_profile_fields( $user ) { ?> <h3>Module Options</h3> <table class="form-table"> <tr> <th><label for="module_activation">Module Activation</label></th> <td> <input id="module_activation" name="module_activation" type="checkbox" value="1" <?php if ( get_the_author_meta( 'module_activation', $user->ID ) == 1 ) echo ' checked="checked"'; ?> /> <span class="description"><?php _e("Please enter your address."); ?></span> </td> </tr> </table> <?php } add_action( 'personal_options_update', 'save_module_user_profile_fields' ); add_action( 'edit_user_profile_update', 'save_module_user_profile_fields' ); function save_module_user_profile_fields( $user_id ) { if ( !current_user_can( 'edit_user', $user_id ) ) { return false; }else{ if(isset($_POST['module_activation']) && $_POST['module_activation'] > 0){ update_usermeta( $user_id, 'module_activation', $_POST['module_activation'] ); }else{ delete_usermeta($user_id, 'module_activation'); } } } </code>
|
Add extra field to users
|
wordpress
|
I've been able to setup and use a couple different LDAP plugins (CoSign SSO, Simple LDAP Logon) to create new WordPress users based on the Active Directory users but it still requires them to manually log in to make posts. Is there a way to have it pull the user's credentials from the browser and automatically log them in whenever they visit the WordPress site? I have IIS set up with Windows Authentication and the URL is listed in the browser as one it can trust and send credentials to. Do I need another plugin or would this require editing a page or two in WordPress? thanks
|
If using Windows Authentication with IIS PHP can read the current authenticated user thats logged on from <code> $_SERVER["LOGON_USER"]; </code> If this is set and the user is not getting a HTTP auth prompt you can assume the user credentials are correct. So with some WP coding you could read that <code> $_SERVER['LOGON_USER'] </code> and if not logged into WP auto log them in with that username. place in theme functions file or in a MU plugins file. <code> function auto_login() { if (!is_user_logged_in() && isset($_SERVER['LOGON_USER'])) { $user_login = $_SERVER['LOGON_USER']; $user = get_userdatabylogin($user_login); $user_id = $user->ID; wp_set_current_user($user_id, $user_login); wp_set_auth_cookie($user_id); do_action('wp_login', $user_login); } } add_action('init', 'auto_login'); </code> You may need to do some further tweaking to the <code> $user_login </code> variable so that you get the correct username that matches in the WP table.
|
Auto login using Active Directory and Windows Authentication
|
wordpress
|
I am searching for a plugin with the following properties, any suggestions would be appreciated: All events should able to be organised either by date or subject, searchable by visiting users and should include the capability to auto-expire. Each event should include a general description, venue details (date / time / area etc) and related images or videos. Users must be able to subscribe to an email notification mechanism which informs them about upcoming events. Calendar must also provide an approval workflow process prior the publishing of an event.
|
I'll give various types of calendar's, you choose any one of them as your needs. Sample Calendar . I think some combination is too good. :)
|
Suggestion for Calendar of Events Plugin
|
wordpress
|
Hy guys, I have some problems with my taxonomies... here my code: define('REVIEWS_SLUG', 'review'); define('REVIEWS_CATEGORY_SLUG', 'review-category'); function create_reviews_section(){ $labels = array( 'name' => __('Reviews'), 'singular_name' => __('review'), 'add_new' => __('Add New'), 'add_new_item' => __('Add New Review'), 'edit' => __('Edit'), 'edit_item' => __('Edit Review'), 'new_item' => __('New Review'), 'view' => __('View'), 'view_item' => __('View Review'), 'search_items' => __('Search Reviews'), 'not_found' => __('No reviews found'), 'not_found_in_trash' => __('No reviews found in Trash'), ); register_post_type('reviews', array( 'labels' => $labels, 'description' => __('Reviews Section'), 'public' => true, 'show_ui' => true, 'publicly_queryable' => true, 'exclude_from_search' => false, 'supports' => array('title', 'editor', 'custom-fields', 'excerpt', 'comments', 'author'), 'rewrite' => array('slug' => REVIEWS_SLUG, 'with_front' => true), 'query_var' => false, 'taxonomies' => array('review-category') ) ); } function create_review_category(){ $labels = array( 'name' => _x('Review Categories', 'Review Categories'), 'singular_name' => _x('Review Category', 'Review Category'), 'search_items' => __('Search Review Categories'), 'popular_items' => __('Popular Review Categories'), 'all_items' => __('All Review Categories'), 'edit_item' => __('Edit Review Category'), 'update_item' => __('Update Review Category'), 'add_new_item' => __('Add New Review Category'), 'new_item_name' => __('New Review Category'), 'separate_items_with_commas' => __('Separate review categories with commas'), 'add_or_remove_items' => __('Add or remove review categories'), 'choose_from_most_used' => __('Choose from the most used review categories'), 'menu_name' => __('Categories') ); register_taxonomy('review-category', array('reviews'), array( 'hierarchical' => true, 'labels' => $labels, 'show_ui' => true, 'query_var' => true, 'rewrite' => array('slug' => REVIEWS_CATEGORY_SLUG), )); First problem is that wordpress doesn't recognize this taxonomy as hierarhical. For example when I generate a dropdown with this taxonomy and depth="1", return all taxonomies (parents & childs). Second problem: when I'm trying to insert a new term (with wp_insert_term) is telling me that the taxonomy it's not valid. Third problem: I thought that child taxonomy url will be like: domain.com/review-category/parent-taxonomy/child-taxonomy/ but in my case is: domain.com/review-category/child-taxonomy/. How I can modify the url to something like that ? Thanks in advance ;) LE: add_action('init', 'create_reviews_section'); add_action('init', 'create_review_category', 0); $args = array( 'show_option_none' => 'Choose make', 'hide_empty' => 0, 'name' => 'vehicle_category', 'id' => 'vehicle_category', 'taxonomy' => 'review-category', 'hierarchical' => 0, 'class' => 'maxw', 'depth' => 1 ); wp_dropdown_categories( $args );
|
For question one, reading the following from the codex makes me think you need to change <code> hierarchical </code> to 1: depth (integer) (optional) The max depth. This is ignore unless hierarchical is set to true. Default: 0/False hierarchical (boolean) (optional) Display all categories (0/False) or display categories (1/True) to a depth of 'depth'. Default: 0/False
|
Taxonimies for custom post types
|
wordpress
|
I would like to have a page with downloadable items like PDFs, but I would like the user to be required to insert email details before being able to download the files, although he would be able to view the files available even before providing the email address. The system must also ask only once for the email, and then maybe keep a cookie so that it won't ask for each download requested. Is there a plugin or code hack available for this? Thanks
|
I spent a long time looking. The best today seems to be http://wordpress.org/plugins/ss-downloads/ or if you want something more complex, https://easydigitaldownloads.com/
|
Ability to download only after email supplied
|
wordpress
|
I'm loading wp-load.php in order to access WP functions inside of a PHP file that I'm using to process form submissions. Everything works perfectly fine on localhost and every server I've tested (except one). It does not, however, work on one particular server (which is running on rackspace). I'm loading it like this: <code> $oldURL = dirname(__FILE__); $newURL = str_replace(DIRECTORY_SEPARATOR . 'wp-content' . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . 'cgc-post-image-gallery' . DIRECTORY_SEPARATOR . 'includes', '', $oldURL); include($newURL . DIRECTORY_SEPARATOR . 'wp-load.php'); </code> This is in a file called process-submission.php that is called when the form is submitted. The error is thrown after the form is submitted. Unfortunately, the server is configured such that it does not display what the actual error is, only that an error has occurred. The really weird thing is that I have another plugin running (that I wrote) on the exact same server and site that is loading wp-load.php in the exact same manner, except it works perfectly fine! Through some testing I have been able to determine that the error is thrown the moment the include() function is reached. I thought perhaps this file loading wp-load.php and the other plugin (the one that is working) loading the file might be causing a conflict, but the other one still works perfectly fine. Also, neither of the files are ever actually loaded in WP (only accessed from the form on the front end), so there is no redeclaring of anything. Any ideas why including wp-load.php would throw an error in this instance, but not the other? The problem also occurs if I try to load wp-blog-header.php
|
Ok, I've fixed it. Turns out that there was a php class name that was getting redeclared. Declared once in the theme, and once in the plugin.
|
Loading wp-load.php in an external PHP file throws unknown error
|
wordpress
|
Hierarchical taxonomy of custom post type 'projects' > 'projects_category'. Two example 'projects_category' hierarchies would be: Big Corporates > 1st Company Name > A Post Title Small Business > 2nd Company Name > Another Post Title I can get '1st Company Name' with the following: <code> <?php $terms = get_the_terms($post->ID, 'projects_category');foreach($terms as $term){echo $term->name;} ?> </code> How can I display 'Big Corporates' or 'Small Business' as appropriate in single.php ?
|
I've marked up anu's answer and get_ancestors explanation, however this is how I solved it: <code> <?php $terms = wp_get_object_terms($post->ID, 'projects_category', array('orderby' => 'term_id', 'order' => 'ASC') ); if ( !empty( $terms ) ) : $project = array(); foreach ( $terms as $term ) { $project[] = $term->name; } echo '<h1>'.$project[0].'</h1>'; echo '<h2>'.$project[1].'</h2>'; endif; ?> </code>
|
get taxonomy name of current post
|
wordpress
|
I have a tag page that is generated with the first image attachments from all of the posts. I call it in the loop with : <code> <img src="<?php echo get_first_attachment() ?>" /> </code> and this is the function : <code> function get_first_attachment(){ $querystr = " SELECT wp_posts.post_excerpt AS 'imageTitle', wp_posts.guid AS 'imageGuid' FROM wp_posts WHERE wp_posts.post_parent = ".get_the_ID()." AND wp_posts.post_type = \"attachment\" ORDER BY \"menu_order\" LIMIT 1 "; global $wpdb; $url = get_bloginfo('url'); $post_item = $wpdb->get_row($querystr); $first_attachment = $post_item->imageGuid; $not_broken = @fopen("$first_attachment","r"); // checks if the image exists if(empty($first_attachment) || !($not_broken)){ //Defines a default image unset($first_attachment); }else{ $first_attachment = str_replace($url, '', $first_attachment); } return $first_attachment; } </code> This works great with regular posts but not my custom post types. Which are in the post_type portfolio. <code> $args = array( 'labels' => $labels, 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'query_var' => true, 'rewrite' => true, 'capability_type' => 'post', 'hierarchical' => false, 'menu_position' => 4, 'taxonomies' => array('post_tag','category'), 'supports' => array('title','editor','comments','trackbacks','revisions','custom-fields','page-attributes','thumbnail', 'excerpt', 'tags') ); register_post_type( 'portfolio' , $args ); } </code> Looking at the tables Both post and portfolio share post_type = attachment, however different in that one has post_type = post and the other = portfolio. I do not understand the SELECT .. post_excerpt is a blank column and guid is just full of urls. I am confused. Thanks for any help. I figured out that the image attachment has nothing to do with it, my custom post type is not being included in the tag loop... I will post more code once I figure out what it is I am looking for.
|
I'd try to get rid of custom query altogether. Try something like: <code> $attachments = get_posts(array( 'post_type' => 'attachment', 'post_parent' => get_the_ID(), 'numberposts' => 1, )); </code>
|
Why doesnt my tag page populate with this custom post type?
|
wordpress
|
I would like to add avatars to my users. I have a limited group on a site I'm working. Uploading isn't really a problem we can just put the images on the server and use URL's to set our avatars(Only about 5 people will actually be able to post.). That said how would I add a field to the user page they can fill out with a image URL that can then be fetched later. I know you can fetch user data via the <code> the_author_meta(); </code> function but how do I add a custom user field that can them be filled out and put into the database that is the associated with the user? Or would if just be better to use something that already exist like the <code> aim </code> field for example since none of us will be filling that out.
|
To add a field to the profile/user edit page you need to use the <code> edit_user_profile </code> hook and <code> show_user_profile </code> hook so: <code> add_action( 'show_user_profile', 'my_extra_user_fields' ); add_action( 'edit_user_profile', 'my_extra_user_fields' ); function my_extra_user_fields( $user ) { ?> <h3>User avatar</h3> <table class="form-table"> <tr> <th><label for="user_avatar">User avatar</label></th> <td> <input id="user_avatar" name="user_avatar" type="text" value=" <?php $user_avatar = get_the_author_meta( 'user_avatar', $user->ID ); echo $user_avatar ? $user_avatar : '';?>" /> <span class="description"><?php _e("Please enter Avatar URL."); ?></span> </td> </tr> </table> <?php } </code> then to save that field you need to use <code> personal_options_update </code> hook and <code> edit_user_profile_update </code> hook so: <code> add_action( 'personal_options_update', 'save_my_extra_user_fields' ); add_action( 'edit_user_profile_update', 'save_my_extra_user_fields' ); function save_my_extra_user_fields( $user_id ) { if ( !current_user_can( 'edit_user', $user_id ) ) { return false; }else{ if(isset($_POST['user_avatar']) && $_POST['user_avatar'] != ""){ update_usermeta( $user_id, 'user_avatar', $_POST['user_avatar'] ); } } } </code> and as you already know you can featch that data using <code> the_author_meta() </code> or <code> get_user_meta() </code>
|
How do you add a custom option to user data?
|
wordpress
|
I want to add a jQuery dialog modal to a form page. When the dialog box is triggered I see the the text content but with no CSS. I'm pulling in the jquery in the functions.php for the page: <code> wp_enqueue_script('jquery-ui-dialog'); </code> The jquery css (jquery-ui-dialog.css) is under my wp-includes/css directory. I tried adding <code> wp_enqueue_style('jquery-ui-dialog'); </code> but it not work. Does anybody know the proper way to enable jQuery Dialog.
|
There is no <code> jquery-ui-dialog </code> style defined in WordPress Out of the box, you need to ue the stylesheets manually, when i needed to enqueue the jQuery-UI style i pulled it from google api CDN <code> wp_enqueue_style('jquery-style', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css'); </code> but you can enqueue a local copy if you want like this: <code> wp_enqueue_style( 'myStylesheet', WP_PLUGIN_URL . '/path/stylesheet.css' ); </code>
|
CSS not pulling in for jQuery UI dialog
|
wordpress
|
I need to make an SQL call to find all records in wp_options matching a select statement. How do I query the table? My script already has these resources called... <code> require_once('../../../wp-blog-header.php'); require_once('../../../wp-admin/includes/file.php'); </code>
|
All of database querying is handled by global <code> $wpdb </code> object. So when you load WP core you have acess to it and all its methods for queries.
|
wordpress how to query wp_options table
|
wordpress
|
I've tried to import an option value via update_options($name, $value) where $value has special characters (like apostrophe's for example) and I've noticed that the apostrophe gets stripped out of the text before it reaches the database. What is the suggested sanitization of strings prior to sending them to update_options()?
|
Try <code> esc_html( $string ) </code> ( Codex ref ), which among other things encodes single- and double-quotes. For further reference, see the Data Validation entry in the Codex.
|
How to properly sanitize strings for update_option()
|
wordpress
|
I'm working on creating a plugin out of some custom code I use a lot, in hopes that other people find it useful too. It works, so yay! but... Here's my question: I feel like I'm missing some puzzle pieces in my understanding of the system. What happens to all the code I add and hook everywhere after I deactivate my plugin? In my main .php file, when is the code that's not in a function being executed? Only at install? Then what is the purpose of <code> register_activation_hook( __FILE__,'install_method'); </code> ? If I put <code> add_action </code> and <code> add_filter </code> in my main php file, do I have to remove them at uninstall? (For example, I know that if I <code> add_option('option', '0', '', 'yes'); </code> during install I have to <code> delete_option('option'); </code> at uninstall.) In some tutorial, they told me to put <code> if ( is_admin() ) {} </code> around my code, is this necessary?
|
filters and actions are added with every request . when you disable a plugin, they immediately disappear, because they only exist in your plugin code. this is how you're able to selectively add them on a per-request basis. you only need to remove filters or actions if you don't want them to run in the current request. <code> is_admin() </code> is a check if the admin pages are being displayed, and should wrap things only for admin pages.
|
Where do I put my add_action(... and add_filter(... and do I need to remove them?
|
wordpress
|
My theme gives the site owner the option of using each post's "Excerpt" field to fill in the "meta description" tag for each page. It would be helpful if I can filter the text label and description text that appears on the default Excerpt input control when viewed inside the post editor. Does a filter or hook exist for this? Alternately, I suppose I could use jQuery to do something via the DOM.
|
there is a filter hook you can use and it is <code> gettext </code> here: <code> add_filter( 'gettext', 'wpse22764_gettext', 10, 2 ); function wpse22764_gettext( $translation, $original ) { if ( 'Excerpt' == $original ) { return 'My Excerpt label'; }else{ $pos = strpos($original, 'Excerpts are optional hand-crafted summaries of your'); if ($pos !== false) { return 'My Excerpt description'; } } return $translation; } </code>
|
How to alter the text of the post "Excerpt" box label in WordPress post editor?
|
wordpress
|
I found this wonderdul script that @Bainternet here at Wordpress Answers created, that makes it possible to attach images into posts from a html form.. I tried to combine in into my "html form to post" script.. I does create a post as draft in the backend.. but the image does not show up, and it doesn't show in "media" .. This is @Bainternet script/answer, stackexchange-url ("Submit post and upload image from front-end") This is mine, <code> <?php if(isset($_POST['new_post']) == '1') { $post_title = $_POST['post_title']; $post_category = 'fashion'; $post_content = $_POST['post_content']; $new_post = array( 'ID' => '', 'post_author' => $user->ID, 'post_category' => array($post_category), 'post_content' => $post_content, 'post_title' => $post_title, 'post_status' => 'draft' ); $post_id = wp_insert_post($new_post); if (!function_exists('wp_generate_attachment_metadata')){ require_once(ABSPATH . "wp-admin" . '/includes/image.php'); require_once(ABSPATH . "wp-admin" . '/includes/file.php'); require_once(ABSPATH . "wp-admin" . '/includes/media.php'); } if ($_FILES) { foreach ($_FILES as $file => $array) { if ($_FILES[$file]['error'] !== UPLOAD_ERR_OK) { return "upload error : " . $_FILES[$file]['error']; } $attach_id = media_handle_upload( $file, $post_id ); } } if ($attach_id > 0){ //and if you want to set that image as Post then use: update_post_meta($post_id,'_thumbnail_id',$attach_id); } // This will redirect you to the newly created post $post = get_post($post_id); wp_redirect( 'http://domain.com' ); } ?> <form method="post" action=""> <input type="text" name="post_title" size="45" id="input-title" value="heading"/><br> <input type="text" name="post_url" size="45" id="input-url" value="Url"/><br> <input type="file" name="thumbnail" id="thumbnail"><br> <textarea rows="5" name="post_content" cols="66" id="text-desc"></textarea> <br> <input type="hidden" name="new_post" value="1"/> <br> <input class="subput round" type="submit" name="submit" value="Post"/><br> </form> </code>
|
I think the problem is with your form tag missing <code> enctype="multipart/form-data" </code> so try changing: <code> <form method="post" action=""> </code> to: <code> <form method="post" action="" enctype="multipart/form-data"> </code> and as a side note, if you want to redirect to the newly created post change: <code> wp_redirect( 'http://domain.com' ); </code> to: <code> wp_redirect( get_permalink($post_id)); exit(); </code> Update: From the comments i understand that want the image to show inside the content, well that is a different thing but not that hard, change: <code> if ($attach_id > 0){ //and if you want to set that image as Post then use: update_post_meta($post_id,'_thumbnail_id',$attach_id); } </code> to: <code> if ($attach_id > 0){ $post = get_post($post_id,'ARRAY_A'); $image = wp_get_attachment_image_src( $attach_id ); $image_tag = '<img src="'.$image[0].'" width="'.$image[1].'" height="'.$image[2].'" />'; //add image above the content $post['post_content'] = $image_tag . $post['post_content']; //add image under the content //$post['post_content'] = $post['post_content'] . $image_tag; $post_id = wp_update_post( $post ); } </code>
|
Create post from form with image
|
wordpress
|
I recently stackexchange-url ("asked a question") about l18n for WordPress terms like "Taxonomy", "Plugin", "Custom Post Type", etc. I was wanting to get some input on whether to translate these terms or not. Scribu made a great point suggesting that WordPress translates them and therefore, they should be translated in plugins. Also, he made a great suggestion that I could use the WordPress translations if I do not assign these terms a new textdomain. My new question is, how would this be best implemented. For instance, imagine I had an text input and I wanted to label it with "Taxonomy Name". Would it make sense to do the following: <code> <label><?php echo __('Taxonomy') . ' ' . _x('Name', 'text input label', 'my_plugin_domain'); ?></label> </code> This looks hideous, but I would be able to take advantage of WordPress' l18n. Also, I'm uncertain of this method because it does not take advantage of argument swapping with printf. I'm not sure if you can mix the WordPress and custom l18n within argument swapping. Any advice on how to go about handle this?
|
Only use the internal translations if you use the complete string without any addition. Grammar rules, writing directions etc may be different in your user’s language and your order may not match their needs. You example would be Taxonomiename or Name der Taxonomie in German. How should a translator handle this? So, use: <code> <?php echo _x('Taxonomy Name', 'text input label', 'my_plugin_domain'); ?> </code>
|
Mixing l18n string from my plugin with WordPress' translations
|
wordpress
|
I've been building some WordPress themes and plugins. What are the online marketplaces I can sell them?
|
here is a nice brake down for you: MarketPlaces Themes: Theme Forest - Probably the biggest theme marketplace by Evanto. Rates: New authors begin at the 50% . Templamatic - Rates: between 50% and 70% . BuyStockDesign - Rates: Start from 50% to 75% . BuySellWordpress - Rates: Starts from 50% and may go up to 70% . WPmart - Free listing. Plugins: Code Canyon - Probably the biggest Plugin marketplace again by Evanto. - Rates: New authors begin at the 50% WPPlugins - The only other major plugin market place by Incsub. - Rates: 70% fixed. WPmart Forums There is a lot of potential for selling templates on webmaster and webdev forums with marketplaces and very high traffic: Webmaster-Talk TalkFreelance Digital Point Other Designers and Developers Two approaches here Contact Designers and Developers who are selling in there own sites and ask to list your theme/plugin for a cut of the profit (negotiate well). Contact Designers, Developers and Website builders look for there portfolios and see if you have a product (theme/plugin) they would need and use, offer to license a such product so they could use for there customers. and lastly, Sell on your Own site Its harder then any other option but you get to keep 100% of the profits so if you market your self the right way you won't need any of the places listed here :)
|
Where can I sell WordPress themes and plugins?
|
wordpress
|
We have customers that come from other sites and I would like to retain a url parameter /?lead=openeye throughout the time that they're browsing. That way when they fill out a form I can capture the lead for sales. How do I retain url parameters the entire time they're browsing the site. Update.. I've began using a combination of sessions and cookies to accomidate this. It sort of works but doesn't seem to stick for more than a few seconds between pages. In the header <code> <?php $lead = $_GET['lead']; $_SESSION['lead'] = $lead; $url = parse_url(get_bloginfo('url')); setcookie("lead", $lead, 0, $url['path'], $url['host']); (set) ?> </code> To test <code> <?php echo ($_COOKIE['lead']); // Lead Cookie ?> </code>
|
Better Answer: <code> session_start(); $lead = $_GET['lead']; $_SESSION['lead'] = $lead; </code> Then, create an additional field on the form, with the input hidden. For the value, I would echo out the $_SESSION, with a name that is easy to grab (lead works). then, wherever the form is processed, just add a line to grab the lead, and do with it what you want. –
|
How do I retain url parameters the entire time a user browses my site?
|
wordpress
|
What's the earliest possible action I can hook into where I'll be able to access the global <code> $post/$posts </code> variables on both the front and back ends? I've tried looking through the Codex reference, Adam Brown's reference and skimming through the source several times but haven't had much luck finding a good one. <code> pre_get_posts </code> is too early; Using <code> posts_selection </code> doesn't work if you want to make a second get_posts() call during the callback; and <code> template_redirect </code> doesn't run on the admin side. <code> the_post </code> might be earlier than <code> template_redirect </code> for the front end, but it also doesn't run on the back end. Ideally I'd want something that runs right before <code> get_post()/get_posts() </code> returns, but I'm not seeing anything like that. I've used the <code> the_posts </code> filter in the past, but I'd prefer an action because it's more technically correct. Right now I'm just hooking in twice; once using <code> template_redirect </code> for the front end, and again using <code> admin_xml_ns </code> for the back end. I don't really like that, though, since the my logic isn't semantically related to either of those hooks, and it seems like this is a very common need and there should be a hook like "post_get_posts" (ala <code> pre_get_posts </code> ) that works on both sides.
|
For all admin pages and front end pages except individual post edit screens ( <code> wp-admin/post.php </code> ), <code> 'wp' </code> is the most reliable hook for getting the global values. http://phpxref.ftwr.co.uk/wordpress/nav.html?wp-includes/class-wp.php.source.html#l486 You can see there that it fires immediately after <code> WP::main() </code> fires <code> WP::register_globals() </code> . The problem with using things like <code> post_results </code> and <code> get_posts </code> is that it will run every time you make a query for posts. <code> 'wp' </code> only fires in the function <code> WP::main() </code> , which is what WP core uses to run the page's main request query. For post edit screens, it looks like the first hook you can use reliably would be <code> 'add_meta_boxes' </code> . You would just need to make sure that you're on a core page when hooking in, although it does pass the global <code> $post </code> object as the second argument (the first being the <code> $post_type </code> of the current post).
|
Earliest hook to reliably get $post/$posts
|
wordpress
|
After transferring a working WordPress site to GoDaddy hosting, we've begun getting "Error establishing a database connection" errors on all pages- first intermittently, and now consistently. It's strange because it worked most of the time, at least at the beginning, but now errors all the time. This is all within the first few hours of our install- I'm wondering if this might be a database caching issue on WordPress? Is there a cache to clear? Thanks-
|
-First, try contacting the hosting provider if the database server is online / if they have any other problem at their end, or they made any changes to your account, or if there are any limitations/restrictions, etc . double check your wp-config.php file settings for the database name, database username and database password. This is where most errors occur. -Then check that you don't need to change the database host from "localhost" to something else. You can get that info from your hosting provider. -Check you have actually created a database with the same database name as is in your wp-config.php file. -Last, but not least, if all that information is correct your database probably has a problem with it, and you may need to contact your hosting provider. There are also many threads on this topic on WP forums: http://wordpress.org/search/Error+establishing+a+database+connection?forums=1
|
"Error establishing a database connection" - Intermittent error on GoDaddy
|
wordpress
|
When creating a user in Wordpress an email address is required for that user. The website I'm working on requires that users remain anonymous (it's part of a research study) and I'd consider email to be an identifying piece of data. Users will be added manually, so email is not required to confirm accounts or prevent spam sign-ups. Am I going to have to provide a fake email address for each account, or is there a way to leave this field blank?
|
It's possible, just no so easily via the Users page without some hackery. The WordPress API will let you insert users without email addresses, so a little custom plugin to accept a login name and password, and a call to <code> wp_insert_user </code> or <code> wp_update_user </code> should work for you. Unfortunately I don't have time to code it up for you, but perhaps this will point you in a direction. <code> $userdata = array ('user_login' => 'someuser', 'user_pass' => 'swordfish'); $new_user_id = wp_update_user( $userdata ); </code>
|
User Without Email?
|
wordpress
|
I have 3 shortcodes. Each of them will be displaying a list. PS> the lists do NOT contain wordpress posts/pages. Is there any WordPress plugin that can achieve the purpose? OR Please suggest me a jQuery plugin that uses Ajax to fetch subsequent paged data and can work with my scenario.
|
I've used jpaging before which is simple ,easy and highly customizable.
|
WordPress/jQuery pagination plugin for multiple lists
|
wordpress
|
I have a Multi-Site installation of Wordpress, with multiple subdomains, but only one of the subdomains has an SSL certificate. The domains are such: www.example.com blog1.example.com blog2.example.com secure.example.com <code> secure.example.com </code> is the subdomain which has a SSL cert installed. If someone types in <code> blog1.example.com/wp-admin/dashboard.php </code> , how can I force them to <code> secure.example.com/wp-admin </code> and then after they log in redirect them back to <code> blog1.example.com/wp-admin/dashboard.php </code> ?
|
I would recommend using Peters Login Redirect to redirect users after login I have used it before and works well. You could redirect users to the secure area by adding the below to your .htaccess file : <code> Redirect 301 blog1.example.com/wp-admin/dashboard.php secure.example.com/wp-admin </code>
|
How can I force users to a particular subdomain to log in for MU (Multisite)?
|
wordpress
|
I'm attempting to set up a fairly long multi-part form (~50 questions, a few questions per page) with conditional logic. I'd like to offer registered visitors the ability to save their data between each page/step and give them the option to return later to finish. I have Gravity Forms and thought that might work, but it sounds like this isn't functionality they offer yet. Does anyone have any advice/suggestions on other form plugins or code which might meet these requirements? Thanks in advance for all your help!
|
If you are working on a custom theme, I believe it is easier to be done with a page template and WordPress's wp_ajax function. The form can be included in the page using <code> <?php get_template_part('form','0f-50-question') ?> </code> . Here is the pseudo code for the form <code> <form id="quite-a-long-form" action="<?php echo admin_url('admin-ajax.php'); ?>" method="post" class="form" > $step = $_GET['step'] if $step = 1 //first section of question echo <label> echo <input> echo <label> echo <input> else if $step = 2 //second section of question echo <label> echo <input> echo <label> echo <input> else if $step = 3 //third section of question echo <label> echo <input> echo <label> echo <input> // just repeat for all sections endif <input type="Submit"> <?php wp_nonce_field('input-answer','security-code-here'); ?> <input name="action" value="input-answer" type="hidden"> </form> </code> And for the php that will process the file <code> function process_add_transfer() { if ( empty($_POST) || !wp_verify_nonce('security-code-here','add_transfer') ) { echo 'You targeted the right function, but sorry, your nonce did not verify.'; die(); } else { // do your function here wp_redirect($_POST['_wp_http_referer'].'?step='.$index_of_the_next step); } } </code> Hope this help
|
Best way to create multi-step form with data saved to user account for later updating?
|
wordpress
|
When you create a plugin and set up a process function, Wordpress will run the plugin process function twice upon clicking the update button. I believe the first process is for the versioning (revision) post, and the second the actual post. Now, I've got an INSERT function in my process, so it is now inserting the data twice. What is the best way to ensure that processing doesn't happen while creating the revision and and only on the actual post processing? * Note: Targeting Wordpress 3.0+ * An Example (complete plugin): <code> <?php /* Plugin Name: Something Amazing Plugin URI: http://www.somewhere.com/ Description: Displays something. Author: Some guy Version: 1.0 Author URI: http://www.somewhere.com/ */ function call_something() { return new something(); } if (is_admin()) add_action('load-post.php','call_something'); class something { public function __construct() { add_action('add_meta_boxes',array(&$this,'something_add_boxes')); add_action('save_post',array(&$this,'something_process'),1,1); } public function something_add_boxes() { add_meta_box('something','Some Thing',array(&$this,'something_form'),'post','side','default'); } public function something_form($post,$args) { echo '<p><input type="text" name="somethingnew" /></p>'; } public function something_process($id) { echo 'hey there! I'm going to cause a redirect warning, but you will see this line twice per submit!'; //do_something_amazing(); } } ?> </code> Perhaps there is a better hook to use to process that doesn't make it write twice?
|
@Steve Functions hook to save_post are always called twice, Wordpress call functions hooked to save_post twice because: first time it saves the post revision. second time it saves the actual post. NOTE: If you have disabled post revisions using <code> define('WP_POST_REVISIONS', false); </code> then the save_post hook will be fired only once when the actual post will be saved. I just tested the following code and it works as expected and the echo only runs once in the something_process function. NOTE: the way I have hooked to save_post <code> <?php /* Plugin Name: Something Amazing Plugin URI: http://www.somewhere.com/ Description: Displays something. Author: Some guy Version: 1.0 Author URI: http://www.somewhere.com/ */ function call_something() { return new something(); } if (is_admin()) add_action('load-post.php','call_something'); class something { public function __construct() { add_action('add_meta_boxes',array(&$this,'something_add_boxes')); add_action('save_post',array(&$this,'something_process'),1,2); } public function something_add_boxes() { add_meta_box('something','Some Thing',array(&$this,'something_form'),'post','side','default'); } public function something_form($post,$args) { echo '<p><input type="text" name="somethingnew" /></p>'; } public function something_process($id, $post_object) { // don't run the echo if this is an auto save if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) return; // don't run the echo if the function is called for saving revision. if ( $post_object->post_type == 'revision' ) return; echo 'hey there! I'm going to cause a redirect warning, but you will see this line twice per submit!'; //do_something_amazing(); } } ?> </code>
|
Plugin Development: Wordpress processes twice on post update. How to skip process on the first?
|
wordpress
|
I'm having problems saving a large menu. I keep getting a 500 Internal Server Error. I'm using WP 3.1. I use a HostGator dedicated Linux server and the Superb theme. I have a menu with 4 main headings each with dropdown menus. Is it possible to divide my menu into "4 menus" and display them side by side? The Superb theme has one menu area. Is this possible? If so, how can I do that? Thank you. -Laxmidi
|
I found a work around. I used the Gecka Submenu Pro plugin. (No, they didn't pay me to post). Thank you.
|
Divide Menu into Separate Menus and Display them Side by Side
|
wordpress
|
I used a WP hack for displaying author's pics. For example, my single.php has an author slug which displays the author's pic. I created a folder called authors in my theme/images folder. Based on the author's ID, I name the file 1.jpg, 2.jpg and so on. So I call this image as <code> <img src="<?php bloginfo('template_directory') ?>/images/authors/<?php the_author_ID()?>.jpg" alt="<?php the_author(); ?>"> </code> Now i'm modifying a plugin that displays the authors in the sidebar. However this plugin uses the get_avatar function, which is as follows: <code> /** * If show avatar option is checked, add get_avatar function to cache. */ if($jmetc_options['show_avatar'] == 1) { $jmevar['cache'] .= get_avatar($tc->comment_author_email, $jmetc_options['avatar_size']); } </code> Can someone advise me on how to use/modify the get_avatar in order to use the default code that I use?
|
The <code> get_avatar() </code> function applies a <code> get_avatar </code> filter hook, that you can use to change the avatar markup: <code> return apply_filters('get_avatar', $avatar, $id_or_email, $size, $default, $alt); </code> I think this would be the correct way to hook into this filter: <code> function mytheme_get_avatar( $avatar ) { $avatar = '<img src="<' . get_template_directory_uri() . '/images/authors/' . get_the_author_ID() . '.jpg" alt="' . get_the_author() . '">'; return $avatar; } add_filter( 'get_avatar', 'mytheme_get_avatar' ); </code> EDIT p.s. a nice alternative to this approach might be the Simple Local Avatars Plugin. EDIT 2 The filter is applied using <code> add_filter() </code> , not <code> apply_filters() </code> . That was a typo on my part; fixed now! EDIT 3 I don't think this is correct: P.S: Just to clarify.. I replaced <code> get_avatar($tc->comment_author_email, $jmetc_options['avatar_size']); </code> with <code> add_filter('get_avatar', $avatar, $id_or_email, $size, $default, $alt); </code> First, you still call <code> get_avatar() </code> in your template file, passing all the same parameters as previous. The <code> add_filter() </code> call belongs in <code> functions.php </code> . Second, you can pass additional parameters to your filter function; e.g.: <code> function mytheme_get_avatar( $avatar, $id_or_email, $size ) { $avatar = '<img src="<' . get_template_directory_uri() . '/images/authors/' . $id_or_email . '.jpg" alt="' . get_the_author() . '" width="' . $size . 'px" height="' . $size . 'px" />'; return $avatar; } add_filter( 'get_avatar', 'mytheme_get_avatar', 10, 3 ); </code>
|
Alternative to using get_avatar function?
|
wordpress
|
I'm trying to do some capability checks on comment authors using the user_can() function, but for some reason it isn't working at all. I have a custom capability setup with the Role Manager plugin called "read_citizen". My check looks like this: <code> if(user_can($commentAuthor->user_id, 'read_citizen') { //do stuff here } </code> I have confirmed that the $commentAuthor object is set correctly. Ideas?
|
Ok, found the answer. It was just an oversight on my part. I was using the wrong variable name for the USER ID. In the $wpdb comment object, the user ID is stored as <code> user_id </code> , but in the USER object, the ID is stored just as <code> ID </code> . So, by using <code> if ( user_can($commentAuthor->ID, 'read_citizen') ) </code> , it all works.
|
user_can() not working for comment authors
|
wordpress
|
This is probably really simple, but I just can't figure it out. So I change the input form on my comment form php. The changed snipped looks like this: http://pastebin.com/3Mj1XHGJ Yet when somebody doesn't click on "Website" at all, still a "http://Website" link will be generated for some. Is there any way to make it so that there won't be any url display if they haven't inserted a website url at all? Right now only when I click on the "Website input" textarea and make the "Website" text actually disappear it works. (The following is just a side question and I'm also not sure if it's okay to ask this, so you might as well ignore this): I also wanted to insert little icons in front of the text (before Website, Mail etc.) I know how to do it (just as background image using the stylesheet), but I'm already using a background image and I was wondering if there's another way round as using two background images won't work. Probably I have to rewrite the comment.php a bit instead, but I don't think it's possible to insert a "img src" into the input command? My website is here . Thanks a lot in advance! :D
|
Try adding the code to the comment-template.php file located in wp-includes, right under the <code> function get_comment_author_link( $comment_ID = 0 ) { /** @todo Only call these functions when they are needed. Include in if... else blocks */ $url = get_comment_author_url( $comment_ID ); $author = get_comment_author( $comment_ID ); if ( empty( $url ) || 'http://' == $url ) $return = $author; else $return = "<a href='$url' rel='external nofollow' class='url'>$author</a>"; return apply_filters('get_comment_author_link', $return); } </code> so that the final result looks like this: <code> function get_comment_author_link( $comment_ID = 0 ) { /** @todo Only call these functions when they are needed. Include in if... else blocks */ $url = get_comment_author_url( $comment_ID ); $author = get_comment_author( $comment_ID ); if ( empty( $url ) || 'http://' == $url ) $return = $author; else $return = "<a href='$url' rel='external nofollow' class='url'>$author</a>"; return apply_filters('get_comment_author_link', $return); } add_filter('pre_comment_author_url', 'filter_comment_url'); function filter_comment_url($url){ if ($url == "Website" || $url == "http://Website"){ $url = ''; } return $url; } </code>
|
Commentform input area issue
|
wordpress
|
I am currently building a website, that is heavily reliant on custom post types, 2 of my custom post types are "Clients" and "Case Studies", now what I am wanting is a way to create a dropdown in the "Case Studies" custom post type so that I can select from the Clients that have already been added to the site? Is this possible, I assume it would be similar creating a relationship in database, and then pulling in the clients from the clients and table and placing them in a <code> <select> </code> .
|
You can create relationships between posts / pages with the Posts 2 Posts plugin. (more info on the wiki ) You could then create a connexion between <code> Case Studies </code> and <code> Clients </code> , and associate them accordingly. For clarity, you should ask your second question in a separate question, as it is not related to the title of this thread.
|
creating a foreign key like relationship with custom post types
|
wordpress
|
I am trying to make a child theme of the toolbox theme and use it in my multisite WP 3.2 install. I created a folder called <code> wp-content/themes/charlie-repair-toolkit/ </code> then I created <code> style.css </code> in the folder with the following information (some of which is copied from the original theme): <code> /* Theme Name: Charlie's Repair Theme URI: http://wordpress.org/extend/themes/toolbox/ Author: Mike Wills Author URI: http://mikewills.me Theme: toolbox Description: Based on the Toolbox theme from Automatic. This site is for Charlie's Repair Version: 0.1 License: GNU General Public License License URI: license.txt Tags: custom-menu, sticky-post, microformats, rtl-language-support, translation-ready This theme, like WordPress, is licensed under the GPL. Use it to make something cool, have fun, and share what you've learned with others. */ @import url("../toolbox/style.css"); </code> The theme is not shown in the Network Admin or the site's dashboard. Any thoughts as to what I am not doing right?
|
You're missing the Template Name for the parent theme. It should look like this: <code> /* Theme Name: Charlie's Repair Theme URI: http://wordpress.org/extend/themes/toolbox/ Author: Mike Wills Author URI: http://mikewills.me Template: toolbox Description: Based on the Toolbox theme from Automatic. This site is for Charlie's Repair Version: 0.1 License: GNU General Public License License URI: license.txt Tags: custom-menu, sticky-post, microformats, rtl-language-support, translation-ready This theme, like WordPress, is licensed under the GPL. Use it to make something cool, have fun, and share what you've learned with others. */ @import url("../toolbox/style.css"); </code> Where you have "Theme: toolbox" it needs to be "Template: toolbox"
|
Child Theme Based on Toolbox Not Found
|
wordpress
|
I'm using get_the_terms to display 2 terms on a post, associated with the taxonomy "location". The terms are the suburb and the city. The location taxonomy is hierarchical so the suburb is a child of the city. In the post edit screen a user selects their city, followed by their suburb (which lists the suburbs based on the city they pick). Both are selectable from drop down menus. My problem is that when the terms are outputted onto the post, it lists them alphabetically, and in some instances the City will be listed first: <code> Alpha (City), Beta (Suburb) </code> I need them to reflect their Hierarchy so they are always listed by Suburb first, then city. <code> Beta (Suburb), Alpha, (City) </code> Here is my code. <code> <?php $terms = get_the_terms ($post->id, 'location'); if ( !is_wp_error($terms)) : ?> <li id="location"> <?php unset($locations); foreach ($terms as $term) { $locations[] = $term->name; } $location = join(", ", $locations); ?> <?php echo $location; ?> </li> <?php endif ?> </code> Would this be better achieved with wp_list_categories somehow? It seems there is an option "hierarchical" but unsure on how to use it so it just grabs the post's terms and not everything
|
I managed to hack this together using wp_get_object_terms. The <code> 'orderby' => 'term_id' </code> was most helpful. It's probably not the best method, but seems to work fine. Because the child terms (suburbs) are always created after the parent terms (Cities), they will always have a higher ID. <code> <?php $terms = wp_get_object_terms($post->ID, 'location', array('orderby' => 'term_id', 'order' => 'DESC') ); if ( !empty( $terms ) ) : $location = array(); foreach ( $terms as $term ) { $location[] = $term->name; } echo implode(', ', $location); endif; ?> </code>
|
How to list 2 taxonomy terms for a post, based on their hierarchy
|
wordpress
|
I'm trying to register a CPT from a plugin upon activation but seem to have hit a wall... Anyone see anything im missing? I don't get any errors but the CPT doesn't show up in the dashboard links.... <code> function ctg_cpt_init() { register_post_type( 'ctg_questions', array( 'labels' => array( 'name' => __( 'Questions' ), 'singular_name' => __( 'Question' ) ), 'public' => true, 'has_archive' => true, 'rewrite' => array( 'slug' => 'questions' ) ) ); } add_action( 'init', 'ctg_cpt_init' ); function ctg_rewrite_flush() { ctg_cpt_init(); flush_rewrite_rules(); } register_activation_hook( __FILE__, 'ctg_rewrite_flush' ); </code> Thanks,
|
Pull the CPT registration functionality out of the Plugin activation hook, so that it can fire at <code> init </code> , where you want it to. The Plugin activation hook is a one-time only hook; you need your CPT to fire every time at the <code> init </code> hook, not just once.
|
Register Custom Post Type from Plugin
|
wordpress
|
Continuing the build on a free theme. Working on the gallery CSS. Wordpress automatically adds a left margin to the gallery. Example: http://themeforward.com/demo2/features/gallery-2/ So, how do I get rid of that nasty margin? <code> /* Gallery */ .gallery { margin:30px auto auto; text-align:center } .gallery-item { float:left; margin-top:10px; text-align:center; width:33% } .gallery img { border:1px solid #E6E6E6!important; margin-bottom:27px; padding:5px } .gallery img:active { margin:1px 0 0 } .gallery-caption { display:none; font-size:.8em; margin-left:0 } .gal_img { margin:20px auto 0!important; text-align:center } .gal_caption p { font-size:1.3em!important; font-weight:700; text-align:center; font-family:Arial, Helvetica, sans-serif!important } .gal_description p { font-size:1.1em!important; text-align:center } </code>
|
The simplest method is to remove the WordPress-injected inline style definitions, so that you can control style completely via the Theme: <code> /** * Remove default gallery shortcode inline styles */ add_filter( 'use_default_gallery_style', '__return_false' ); </code> Note that this will remove ALL WordPress-injected gallery CSS definitions, so you may need to port some of the original style definitions into your stylesheet.
|
Overriding Gallery Margin
|
wordpress
|
I've got a weird problem that's very similar to this one: stackexchange-url ("Why does Wordpress Pagination Remove the Spaces from my GET Variable?"). Except that mine isn't withn search results pages--it's with custom taxonomy pages. Here's the problem: clean WP install with no plugins. I add a custom taxonomy like so in my functions file: <code> register_taxonomy( 'my-categories', array( 'post', ), array( 'hierarchical' => true, 'label' => 'My Categories', 'query_var' => true, 'rewrite' => array( 'slug' => 'my-categories' ), ) ); </code> I've created a term in this taxonomy called "test one". If I go to the taxonomy page and add a custom var to the query string, everything seems fine (like so: /my-categories/test-one/?something=one+two). Here's where it gets weird: if I add in some pagination vars (manually changing the URL to /my-categories/test-one/page/2/?something=one+two), the resulting page actually rewrites my URL, stripping out spaces from the custom var (the resulting URL is /my-categories/test-one/page/2/?something=onetwo). Adding my custom var to the vars list using the query_vars filter has no effect. There is obviously a bad rewrite happening somewhere in the WordPress core (I assume in the register_taxonomy() function?), but I don't know enough about WP's rewriting API to figure out what it is. Anybody have any ideas? I'll file an issue in Trac if it is indeed a bug, but I need to know how to patch it short-term.
|
I'm answering this just so it doesn't stay in the unanswered list. This was a core bug that has been patched in 3.3. http://core.trac.wordpress.org/ticket/18086
|
Pagination on Custom Tax Pages Removes Spaces from Query Vars
|
wordpress
|
I am getting errors in the server log for cformsII plugin but don't understand why. <code> PHP Notice: Undefined index: b in /var/www/wordpressmu/wp-content/plugins/cforms/cforms-captcha.php on line 12 [Tue Jul 12 15:02:26 2011] [error] [client 172.18.30.81] PHP Notice: Undefined index: f in /var/www/wordpressmu/wp-content/plugins/cforms/cforms-captcha.php on line 15 [Tue Jul 12 15:02:26 2011] [error] [client 172.18.30.81] PHP Notice: Undefined index: f1 in /var/www/wordpressmu/wp-content/plugins/cforms/cforms-captcha.php on line 18 [Tue Jul 12 15:02:26 2011] [error] [client 172.18.30.81] PHP Notice: Undefined index: f2 in /var/www/wordpressmu/wp-content/plugins/cforms/cforms-captcha.php on line 19 [Tue Jul 12 15:02:26 2011] [error] [client 172.18.30.81] PHP Notice: Undefined index: a1 in /var/www/wordpressmu/wp-content/plugins/cforms/cforms-captcha.php on line 21 [Tue Jul 12 15:02:26 2011] [error] [client 172.18.30.81] PHP Notice: Undefined index: a2 in /var/www/wordpressmu/wp-content/plugins/cforms/cforms-captcha.php on line 22 [Tue Jul 12 15:02:26 2011] [error] [client 172.18.30.81] PHP Notice: Undefined index: l in /var/www/wordpressmu/wp-content/plugins/cforms/cforms-captcha.php on line 30 </code> The url to the captcha image is http://mysite/wp-content/plugins/cforms/cforms-captcha.php?ts=3&c1=4&c2=5&ac=abcdefghijkmnpqrstuvwxyz23456789&i=i&w=115&h=25&c=#A6BEA4&l=000066&f=font4.ttf&a1=-20&a2=11&f1=17&f2=19&b=12.gif&rnd=448710 As you can see the variables throwing errors are included in the querystring. The error is happening against this statement (prep being a function which strips slashes): <code> $im_bg_url = 'captchabg/' . ( prep($_REQUEST['b'],'1.gif') ); </code>
|
The cforms Wordpress Plugin you're using is not properly sanitizing input variables prior use, that's why you get the warnings. You can either fix the problem your own if you're a coder, or report the issue to the plugin author and discuss if she can fix it. But from what I googled, there is another version of that plugin, called cfomsII (Wordpress Plugin) . It will probably have this issue already fixed so perhaps changing the plugin to the new version is the best suggestion to give.
|
Undefined index: b in /path/file.php relating to querystring parameters
|
wordpress
|
Up until now, I've been building my WordPress sites by transferring files through FTP. This can sometimes get really slow (time it takes to upload the file, Firebug slows to a crawl, etc.) and I was wondering how all the pros do it. I heard about installing something locally on your computer and building everything there? I'm new to this whole concept of building a site locally and would appreciate some guidance—mostly to speed up my development time. Thanks in advance.
|
Local web server is a must, it's pretty much generic web server stack (Apache, MySQL, PHP plus other bits) only running on your local computer. Deployment depends on how you manage your code: just resides on your computer - you will need to sync it to remote server in some way (FTP, SFTP, etc), any decent software for such is smart enough to transfer changed files only; resides in version control - you commit local code to repository, then you can either pull to remote site from that repository (or simply make commits and uploads independently). See stackexchange-url ("Software for WordPress Theme and Plugin Development?") for specific software titles.
|
How do the pros code up a WordPress theme? Locally? Through FTP?
|
wordpress
|
I'm finding GD Star Ratings a bit complex to work with. I'm using the comment_form function to generate a custom "review" form on a custom post type. At the top of the form, I want reviewers to leave their rating. I am guessing that I want to hook into the "comment_form_top" action with one of the gd star ratings functions. Am I thinking the right direction? If so, do any of you have a code sample I could refer to? I'm having a hard time finding much in terms of documentation. Any ideas and suggestions are welcomed - Thank you!
|
Got it! The key was a custom callback on wp_list_comments. Here's the snippet of code I used within my comments: <code> <?php if (defined("STARRATING_INSTALLED")) : ?> <div class="rating" style="float: right"> <?php wp_gdsr_comment_integrate_standard_result(get_comment_ID()); ?> </div> <?php endif; ?> </code>
|
Comment_form and GD Star Rating
|
wordpress
|
I've got a few dozen pages in my menu. When I try to add new pages to the menu, then Firefox gives me the "connecting" message int eh tab and it eventually stops after a few minutes and gives me an 500 Internal Server Error. The problem is intermittent. I'll be able to add a few pages to the menu without a problem and then run into the error again and lose many of the menu items that I had saved. I use HostGator and I have the dedicated server option. I submitted a ticket to HostGator to work on it. I'm running WP 3.1 I looked at the server's error log and saw these entries: [Mon Jul 11 14:40:42 2011] [error] [client 74.202.255.243] SoftException in Application.cpp:303: UID of script "/home/mysite/public_html/wp-admin/index.php" is smaller than min_uid [Mon Jul 11 14:40:38 2011] [error] [client 216.110.94.228] SoftException in Application.cpp:303: UID of script "/home/mysite/public_html/wp-admin/index.php" is smaller than min_uid [Mon Jul 11 14:40:36 2011] [error] [client 74.202.255.243] SoftException in Application.cpp:303: UID of script "/home/mysite/public_html/wp-admin/edit.php" is smaller than min_uid, referer: http://www.mysite.com/wp-admin/ [Mon Jul 11 14:27:31 2011] [error] [client 74.202.255.243] SoftException in Application.cpp:303: UID of script "/home/mysite/public_html/wp-admin/index.php" is smaller than min_uid [Mon Jul 11 14:27:30 2011] [error] [client 74.202.255.243] SoftException in Application.cpp:303: UID of script "/home/mysite/public_html/wp-admin/index.php" is smaller than min_uid [Mon Jul 11 14:27:22 2011] [error] [client 74.202.255.243] SoftException in Application.cpp:303: UID of script "/home/mysite/public_html/wp-admin/index.php" is smaller than min_uid [Mon Jul 11 14:27:19 2011] [error] [client 74.202.255.243] SoftException in Application.cpp:303: UID of script "/home/mysite/public_html/wp-admin/index.php" is smaller than min_uid [Mon Jul 11 14:27:18 2011] [error] [client 74.202.255.243] SoftException in Application.cpp:303: UID of script "/home/mysite/public_html/wp-admin/nav-menus.php" is smaller than min_uid Any suggestions on what to do? Could this have something to do with it? Thank you! -Laxmidi
|
Okay, I found a work around so I can save menus as long as I want. I used the Gecka Submenu Pro plugin. It worked great. I wish that I had found this solution 2 weeks ago. (No, I do not work for Gecka. I'm not receiving anything from them. They didn't ask me to post this.)
|
500 Internal Server Error when Trying to Save Menu
|
wordpress
|
Is there a way to limit the amount of months shown in the Archive widget? I don't want to use a drop-down list (I can manually add a drop down in my footer so people can get the full archive). I'm currently showing 19 months in my Archive list, and want to limit it to 7. I know you can do this manually, but that would mess up my theme, so I wanted to do this with the Archive widget.
|
I would use the PHP Code Widget from stackexchange-url ("Otto") and then simply put this in the widget to limit the archives to 7 months: <code> <ul><?php wp_get_archives('type=monthly&limit=7'); ?></ul> </code> (Give the widget a title like Archives if you want, and remove the default WordPress Archive widget.) Function Reference/wp get archives
|
Limit archive widget results
|
wordpress
|
Sometimes upgrading WP is catastrophic: critical plugins don't work any more (and new compatible versions don't exist yet). What do the WP veterans do about it? Do they upgrade WP after the boring work of backing up everything (and the horrible, awful perspective of having to reinstall the previous version after a potential catastrophe) or do they just never upgrade WP?
|
"the boring work of backup"... Backups may be boring, but they are essential and gives you a fallback position in case things go wrong. Without backups, you're essentially playing Russian roulette with your site. It doesn't even take very long, and reverting isn't horrible or awful, it's pretty easy. WP veterans take backups, test upgrades on non-production servers, and when they're happy do the upgrade. Most 'ordinary' people don't have access to multiple servers or even local development environments, in which case the best way to mitigate your risk is to have a backup If you have access to the command line, then doing a complete backup is as easy as: <code> tar czvf yoursite_backup.tar.gz /path/to/your/wordpress </code> <code> mysqldump -u <username> -p <database name> > mysqlbackup.sql </code> Reverting is as easy as unarchiving your WP backup to your WP directory and importing the MySQL dump into your database.
|
How do WordPress veterans deal with the issues of upgrading WordPress?
|
wordpress
|
I've noticed a problem that pops up occasionally when moving a WP install from one place to another (usually the same server.) I copy all the files to their new location, get a mysql dump, update all references to the old paths in the sql file, then import it to the new database. Everything always works just fine apart from custom settings that have been added using register_setting. I can still see them in the database, but WP completely ignores them, and they need to be added again in the backend. Is there something obvious I'm overlooking here? I can post up the code I'm using to build the custom settings panels if necessary... Cheers.
|
Mostly a dupe: stackexchange-url ("Why is my database import losing text widget data?") Doing a search and replace on an sql dump breaks URLs in the serialized data of widgets and theme options. See the link above for better ways to change URLs when moving WP sites.
|
Custom settings disappear during database migration?
|
wordpress
|
Thank you in advanced. I know there are plugins that can do this, but I am looking for a simple solution for my function file. I would like to display the excerpt for all posts with the more tag for public visitors, even for private posts.
|
I've not tested this, but you should be able to complete this task by placing the following code in your template above the loop. <code> query_posts( array( 'post_status' => array( 'published', 'private' ) ) ); </code> This should allow for published and private posts to be displayed in that template.
|
display public excerpt for private post
|
wordpress
|
Can someone please assist with how to remove from my theme, whilst in author mode, the edit_post_link (Edit link), throughout all my pages. Which php files in the Twenty Eleven theme (WordPress v3.2) do I need to comment out to no longer display this edit link? I realise that you only see this during author mode but would like to know how to remove altogether. Thanks.
|
It's the <code> edit_post_link() </code> function. You'll find lines like the following, that you need to comment out: <code> // from /twentyeleven/content-intro.php edit_post_link( __( 'Edit', 'twentyeleven' ), '<span class="edit-link">', '</span>' ); </code>
|
How to Remove all Instances of edit_post_link
|
wordpress
|
In translating a plugin, how should "WordPress" key terms be handled? For instance, should the following need translations or should they be left as is: Taxonomy Custom Post Type Taxonomy Term Plugin Since these terms all have very specific meanings and are documented within the Codex using these English words, would it make more sense to just leave them in English as opposed to translating them? I almost think of these words as proper nouns that would not be changed when translated.
|
These terms are not proper nouns and are translated in localized versions of WP Core. Therefore, they should also be translated in plugins. Ideally, you could use them without a textdomain and WP would load it's own translation.
|
Is it necessary to translate WordPress key terms when localizing a plugin
|
wordpress
|
I'm using a plugin that failed after upgrade to wp3.2. The error log shows: WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 for <code> query SELECT post_id, meta_value, post_status FROM bxxoai_postmeta LEFT JOIN bxxoai_posts ON post_id=bxxoai_posts.ID WHERE post_status='publish' AND meta_key='wpfp_favorites' AND meta_value > 0 ORDER BY ROUND(meta_value) DESC LIMIT 0, made by require, require_once, include, get_header, locate_template, load_template, require_once, get_sidebar, locate_template, load_template, require_once, wpfp_widget_view, wpfp_list_most_favorited </code> mysql version I used is 5.0.92-community I'm clueless with database, can anyone please teach or help explain to me what needed to be done to fix this?
|
I ran into this as well... I am using the SQL query, but not the wpfp_list_most_favorited() function, so this may or may not work for you, but worth a shot. Try updating the SQL query in wp-favorite-posts.php (around line 206) from: <code> $query = "SELECT post_id, meta_value, post_status FROM $wpdb->postmeta"; </code> To: <code> $query = "SELECT post_id, meta_value, meta_key, post_status FROM $wpdb->postmeta"; </code> Hope this helps!
|
Need help fixing sql syntax error after WP 3.2 upgrade
|
wordpress
|
My code was working up until the 3.2 update, where I noticed that tinyMCE has been updated too. Does anyone have any ideas why this may not work now? I don't get any console errors but I don't get any tinyMCE editors on the page either! CLARIFICATION: every instance of the TinyMCE editor has disappeared! FURTHER CLARIFICATION: this is only occurring on my custom post type pages where I have custom instances of the TinyMCE editor. I still have the default "theEditor" MCE on the default Posts area. <code> function meta_genus_species() { global $post; $genus = get_post_custom_values( 'genus', $post->ID ); $species = get_post_custom_values( 'species', $post->ID ); $etymology = get_post_custom_values( 'etymology', $post->ID ); $family = get_post_custom_values( 'family', $post->ID ); $common_names = get_post_custom_values( 'common_names', $post->ID ); if (!isset($id)) { $id = "etymology"; } if (!isset($temp_min)) { $temp_min = plugins_url('images/temp_max.png' , __FILE__); } if (!isset($temp_max)) { $temp_max = plugins_url('images/temp_min.png' , __FILE__); } if (!isset($pH_min)) { $pH_min = plugins_url('images/pH_max.png' , __FILE__); } if (!isset($pH_max)) { $pH_max = plugins_url('images/pH_max.png' , __FILE__); } $tinyMCE = <<<EOT <script type="text/javascript"> jQuery(document).ready(function($) { $("#{$id}").addClass("mceEditor"); if ( typeof( tinyMCE ) == "object" && typeof( tinyMCE.execCommand ) == "function" ) { tinyMCE.settings = { theme : "advanced", mode : "none", language : "en", height:"75", width:"100%", theme_advanced_layout_manager : "SimpleLayout", theme_advanced_toolbar_location : "top", theme_advanced_toolbar_align : "left", theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,temp_min,temp_max,pH_min,pH_max", theme_advanced_buttons2 : "", theme_advanced_buttons3 : "", setup : function(ed) { ed.addButton('temp_min', { title : 'Temperature: Minimum', image : '{$temp_min}', onclick : function() { ed.focus(); ed.selection.setContent('[temp_min]'); } }), ed.addShortcut("ctrl+1", "temp_min", "temp_min"), ed.addButton('temp_max', { title : 'Temperature: Maximum', image : '{$temp_max}', onclick : function() { ed.focus(); ed.selection.setContent('[temp_max]'); } }), ed.addButton('pH_min', { title : 'pH: Minimum', image : '{$pH_min}', onclick : function() { ed.focus(); ed.selection.setContent('[pH_min]'); } }), ed.addButton('pH_max', { title : 'pH: Maximum', image : '{$pH_max}', onclick : function() { ed.focus(); ed.selection.setContent('[pH_max]'); } }); } }; tinyMCE.execCommand("mceAddControl", true, "{$id}"); } }); </script> EOT; echo $tinyMCE; ?> <div class="meta_control normal"> <p>Description of taxonomy.</p> <div class="box"> <label>Genus</label> <p> <input name="genus" class="text" value="<?php if(isset($genus[0])) { echo esc_attr( $genus[0] ); } ?>" /> <span>Testing...</span> </p> </div> <div class="box"> <label>Species</label> <p> <input name="species" class="text" value="<?php if(isset($species[0])) { echo esc_attr( $species[0] ); } ?>" /> <span>Testing...</span> </p> </div> <p> <label>Etymology</label> <textarea cols="50" rows="5" name="etymology" id="etymology"><?php if(isset($etymology[0])) { echo esc_attr( $etymology[0] ); } ?></textarea> <span>Description</span> </p> <p> <label>Family</label> <input name="family" class="text" value="<?php if(isset($family[0])) { echo esc_attr( $family[0] ); } ?>" /> <span>Description</span> </p> <p> <label>Common Names</label> <input name="common_names" class="text" value="<?php if(isset($common_names[0])) { echo esc_attr( $common_names[0] ); } ?>" /> <span>Description</span> </p> </div> <?php } function meta_authored() { global $post; $species_author = get_post_custom_values( 'species_author', $post->ID ); $year_described = get_post_custom_values( 'year_described', $post->ID ); ?> <div class="meta_control side"> <label>Species Author</label> <p> <input name="species_author" class="text" value="<?php if(isset($species_author[0])) { echo esc_attr( $species_author[0] ); } ?>" /> </p> <label>Year Described</label> <p> <input name="year_described" class="text" value="<?php if(isset($year_described[0])) { echo esc_attr( $year_described[0] ); } ?>" /> </p> </div> <?php } </code>
|
I found some info on changes in 3.2 that might be relevant: Aparrently, <code> wp_tiny_mce_preload_dialogs() </code> no longer exists from WP3.2 on. It got replaced by <code> wp_preload_dialogs() </code> which is now being called from <code> wp_quicktags() </code> . <code> wp_quicktags </code> , on his turn, is being called from <code> the_editor() </code> function. So, if you’re using <code> the_editor() </code> you no longer need to manually call the function to preload any dialogs! If you’re not using <code> the_editor() </code> , make sure to call <code> wp_preload_dialogs() </code> somewhere from your footer in the following manner: <code> wp_preload_dialogs( array( 'plugins' => 'wpdialogs,wplink,wpfullscreen' ) ); </code> You could try calling wp_preload_dialogs(), or maybe switch to using <code> the_editor() </code> instead of <code> tinyMCE.execCommand() </code> . Also, check out stackexchange-url ("this question"); calling <code> wp_tiny_mce() </code> solved my problem. Update : wp_tiny_mce() might be deprecated in 3.3 .
|
Wordpress 3.2 has broken my TinyMCE code
|
wordpress
|
What is the simplest way to query posts using blog_id? I have a post type called video that holds, not surprisingly, multiple embedded videos. Each post has a different video. I would like to display a specific video in specific locations across different sites. The video posts are on Site 1, and other sites in the network could be Site 2, Site 3, Site 4 and Site 5. All sites are in the same multisite setup. Each video is currently being identified by matching terms in two custom taxonomies, Taxonomy A and Taxonomy B. If all posts were on the same blog I would use this to query the right video: <code> $video_query = new WP_Query( array( 'post_type' => 'video', 'post_status' => 'publish', 'posts_per_page' => 1, 'no_found_rows' => true, 'tax_query' => array( 'relation' => 'AND', array( 'taxonomy' => 'TaxA', 'field' => 'slug', 'terms' => $the_termA ), array( 'taxonomy' => 'TaxB', 'field' => 'slug', 'terms' => $the_termB ), ) ) ); if( $video_query->have_posts() ) : while( $video_query->have_posts() ) : $video_query->the_post(); </code> How can I make the query only look for posts in Site A?
|
Use <code> switch_to_blog() </code> http://codex.wordpress.org/WPMU_Functions/switch_to_blog , do the query and then restore back using <code> restore_current_blog() </code>
|
Simplest way to query with blog_id?
|
wordpress
|
i'm creating some custom shortcodes for my wordpress theme. Shortcodes are by nature optional on pages/posts, but may contain css, js or other files. My question is, how can i enqueue css styles ONLY IF a particular shortcode has been used ? I would not want to load everything for no reason.
|
The general process for this is: Create a function, hooked into <code> wp_enqueue_scripts </code> Inside your function, cycle through the Loop, looking for your shortcode string If found, call <code> wp_enqueue_style( 'my_custom_style' ) </code> Rewind the Loop, by calling <code> <?php rewind_posts(); ?> </code>
|
Wordpress Shortcodes - Optional Styles
|
wordpress
|
I've followed the official documentation to create my archives page: http://codex.wordpress.org/Creating_an_Archive_Index It works fine exept that "is_archive() returns false when I'm viewing this page. Any idea ?
|
Because an "archives" Page is not an archive index of blog Posts , but rather a Page . An "archives" page is simply a custom Page template, which applies to a static Page. The <code> is_archive() </code> conditional returns true if an archive index is being displayed. An archive index page displays Posts , not static Pages . EDIT Instead of using <code> if ( is_archive() ) </code> , try using <code> if ( is_page( 'archives' ) ) </code> (assuming you've named your static Page Archives ). Alternately, you could use <code> if ( is_page_template( 'archives.php' ) ) </code> (assuming you've named your template file as <code> archives.php </code> ).
|
is_archive() returns false on the archives page
|
wordpress
|
I'm currently creating a theme and I would like to associate an image to one of my taxonomies. I'm already able to add some fields and I now want to add a file input which'll be handle by Wordpress upload function. So, 2 questions : - Is it possible to add an enctype to the taxonomy form ? - Is it possible to use the Wordpress upload function at this point ? Thanks for your answers. Cyril
|
Michael Fields built the perfect plugin for this: http://wordpress.mfields.org/plugins/taxonomy-images/
|
Taxonomies image
|
wordpress
|
With WP 3.2, WordPress maybe has a new function to add Link-Quicktags to the editor. But I found an function to set defaults for the link-button: Take a look at wplink.js Line 278 . <code> setDefaultValues : function() { // Set URL and description to defaults. // Leave the new tab setting as-is. inputs.url.val( 'http://' ); inputs.title.val( '' ); // Update save prompt. inputs.submit.val( wpLinkL10n.save ); }, </code> How is it possible to set the values for a custom value? Is this possible and can you help me? Thanks for an answer from an JavaScript Expert.
|
Also an small example for change the url in link-button to use the url from installed blog. Use print JS in footer, not an include from js file via <code> wp_enqueue_script() </code> - ist faster vor development, specially for this small requirement, but not so on standard and fine, how the example from the other answer. <code> <?php /** * Plugin Name: Change URL in Link Popup * Plugin URI: http://bueltge.de/ * Description: Adds a domain link button to the post editing screen. * Version: 0.0.1 * Author: Frank B&uuml;ltge */ if ( ! function_exists( 'fb_add_quicktag_button' ) ) { function fb_add_quicktag_button() { ?> <script type="text/javascript"> // change link on Link popup in TinyMCE and quicktag popup ( function( $ ) { if ( typeof wpLink == 'undefined' ) return; wpLink.setDefaultValues = function () { $('#url-field').val('<?php echo home_url( '/' ); ?>'); }; } )( jQuery ); </script> <?php } add_action( 'admin_footer-post-new.php', 'fb_add_quicktag_button', 9999 ); add_action( 'admin_footer-post.php', 'fb_add_quicktag_button', 9999 ); } </code>
|
How set defaults on wpLink()
|
wordpress
|
I am trying to use wp-minify to minify my js/css on the fly. I can get the 'direct' css files to be minified, but I can't seem to get wp-minify to minify the 'linked' css files. My theme is a child theme off of twenty-ten, so my child theme's styles.css gets minified, but not twenty-ten's styles file.
|
<code> @import </code> prevents "parallel" downloads. I'd not suggest to use it in case you want to minify css files.
|
How do I minify '@import' css files with wp-minify?
|
wordpress
|
I'm using the code below to add a logo in the header of certain pages and I'm wodering if there a way to add the logo(sublogo.jpg) to certain categories as well as "page-one", "page-two" and so on? <code> <div id="header-logo" onclick="location.href='<?php bloginfo('url'); ?>'" style="cursor: pointer;" > <?php if (is_page(array('page-one', 'page-two', 'page-three','page-four'))) $logo_image = 'subLogo.jpg'; else $logo_image = 'mainLogo.jpg';?> <img src="<?php bloginfo('stylesheet_directory'); ?>/images/<?php echo $logo_image;?>" alt="<?php bloginfo('name'); ?>" /> </div> </code> Thanks,
|
extend this line: <code> <?php if (is_page(array('page-one', 'page-two', 'page-three','page-four'))) $logo_image = 'subLogo.jpg'; </code> with <code> || is_category(array('cat-1', 'cat-2')) </code> so you get, for example: <code> <?php if (is_page(array('page-one', 'page-two', 'page-three','page-four')) || is_category(array('cat-1', 'cat-2')) ) $logo_image = 'subLogo.jpg'; </code> http://codex.wordpress.org/Function_Reference/is_category
|
How to get a page array and category array going at the same time?
|
wordpress
|
I changed the name of two of my custom post types. The original slugs for them did not properly reflect the post type. So I need to redirect requests for posts beginning with <code> designer_lingerie </code> (the old post type slug) to just <code> designer </code> . All of the posts are the same just the post type slug has changed. I am sure I'll need to use <code> .htaccess </code> but am unsure of what to tell it to change. Basically what URL should I use to do this? The WordPress pretty URL or the default URL?
|
All you need to do is add a line like: <code> RewriteRule ^aboutus$ /about-us [R=301,L] </code> In to your .htaccess file. The old url should go between the ^ and $ and then new url after the slash.
|
Redirecting when changing custom post type slugs?
|
wordpress
|
Hi I'm evaluating wordpress to implement a rather static website (http://www.eddaconsult.se) that now uses static html that I think could be advantageous to do with wordpress since it would make updates and administration easier. Do you agree with me that it's possible to implement these quite simple webpages with wordpress? I started a project to do this at http://eddaconsult.wordpress.com not getting very long since I didn't see how to upload a logo image etc but I'm sure that it can do all or most of what is required.
|
Yes of course you can recreate that site using WordPress. You gain the benefit of managing all the pages from the WordPress admin, and gain consistency across all the pages due to the templated nature of WordPress pages. You can start by finding or creating a very basic theme that mimics the look of the existing site. Then just copy your content into WordPress Pages (copy and paste.) You can even make it look like the pages are HTML by adding the .html extension to your permalink structure. You can redirect traffic to your old pages to the new pages, if the names are different. So long at the host that hosts www.eddaconsult.se supports PHP 5.2.4 and MySQL 5.0, you can run WordPress without a problem. Here are the requirements for WordPress version 3.2 . Without a doubt, you can do this project with WordPress.
|
Can I Create a Static-Content Site With WordPress?
|
wordpress
|
I'm developing on a local install of WP 3.2 and noticed that the search box inside the insert/edit link dialog is not working (Tiny MCE link button in the visual editor). Has anyone else experienced this / know what might be causing it? The search indicator just spins without returning any results when I type in keywords which I know to be good.
|
Looks like this was caused by the WP-o-Matic plugin which my client was using.
|
Internal linking search box not working - WP 3.2
|
wordpress
|
Wordpress changed quite a bit from 3.1 to 3.2. I have played for an hour to find the plugin section but not success. Usually they would be on the left hand side in the menu. Now they are not there. Anyone knows where to find them and how to install them on xyz.wordpress site? This image is from 3.1. Plugin option is second from top. Here is 3.2 menu. Can you find Plugins?
|
According to Wordpress Customer Support, they don't allow plugins on .wordpress.com website for security reasons, which kind of sucks. The plugins should work on your own domain/site though.
|
Can't find plugins in menu for wordpress 3.2?
|
wordpress
|
This problem is driving me crazy. So, I've Jetpack installed and the Gravatar hovercards activated. I could live without them, but other "hover over image" functions (e.g. I'm using the Guan Image Annotation plugin that lets you add a note to an image in a post by hovering over it) don't work either. It still worked earlier today and all I did was activate and deactivate a few other plugins. I tried to figure out with plugins are causing the misfunction, but couldn't figure it out. Maybe it's not a plugin interfernence after all. I just can't seem to figure it out :( As I'm a total beginner I'm not sure, but I think both (hovercards and the mentioned plugin) work with javascript? So maybe something is interfering with that? I hope you can help me figure this out. My (under construction) website is here . Thanks a lot in advance for any kind of advice! :)
|
If you look in the source code of your homepage, in the header you will see that you have a lot (infact i have never seen as many jquery files in a header before) calls to jquery files, this is definatly a cause for conflict if two of the files are the same, i can see at least 2 references to a similar file. What you will need to do, is deactivate all plugins, and start reactivating them one by one, each time testing the site, eventually you will activate the plugin that is breaking your jquery what you can do then is open up that plugins files and comment out the line that calls the jquery file and see if it will run off the other one.. these could be the issue http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js?ver=3.2 http://www.zoomingjapan.com/wp-content/themes/alltuts/js/jquery-1.4.2.min.js http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.min.js?ver=3.2 http://www.zoomingjapan.com/wp-content/plugins/guan-image-notes/js/jquery-ui-1.7.1.js
|
Hovercards and other hover over image functions don't work anymore!
|
wordpress
|
I am trying to display all of the terms for a custom taxonomy( <code> characters </code> ), the taxonomy is related to a custom post type( <code> books </code> ). What I would like to do is display all of the terms for <code> characters </code> , so say for instance I have two <code> books </code> , and I add three <code> characters </code> to each <code> book </code> , I would like all six characters to display. I would only like to get the names, not links, or in list form, if I could get a set of objects or an array that would be preferable. Thank you.
|
I believe what you are looking for is the get_terms function. I found it looking at the code for wp_tag_cloud , here is the source of the function . This little snippet should get you what you are wanting. <code> $terms = get_terms("characters"); if ( empty( $tags ) || is_wp_error( $tags ) ) return; foreach ( $terms as $term ) { echo $term->name; } </code>
|
List custom taxonomy terms
|
wordpress
|
I just activated wordpress multisite in my site. I have few questions. 1) WPMU and wordpress multisite both are same? 2) I created a network in my site. I created like site1.mydomain.com, site2.mydomain.com etc. Is it possible to make my subdomains posts summary appear in my main domain? 3) Is it possible to make users access all subdomains with single registration? Thanks
|
1) WordPress MultiUser (WPMU) was the term used before WP3. WPMS is for version 3 and newer. 2) Subsite posts appearing on the main site is built into BuddyPress. You will need to install BP to your multisite setup for this to work. 3) There are several plugins that achieve this either through a) a single user database shared across all sites, or b) duplication of users with differing user permissions per site.
|
Some questions about WPMU
|
wordpress
|
I'm trying to use my category.php file to display all posts of a certain custom post type (say "Company") with a given category. However, when I try to use it by navigating to domain.com/category/company/category1, which is the link automatically generated by wp_list_categories(), no posts appear. The code I'm using is: <code> <?php while ( have_posts() ) : the_post(); ?> <?php get_template_part( 'type-company', get_post_format() ); ?> <?php endwhile; ?> </code> What am I doing wrong?
|
I figured it out! For anyone having the same problem, I solved it by adding <code> $cat_id = get_query_var('cat'); query_posts("post_type=company&cat=$cat_id"); </code> right in front of the loop. Anyone having the same problem would probably also benefit from looking at this , too.
|
Category.php template for custom posts
|
wordpress
|
Are there any hosting companies out there that cater to users who want to utilize TLD domain mapping and WordPress Multisite? Or will you have to go the route of building, configuring, and maintaing your own server configuration with a service provider, like SliceHost?
|
Try wpengine.com , they seem to be WordPress-addicted enough to provide, what you need :)
|
Are there any hosting companies that are already setup and configured for TLD domain mapping?
|
wordpress
|
I have tried to - enable <code> Use jQuery </code> & then save changes. But after saving changes, checkmark <code> Use jQuery </code> automatically unchecks itself. I am not sure whats going on. Please help me here.
|
From the comments fo @OneTrickPony, I came to know that, <code> Mystique hasn't been updated for a long time, but a major update is going to be released these days, and most likely this won't happen in the new version... </code> So, I conclude that issue is coming from the Theme itself. ( Not sure, but from the comments of @Milo & @OneTrickPony ) So, I uninstalled & removed <code> mystique </code> theme & at last I installed other theme. I know this is not the exact solution. But I had no option.
|
I am not able to enable jQuery in theme settings
|
wordpress
|
I know that the theme review team has been active for about one year now. Thanks to their hard work and diligence, the themes in the repo are much better now than ever before. However, I have noticed that there are still older themes in the repo that, at first glance, probably would not pass the review if submitted or updated today. Is there a date that anyone can point to where we might want to be wary of any themes that were last updated before then? On a related note, is there a plan to possibly phase out some of these themes?
|
Anything updated since late 2010 or so should be pretty reliable. The Guidelines have been pretty much stable since fall 2010 or so. As for existing Themes in the repository: I think most of the Theme Review Team would like to see some policy implemented in which obsolete Themes could be suspended; however, that decision is above our pay grade. For the time being: any Theme already in the repository, regardless of when it was approved, will remain active/available. We have removed some older Themes, if they were found to have a security exploit, malicious code, non-GPL-compatible license, or spammy links.
|
What is the general cut-off date for reviewed themes in the WordPress.org repository?
|
wordpress
|
I'm working on a custom dropline menu using wp_nav_menu. Using <code> wp_nav_menu( array( 'theme_location' => 'primary', 'after' => '|' ) ); </code> , I can put separators after every item. However, I'm only wanting them after the child items in the sub-menu. Is there any way I can be more specific about which items have separators, such that only the non-parent items are separated? Thanks!
|
Why not use a purely CSS-based solution, using the <code> :after </code> pseudo-element? e.g. <code> #nav li li a:after { content: '|'; } </code>
|
Dropline menus -- seperators between children only?
|
wordpress
|
I have 15 custom fields that I use to generate reviews for my site. Currently I access each field like this: <code> //Buy or rent, type home, price if ( get_post_meta(get_the_ID(), 'survey_home_type', true) ) { echo get_post_meta(get_the_ID(), 'survey_home_type', true) . " - "; } if ( get_post_meta(get_the_ID(), 'survey_buy_or_rent', true) ) { echo get_post_meta(get_the_ID(), 'survey_buy_or_rent', true) . " for "; } if ( get_post_meta(get_the_ID(), 'survey_purchase_price', true) ) { echo get_post_meta(get_the_ID(), 'survey_purchase_price', true); } elseif ( get_post_meta(get_the_ID(), 'survey_rent', true) ) { echo get_post_meta(get_the_ID(), 'survey_rent', true); } </code> Is there a better way to do this? I tried using get_post_custom but it seems to mainly deal with arrays, not single items. I could also declare all the variables ahead of time, such as <code> $rent </code> , <code> $purchase_price </code> . I would like to hear any advice!
|
I would write a function to handle the monotony of this task. <code> function my_print_meta($id, $key, $alternate = '') { if($value = get_post_meta($id, $key, true)) echo $value; else echo $alternate; } </code> Notice in the function that I only call <code> get_post_meta </code> once and store the value in a variable so that two separate database queries don't need to be made. With this function set, I would then call it in a template file using: <code> my_print_meta(get_the_ID(), 'survey_home_type', 'No Home Type'); </code> Now, realize that this function, with the way that it manages the "alternate" text might not work for your template, but this is just an idea to get you going
|
Cleaner way to access custom fields in code?
|
wordpress
|
I have added the code below to an active plugin, but it's having no effect on my posts. <code> add_filter( ‘the_title’, ‘myfunction’); function myfunction($title) { return "Why won't this work?" . $title; } </code> What am I missing here? The post templates are definitely using the_title(), and the theme is normal (wp_head(), etc), and there are no conditionals surrounding the function in the plugin that would make it not run. I have also tried adding different priority in the add_filter function, from -9999 to 9999, to no effect.
|
Try changing this: <code> add_filter( ‘the_title’, ‘myfunction’); </code> to this: <code> add_filter( 'the_title', 'myfunction' ); </code> (If this is indeed your problem it is likely an issue of copy/pasting code from a tutorial with curly quotes in place of standard single-quote marks.) p.s. prefix your function name with your Plugin slug. " <code> myfunction </code> " is far too generic.
|
Why doesn't my simple the_title filter get applied?
|
wordpress
|
I am trying to integrate the Jquery UI select menu ("dropdown" Style), in my wordpress site. But I am not able to do it, in widget area I created a select box and gave it respective ID of that css and jquery, but its not getting loaded with jquery. Here is my code, which I am using it to achieve:- The head part:- <code> <link rel="Stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/ui-darkness/jquery-ui.css" type="text/css" /> <link rel="Stylesheet" href="<?php echo get_template_directory_uri(); ?>/ui.selectmenu.css" type="text/css" /> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js"></script> <script type="text/javascript" src="<?php echo get_template_directory_uri(); ?>/js/ui.selectmenu.js"></script> <style type="text/css"> /*demo styles*/ select,.ui-select-menu { float: left; margin-right: 10px; font-size: 62.5%;} select, .ui-selectmenu { width: 200px; font-size: 62.5%; margin:10px;} #cat{font-size: 62.5%;} </style> <script type="text/javascript"> JQuery(function(){ JQuery('select#cat').selectmenu({style:'dropdown'}); }); </script> <script type="text/javascript" src="http://ui.jquery.com/applications/themeroller/themeswitchertool/"></script> </code> The select menu appears with normal css, but the jquery is not working, I am bad in Jquery, so can any one help, I am using 2011 Theme, and you can check the selet menu on my site http://webstutorial.com/ Edited: <code> <script type="text/javascript"> jQuery.noConflict(); jQuery(function(){ jQuery('select#cat').selectmenu({style:'dropdown'}); }); </script> </code>
|
This works for me locally in testing.. <code> add_action('wp_enqueue_scripts','enq_menu_scripts_and_styles'); function enq_menu_scripts_and_styles() { // UI Core, loads jQuery as a dependancy wp_enqueue_script( 'uicore', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.12/jquery-ui.min.js', array('jquery') ); // UI Theme CSS wp_enqueue_style( 'uicss', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/ui-darkness/jquery-ui.css' ); // Selectmenu JS wp_enqueue_script( 'uisel', 'http://jquery-ui.googlecode.com/svn/branches/labs/selectmenu/ui.selectmenu.js' ); // Selectmenu CSS wp_enqueue_style( 'uicss2', 'http://jquery-ui.googlecode.com/svn/branches/labs/selectmenu/ui.selectmenu.css' ); } add_action('wp_head','select_menu_test_code'); // Simple test code function select_menu_test_code() { // Simple no-conflict function ?> <script type="text/javascript"> jQuery(function($){ // You can use $ here $('select#cat').selectmenu(); }); </script> <?php } </code> It wouldn't work for me when trying to use ui-core from WordPress, jQuery seems to be ok though. I used the same version of UI with the test code so it's strange that the one included in WordPress didn't work for me(i do have a plugin active that uses ui core, but disabling didn't seem to help at all). See if my above code works for you, and tweak as necessary if it does.. :)
|
Jquery UI not working
|
wordpress
|
I am using Gravity Forms to allow users to create posts from the front end. However, the way this site I am building is going to work, one specific Post_Type is essentially just a "Data" post. There is a specific Taxonomy who's Terms are actually the "Title" of the data set. I have already figured out a way to hide the "Title" field in Gravity forms but still have it present on the form (for some reason they lock the "Post_Type" and "Post Status" into the 'Title' field in the GUI, so I overloaded it's conditional logic to force it to always hide). I want to create a filter that would always copy the [Term] value for a specific [Taxonomy] into the [Title] field of a specific [Post_Type]. Any advice I could get on how to accomplish this would be great! Thanks in advance! ============================================================== OK, using code from @Manny Fleurmond below, and from this post: stackexchange-url ("Title_save_pre - Simple problem that u know for sure") I came up with <code> function taxonomy_title_rename($title) { global $post; $type = get_post_type($post->ID); if ($type== 'CUSTOM_POST_TYPE') { if($post->post_type === 'CUSTOM_POST_TYPE') { $terms = wp_get_object_terms($post->ID, 'MY_TAXONOMY'); if(!is_wp_error($terms) && !empty($terms)) { $title = $terms[0]->name; } } return $title; } else if ($type != 'CUSTOM_POST_TYPE') { return $title; } } add_filter ('title_save_pre','taxonomy_title_rename'); </code> This is actually saving the post title to the post from the taxonomy. However, it is not then pulling it into the permalink as well, my permalink is just the post ID number. Will see if I can get this solved on my own, but any help would be appreciated!
|
Well, since I essentially came up with my own answer using what was posted (which didn't really work) plus some extra research, I am going to close this question, even though I sort of added an additional question; OK, using code from @Manny Fleurmond below, and from this post: Title_save_pre - Simple problem that u know for sure I came up with <code> function taxonomy_title_rename($title) { global $post; $type = get_post_type($post->ID); if ($type== 'CUSTOM_POST_TYPE') { if($post->post_type === 'CUSTOM_POST_TYPE') { $terms = wp_get_object_terms($post->ID, 'MY_TAXONOMY'); if(!is_wp_error($terms) && !empty($terms)) { $title = $terms[0]->name; } } return $title; } else if ($type != 'CUSTOM_POST_TYPE') { return $title; } } add_filter ('title_save_pre','taxonomy_title_rename'); </code> This is actually saving the post title to the post from the taxonomy.
|
Copy a Taxonomy Term into the Post Title for a certain Custom Post Type
|
wordpress
|
Sometimes after activating a plugin the admin side is blank with a memory error message, sometimes the front page too. The standard fix is to increase the memory in config.php. What is the best way to prevent in advance all or most memory problems to occur ?
|
Using FTP, try increasing the memory for PHP and Wordpress by editing the memory_limit line in your php.ini (if you have access to it) to 64M or 128M, which should be fine for non-multisite installs. <code> memory_limit = 64M; </code> If you can't get to the php.ini file, add this line at the top of your .htaccess file: <code> php_value memory_limit 64M </code> If that doesn't work or throws an error, add this line near the top of your wp-config.php file right after the opening <code> <?php </code> <code> define('WP_MEMORY_LIMIT', '64M'); </code> But your host may limit changes to .htaccess in your account and to the host-wide php.ini, so these may not work. if not, ask your host. You can run phpinfo to see what kind of memory allocation you already have. Make a plain text file and call it phpinfo.php and put just this line in it: <code> <?php phpinfo(); ?> </code> then put the file in the root of your server, and then go to that file with your web browser. You'l see all the php info you need; scroll down for memory settings. If you get an error, that means your server company won't allow phpinfo to run for security reasons.
|
Not enough memory
|
wordpress
|
I'm creating a very basic Wordpress plugin whose purpose is to display a numerical value beside each post. My Logic for the plugin function ( plugin.php ) is this: <code> <?php function foo($post_id){ $somevalue=1 //Some random value add_post_meta($post_id, 'posts_numericalvalue', '0', true) or update_post_meta($_post_id, 'posts_numericalvalue', $somevalue); } add_action('post_save', 'foo'); ?> </code> And in my template's index.php , I have (inside the loop): <code> <?php .... printf(__('Permanent Link to %s', 'kubrick'), the_title_attribute('echo=0')); $numerical_val = get_post_meta($post->ID, posts_numericalvalue); echo 'this post has a value of ' .$numerical_val; .... ?> </code> 1) The code above is obviously not working. I think its because my function in plugin.php requires me to pass the current post's ID, but the action hook doesn't pass the post's current ID I guess (correct me if I'm wrong). How do I pass the post ID to my function inside plugin.php using an action hook? 2) Any other elegant way of doing this? I just need to assign my posts with a numerical value which should be updated with 1 if the post already has one, zero if the post hasn't got one already. Any help is much appreciated. Thanks.
|
When hooking the save_post action, you really need to isolate your operations so that every page/post/post_type save doesn't try to add your post meta to the post. <code> function foo_save(){ if(isset($_REQUEST['bar') update_post_meta($_REQUEST['post_ID'], 'bar', $_REQUEST['bar']); } add_action('save_post', 'foo_save'); </code> The main issue with your code above is posts_numericalvalue needs quotes. Also, to use $post-> ID you will need to make sure your code is in the loop or declare global $post; somewhere above your code if you're using it outside of the loop. <code> if(have_posts()): while(have_posts()): the_post(); $foo = get_post_meta($post->ID, 'bar', true); echo $foo; endwhile; else: endif; </code> Also, if you are distributing this plugin to the public, you will need to create a function to filter the content and add your post meta there since you won't have true access to the template files. If this is just for your own use in your theme, I would place the function foo_save() in your functions.php file instead. Hope this helps you out!
|
Wordpress Action Hooks and Post ID?
|
wordpress
|
I'm trying to create a taxonomy that is sort of hidden.. meaning i intend to adjust the metabox so that you can only select a unique term from 3 options. "featured","normal" or "excluded". but i can't figure out how to remove the administration menu. the following removes the Tags menu item from underneath Posts: <code> add_action('admin_menu','yoursite_admin_menu'); function yoursite_admin_menu() { // remove_submenu_page was introduced in 3.1 remove_submenu_page( 'edit.php', 'edit-tags.php?taxonomy=post_tag' ); } </code> but this doesn't remove the Featured taxonomy from underneath Portfolio <code> add_action('admin_menu','yoursite_admin_menu'); function yoursite_admin_menu() { // remove_submenu_page was introduced in 3.1 remove_submenu_page( 'edit.php?post_type=portfolio', 'edit-tags.php?taxonomy=featured&post_type=portfolio' ); } </code> i've tried it a couple of different ways w/ regards to the slugs, but can't get any of them to work. what am i missing?
|
following Bainternet's comment, i registered the taxonomy without showing any of the UI elements <code> add_action( 'init', 'kia_register_featured_tax', 0 ); function kia_register_featured_tax(){ if(!taxonomy_exists('portfolio_featured')){ $labels = array( 'name' => _x( 'Featured', $this->plugin_domain ), 'singular_name' => _x( 'Featured', $this->plugin_domain ) ); $args = array( 'labels' => $labels, 'rewrite' => array( 'slug' => 'portfolio-featured' ), 'query_var' => true, 'public' => true, 'show_ui' => false, 'show_tagcloud' => false, 'show_in_nav_menus' => false, ); register_taxonomy( 'portfolio_featured', array( 'portfolio' ), $args ); } } </code>
|
Remove admin menu for custom taxonomy attached to custom post type
|
wordpress
|
I was wondering if there was a way to make the search only look for the first letter in the posts title, basically let's say my search query is www.mysite.com/?s=q I'd like to get all posts that start with the letter "Q". Is this possible? Thanks in advance.
|
I know it is too late but I hope it is going to help someone in the future You can add a filter to posts_where and add a regexp to limit it to the first letter. Wordpress documentation for posts_where <code> add_filter( 'posts_where' , 'posts_where' ); function posts_where( $where ) { if( is_admin() ) { global $wpdb; if ( isset( $_GET['author_restrict_posts'] ) && !empty( $_GET['author_restrict_posts'] ) && intval( $_GET['author_restrict_posts'] ) != 0 ) { $author = intval( $_GET['author_restrict_posts'] ); $where .= " AND ID IN (SELECT object_id FROM {$wpdb->term_relationships} WHERE term_taxonomy_id=$author )"; } } return $where; } </code>
|
How to limit search to first letter of title?
|
wordpress
|
I created a custom loop using WP_Query for my featured content slider. <code> <?php $slider_query = new WP_Query(); $slider_query->query("posts_per_page=5&tag=".(get_option('cgr_slider_tag'))" ");?> <?php while ($slider_query->have_posts()) : $slider_query->the_post(); ?> <article class="slide-item "> .... </code> It works fine in previous 3.1.4 , but after upgraded to 3.2 that code is just didn't work. No error found in WP_Debug mode, and Then i try to directly assign the tag name without using the get_option : <code> <?php $slider_query = new WP_Query(); $slider_query->query("posts_per_page=5&tag=tag1");?> <?php while ($slider_query->have_posts()) : $slider_query->the_post(); ?> <article class="slide-item "> .... </code> it works, so i assume the problem is the get_option thing. I've checked the database and other part of the theme that also using get_option and found no problem. I start thinking that the problem is I didn't code the get_option part correctly, i'm php noob so maybe it's about encapsed string or others. Any help will be appreciated.
|
this line: <code> $slider_query->query("posts_per_page=5&tag=".(get_option('cgr_slider_tag'))" "); </code> should be: <code> $slider_query->query("posts_per_page=5&tag=".(get_option('cgr_slider_tag'))); </code>
|
My WP_Query didn't work after upgrading to WordPress 3.2
|
wordpress
|
I have this typical WordPress page (page.php): <code> <?php the_post(); ?> <div id="rightcol"> <div <?php post_class(); ?>> <?php the_content(); ?> </div> </code> All works fine; have some shortcode, [gallery] , in the page content. So then I add a simple loop to the page to display random posts form a given category: <code> <?php query_posts('category_name=interesting_sites&posts_per_page=3&orderby=rand'); ?> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <div <?php post_class(); ?>> <h1><?php the_title(); ?></h1> <?php the_content(); ?> </div> <?php endwhile; ?> <?php endif; ?> <?php wp_reset_postdata(); ?> </code> Then, shortcode in page content fails! Why this happens? Any ideas?
|
You really shouldn't use <code> query_posts() </code> for anything other than the main loop of that page and use either <code> WP_Query() </code> or <code> get_posts() </code> , try this: <code> $my_query = new WP_Query( array( 'category_name' => 'interesting_sites', 'posts_per_page' => 3, 'orderby' => 'rand' ) ); while ($my_query->have_posts()){ $my_query->the_post(); ?> <div <?php post_class(); ?>> <h1><?php the_title(); ?></h1> <?php the_content(); ?> </div> <?php } wp_reset_postdata(); </code>
|
loop on page makes shortcode fail
|
wordpress
|
I have one plugin which conflicts with new design of dashboard. I see, that author doesn't bother with support, so I thought I do it myself or at least try. So I would like to add custom row to this menu in dashboard if it is possible. If anyone could help I would be really appreciated.
|
Yes it's quite possible, there's a filter hook in place so we can add our own links in, adjust the following code as necessary.. <code> add_filter( 'admin_user_info_links', 'custom_admin_user_info_links' ); function custom_admin_user_info_links( $links ) { $links[] = '<a href="http://www.google.com">Example link</a>'; //$links[] = '<a href="stackexchange-url example</a>'; return $links; } </code> Hope that helps.
|
Add custom row to welcoming in dashboard
|
wordpress
|
I am developing a wordpress site (http://new.saffronresourcing.com/candidates/) where candidates who wants to apply for jobs will be able to upload their cv along with their personal details. I already created custom content type for job list which will be used for job listing. it working fine. Now there is a "apply now" button attached to all job listing. Problem is when user clicks apply button, it goes to another page named uploadcv.php. Question is when I'm in uploadcv.page, I have no way to find which job listing page user came from. So I need a reference variable which will hold the current page job list ref. number and when user clicks apply now button it will carry out that variable and move to uploadcv.php page so I can save the details to the database along with that job reference number. Is there any idea how to get the current page URL and pass to the next page? Now as I said earlier candidates will upload their cv, I'm not sure whether how I am gonna add this CV (type .doc, .pdf) into mysql database. Is their any special code to insert the .pdf or .doc file to the database ? And when the information will be added to the database , I also need to retrieve those details and display in wordpress dashboard so the admin of the site can view which candidates applied for which jobs. So i'm looking for some kind of options panel or candidates lists page where the data will come from database. So in a nutshell, Please let me know if you guys know how to get the current page URL and pass to next page insert the values from details entry form to database and retrieve the values and display into dashboard, somewhere in dashboard so admin can view the candidates list. I'm aware there is a plugin exists wp job manager, but I have no clue how to use this plugin, couldn't find a proper documentation. So I decided I will not use this plugin and write code by myself. If you guys know about this plugin, let me know how did you use this for job listing purpose. Thanx in advance.
|
You say that the listing is a custom post type so each job listing has a post ID so you can just pass that to your uploadcv.php in your Apply Now Button : <code> <a href=".../uploadcv.php?listing_id=<?php echo $post->ID; ?>">Apply Now</a> </code> and then retrieve that in your uploadcv.php : <code> $listing_ID = (int)$_GET['listing_id']; </code> Now as far as saving the CV in the database, that would be a bad id, when you can simply upload the cv to your server and just save the URL in the database.
|
How to: wordpress job listing and candidates details
|
wordpress
|
I try to made a website in full ajax (a html5 website). I use jquery and innerShiv (for ie). For exemple I want to load all the content of the "section" tag of a page. When I use that script, it works perfectly : var link = 'http://ajax.wuiwui.net'; $('#new').load(link + ' #contenu'); But when i use this one, I can't find element which aren't into the wordpress loop... $.ajax({ url: link, processData: false, success: function(data){ data = innerShiv(data,false); var truc = $(data).find('#contenu'); $('#new').append(truc); } }); For my project I want to load some elements with only one ajax request, so the second script is more intersting. But it dont work... Do you know why ? My project : http:/ajax.wuiwui.net Thanks a lot for your help !
|
I solved my problem !! In fact, jQuery can't parse an element at the root stage. I juste wrap all my body content into a div , and it works... I can also use " filter " function instead of "find".
|
Ajax request with jQuery without WP_ajax
|
wordpress
|
I'm new here and I really hope somebody can help me. I've tried alone for many days, found a lot of solutions that worked for others, but that didn't work for me and so I really hope somebody here can help me figure it out. I have the "Guan Image Notes" Plugin installed. I finally got it to work (it seems to interfer with other plugins, especially OpenID and Captcha plugins). However I can't seem to get rid of this error message when somebody sends a comment: <code> Warning: Cannot modify header information - headers already sent by (output started at /hermes/bos.../wp-content/plugins/guan-image-notes/imageannotation.php:178) in /hermes/bos.../wp-comments-post.php on line 95 Warning: Cannot modify header information - headers already sent by (output started at /hermes/bos.../wp-content/plugins/guan-image-notes/imageannotation.php:178) in /hermes/bos.../wp-comments-post.php on line 96 Warning: Cannot modify header information - headers already sent by (output started at /hermes/bos.../wp-content/plugins/guan-image-notes/imageannotation.php:178) in /hermes/bos.../wp-comments-post.php on line 97 Warning: Cannot modify header information - headers already sent by (output started at /hermes/bos.../wp-content/plugins/guan-image-notes/imageannotation.php:178) in /hermes/bos.../wp-includes/pluggable.php on line 934 </code> The comment is still being sent, though! I tried to modify that line. Wrapping it. The content of that line is: <code> echo "&nbsp;"; </code> Here*s the whole code: http://pastebin.com/pu86tyn5 I really hope somebody can help me figure this out. I'm a total beginner when it comes to coding. My website looks horrible right now as I'm still trying out things. If you need to check my website, here it is: click Thanks so much in advance.
|
Okay, just looking through this code quickly, it looks like the problem may be that the <code> getImgID() </code> function is echoing rather than returning its output. This function is called from within another function, <code> guan_getImgID_inserter() </code> , that is hooked into the <code> comment_text </code> filter hook. Anything that filters <code> comment_text </code> (or any filter hook, for that matter), should be returning its output, since the hook is already echoed, usually via a call to <code> echo apply_filters() </code> . So, you may want to change the <code> echo </code> calls to <code> return </code> calls, in lines 176 and 178. i.e. these: <code> if($imgIDNow != "") { $str = substr($imgIDNow, 4, strlen($imgIDNow)); echo "<div id=\"comment-".$str."\"><a href='#".$str."'>noted on #".$imgIDNow."</a></div>"; } else { echo "&nbsp;"; } </code> should instead be this: <code> if($imgIDNow != "") { $str = substr($imgIDNow, 4, strlen($imgIDNow)); return "<div id=\"comment-".$str."\"><a href='#".$str."'>noted on #".$imgIDNow."</a></div>"; } else { return "&nbsp;"; } </code> I'm not 100% certain that's the problem, but it's at least worth a shot...
|
wp-comment-post.php and header already sent issues
|
wordpress
|
I have a custom post type; posts of this type can have either one or two categories associated with them. I need to display the names of the categories that are associated with each of these custom posts within the loop. Is there a way to do this?
|
Assuming you have added the <code> category </code> taxonomy to your Custom Post Type, you can simply call <code> the_category() </code> . Alternately, if you're using a custom taxonomy, you can echo the results of <code> get_the_terms( $id, $taxonomy ) </code> .
|
Show the categories the current post has
|
wordpress
|
I have a function that kills the media buttons on certain custom post types. I want it to load whenever any post/ page edit page opens. What's the best action to hook this up to? Thanks in advance.
|
Try the <code> 'load-post.php' </code> action.
|
Action for opening edit page in admin?
|
wordpress
|
I'm gonna create a new site. I want to make the site as user generate able content site. Basically this is my site's function. Users signup in my wordpress site, Submit content from wp-admin panel, some points will be given if the post approved by admin, later those points will be converted into some cash money. So i need some advise. I heard wordpress has low security. If i let the users to create content from wp-admin, will they hack my site? is it good or bad to let them use wp-admin area? Is it possible to make those user content submission form from frontend? I'm not interested in plugin like TDO Mini Forms. Because i need points system. Some tips needed. Thanks in advance PS: Can i use buddypress to achieve this?
|
You need to stop listening to people who says PHP and WordPress is not secure. Its how you do it. You can do it in WordPress, without using BuddyPress. In fact you don't even need it for anything. All you need to make default users contributors, and a small plugin which takes care of their points when their posts are approved.
|
User generated content and security
|
wordpress
|
I am looking for a solution to returning multiple get_post_meta values... Current I am using a meta box array as follows: <code> $meta_boxes[] = array( 'id' => 'setlist', 'title' => 'Setlist Information', 'pages' => array('post'), 'fields' => array( array( 'name' => 'Setlist 1', // field name 'desc' => 'Entry 1', // field description, optional 'id' => $prefix . 'setlist_1', // field id, i.e. the meta key 'type' => 'text', // text box 'std' => '', // default value, optional 'style' => 'width: 100px', // custom style for field, added in v3.1 ), array( 'name' => 'Setlist 2', 'desc' => 'Entry 2', 'id' => $prefix . 'setlist_2', 'type' => 'text', 'std' => '', 'style' => 'width: 100px', ), </code> and so on so forth (i.e. setlist_3,4,5,6,7,8....) In my single.php I have: <code> <?php if ( get_post_meta( $post->ID, 'rw_setlist_1', true ) ) : echo "<li>"; echo get_post_meta( $post->ID, 'rw_setlist_1', true ); echo "</li>"; ?> <?php endif; ?> <?php if ( get_post_meta( $post->ID, 'rw_setlist_2', true ) ) : echo "<li>"; echo get_post_meta( $post->ID, 'rw_setlist_2', true ); echo "</li>"; ?> <?php endif; ?> <?php if ( get_post_meta( $post->ID, 'rw_setlist_3', true ) ) : echo "<li>"; echo get_post_meta( $post->ID, 'rw_setlist_3', true ); echo "</li>"; ?> <?php endif; ?> <?php if ( get_post_meta( $post->ID, 'rw_setlist_4', true ) ) : echo "<li>"; echo get_post_meta( $post->ID, 'rw_setlist_4', true ); echo "</li>"; ?> <?php endif; ?> <?php if ( get_post_meta( $post->ID, 'rw_setlist_5', true ) ) : echo "<li>"; echo get_post_meta( $post->ID, 'rw_setlist_5', true ); echo "</li>"; ?> </code> The set-list values can range from 2 to 30... Call me crazy, but I feel as if this method causes unnecessary and lengthy load times, am I right? So how would I go about creating a more efficient script for this that would check all the values in the array in a "simpler way".
|
The way your code is setup is just wrong, you are making two database calls for each custom field and if you have between 2-30 fields like this then that means you make over 60 calls to the database which can be done with a single call using <code> get_post_custom() </code> for ex: <code> $custom_fields = get_post_custom($post->ID); for ($i = 1; $i <= 30; $i++) { if(isset($custom_fields["rw_setlist_$i"])){ echo "<li>"; echo $custom_fields["rw_setlist_$i"]; echo "</li>"; } } </code>
|
Returning multiple get_post_meta values
|
wordpress
|
Is there a filter or hook that is triggered just before post content is rendered? What I'd like to do is to apply a filter to the text content of a post just before the post text is being rendered.
|
Can you not simply use <code> the_content </code> filter hook? <code> function mytheme_content_filter( $content ) { // Do stuff to $content, which contains the_content() // Then return it return $content; } add_filter( 'the_content', 'mytheme_content_filter' ); </code>
|
Filter or Hook to catch pre-rendering of post content
|
wordpress
|
There are several threads on Wordpress.org about this problem, but none with solutions. I just went from localhost (MAMP) to a live server (Dreamhost) and I'm getting constant 404s when submitting actions (such as changing a title) or trying to load pages in the admin (such as post/page/cpt lists). The problem is WP is running up against memory limits (see support message below). What is the best systematic way to evaluate/troubleshoot memory use in the WP admin? Plugins tend to be implicated in this sort of problem; are there any other usual suspects? <code> `I've checked into why you've been receiving these 404 errors, and it seems your scripts have been getting automatically killed by our Process Watcher script due to your site(s) going over Memory limits on the shared server. 2011-07-08 08:53:59 procwatch2 INFO: Process(pid=12921, name='php5.cgi', uid=_, tty=None, cpu=17.5, rss=155764.0, vsize=264456.0): kill for total RAM 2011-07-08 08:54:19 procwatch2 INFO: Process(pid=13248, name='php5.cgi', uid=_, tty=None, cpu=29.8, rss=197348.0, vsize=305212.0): kill for total RAM 2011-07-08 08:54:40 procwatch2 INFO: Process(pid=13253, name='php5.cgi', uid=_, tty=None, cpu=39.9, rss=197376.0, vsize=305188.0): kill for total RAM` </code>
|
Here's a systematic way to troubleshoot this, from user asbjornu in stackexchange-url ("How to eliminate weird 404 errors in wp-admin?") The only way to debug this is to disable one plugin at a time, each time trying to reproduce the problem before you disable another plugin. Start with the plugins that have anything to do with the administration of WP, then move down to regular theme plugins, widgets and such. Inspect the "Not Found" page that you are served better (browse with Opera and open the Info panel which will show you the headers, alternatively browse with Firefox and have Firebug with the "Net" panel enabled) and do a search through all of your plugins to see if they might be serving it directly. If not, take a look at the log of the web server to find out what exact resource it's unable to serve; a plugin might be doing some fancy redirecting or rewriting so it's not necessarily the URL you see in your browser that's causing the 404.
|
How to troubleshoot 404s in Wordpress admin
|
wordpress
|
I've been trying to get the TinyMCE editor working in the comments field but I've been unable to do so. Another suggestion I found was http://nicedit.com , the editor is working but the comments are not saved in rich text. TinyMCEComments seems to do it but hasn't been updated in a while, it's not working for 3.2. Did anybody got this working? Thanks!
|
Solved it myself by loading tinymce in the header: <code> wp_enqueue_script('tiny_mce'); </code> This will include the TinyMCE javascript. Then simply use TinyMCE as you wish <code> <script type="text/javascript"> tinyMCE.init({ mode : "textareas", theme : "advanced", plugins : "autolink,lists,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template", theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect", theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor", theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen", theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak,|,insertfile,insertimage", theme_advanced_toolbar_location : "top", theme_advanced_toolbar_align : "left", theme_advanced_statusbar_location : "bottom", theme_advanced_resizing : true, skin : "o2k7", skin_variant : "silver", }); </script> </code>
|
Use rich text editor in comments?
|
wordpress
|
I have from my perspective a complicated loop. Code below. <code> <!-- *** Check Mass List (Custom Post Type) *** --> <!-- *** End Mass List (Custom Post Type) *** --> <?php if (have_posts()) : ?> <?php $new = 'first'; ?> <?php while (have_posts()) : the_post(); ?> <?php if( $new == 'first' && !is_paged() ) : $new = 'not-first'; ?> <p class="timedate"><?php the_date('F jS, Y'); ?></p> <article id="post-<?php the_ID(); ?>" class="latest"> <h1><?php the_category(', '); ?></h1> <?php ($post == $posts[0] && !is_paged()) ? the_content('', 'FALSE') : the_excerpt() ; ?> <p><?php the_tags('Tags: ', ', ', '<br>'); ?></p> </article> <?php else : ?> <p class="timedate"><?php the_date('F jS, Y'); ?></p> <article id="post-<?php the_ID(); ?>"> <h1><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"> <?php the_category(' '); ?></a></h1> <div class="shortstuff"> <?php $tags = get_the_tags(); $html = '<div class="post_tags">'; foreach ( $tags as $tag ) { $tag_link = get_tag_link( $tag->term_id ); $html .= "<a href='{$tag_link}' title='{$tag->name} Tag' class='{$tag->slug}'> <h2>{$tag->name}</h2></a>"; $html .= "<p>$tag->description</p>".""; } $html .= '</div>'; echo $html;?> <?php ($post == $posts[0] && !is_paged()) ? the_content('', 'FALSE') : the_excerpt() ; ?> </div> </article> <?php endif; ?> <?php endwhile; ?> <nav> <p> <?php posts_nav_link('&nbsp;&bull;&nbsp;'); ?> </p> </nav> <?php else : ?> <article> <h1>Not Found</h1> <p>Sorry, but the requested resource was not found on this site.</p> <?php get_search_form(); ?> </article> <?php endif; ?> </code> This loop as you may have read does the following: Displays the latest post made then goes on to display the older posts. The Latest post is displayed in another style as opposed to the older posts. I would like to add a 3rd check to this loop for a custom post type. So wordpress checks all 3 arguments then displays them based in the order on what date & time they were posted. Example of the output logic could be. July 5 - Latest, custom post type, other posts. July 6 - custom post type, newest post then oldest post. So everything works as my code shows in the sample. Only change would be the loop checks to see if a custom post type exists for that day and if it does it inserts it into the output. Edited*
|
To alter your default or main loop you can add <code> query_posts </code> before the loop runs. http://codex.wordpress.org/Function_Reference/query_posts http://codex.wordpress.org/Class_Reference/WP_Query ( parameters) For example in your above code, to include all posts including custom posts types you would write; <code> <?php query_posts( 'post_type=any'); ?> <?php while (have_posts()) : the_post(); ?> //rest of your code from above </code> If you want to just include all default posts and 1 custom post type called "mass_list" , I recommend using WP Query over query_posts in this case. <code> <?php $query = new WP_Query( array( 'post_type' => array( 'post', 'mass_list' ) ) ); ?> <?php while (have_posts()) : the_post(); ?> //rest of your code from above </code> You can drill down by looking at the parameters of WP Query in the link above, as you can see the options of WP Query allow for a lot of custom output.
|
Insert a Custom Post type into my Loop
|
wordpress
|
Here is my current code. <code> function custom_login_footer() { return '<p>text text text</p>'; } add_filter('login_form_bottom', 'custom_login_footer'); </code> I am trying to add text below the submit button, but I do not know how to apply the <code> login_form_bottom </code> filter.
|
your code is correct, however, that filter only applies to the <code> wp_login_form() </code> function, which is not what <code> wp-login.php </code> uses, so you won't be seeing your text there if that's what you're expecting! try adding a call to <code> wp_login_form() </code> in a template to see what the filter does.
|
What is the proper way to apply the login_form_bottom filter?
|
wordpress
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.