question
stringlengths 0
34.8k
| answer
stringlengths 0
28.3k
| title
stringlengths 7
150
| forum_tag
stringclasses 12
values |
---|---|---|---|
I have a list of the most recent post titles in <code> sidebar.php </code> . Here is an example of how that code looks: <code> <?php $args = array('posts_per_page' => 20); ?> <?php $sidebar = new WP_Query($args); ?> <?php if ( $sidebar->have_posts() ) : ?> <?php while ( $sidebar->have_posts() ) : $sidebar->the_post(); ?> <div class="story"> <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"> <?php the_title(); ?> - <?php the_time("F j, Y h:i A"); ?> </a> </div> <?php endwhile; ?> <?php endif; ?> </code> That part works perfectly. It displays the 20 latest post titles and post times wrapped in permalinks. However, I am trying to do a bit more. I want to create a load more button at the bottom to fetch the next 20 post titles. I know my jQuery and that is not the issue. I need help with figuring out how to create a custom loop in a new custom <code> .php </code> template file that only generates the html above. That file needs to be able to accept a parameter for a page number, so that my <code> javascript </code> can fetch an incremented URL each time. I would appreciate any help, thanks!
|
you can wrap your function and hook it to ajax call like this: <code> //if you want only logged in users to access this function use this hook add_action('wp_ajax_more_links', 'my_AJAX_more_links_function'); //if you want none logged in users to access this function use this hook add_action('wp_ajax_nopriv_more_links', 'my_AJAX_more_links_function'); function my_AJAX_more_links_function(){ check_ajax_referer('more_links'); $success_response = new WP_Ajax_Response(); $args = array('posts_per_page' => 20 , 'offset' => $_POST['offset']); $sidebar = new WP_Query($args); if ( $sidebar->have_posts() ){ while ( $sidebar->have_posts() ) { $sidebar->the_post(); $out .= '<div class="story">'; $out .= '<a href="' . the_permalink().'" title="'. the_title'.">' . the_title().' - '.the_time("F j, Y h:i A") .'</a></div>'; } $success_response->add(array( 'what' => 'has', 'data' => array('html' => $out, 'offset' => $_POST['offset'] )); }else{ $out = __('Sorry but No more!'); $success_response->add(array( 'what' => 'none', 'data' => $out )); } $success_response->send(); exit; } </code> then add this to your sidebar function at the end <code> <span class="more_links"></span> <span class="get_more"> <input type="hidden" name="offset" id="offset" value="20"> <input type="submit" name="more" id="more" value="Get more links"> </span> <script type="text/javascript" > jQuery(document).ready(function($) { jQuery('#more').click(function() { var data = { action: 'more_links', offset: jQuery( '#offset' ).val(), _ajax_nonce: <?php echo wp_create_nonce( 'more_links' ); ?> }; // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php jQuery.post(ajaxurl, data, function(response) { var res = wpAjax.parseAjaxResponse(response, 'ajax-response'); jQuery.each( res.responses, function() { if (this.what == 'has') { //insert links jQuery(".more_links").append( this.data.html ); //update offset value jQuery("#offset").val(this.data.offset); jQuery(".more_links").fadeIn("fast"); }else{ //no more links found jQuery(".more_links").append( this.data.html ); jQuery(".get_more").remove(); } //end if });//end each }); return false; }) }); </script> </code> and there you go, oh wait you need to add wp-ajax-response so <code> add_action('wp_head','add_scripts_121'); function add_scripts_121(){ wp_enqueue_script('wp-ajax-response'); } </code> and you are set
|
How can I fetch loop of post titles via AJAX?
|
wordpress
|
I am trying to customize the admin area using the functions.php file to make things easier for my clients. One request I have got before and hope to be able to accomplish, is to move some of the sub menus into the main navigation. For instance I would like to make Widgets and Menus appear in the main navigation as opposed to being a submenu for Appearances. I would then end up removing the Appearances tab all together. I have been able to remove the tab but unable to make the new buttons for Widgets and Menus. Even if I can get help of not technically moving them but instead creating a new button and setting the link myself (ex. for Menus -> /nav-menus.php). Is any of that possible? Thanks
|
OK, it's a bit messy, but it works. Take a look <code> function remove_submenus() { global $submenu; unset($submenu['themes.php'][10]); // Removes Menu } add_action('admin_menu', 'remove_submenus'); function new_nav_menu () { global $menu; $menu[99] = array('', 'read', 'separator', '', 'menu-top menu-nav'); add_menu_page(__('Nav Menus', 'mav-menus'), __('Nav Menus', 'nav-menus'), 'edit_themes', 'nav-menus.php', '', 99); } add_action('admin_menu', 'new_nav_menu'); </code> Essentially it is removing the nav menu settings from the Appearance sub-panel, then re-adding it as a top level page (similar to a plugin). You can set an icon URL in there as well. The only part I can't get working the way I want is the positioning.
|
Make sub menu items a main link in the admin menu using fuctions.php
|
wordpress
|
I tried using http://wordpress.org/extend/plugins/wp-dummy-content/ but when I try using it, I get something like An error occurred: Field 'to_ping' doesn't have a default valueAn error occurred: Field 'to_ping' doesn't have a default valueAn error occurred: Field 'to_ping' doesn't have a default valueAn error occurred: Field 'to_ping' doesn't have a default valueAn error occurred: Field 'to_ping' doesn't have a default value Is it the plugin or is it my WordPress (which is new? 3.0.5 just downloaded) Perhaps there are other Dummy content available
|
Might wish to try the theme unit tests for creating test/dummy content. Just note, some of the images in the unit test may have incorrect URLs, they were for me(but should be relatively easy to correct - i can give you the URLs if you need them, i've fixed them in my installation - i just can't remember specifically which ones right now).
|
Any dummy content I can use for development?
|
wordpress
|
My main page has a intro image beside the main content. I would like to add that image using custom fields. I've noticed that pages don't have. I would like to enable them. Is it a bad practice?
|
Pages do have Custom Fields enabled by default on WordPress. If you're not seeing them on the "New/Edit Page" page, then check the "Screen Options" pull down tab on the upper right corner of your Dashboard. See if "custom fields" is checked.
|
How to enable custom fields for pages (if not a bad practice)?
|
wordpress
|
When I search plug-ins for RSS, so many of them are dealing with pulling in RSS feeds. I just want an RSS icon to let people subscribe to my feed? I'm also using FeedBurner. I looked for Feedburner plugins as well, but still confused what is simple and best. Shouldn't all blogs have an RSS icon? Or is that simply a matter of the theme? Seems like the default 2010 theme would even have that.
|
It is matter of theme, unlike technical links for browser discovery (that make RSS show up in browser address bar) there is no convention on how to present RSS links in page. So that completely up to designer/web master. The simplest way is putting together HTML for link (or taking FeedBurner's snippet) and putting it into text widget.
|
How to add RSS Icon/link as a widget?
|
wordpress
|
I'm looking for a way to search through posts by ID, preferably with support for custom post types. I was hoping there'd be a plugin enabling this functionality, but I've failed to find anything. Any ideas would be greatly appreciated, thank you.
|
Not sure i understand why you'd want to query by ID, but that said it's possible in a hacky kind of way(i like this method because it's simple). <code> add_action( 'parse_request', 'idsearch' ); function idsearch( $wp ) { global $pagenow; // If it's not the post listing return if( 'edit.php' != $pagenow ) return; // If it's not a search return if( !isset( $wp->query_vars['s'] ) ) return; // If it's a search but there's no prefix, return if( '#' != substr( $wp->query_vars['s'], 0, 1 ) ) return; // Validate the numeric value $id = absint( substr( $wp->query_vars['s'], 1 ) ); if( !$id ) return; // Return if no ID, absint returns 0 for invalid values // If we reach here, all criteria is fulfilled, unset search and select by ID instead unset( $wp->query_vars['s'] ); $wp->query_vars['p'] = $id; } </code> All you then do is search using the regular search box using a <code> # </code> (hash) prefix infront of the numeric ID. <code> #123 </code> ..would return the post with an ID of 123. I'm sure there's more complicated routes that could be taken to do this, but i don't see any issues with this approach, unless you have lots of posts with titles that start with a hash(but you could always swap the hash for another character). Hope that helps. :)
|
Search posts by ID in admin
|
wordpress
|
I'm using this code to display the thumbnail (featured picture) of the previous and next post (a custom post type called Blocks). (A custom loop) <code> <?php // Create and run custom loop $custom_posts = new WP_Query(); $custom_posts->query('post_type=blocks&location=Front Page&section=Mainbar'); while ($custom_posts->have_posts()) : $custom_posts->the_post(); ?> <div class="block-2 border-top"> <h2><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2> <?php endwhile; ?> <?php // Display previous and next posts thumbnails ?> <div class="float-left"> <?php $prevPost = get_previous_post(); $prevthumbnail = get_the_post_thumbnail($prevPost->ID); previous_post_link('%link', $prevthumbnail); ?> </div> <?php // Get thumbnail of next post ?> <div class="float-right"> <?php $nextPost = get_next_post(); $nextthumbnail = get_the_post_thumbnail($nextPost->ID); next_post_link('%link', $nextthumbnail); ?> </div> </div> </code> This is the chronology: And this is the output: <code> <div class="block-2 border-top"> <h2><a href="http://localhost/wpac/?blocks=mainbar" title="Permalink to Mainbar" rel="bookmark">Mainbar</a></h2> <div class="float-left"> <a href="http://localhost/wpac/?blocks=mainbar-left" rel="prev"><img width="160" height="150" src="http://localhost/wpac/wp-content/uploads/2011/02/showcase2.png" class="attachment-post-thumbnail wp-post-image" alt="showcase2" title="showcase2" /></a> </div> <div class="float-right"> <a href="http://localhost/wpac/?blocks=mainbar-right" rel="next"><img width="160" height="150" src="http://localhost/wpac/wp-content/uploads/2011/02/2974999772_7085da4d347.jpg" class="attachment-post-thumbnail wp-post-image" alt="2974999772_7085da4d347" title="2974999772_7085da4d347" /></a> </div> </div> <div class="block-3 border-top"> <h2><a href="http://localhost/wpac/?blocks=sidebar" title="Permalink to Sidebar" rel="bookmark">Sidebar</a></h2> <a href="http://localhost/wpac/?blocks=sidebar" title="Permalink to Sidebar" rel="bookmark"><img width="160" height="150" src="http://localhost/wpac/wp-content/uploads/2011/02/2974999772_7085da4d3410.jpg" class="attachment-post-thumbnail wp-post-image" alt="2974999772_7085da4d3410" title="2974999772_7085da4d3410" /></a> <p></p> <p></p> </div> </code> It doesn't matter in which single post I am. The thumbnails of <code> Mainbar Left </code> and <code> Mainbar Right </code> are always displayed) Any suggestions? EDIT: Full code: <code> <?php /** * The Template for displaying all single posts. * * @package WordPress * @subpackage Starkers * @since Starkers 3.0 */ get_header(); ?> <?php get_sidebar(); ?> <div id="content"> <?php // Create and run custom loop $custom_posts = new WP_Query(); $custom_posts->query('post_type=blocks&location=Work&section=Intro'); while ($custom_posts->have_posts()) : $custom_posts->the_post(); ?> <div class="block-1"> <?php the_post_thumbnail('large'); ?> </div> <?php endwhile; ?> <?php // Create and run custom loop $custom_posts = new WP_Query(); $custom_posts->query('post_type=blocks&location=Work&section=Tagline'); while ($custom_posts->have_posts()) : $custom_posts->the_post(); ?> <div class="block-2 padding-top"> <?php the_content(); ?> </div> <?php endwhile; ?> <?php wp_reset_query(); ?> <?php // Create and run custom loop ?> <div class="block-2 border-top"> <?php // Display the thumbnail of the previous post ?> <div class="float-left"> <?php $prevPost = get_previous_post(); $prevthumbnail = get_the_post_thumbnail($prevPost->ID); ?> <h2><?php previous_post_link('%link', 'Previous'); ?></h2> <?php previous_post_link('%link', $prevthumbnail); ?> </div> <?php // Display the thumbnail of the next post ?> <div class="float-right"> <?php $nextPost = get_next_post(); $nextthumbnail = get_the_post_thumbnail($nextPost->ID); ?> <h2><?php next_post_link('%link', 'Next'); ?></h2> <?php next_post_link('%link', $nextthumbnail); ?> </div> </div> <?php // Create and run custom loop $custom_posts = new WP_Query(); $custom_posts->query('post_type=blocks&location=Front Page&section=Sidebar'); while ($custom_posts->have_posts()) : $custom_posts->the_post(); ?> <div class="block-3 border-top"> <h2><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2> <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_post_thumbnail(); ?></a> <p><?php the_excerpt(); ?></p> <p><?php echo get_post_meta($post->ID, "Other_Work", true); ?></p> </div> <?php endwhile; ?> <?php // Start the main loop if ( have_posts() ) while ( have_posts() ) : the_post(); ?> <div class="block-4 border-top"> <?php the_content(); ?> </div><!-- .entry-content --> <?php endwhile; // end of the loop. ?> <?php get_sidebar('secondary'); ?> </div><!-- #content --> <?php get_footer(); ?> </code>
|
Update: OK. If you get to keep changing the question, I get to delete what I had written before and start all over again. To be honest, I'm a bit confused about what you are trying to do. Since this appears to be for a single post (based on the comment at the top of your template), it is unclear to me what your first 2 custom loops are meant to accomplish. It looks like you are printing out the thumbnails and contents of all <code> blocks </code> posts that have a location of <code> Work </code> , regardless of what single post you are on. If you simply want to show the thumbnail and content for the current, single post, then just do that. Note: because the custom loop for the <code> Front Page </code> posts calls <code> the_post() </code> , it is modifying the global <code> $post </code> . I don't know if your sidebar code is depending on that being the original post or not, but I stuck in a call to <code> wp_reset_query() </code> just in case. Below is what I think you were trying to accomplish, but I could be wrong: <code> <?php /** * The Template for displaying all single posts. * * @package WordPress * @subpackage Starkers * @since Starkers 3.0 */ get_header(); ?> <?php get_sidebar(); ?> <div id="content"> <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?> <div class="block-1"> <?php the_post_thumbnail('large'); ?> </div> <div class="block-2 padding-top"> <?php the_content(); ?> </div> <div class="block-2 border-top"> <?php // Display the thumbnail of the previous post ?> <div class="float-left"> <?php $prevPost = get_previous_post(); $prevthumbnail = get_the_post_thumbnail($prevPost->ID); ?> <h2><?php previous_post_link('%link', 'Previous'); ?></h2> <?php previous_post_link('%link', $prevthumbnail); ?> </div> <?php // Display the thumbnail of the next post ?> <div class="float-right"> <?php $nextPost = get_next_post(); $nextthumbnail = get_the_post_thumbnail($nextPost->ID); ?> <h2><?php next_post_link('%link', 'Next'); ?></h2> <?php next_post_link('%link', $nextthumbnail); ?> </div> </div> <?php endif; ?> <?php // Create and run custom loop $custom_posts = new WP_Query(); $custom_posts->query('post_type=blocks&amp;location=Front Page&amp;section=Sidebar'); while ($custom_posts->have_posts()) : $custom_posts->the_post(); ?> <div class="block-3 border-top"> <h2><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2> <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_post_thumbnail(); ?></a> <p><?php the_excerpt(); ?></p> <p><?php echo get_post_meta($post->ID, "Other_Work", true); ?></p> </div> <?php endwhile; ?> <?php wp_reset_query(); // I don't know if this is needed by the sidebar code. If not, you can delete this. ?> <?php get_sidebar('secondary'); ?> </div><!-- #content --> <?php get_footer(); ?> </code>
|
Thumbnail (featured image) of next and previous post is not being properly displayed!
|
wordpress
|
I'm trying to do something I assumed would be easy. I assumed wrong. What I want to do is list all the authors of a site on the sidebar, with a link to their respective author page, number of posts written, and gravatar. wp_list_authors doesn't give me an option to include the gravatar at all. Here is what I have <code> $blogusers = get_users_of_blog(); if ($blogusers) { foreach ($blogusers as $bloguser) { $user = get_userdata($bloguser->user_id); $post_count = count_user_posts($user->ID); if ($post_count) { echo '<li>'; echo '<a href="'.get_bloginfo('url').'/author/' . $user->user_nicename . '">'.get_avatar($user->user_email, '36').'</a>'; echo '<a href="'.get_bloginfo('url').'/author/' . $user->user_nicename . '">'.$user->display_name.' ('.$post_count.')</a><li>'; } } } </code> Which works, albeit with two problems: I can't find a way to have them sort by number of posts the get_users_of_blog is a depreciated function. I really don't want to use it. I was able to create an explode with wp_list_authors, but didn't have a clue how to extract the data out of it to display in this manner. Help?
|
To answer your problems: Sorting by post count You can collect all the information you need in to an array and sort that array by number of posts , like this: <code> //function to sort array by filed function authors_orderBy($data, $field){ $code = "if (\$a['$field'] == \$b['$field']) {return 0;} return (\$a['$field'] < \$b['$field']) ? 1 : -1;"; usort($data, create_function('$a,$b', $code)); return $data; } </code> then change your code a bit like so: <code> $blogusers = get_users_of_blog(); if ($blogusers) { $au = array(); foreach ($blogusers as $bloguser) { $user = get_userdata($bloguser->user_id); $post_count = count_user_posts($user->ID); $au[] = array('user_id' => $user->ID , 'nicename' => $user->user_nicename, 'display_name' => $user->display_name, 'email' => $user->user_email ,'post_count' => $post_count); } //Sort array $au = authors_orderBy($au, 'post_count'); //then loop through the authors foreach ($au as $aut){ if ($aut['post_count'] > 0) { echo '<li>'; echo '<a href="'.get_bloginfo('url').'/author/' . $aut['nicename'] . '">'.get_avatar($aut['email'], '36').'</a>'; echo '<a href="'.get_bloginfo('url').'/author/' . $aut['nicename'] . '">'.$aut['display_name'] .' ('.$aut['post_count'].')</a><li>'; } } } </code> get_users_of_blog is a depreciated It's weird because looking at the codex Yes this function is depreciated and you should use <code> get_users() </code> which should be shipped with Version 3.1 <code> /** * Retrieve list of users matching criteria. * * @since 3.1.0 * @uses $wpdb * @uses WP_User_Query See for default arguments and information. * * @param array $args * @return array List of users. */ function get_users( $args ) { $args = wp_parse_args( $args ); $args['count_total'] = false; $user_search = new WP_User_Query($args); return (array) $user_search->get_results(); } </code> but if you look at wp_list_authors it uses get_users_of_blog() be itself. Hope this helps.
|
List authors of site with link and gravatar
|
wordpress
|
I'm unable to devine what's causing my theme to crash in WP 2.9.2, although I know its something in my query statement below, so I need to do a version check for (version) < 3 to branch it. What is the method to get the currently installed WP version? - I'm just using "wp_version" as a stand in :) <code> if(wp_version < 3) $myqueryTopMenu = ''; else $myqueryTopMenu = new WP_Query();$myqueryTopMenu->query(array('cat' => "$cat,-$catHidden",'post_not_in' => get_option('sticky_posts'))); </code>
|
<code> get_bloginfo( 'version' ) </code> Other version globals can be found in wp-includes/version.php Also, it's safer to use PHP's version_compare() .
|
Code to determine WP version check
|
wordpress
|
I am working on a WordPress site, it's an online newspaper site. The theme I am developing, I want to add custom template functions like <code> get_footer() </code> or <code> get_header() </code> , so that I can save those HTML and PHP codes like the way <code> footer.php </code> stores. Thanks in advance.
|
You can define your function in the file function.php and use it later in your theme.
|
How to add custom template tag in wordpress theme?
|
wordpress
|
I have an error generated from thickbox loading on every page including the admin area. This is being printed into the html <code> <script type='text/javascript'> <![CDATA[ */ var thickboxL10n = { next: "Next &gt;", prev: "&lt; Prev",image: "Image", of: "of", close: "Close", noiframes: "This feature requires inline frames. You have iframes disabled or your browser does not support them." }; try{convertEntities(thickboxL10n);}catch(e){}; /* ]]> */ </script> </code> I would not really care but it is breaking firefox which sucks when the project is mid-development. The problem is here: convertEntities is not defined Line 55 try{convertEntities(thickboxL10n);}catch(e){}; I tried to just stop it with a function <code> function conditional_thickbox() { global $post; if (is_singular() && strpos($post->post_content,'class="thickbox"') !== false) { wp_enqueue_script('thickbox'); wp_enqueue_style('thickbox'); } } add_action('wp_print_styles','conditional_thickbox'); </code> That works well but it removes from everywhere and I realized this is a dependency for Wordpress image upload functionality. I think I found the fix here : http://core.trac.wordpress.org/attachment/ticket/16227/convertEntities-Firebug-Fix.diff Which requires me hacking the core, any ideas on the best way to fix this ?
|
The <code> convertEntities </code> function was defined in <code> utils.js </code> , but if you use script concatenation this file would be included after it is needed. Because it was in a try-catch clause, the error was not (always) noticed. The solution is to include the <code> convertEntities </code> function before this code is loaded. In WordPress 3.1 this is now included in <code> l10n.js </code> , stackexchange-url ("which you cannot disable"). A quick and dirty solution would be to copy this code and write it at the top of each page, so you are sure it is available.
|
convertEntities() used before it is defined
|
wordpress
|
I had a WordPress webshop setup, and I am using the [MailChimp Framework plugin][1] for sending newsletter, among other things. Now, the setup has been running since January 1st, then all of the sudden the Mailchimp framework suddenly stopped sending. The "Everything's Chimpy" ping status does not appear as well, sometimes it's NULL, sometimes it's garbage character. I am pretty sure I haven't touched any code of the plugin, and a colleague having a totally different project has experienced it as well. Also, I remember their reply used to be "text/json", but now I see a reply with Content-type "application/json". Is any one of you experiencing this as well? Update: Mailchimp API responded: http://groups.google.com/group/mailchimp-api-discuss/browse_thread/thread/f46b9ddfc6725aa3 http://groups.google.com/group/mailchimp-api-discuss/browse_thread/thread/8a03c3a9cd3dc3bf There seems to be a problem with connections being suddenly being dropped at mid-call. They have updated the MCAPI wrapper. I haven't tested this yet.
|
Well, it seems that the author of Wordpress MailChimp Framework is on indefinite vacation. So I suggest to you having the same problem as this one is to go through the PHP MCAPI wrapper (http://apidocs.mailchimp.com/downloads/#php) since this one is directly supported by the MailChimp team. The team has updated the wrapper to handle dropped connections. And yeah, forget about the Wordpress MailChimp Framework if you want your sanity.
|
Wordpress MailChimp Framework suddenly stopped working without modification
|
wordpress
|
I am new to wordpress development, just trying to convert my HTML into a WordPress theme, I started with Chris Coyer's blank theme. <code> <div class="navigation"> <div class="next-posts"><?php next_posts_link('&laquo; Older Entries') ?></div> <div class="prev-posts"><?php previous_posts_link('Newer Entries &raquo;') ?></div> </div> </code> How can I output the div only if there is a <code> next_posts_link() </code> . I need this as I will be using <code> <ul> </code> for my pagination. If I don't do that, I will get an empty bullet
|
You can use <code> get_previous_posts_link </code> and <code> get_next_posts_link </code> to determine if they exists like this: <code> $prev_link = get_previous_posts_link(__('&laquo; Older Entries')); $next_link = get_next_posts_link(__('Newer Entries &raquo;')); // as suggested in comments if ($prev_link || $next_link) { echo '<ul class="navigation">'; if ($prev_link){ echo '<li>'.$prev_link .'</li>'; } if ($next_link){ echo '<li>'.$next_link .'</li>'; } } </code> Hope This Helps
|
How to determine if theres a next page
|
wordpress
|
is there a way to add a new user role? I need two kind of readers: can read all private posts can read just private posts from a specific category. Subscriber as described here could be fair enough to satisfy the first kind of reader. Then what I need is to define something less than subscriber, once I can test if a user has this new role for me it's ok.
|
this plugin should help you with what you need and more http://justintadlock.com/archives/2009/09/17/members-wordpress-plugin
|
create new user role for reader
|
wordpress
|
Is there a server-side email solution that will allow users to subscribe to updates via email and, specifically, also be able to do this by category? I'm aware of Aweber and Feedburner being able to provide this kind of functionality, but my client has requested this as a server-side solution, with a database on-site. Any suggestions?
|
I found Mailpress to be a far superior option to the others I tried (Post Notification and Subscribe 2). It has many options, it's own set of additional plugins, its own themes, and the option to sync subscribers with your userbase. 10/10!
|
Server-side subscribe by email?
|
wordpress
|
I have spent the last day using the functions.php file to fully customize WordPress for my client sites. I am amazed at how much I have been able to accomplish and how much easier it will make things for my clients. I have removed certain menu items for users that are not logged in as an admin. What I am hoping (and from what I have read know it can be done) is to find a way to rename some of the menu items (left sidebar in the admin area). For instance change Posts to Articles. If anyone can supply the code for the functions.php file or point me in the direction I would greatly appreciate it!
|
Here's the process to change the labels (I changed posts to "contacts" in my example) <code> function change_post_menu_label() { global $menu; global $submenu; $menu[5][0] = 'Contacts'; $submenu['edit.php'][5][0] = 'Contacts'; $submenu['edit.php'][10][0] = 'Add Contacts'; $submenu['edit.php'][15][0] = 'Status'; // Change name for categories $submenu['edit.php'][16][0] = 'Labels'; // Change name for tags echo ''; } function change_post_object_label() { global $wp_post_types; $labels = &$wp_post_types['post']->labels; $labels->name = 'Contacts'; $labels->singular_name = 'Contact'; $labels->add_new = 'Add Contact'; $labels->add_new_item = 'Add Contact'; $labels->edit_item = 'Edit Contacts'; $labels->new_item = 'Contact'; $labels->view_item = 'View Contact'; $labels->search_items = 'Search Contacts'; $labels->not_found = 'No Contacts found'; $labels->not_found_in_trash = 'No Contacts found in Trash'; } add_action( 'init', 'change_post_object_label' ); add_action( 'admin_menu', 'change_post_menu_label' ); </code> To change the menu order, go with this: <code> // CUSTOMIZE ADMIN MENU ORDER function custom_menu_order($menu_ord) { if (!$menu_ord) return true; return array( 'index.php', // this represents the dashboard link 'edit.php', //the posts tab 'upload.php', // the media manager 'edit.php?post_type=page', //the posts tab ); } add_filter('custom_menu_order', 'custom_menu_order'); add_filter('menu_order', 'custom_menu_order'); </code> I've got code to remove items, but it's globally and not based on user access level
|
Changing Admin Menu Labels
|
wordpress
|
I'm working on a category page for a custom post type called articles in WP 3.1, and I'm having some trouble with extracting the page number. The url: <code> /articles/category/background/ </code> Currently, what works for me, from my <code> functions.php </code> : <code> add_action( 'init', 'wpse7379_init' ); function wpse7379_init() { add_rewrite_rule( 'articles/category/([^/]+)(/page/([0-9]+))/?$', 'index.php?post_type=articles&category_name=$matches[1]&paged=$matches[2]', 'top' ); } </code> This internally rewrites the url to: <code> /index.php?post_type=articles&category_name=background </code> I'm trying to make the pagination work by expanding the rewrite rule, but it's not working for me. The pagination works as follows: <code> /articles/category/background/page/2/ </code> New rule: <code> add_rewrite_rule( 'articles/category/([^/]+)(/page/([0-9]+))/?$', 'index.php?post_type=articles&category_name=$matches[1]&paged=$matches[2]', 'top' ); </code> This should rewrite the url to: <code> /index.php?post_type=articles&category_name=background&paged=2 </code> I'm using a query with args on my <code> archive-articles.php </code> page, but just a regular loop on the <code> categories.php </code> page, where the posts are displayed. When I try <code> /index.php?post_type=articles&category_name=background&paged=2 </code> it works, but the url that gets rewritten doesn't. Its just displaying the first page, no matter what I enter as pagenumber. Does anyone know how to fix this? I think I'm looking for a proper regex, I kinda suck at regexes, so I guess thats the problem.
|
I see three issues in your rewrite rule. The page number is the third , not the second capture group. You count each opening <code> ( </code> , so the first is the category name, the second is <code> /page/[0-9]+ </code> , and the third is only the <code> [0-9]+ </code> you need. So change the <code> paged </code> parameter to <code> $matches[3] </code> . The page part can be optional, so you need to add a <code> ? </code> at the end (this is the reason we put it in a group). The categories can be hierarchical, like <code> /fruit/banana/ </code> . For this reason, you should not match them with <code> [^/]+ </code> (any character except a slash), but <code> .+? </code> (any character, but non greedy , so that the rest of the regex can still match). Together, this results in the following rewrite rule: <code> add_rewrite_rule( 'articles/category/(.+?)(/page/([0-9]+))?/?$', 'index.php?post_type=articles&category_name=$matches[1]&paged=$matches[3]', 'top' ); </code> If you don't use it already, I recommend you debug your rules with my stackexchange-url ("rewrite analyzer"). You can test them live and see what the query values will be.
|
Regex problem in an add_rewrite_rule
|
wordpress
|
This is my single.php file: I'm using <code> previous_post_link(); </code> and <code> next_post_link(); </code> . In the Worpress codex it says that it only works inside the loop . <code> <?php /** * The Template for displaying all single posts. * * @package WordPress * @subpackage Starkers * @since Starkers 3.0 */ get_header(); ?> <?php get_sidebar(); ?> <div id="content"> <?php // Create and run custom loop $custom_posts = new WP_Query(); $custom_posts->query('post_type=blocks&location=Work&section=Intro'); while ($custom_posts->have_posts()) : $custom_posts->the_post(); ?> <div class="block-1"> <?php the_post_thumbnail('large'); ?> </div> <?php endwhile; ?> <?php // Create and run custom loop $custom_posts = new WP_Query(); $custom_posts->query('post_type=blocks&location=Work&section=Tagline'); while ($custom_posts->have_posts()) : $custom_posts->the_post(); ?> <div class="block-2 padding-top"> <?php the_content(); ?> </div> <?php endwhile; ?> <?php wp_reset_query(); ?> <?php // Display the thumbnails of previous and next posts ?> <div class="block-2 border-top"> <?php // Display the thumbnail of the previous post ?> <div class="float-left"> <?php $prevPost = get_previous_post(); $prevthumbnail = get_the_post_thumbnail($prevPost->ID); ?> <h2><?php previous_post_link('%link', 'Previous'); ?></h2> <?php previous_post_link('%link', $prevthumbnail); ?> </div> <?php // Display the thumbnail of the next post ?> <div class="float-right"> <?php $nextPost = get_next_post(); $nextthumbnail = get_the_post_thumbnail($nextPost->ID); ?> <h2><?php next_post_link('%link', 'Next'); ?></h2> <?php next_post_link('%link', $nextthumbnail); ?> </div> </div> <?php // Create and run custom loop $custom_posts = new WP_Query(); $custom_posts->query('post_type=blocks&location=Front Page&section=Sidebar'); while ($custom_posts->have_posts()) : $custom_posts->the_post(); ?> <div class="block-3 border-top"> <h2><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2> <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_post_thumbnail(); ?></a> <p><?php the_excerpt(); ?></p> <p><?php echo get_post_meta($post->ID, "Other_Work", true); ?></p> </div> <?php endwhile; ?> <?php // Start the main loop if ( have_posts() ) while ( have_posts() ) : the_post(); ?> <div class="block-4 border-top"> <?php the_content(); ?> </div><!-- .entry-content --> <?php endwhile; // end of the loop. ?> <?php get_sidebar('secondary'); ?> </div><!-- #content --> <?php get_footer(); ?> </code>
|
"Inside the Loop" essentially means that function relies on data from global variables (such as <code> $post </code> ) that are set up when Loop runs. Note that this is not necessarily done by main Loop of <code> query_posts() </code> . In your specific code those variables are filled by <code> $custom_posts->the_post() </code> calls and after that <code> wp_reset_query() </code> gets those values back to initial state.
|
Why is previous_post_link and next_post_link working outside of the Loop?
|
wordpress
|
I want to know how to get image url on <code> the_post_thumbnail() </code> Default <code> the_post_thumbnail() </code> <code> <img width="800" height="533" src="http://domain.com/wp-content/uploads/2011/02/book06.jpg" class="attachment-post-thumbnail wp-post-image" alt="book06" title="book06" /> </code> Here I want grab the src only. How do I filter <code> the_post_thumbnail() </code> only to get <code> http://domain.com/wp-content/uploads/2011/02/book06.jpg </code> Let me know
|
You might also try: If you only have one size thumbnail: <code> $thumbnail_src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ) ); </code> Or...if you have multiple sizes: <code> $thumbnail_src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), "size" ); </code> Found this here: http://wpcanyon.com/tipsandtricks/get-the-src-attribute-from-wordpress-post-thumbnail/
|
How do I get image url only on the_post_thumbnail
|
wordpress
|
I have 3 problems. First,I would like something like this to do : <code> www.example.com/myblog => myblog.example.com </code> myblog is template page. and then when open one post from that page(post are custom post type) url will look like this <code> myblog.example.com/my-custom-post-type-post </code> Second : <code> www.example.com/mycar => mycar.example.com </code> my car is also template page,and then when open post from that page(posta are also custom post type,but this time post will be in subcategory) url will look something like this <code> mycar.example.com/my-subcategory/my-car-custom-post-type </code> Dont know how to do this in wp. Third,can someone help me to figure it out why is this not working. I would like to rewrite this url http://www.example.com/data-page/?data_id=123456789 to http://www.example.com/data-page/data_id/123456789 add_filter('query_vars', 'add_my_var'); <code> function add_my_var($public_query_vars) { $public_query_vars[] = 'data_id'; return $public_query_vars; } function add_rewrite_rules($rules) { $newrules['data-page/data_id/([0-9]{1,})/?$'] = 'index.php?data_id=$matches[1]'; $rules = $newrules + $rules; return $rules; } function flushRules() { global $wp_rewrite; $wp_rewrite->flush_rules(); } add_filter('rewrite_rules_array', 'add_rewrite_rules'); add_filter('init', 'flushRules'); </code> This is the way I send data to another page. <code> <a href="<?= add_query_arg(array('data_id'=>32),get_permalink(get_page_by_path('data-page'))); ?>">Data page test link</a> </code> Thanx in advance.
|
Changing the rewrite rules does not affect how WordPress writes links (except for the standard links, to posts, archives, ... and then only in simple cases). The rewrite rules only cover how incoming URLs are handled, you are responsible for writing the links in the new format. This is different from frameworks with more advanced routing systems, like Symfony. This means that you should change the link you write: <code> <a href="<?php echo '/data-page/data_id/' . 32; ?>">Data page test link</a> </code> (Using <code> get_page_by_path() </code> and then <code> get_permalink() </code> seems redundant to me, since you already know the permalink, no? You can wrap it in <code> home_url() </code> to get the full path.) The rewrite rule should then look like this: <code> $newrules['data-page/data_id/([0-9]{1,})/?$'] = 'index.php?data_id=$matches[1]&pagename=data-page'; </code> We add the <code> pagename=data-page </code> because otherwise WordPress doesn't know what page to show. You currently have a page with the slug <code> data-page </code> and a custom template, but there are also other ways to solve this. Also, you should not flush the rewrite rules on every <code> init </code> . Only do this when the rules change. If you write this as a plugin use the activation hook, otherwise just visit the Permalinks page to flush them. The first part of your question is not really clear to me. I once answered stackexchange-url ("how to let a single post have its own domain name"), perhaps that can help you?
|
Help with Wordpress custom url rewriting?
|
wordpress
|
I allow users to save some notes on my wordpress site. They can only do this after they login to the site. Now I want to save their notes in a database table and associate them with the user's id i.e. if a user has saved 2 notes, when they login and go to "my page", they should be able to see the 2 notes they saved. Can someone please guide me on how to do this? I could find a lot of information on saving custom user metadata when they register. But could not find any help on saving information associated with a user account after they have logged in. Thank you.
|
Take a look at update_user_meta you can save user data if they are registering or signed in, its just a matter of what user ID you pass to it. say in your function to save the user data after he is logged in: <code> function save_user_data_7231(){ global $current_user; if is_user_logged_in{ //check if user is logged in. if (isset($_POST['Notes'])){ // get current user info get_currentuserinfo(); $old_notes = get_user_meta($current_user->ID, 'user_notes', true); if (isset($old_notes)&& is_array($old_notes)){ //if we saved already more the one notes $old_notes[] = $_POST['Notes']; update_user_meta( $current_user->ID, 'user_notes', $old_notes); } if (isset($old_notes)&& !is_array($old_notes)){ //if we saved only one note before $new_notes = array($old_notes,$_POST['Notes']); update_user_meta( $current_user->ID, 'user_notes', $new_notes) } if (!isset($old_notes)){ //first note we are saving fr this user update_user_meta( $current_user->ID, 'user_notes', $_POST['Notes']) } } } } </code> they to display there notes you can use get_user_meta <code> function get_user_notes_654(){ global $current_user; if is_user_logged_in{ //check if user is logged in. // get current user info get_currentuserinfo(); $old_notes = get_user_meta($current_user->ID, 'user_notes', true); if (!isset($old_notes)){ $re = 'No Notes YET!'; } if (isset($old_notes)){//we have notes. Removed the extra ! here. if (is_array($old_notes)){//more then one foreach($old_notes as $note){ $re .= '<strong>note:</strong>' . $note . '<br />'; } }else{//just one $re = '<strong>note:</strong>' . $old_notes . '<br />'; } } re .='//add note form would come here'; return $re; } } </code> Hope this Helps
|
Saving custom data for each user
|
wordpress
|
I need to add about 50 properties to a product, such as heigh, width, location etc. I created custom taxonomies for every property and ran into serious problems. First of all, the UI is a mess! Every taxonomy uses to much space. Some of the propertys should be presented to the user with radio buttons, checkboxes and dropwdowns. What is the best practice? Use custom fields instead and lose the taxonomy functionality?
|
For each propery, ask yourself these questions: Is it likely that, on average, more than 1-2 posts will have the same value for this property? If so, do I need to filter posts based on this property, or is it just for display? If you answered both with 'yes', then make it a taxonomy, otherwise a custom field. Whichever you choose, you can make a custom metabox for that individual property, or several metaboxes that group related properties together. Whatever makes more sense.
|
Solve product properties with custom taxonomies?
|
wordpress
|
Can the hook <code> admin_print_scripts-$hook_suffix </code> be used for a hook which has been created like <code> $hookname = get_plugin_page_hookname("my-quiz/lib/admin/$code_page", '' ); </code> ? .. where <code> $code_page </code> is <code> somefilename.php </code> . I've tried it and it doesn't seem to work. I think its probably because of the filepath ? UPDATE What gets registered by the above code is 'admin_page_my-quiz/lib/admin/question_form' but this only works in a page if you do: <code> <a href="<?php echo admin_url('admin.php?page=my-quiz/lib/admin/question_form.php&question=edit&question='.$question->ID); ?>" class='edit'> <?php _e('Edit', 'my-locale'); ?> </a> </code> I have to add the .php suffix for that link to work or I get the 'you do not have permission' error. @t31os function outputs 'nmsi-quiz/lib/admin/question_form.php' and so this doesn't match 'admin_page_my-quiz/lib/admin/question_form' this works - add_action( 'admin_print_scripts-'.'my-quiz/lib/admin/question_form.php', array($this,'enqueue_my_js')); Requested code: <code> $plugin_scripts = array('question_form.php', 'manage_questions.php'); foreach($plugin_scripts as $code_page) { $hookname = get_plugin_page_hookname("my-quiz/lib/admin/$code_page", '' ); $_registered_pages[$hookname] = true; //fb($hookname); } </code>
|
I think it's really a question of whether that code is giving the correct hook name for the given page. Here's a simple function you can use to output the hook suffix on each admin page, it will appear inside a red error box(so it'll be easy to spot) for admins only. <code> add_action( 'admin_notices', 'print_admin_pagehook' ); function print_admin_pagehook() { global $hook_suffix; if( !current_user_can( 'manage_options') ) return; ?> <div class="error"><p><?php echo $hook_suffix; ?></p></div> <?php } </code> Load up the page you're having a problem with and compare the value you see in the box with what you're getting back from the code you posted. Addition Following on from my last comment, you can actually do something like this.. <code> add_action( 'admin_menu', 'testing_registered_pages', 100 ); function testing_registered_pages() { global $_registered_pages, $submenu; $plugin_scripts = array( 'Question Form' => array( 'page' => 'question_form', 'callback' => 'my_callback_1' ), 'Manage Questions' => array( 'page' => 'manage_questions', 'callback' => 'my_callback_2' ) ); foreach( $plugin_scripts as $title => $my_pages ) { $hookname = get_plugin_page_hookname("my-quiz/lib/admin/$my_pages[page]", 'my-quiz' ); $_registered_pages[$hookname] = true; $submenu['my-quiz'][] = array( $title, 'manage_options', "my-quiz/lib/admin/$my_pages[page]", $title ); add_action( $hookname, $my_pages['callback'] ); } } // Remove the add_action to reference actual files, leave in place to use a callback function </code> ...there's just one problem with this approach, and that's in being able to defeat the capability requirements of the page(s). Take this URL. <code> example.com/wp-admin/admin.php?page=my-quiz/lib/admin/manage_questions </code> We can defeat the cap check by querying for.. <code> example.com/wp-admin/admin.php?page=my-quiz/lib/admin/manage_questions.php </code> If we switch the code from earlier to use the file extension instead, eg.. <code> $plugin_scripts = array( 'Question Form' => array( 'page' => 'question_form.php', 'callback' => 'my_callback_1' ), 'Manage Questions' => array( 'page' => 'manage_questions.php', 'callback' => 'my_callback_2' ) ); </code> ..and optionally disable callbacks, ie. use a real file.. <code> // add_action( $hookname, $my_pages['callback'] ); </code> ..this then gives us.. <code> example.com/wp-admin/admin.php?page=my-quiz/lib/admin/manage_questions.php </code> ..it's still possible to defeat capability requirements using.. <code> example.com/wp-admin/admin.php?page=my-quiz/lib/admin/manage_questions </code> Regardless of whether you use an actual file or a callback function, in either case the capability requirements(as above) can be circumvented(obviously this would not be desired behaviour).
|
Does admin_print_scripts-$hook_suffix work for nested paths to individual files?
|
wordpress
|
I would like to have a separate page for the comments on a post, such that this page: <code> /2011/02/post-name/ </code> just shows the post and then you click a link to view the comments, taking you to a page like this: <code> /2011/02/post-name/comment-page-1/ </code> I will then check the URL to see if "comment-page-x" is in it, and display the page differently if so (remove the post, so people don't have to scroll past that every time, and also style things a bit differently). This would work, but WordPress redirects <code> comment-page-1 </code> to the post page - I need it to keep <code> comment-page-1 </code> there in the URL. Is this possible? How can I do it? Thanks!
|
Hi @Shaun: Great question! WordPress assigns your comment page number to the query var <code> 'cpage' </code> which gets set when your URL has <code> /comment-page-1/ </code> at the end. So your culprit is in the <code> redirect_canonical() </code> function, line 192 of <code> /wp-includes/canoncial.php </code> . <code> if ( get_query_var('paged') || is_feed() || get_query_var('cpage') ) { </code> Since the <code> redirect_canonical() </code> function gets set as an action what we can do is to insert our own function to be called instead, have our function set the <code> 'cpage' </code> query var to <code> false </code> , call <code> redirect_canonical() </code> , and then set <code> 'cpage' </code> back to what it was; that will keep WordPress from redirecting on you. To insert your own function you need to call the two hook <code> 'init' </code> and <code> 'template_redirect' </code> like so being sure to set the <code> 'init' </code> hook to be called after the <code> do_action() </code> inside WordPress core that adds <code> redirect_canonical() </code> : <code> add_action('init','yoursite_init',11); //11=lower priority function yoursite_init() { remove_action('template_redirect','redirect_canonical'); add_action('template_redirect','yoursite_redirect_canonical'); } add_action('template_redirect','yoursite_redirect_canonical'); function yoursite_redirect_canonical($requested_url=null, $do_redirect=true) { $cpage = get_query_var('cpage'); set_query_var('cpage',false); redirect_canonical($requested_url, $do_redirect); set_query_var('cpage',$cpage); } </code> Then of course you need to do something with your <code> 'cpage' </code> . You can either check for the value returned by <code> get_query_var('cpage') </code> or you can add another hook to allow you to create a comment-specific template which is what I did. It will add look for a theme template file with the same as it would normally load but with <code> [comments].php </code> at the end of the name instead of <code> .php </code> , i.e. <code> single[comments].php </code> . Note that I set priority for this filter to be 11; you may need to set to an even larger number if a plugin you use adds itself after your hook: <code> add_filter('single_template','yoursite_single_template',11); function yoursite_single_template($template) { if (get_query_var('cpage')) $template = str_replace('.php','[comments].php',$template); return $template; } </code> And here's the proof that it all works!
|
Stop WordPress redirecting comment-page-1 to the post page?
|
wordpress
|
I've handrolled a form for posting from the front-end, with some custom functions that I needed. However, I've made the form only accessible when a user is logged in, and I'd like to have the articles show up as being posted by that user. Thoughts?? Here is my current code: backend: <code> if( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) && ($_POST['action']== 'new_post')) { $has_errors = false; $title = $_POST['title']; $tablature = $_POST['tablature']; $performer = $_POST['performer']; $composer = $_POST['composer']; $submitter = $_POST['submitter']; $cat = array( $_POST['cat'] ); if(!isset($title)) { echo '<div class="error">Title required.</div>'; $has_errors = true; } if(!isset($tablature)) { echo '<div class="error">Description required.</div>'; $has_errors = true; } if(!isset($performer)) { echo '<div class="error">Performer required.</div>'; $has_errors = true; } if(!isset($composer)) { echo '<div class="error">Composer required.</div>'; $has_errors = true; } if($cat == -1) { echo '<div class="error">Please select a category.</div>'; $has_errors = true; } $tags = $_POST['post_tags']; if (!$has_errors){ // Save <title> by: <performer> $title .= " by " .$performer; // Save Composed by: <composer> Performed by: <performer> <tablature> $content = "<h4>Composed by: ".$composer."</h4><h4>Performed by: ".$performer."</h4><p>Submitted by: ".$submitter."</p><br/>".$tablature; $new_post = array( 'post_title' => $title, 'post_content' => $content, 'post_category' => $cat, 'post_status' => 'draft' ); wp_insert_post($new_post); // save email and submitter as post meta in custom fields wp_redirect( home_url('/thank-you/') ); } </code> } frontend: <code> <div id="postbox"> <form id="new_post" name="new_post" method="post" action=""> <p><label for="submitter">Submitted By</label><br /> <input type="text" id="submitter" value="" tabindex="1" size="20" name="submitter" class=”required” minlength="3" /> </p> <p><label for="email">Email Address</label><br /> <input type="text" id="email" value="" tabindex="2" size="20" name="email" /> </p> <p><label for="title">Song Title</label><br /> <input type="text" id="title" value="" tabindex="3" size="20" name="title" class=”required” minlength="3" /> </p> <p><label for="composer">Composed By</label><br /> <input type="text" id="composer" value="" tabindex="4" size="20" name="composer" class=”required” minlength="3" /> </p> <p><label for="performer">Performed By</label><br /> <input type="text" id="performer" value="" tabindex="5" size="20" name="performer" class=”required” minlength="3" /> </p> <p><label for="tablature">Song Body</label><br /> <textarea id="tablature" tabindex="6" name="tablature" cols="50" rows="6" class=”required” minlength="50"></textarea> </p> <p><?php wp_dropdown_categories( 'show_option_none=Category&tab_index=7&taxonomy=category&exclude=5&class=required' ); ?></p> <p align="right"><input type="submit" value="Submit" tabindex="8" id="submit" name="submit" /></p> <input type="hidden" name="action" value="new_post" /> <?php wp_nonce_field( 'new-post' ); ?> </form> </div> </code> Thanks!
|
you can use <code> global $current_user; get_currentuserinfo(); </code> and then add <code> 'post_author' => $current_user->ID </code> to your $new_post array. then you can use <code> <p>Posted by: <?php the_author(); ?></p> </code>
|
Post from front-end only by logged in users, form posts as "posted by: "
|
wordpress
|
I'm using the following line to output an unordered list of taxonomies and their associated terms for a custom post type. The only problem with it is that a period gets added after the term. <code> wp_get_object_terms( $id, the_taxonomies( 'before=<ul><li>&sep=</li><li>&after=</li></ul>' ) ); </code> Here's what it outputs: <code> <ul><li>Taxname: <a href='http://site.com/taxname/taxterm/'>Taxterm</a>.</li></ul> </code> Is there an argument I can add to <code> wp_get_object_terms </code> to remove the period?
|
wp_get_object_terms() isn't the problem. the_taxonomies() is doing the outputting; it doesn't return anything. So, your code is equivalent to: <code> the_taxonomies( 'before=<ul><li>&sep=</li><li>&after=</li></ul>' ); wp_get_object_terms( $id, null ); </code> Now, if you go to wp-includes/taxonomy.php you will find the dot in the_taxonomies() source. To remove the dot, you need to add a filter: <code> function remove_the_dot($template) { return '%s: %l'; } add_filter('taxonomy_template', 'remove_the_dot'); </code> In case you're wondering, yes, this is an akward way of doing things. In WP 3.1, you can modify the template simply by passing it as a parameter: <code> the_taxonomies( array( 'before' => '<ul><li>', 'sep' => '</li><li>', 'after' => '</li></ul>', 'template' => '%s: %l' ) ); </code>
|
Why does wp_get_object_terms add a period after terms are output?
|
wordpress
|
What is the best apache log analyzer plugin for WordPress? Requirements: should produce all reports as available in flashstats: http://www.maximized.com/products/flashstats2006/ Im looking for things such as: files that have the highest impact on bandwidth usage, potential leechers, bad robots, etc... (on posting it said 'the question you are asking appears subjective and is likely to be closed...' no idea why, im really looking for a plugin that gives really a load of reports preferably multisite wide reporting so that i can see which sites use the highest resources). a little update: There are analyzers based on embedded elements in a page, the counters and the counter 2.0: pretty complete list: http://tellertest.com/tellers.php . There are many plugins for each of them (currently clicky is #1 and GA is #5) and even so much blockers: http://www.google.nl/search?sourceid=chrome&ie=UTF-8&q=block+google+analytics There are also log file analyzers like e.g. http://en.wikipedia.org/wiki/List_of_web_analytics_software I think the first class is more for marketing and the second class more for technical people. I think personally that the second class is more useful than the first class of analyzing what is happening on a server but maybe i am wrong. Analyzing data can produce infinite reports depending on imagination. Therefore I was wondering if there was a WordPress specific weblog-weblog Analyzer which among other has Apache logs / Syslogs / Other OS logs as data input. There are 69 pages when i search for 'statistics' in the WordPress Plugin dir.... If not, maybe it is interesting BI addon to create.
|
"best apache log analyzer plugin for WordPress" This is a joke question, right? If not, no offense, but you're probably new to the web. And if so, you probably should know that Apache logs actually pick up and log: Search Engine bots (not just Google: any bot, and there are many, many, many...) Comment spam bots Ping spam bots Referral spam bots Other spam bots More spam bots Did I mention spam bots yet? Oh yeah, there might be a few more I forgot... Seriously though, the only thing you should be using for analytics is Google Analytics or an equivalent (and expensive) piece of software). Unless, of course, you're the only one who actually sees the latter and are not ashamed to tell your customer that his recently search optimized site now has 10k uniques per month -- in spite of the fact that GA tells you that your actual traffic is around 100 real visitors per month. (Seen in real life, don't laugh.) Re your secondary question, for bandwidth just use the host's default analyzer (usually webanalyzer or equivalent, which for this purpose is arguably good since it includes spam bots).
|
Best Apache Log Analyzer Plugin?
|
wordpress
|
Hay, I was wondering if this is possible. I have a company called dotty. The domain for this company is dotty.com. However, my company has many subcompanies (company_1, company_2). Is it possible using WordPress to manage all these subcompanies within one WordPress installation? Each company needs to have it's own template, and the URL's will end up something like this <code> dotty.com dotty.com/company_1 dotty.com/company_2 </code> and i can manage them all from <code> dotty.com/wp-admin </code>
|
Use a WordPress Network. This is one installation with unlimited numbers of blogs, all controlled, to a point, by the central dashboard. See Create A Network - WordPress Codex
|
Multiple Wordpress Blogs on one host, using 1 WordPress installation, using multiple templates
|
wordpress
|
I'm running a WP 3.0.5 website and here is my problem: I define a custom post type with 2 custom taxonomies and I've got to develop a search engine based upon these taxonomies. Until there, no problem : <code> $args = array( 'my_post_type' => 'post_type_name', 'my_taxo_1' => 'taxo-1-slug', 'my_taxo_2' => 'taxo-2-slug' ); query_posts( $args ); </code> Working like a charm! But... What I want is to retrieve only custom posts matching both taxonomies whereas here, only 1 is sufficient. I saw WP 3.1 is introducing a new way dealing with taxonomies (http://codex.wordpress.org/Function_Reference/query_posts#Taxonomy_Parameters) which will absolutely solve my problem but WP 3.1 is still in beta and I can't take risk for my customer. Thanks for your help !
|
You can do this in 3.0 with the Query Multiple Taxonomies plugin .
|
WP 3.0.5 - Custom posts matching 2 taxonomies
|
wordpress
|
My client is looking for a ranking system similar to a forum. As your post count goes up, your "title" changes. I think Buddypress offers something along these lines but we're at the end stage and he doesn't want to take the extra time to let me convert it to a buddypress system. Are there other plugins that can do this? Or maybe someone can suggest some code to use with User Role Editor? Thanks
|
I know i have something like that and I'll post it as soon as i get home. Update Bit late I know , but since i jumped a head and said i have something like that, and i just couldn't find it i wrote something from scratch. Bainternet User Ranks After you install and activate, configre it a bit and you can use it like this: <code> <?php $baur_plugin = new baur_Plugin(); $user_rank = $baur_plugin->ba_get_user_points($user_id,true); echo "title: ". $user_rank['title'] . "Points: " . $user_rank['points'];?> </code> Enjoy!
|
Forum-esque Post Count User Ranks (Without Buddypress)
|
wordpress
|
Hay All, I've setup a WordPress network and have a couple of websites. Within these 'sub-websites' have a created a new custom post type called 'courses'. When i create a new 'course' a sample permalink would be www.mysite.com/site1/course/my-course-name However, this doesn't link to the article in the question. Is this a normal error with wordpress? How, can i fix this? I think there's an issue with the .htaccess file WP generated for me.
|
I wrote a post about it a week ago http://en.bainternet.info/2011/custom-post-type-getting-404-on-permalinks But a simple save changes in the permalink admin panel should fix it for you.
|
Permalinks not working using wordPress Networking with custom post types
|
wordpress
|
I'm a bit confused. I have my own custom post type - products. I'm listing all the products on page-products.php. Every product has also it's own page - single-products.php. And the big and strange thing is... I'm using more quicktag: <code> <!-- more --> </code> And it doesn't work on both single-products and page-products! I don't care about single page, but I'd love to use on the page-products listing. And I'm not able to. Documentation says: The MORE quicktag will not operate and is ignored in Templates, such as single.php, where just one post is displayed. http://codex.wordpress.org/Function_Reference/the_content So is it perfectly normal to not work for me in both cases? As far as I understand it should work in the first case... Is there a way to force more quicktag to display there? And yes, in both cases more "produces" perfect more span... But even content after the span is being shown... Thank you!
|
The "read more" link is essentially a navigational device meant to point visitors to a full version of a piece of some excerpted content. A single.php of any post type is the full version, therefore it is 100% in the nature of <code> <!-- more --> </code> to not appear on single custom post type pages. If you're just looking to display a snippit of your content, check out the_excerpt() .
|
More quicktag driving me nuts
|
wordpress
|
My website is wordswithfriends.net At the moment all of the top navigation menus link to an internal page. I want "Contact Us" to link to an external page ask.wordswithfriends.net How do I do this in the administration panel? At the moment all I see are options for editing the page
|
It depends on your theme and WP version (you're using 2.9.1 - you should consider upgrading). You can: upgrade to V3+ to use the menu editor that's built in (recommended) more info: http://templatic.com/news/wordpress-3-0-menu-management hard code your theme template with the link added to the end in the HTML modify the theme call to wp_list_pages() function excluding your contact page link (see: http://codex.wordpress.org/Template_Tags/wp_list_pages )
|
How do I make my navigation bar link to an external page?
|
wordpress
|
Im trying to make my next and previous post buttons display my custom field but for some reason it doesnt display the custom field its just blank. Heres my code. <code> <div id="next-prev-links"> <?php $previous_post = previous_post_link('%link', ''.$image_prev.'', TRUE); $next_post = next_post_link('%link',''.$image_next.'', TRUE); $image_prev = get_post_meta( $previous_post->ID, 'image', true); $image_next = get_post_meta( $next_post->ID, 'image', true); ?> <?php if ( $image_prev != '' ) : ?> <img src="<?php echo $image_prev; ?>" alt="" /> <?php endif; ?> <?php if ( $image_next != '' ) : ?> <img src="<?php echo $image_next; ?>" alt="" /> <?php endif; ?> <?php previous_post_link('%link', 'Previous post', TRUE); ?> <?php next_post_link('%link', 'Next post', TRUE); ?> </div> </code>
|
Here's the code for what you're trying to do (accessing post custom value): <code> <?php global $post; $prev_post = get_adjacent_post(); $next_post = get_adjacent_post( false, '', false ); $prev_post_id = $prev_post->ID; $next_post_id = $next_post->ID; // this should, according to your code above, be the http://example.com/your/img.jpg string $prev_img_path = get_post_custom_values( 'your_key_name', $prev_post_id ); $next_img_path = get_post_custom_values( 'your_key_name', $next_post_id ); $prev_def_path = get_bloginfo('stylesheet_directory').'/default_next_img_inside_theme_folder.jpg'; $next_def_path = get_bloginfo('stylesheet_directory').'/default_prev_img_inside_theme_folder.jpg'; echo '<img src="'.!empty($prev_img_path) ? $prev_img_path : $prev_def_path.'" alt="Permalink to previous post" />'; echo '<img src="'.!empty($next_def_path) ? $next_def_path : $next_img_path.'" alt="Permalink to next post" />'; ?> </code>
|
adding custom fields to next and previous post link
|
wordpress
|
Currently I am running a wordpress MU site with ~100 blogs. It's Wordpress MU version 2.8.x Because it was so heavily used, I was asked not to update to Wordpress 3 right away. The users are worried that their plugins and themes may not work once I've upgraded. Indeed, we activated some plugins that I suspect will stop working because there have not been any updates to them in a while. Other users are anxious to start using Wordpress 3 and the new features. So, what I have to do now is somehow test what the update will look like, and let users log in to test how their site will look in Wordpress 3. My question is, what is the best way for me to test the upgrade? My the root of my Wordpress MU is at mydomain.com, and the sites are in the directory below, such as mydomain.com/henrys-blog Thanks for your help
|
In this situation, I'd recommend the following: Dump your production database into your test database Install WP 3 and point it at your test DB Run the database upgrade Turn users loose on the test instance We used a similar process on a much larger installation, and it worked fairly well. Having the second instance made it possible to use our testing resources to verify functionality without depending on the users, too.
|
How to run a test WordpressMu to Wordpress3 update?
|
wordpress
|
In the latest version of WP I see the category.php page is now using edit-tags.php. The version Im running seems to have an issue with the search feature on this page whereas the new version doesnt. When searching for categories, the results show the category search AND its heirarchy i.e. - categoryname together in the same list. Short of doing a major overhaul and upgrade as one does need to check compatibility, what was changed in the new version that I could update in the old version of my source? example: I have 5 categorys, 3 parents, 2 children. They all have the word cat in their name. If I search for the word 'cat' I not only get the 5 results, but ALSO another three results with - category name for each of the children again. This is not the case in 3.0.5
|
I feel you on the WPMU -> 3x transition but unfortunately it's going to be hard to troubleshoot the issues without seeing any code (@sanchothefat says something similar in a comment above). I've come up against similiar issues, so let me at least offer some general help in debugging these kinds of things. Whatever the function in question, go into the SVN and compare code revisions for the function in question. Here's the WPMU 2.9.2 trunk and here's 3.0.5 . Try using a diff tool ("diff file1 file2" on the command line) and see what changed between revisions. Are all the parameters the same? Do those array keys exist in both versions? To slueth out what your code isn't doing anymore it's helpful to first figure out it did do that is no longer.
|
Wordpress MU 2.9.2 to 3.0.5 changes to category.php
|
wordpress
|
I want to publish static pages on Wordpress quickly. Live Writer is a very good client for formatting and publishing blog posts. But I couldn't find a way to use it for publishing static pages. Is there any way to publish static pages on Wordpress quickly with an easy to use client?
|
According to the following page Live Writer can manage pages as of Beta2. http://en.support.wordpress.com/xml-rpc/windows-live-writer/ Maybe it's simply a case of waiting to use the newer version that includes page management? I don't use WLW myself, but a quick google did garner the above link, so hope it helps.
|
Any Good Wordpress Client Like Live Writer To Create Static Pages
|
wordpress
|
When I use wp_mail( $to, $subject, $message, $headers ) (with values in place, of course), the email gets sent with a from name and email that isn't set anywhere I can find (not even in PHP or Apache settings). However, using mail( $to, $subject, $message, $headers ) instead works just fine. What could be happening with wp_mail() to cause this?
|
Hi @helenyhou: You can set the header, just not with a parameter. WordPress uses "hooks" and the hooks you need are <code> 'wp_mail_from' </code> and <code> 'wp_mail_from_name' </code> hooks. Here are the hooks you might add to your theme's <code> functions.php </code> file to modify the <code> "From:" </code> header when using <code> wp_mail() </code> to the email address <code> Helen Hou-Sandi <[email protected]> </code> : <code> add_filter('wp_mail_from','yoursite_wp_mail_from'); function yoursite_wp_mail_from($content_type) { return '[email protected]'; } add_filter('wp_mail_from_name','yoursite_wp_mail_from_name'); function yoursite_wp_mail_from_name($name) { return 'Helen Hou-Sandi'; } </code>
|
Why won't wp_mail() let me set the From: header when plain old PHP mail() will?
|
wordpress
|
I have a lot of posts/pages, and I would like to create a list in my sidebar, showing all of the years that I have created posts/pages in, so for instance, if I have 5 posts/pages that were spaced out over 5 years, from 2006 to 2011, each year having one post, I would like 2005, 2006, 2007, 2008, 2009, 2010 and 2011 to show as list items in the sidebar, as links to all of the posts/pages created that year. Any idea of how I can achieve that? Thanx in advance!
|
Not sure if there's a specific function for this as i didn't find anything with a quick search, but i went ahead and wrote a function to do the job, feel free to expand upon it or do whatever you like with it. List year archives for published posts of a type Code is provided "as is", do as you will with it. <code> function get_years_for_type( $type = 'post', $echo = false, $sep = '<br />' ) { global $wpdb, $wp_post_types; $type = '' == $type ? 'post' : $type; if( !isset( $wp_post_types[$type] ) ) return; $q = $wpdb->get_col( $wpdb->prepare( "SELECT YEAR(post_date) as year FROM wp_posts WHERE post_type = %s AND post_status = 'publish' GROUP by year", $type ) ); if( empty( $q ) ) return; $y = array(); foreach( $q as $year ) $y[] = '<a href="' . get_year_link( $year ) . '">' . $year . '</a>'; $y = implode( $sep, $y ); if( $echo ) echo $y; else return $y; } </code> Example usage: <code> // Output list of years for pages echo get_years_for_type( 'page' ); get_years_for_type( 'page', true ); // Output list of years for posts echo get_years_for_type(); get_years_for_type( 'post', true ); // Storing the result in a variable $var = get_years_for_type(); // post is assumed for type when none set // Using an alternate seperator for the links echo get_years_for_type( 'post', false, ' | ' ); get_years_for_type( 'post', true, ' | ' ); </code> Hope that helps..
|
Categorising posts/pages into years published
|
wordpress
|
I'm working on a custom theme framework for educational purposes. I basically have a header.php in a child theme that i want to make smarter. I'd like to only include a stylesheet if the file exist. Getting 404 errors is not cool or efficient. Are there native php or wordpress functions to check if a wordpress file exist. Basically... I want to output <code> <link rel="stylesheet" href="<?php echo get_stylesheet_directory_uri(); ?>/css/<?php echo get_stylesheet() ?>.css" type="text/css" media="screen" /> </code> Only If the stylesheet with the same name as the folder containing the child theme exist. Any ideas would be awesome :-)
|
There's a lot of ways you could go with this. I might enqueue the style in your theme's functions.php dependent on a <code> file_exists() </code> check. <code> $your_css_file_path = "/path/to/file"; if ( file_exists($your_css_file_path) ) { wp_register_style('your_theme_stylesheet', $your_css_file_path); wp_enqueue_style( 'your_theme_stylesheet'); } </code> Here's the relavent core source .
|
Looking for methods to Check if File Exist
|
wordpress
|
I'm trying to customize a WordPress feed. I know that if I modify wp-includes/feed-rss2.php, the feed is modified. But I don't want to modify this file, as it might get overwritten during an upgrade. I tried copying the file to wp-content/themes/mytheme/feed-rss2.php, but the file seems to be ignored. I found this article on customizing WordPress feeds , but the article is very old and references files that are just dummy files now. Background: Here's what I'm actually trying to do, in case there is a better way to do it. Our company has a WordPress blog. The copy of the posts could have been written by anybody, but only one of the two marketing guys actually posts on the blog. I want to overwrite the author attribute in the feed so that they author always displays as "Acme, Inc." instead of showing the marketing guy's name. I've customized the blog pages to do this, but the feed still shows the user name. I tried changing both marketing guys' usernames to "Acme, Inc.", but they didn't like that because they couldn't tell them apart when they needed to edit posts.
|
Feed templates are special case. You can't simply provide your own template - you need to work with <code> do_feed_ </code> hooks to change handler function. But for your specific question it is much easier to override author. Try this (not tested): <code> add_filter( 'the_author', 'feed_author' ); function feed_author($name) { if( is_feed() ) return 'Acme, Inc.'; return $name; } </code>
|
How to customize feed?
|
wordpress
|
HI there, I want to remove the actions added to wp_head by a plugin but only in certain circumstances. Here is code that doesn't work: <code> if (is_single() && get_post_type() == 'tenant') { $row = $wpdb->get_row("SELECT * FROM Events WHERE WP_ID='$post->ID'",ARRAY_A); remove_action('wp-head',array($aiosp, 'wp_head')); $seo_head = "<title>" . $row['Event'] . " | " . $row['Town'] . " | Events in ". $row['Country'] . "</title>"; } </code>
|
Sorted it, turns out all-in-one-seo-pack can be disabled on a post by post basis, so I used: add_post_meta($post-> ID,'_aioseop_disable',true); inside the if parameter and before setting my own title, works a charm. PS $post is gotten with global $post;
|
Remove_action inside a function
|
wordpress
|
Maybe someone has prior experience with this, but when I include the jQuery UI 1.8.9 file within my <code> admin_head </code> I break the functionality of the dashboard (i.e. popup for adding featured image, drag and drop menu items, etc.). If I include 1.7.2 , it doesn't break anymore but then my great little calendar won't work anymore. So my questions is, currently (3.0.x),what is the best way to implement the jquery UI within admin pages without breaking everything? ( Other info: trying to add datepicker to a field within my custom post type ) Thank you! Noel
|
WP 3.1 will come with jQuery UI 1.8 so the easiest solution would be to wait. Also, it sounds like you're outputting the script tag directly. You should try deregistering the bundled jQuery UI version and replacing it with your own. This is done using wp_deregister_script() and wp_enqueue_script().
|
jQuery UI in Admin (Best Practice?)
|
wordpress
|
I've created a site in WordPress on our development machine. In the theme we're using there are numerous widget zones to display text in (sidebar and front page). I've used simple Text widgets in all of these zones to put our display information. When I migrated the site to production, I used the WP-DB-Backup plugin to take a snapshot of the database. I then edited the resulting .sql file to update all of the file paths and URL references to point to our production site. After creating the database, website, and copying all of the files over to the production site, I run the .sql file from the mysql command prompt to import the data into the new database. However, when I go to the production site, some of the text shows up and some of it doesn't. When I look into the widgets section of the site, the text widgets are missing from some of the widget zones. The text widgets aren't even visible in the "Inactive Widget" zone, they simply aren't there. I've even tried to repeat the process using the BackWPup plugin, noticing that the SQL syntax is different when it dumps the database out. Why am I losing text widget data during the import?
|
This is where your problem is: I then edited the resulting .sql file to update all of the file paths and URL references to point to our production site. You can't do that. WordPress stores many options as "serialized data", which contains both the string content of things and their length . So when you modify the URL and the length changes, then the serialized data is no longer correct, and PHP rejects it. The longer term problem is that, basically, you're doing it wrong. If you are setting up a development site that will have its data migrated, then it should have the exact same URL as your production site to begin with. You can manually edit your HOSTS file to give that production domain (like example.com) a different IP address (like 127.0.0.1) and thus the "production" URL will become the development site, for you only. Then you can create your data and links and everything else using that production URL, and when you migrate the data, nothing about it has to be altered. In the short term, however, don't use a simple text search/replace on the SQL file. As you have discovered, this breaks things. And while I hesitate to suggest it, there is a way to alter the WordPress core code to handle these broken serializations. You have to modify the wp-includes/functions.php file, and change the maybe_unserialize() function to this: <code> function maybe_unserialize( $original ) { if ( is_serialized( $original ) ) { $fixed = preg_replace_callback( '!(?<=^|;)s:(\d+)(?=:"(.*?)";(?:}|a:|s:|b:|i:|o:|N;))!s', 'serialize_fix_callback', $original ); return @unserialize( $fixed ); } return $original; } function serialize_fix_callback($match) { return 's:' . strlen($match[2]); } </code> This is NOT a viable long term solution. It should only be used to get you up and working right now. In the long run, you need to fix your development process so that you don't have to do this sort of URL munging to begin with.
|
Why is my database import losing text widget data?
|
wordpress
|
I'm trying to exclude all the posts that doesn't have a category assigned to from the main loop, i searched everywhere and i found a billion ways to exclude some categories or filter from specific category but not what i need to do, is it possibile?
|
Hi @Raffaele: The function <code> wp_get_object_terms(...) </code> can provide you with the information you need. I've written a <code> has_category($post_id) </code> function that can be used in the loop like this: <code> <?php while ( have_posts() ) : the_post(); ?> <?php if (has_category($post->ID)): ?> <p><?php the_title(); ?></p> <?php endif; ?> <?php endwhile; ?> </code> And here is the <code> has_category() </code> function: <code> <?php function has_category($post_id) { $has_category = false; $terms = wp_get_object_terms($post_id,'category'); if (is_array($terms)) { foreach($terms as $index => $term) if ($term->slug=='uncategorized') unset($terms[$index]); $has_category = (count($terms)>0); } return $has_category; } </code> Note that my <code> has_category() </code> function treats posts with the <code> 'uncategorized' </code> category as having no category. There are probably more performant ways to accomplish this but what you see above should work. -Mike
|
Exclude posts without category from loop
|
wordpress
|
I want to be able to edit the post_parent of a custom post type. Basically in my use case I want to mimic how WordPress uses attachments: have a custom post type that is sort of a subtype to post or any other post type. WordPress uses the post_parent field on the wp_posts table to link attachments to their parent posts so I want to be able to do the same. I've tried to use wp_update_posts but it seems to time out the connection when I try to call it during a post save. Is there a way of editing the post_parent directly?
|
Hi @Manny Fleurmond : You can add the following HTML to a post metabox you'll have an edit field that lets you edit the raw <code> post_parent </code> ID. Maybe with this knowledge you can build what you need? <code> <input type="text" id="parent_id" name="parent_id" value="<?php echo $post->post_parent; ?>" /> </code>
|
How do you modify the 'post_parent' of a custom post type?
|
wordpress
|
I am about to press the "upgrade" button in my Wordpress MU 2.8 install. What is going to happen to the mu-plugins folder? And is there an equivalent way for me to automatically activate a plugin across all my sites?
|
WordPress 3 uses the mu-plugins folder in exactly the same way as MU used to use it. Everything in there is automatically active sitewide. Note that WP 3 has some newer methods for dealing with plugins though that you may want to consider switching to. For example, the Network Activation allows you to install a plugin via the normal means and then activate it sitewide and still use the WP upgrade system to keep it up to date. The mu-plugins method doesn't allow that sort of thing.
|
What happens to the mu-plugins folder when you upgrade to Wordpress 3?
|
wordpress
|
I customized the wordpress theme I'm using by changing php, css and even a js file. Is there a way to protect these changes, when updating the theme to a new version?
|
You can do exactly that by creating Child Theme . It depends on specifics of theme you want to customize and amount of changes how complex will it be to implement, but it is definitely most solid way to implement customization and preserve update capabilities.
|
Protect changes made to the theme when updating
|
wordpress
|
Website: [removed] If you goto the above post you will see that there are some comments which when posted appears as admin comments for some reason. If you are having problem finding that specific comment you can also press CTRL+F to find it using the following words Test Comment or Guest which i posted myself for testing purpose to show it here. The problem is that its making guest users comment appear as Admin Comments by putting that ADMIN Image at the right of the comments. and the odd thing is this is only happening if the user replies to an admin comment :o Can someone please help and tell me what could be causing this behavior? i'm pretty new to wordpress theme development :( Thanks in advance.
|
styles.css > line 537: (span.poster-roles) You haven't defined ... any offset to differ between author and admin for the sprite (author/admin) any additional class to make a difference between author/admin It seems that you wanted to only add the graphic for registered authors and admins (there's nothing for guests). You'll need to add ... (on top of your comments template/file) <code> global $current_user; get_currentuserinfo(); $user_ID = $current_user->user_ID; $the_user = get_userdata( $user_ID ); </code> (inline - comment div) a class for authors & admins like <code> <span class="<?php if ( !empty($the_user) ) : echo $the_user->wp_capabilities->role; else : echo 'guest'; endif; ?>"> </code> Then do some offset for the class mentioned above like <code> ol.commentlist li.comment ul.children li.comment-author-admin .poster-roles.admin { background-position: 0px 0px; } ol.commentlist li.comment ul.children li.comment-author-admin .poster-roles.author { background-position: 0px -40px; } </code> I don't know exactly if it's wp_capabilities-> roles, so please refer to some of my old (since a long time not further developed) plugins for the exact user info - your friendly current user deamon .
|
Comments Confusion
|
wordpress
|
WP 3.0.4 multisite network enabled, local installation with MAMP, PHP 5.3.2, WP THEME: Twentyten Child (Wordpress Theme) Having trouble with not displaying my CSS styling for horizontal alignment of 4 div-boxes inside a div-container. NOTE: The same css styling works fine with HTML 4.01 Transitional//EN on my hand-coded html/php website. But on my WordPress site, the four boxes stepped down from each other, like a staircase. Same behavior in Firefox v3.6.13 and Safari v5.0.3. My CSS: div .box-container { display: inline; margin: 0.63em 0pt; padding:10px; width: 640px; background-color:rgb(229, 231, 225); position:relative; float: left; overflow:hidden; } div .small-box { border: 1px solid rgb(153, 51, 102); margin: 10px 5px; padding: 0.325em; float: left; background-color: rgb(255, 244, 227); width: 128px; line-height: 0.85em; max-height: 8em; min-height: 8em; position: relative; } My HTML: <div class="box-container"> <div class="small-box">SOME TEXT & IMAGE</div> <div class="small-box">SOME TEXT & IMAGE</div> <div class="small-box">SOME TEXT & IMAGE</div> <div class="small-box">SOME TEXT & IMAGE</div> </div> The box-container div width is specified as 640px, but I notice the padding extends it beyond this. In any case, it is plenty large to accommodate the four small boxes, which total 512px plus their total 40px margin, plus the 20px padding on the box-container div. My Problem: I don't understand why the padding pushes the size of the box-container div. When I tried to use max-width: 640px, I observed that the boxes all lined up vertically, and the box-container div was no wider than 170px. EDIT: The padding has since been removed from the box-container div, and margins adjusted on the small-box divs. REAL PROBLEM IS AS STATED IN THE FIRST 2 PARAGRAPHS: The four small boxes are stepped down from each other, like a staircase. I want them to align horizontally. The small-box divs are actually all the same size, their contents consist of text & image. Help? Edit: Screenshot of my hand-coded website, behaving as expected: Staircase effect I'm seeing in WordPress my WordPress Theme:
|
FOUND THE PROBLEM! WordPress had churned out invalid HTML. So it was not that WordPress would not recognize the CSS; it was that WordPress was generating paragraph elements willy nilly (and yes, I did enter HTML in the HTML field when creating the Page). I decided to validate the HTML and CSS. The CSS checked out. To get the HTML for the entire Page, I went to Page Source, selected all and copied, then pasted into the HTML validator's direct input field, and ticked the verbose feedback. The validator returned errors, and sure enough, WordPress had inserted a paragraph end tag (where there was no beginning tag) right inside the box-container div. So I went back into the Page editor, eradicated all spaces between HTML code, tidied everything up, saved (updated), and VOILA! IT'S WORKING! :) So you see, Hakre, it did have to do with WordPress after all. I've learned a lesson from this: don't trust WordPress HTML editor. Thanks to everyone for your help.
|
Why is the CSS horizontal alignment for divs inside div container not displayed in my WP Theme?
|
wordpress
|
Ex. Category 1 Post 1 Post 2 Post 3 Post .... Category 2 Post 1 Post 2 Post 3 Post .... Category .... Post 1 Post 2 Post 3 Post ....
|
Not sure if this is exactly what you're asking, but it sounds like you're looking for nested loops. This will list the most recent 5 posts in every category on your site: <code> foreach ( get_terms('category') as $category ) { echo '<h2>'.$category->name.'</h2>'; echo '<ul>'; foreach ( get_posts( 'cat='.$category->term_id ) as $post ) { setup_postdata( $post ); echo '<li><a href="'.get_permalink($post->ID).'">'.get_the_title().'</a></li>'; } echo '</ul>'; } </code> Add the name of the custom post type and any other variables you may want to modify the loop with to the call to <code> get_posts </code> . You can look through the Codex page for a list of argument that can be passed.
|
How to create a custom loop ordered by Categories on a Page Template?
|
wordpress
|
My contact form is here http://wordswithfriends.net/?page_id=124 When users submit a message, I receive an e-mail but the spinning waiting sign keeps on spinning and the user does not receive confirmation. What is wrong with the code?
|
From Contact 7 Help : The spinning arrow icon shows up once I submit a form, but then nothing happens. This is most probably due to a conflict between plugins/theme. Try deactivating all other plugins and switching to the default theme. Also, I have gotten this behavior when you have built your blog at something like mysite/blog and then moved it to simply mysite. You will need to edit the site base url in this case.
|
Why doesn't my contact form work?
|
wordpress
|
How can I call the_tags as a list without hyperlinks?
|
<code> <ul> <?php $tags = get_tags(); foreach($tags as $tag) { echo "<li>$tag->name</li>"; } ?> </ul> </code>
|
the_tags without hyperlinks?
|
wordpress
|
In Loop = There exist a way or hook to get the featured image, if not, the the first image from post and cropit before display it on frontend? Re-asking my question: On upload. How do I set a featured crop size for a giving custom post type like: news. Thanks in advance.
|
In your theme's functions.php add a call add_image_size($name, $width, $height, $crop) where $name is the name or identifier for the new size, and $crop is whether the image should cropped to fit the dimensions or just shrunk to fit within the dimensions given. This will register the new size that will be automatically created when you upload new images: <code> add_image_size('news-thumbnail', 500, 200, true); </code> Then in the template file for your news post type, call the specific thumbnail size name: <code> the_post_thumbnail('news-thumbnail'); </code>
|
A way to get featuread image or first image and crop on the fly before display
|
wordpress
|
I'm using this script on my archive.php in order to list a link list of all posts contained in the current category. However, its limiting the result count relative to the number assigned to "Settings > Reading > Blog Pages Show At Most _ posts". In other words, there may be 10 posts that are in this category, but its only displaying up to the number assigned in that setting. How can I change my script to ignore this setting? <code> <?php if(is_category()) while (have_posts()) : the_post(); ?> <li id="post-<?php the_ID(); ?>"> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"> <?php the_title(); ?> </a> <?php echo get_link_excerpt(); ?> </li> <?php endwhile; } ?> </code>
|
Instead of using the default loop, perhaps try building your own query. Basically, it'll look something like this: <code> $your_posts = get_posts('cat=123&posts_per_page=123'); foreach ($your_post as $post) { do_something-with($post); } </code> You can display all posts by either use the param <code> 'posts_per_page'=>-1 </code> or <code> nopaging=true </code> . (Not sure why someone voted this down? IMHO said person should comment on how the question should be improved if she or he is going to do that.)
|
How to defeat "Blog pages show at most __ posts" setting in the loop?
|
wordpress
|
Is there a way to add numbering to the latest posts/category listing pages? By default you can put older/newer, but is there a way to add numbering like page 1,2,3,4 of the list so people can skip ahead?
|
Take a look at wp-pagenavi its a plugin which adds advanced paging navigation to your WordPress site just like you asked.
|
How to put page numbers with the next/previous on a post/category list?
|
wordpress
|
i did a fresh wordpress install on my NAS and on my local machine (notebook). on my notebook anything is running perfect (takes ~3 secs to load) but from my NAS it is really extremely slow :( (taking ~12 secs) it's the same setup and i couldn't find out the reason .. :( it seems like that the problem is the internal siteurl (the nas' ip-address) and that wordpress is using it for all paths .. any ideas? thanks
|
I guess you already answered the question yourself. The other thing could be that your NAS has a slow harddrive (5.400 rpm) or that your connection is slow. Edit: Speed up with removing unwanted dashboard items... <code> <?php /* Plugin Name: Dashboard-Widgets Removal Plugin Plugin URI: http://example.com Description: Disables admin UI dashboard widgets that you do not want Author: Franz Josef Kaiser Author URI: http://say-hello-code.com Version: 0.1 License: GPL v2 - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html */ /** * Disable unwanted Dashboard Admin UI Widgets */ function oxo_dashboard_widgets() { if ( !is_admin() ) return; global $wp_meta_boxes; // Right Now - Comments, Posts, Pages at a glance # unset( $wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now'] ); // Recent Comments # unset( $wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments'] ); // Incoming Links # unset( $wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links'] ); // Plugins - Popular, New and Recently updated Wordpress Plugins unset( $wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins'] ); // Wordpress Development Blog Feed unset( $wp_meta_boxes['dashboard']['side']['core']['dashboard_primary'] ); // Other Wordpress News Feed unset( $wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary'] ); // Quick Press Form # unset( $wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press'] ); // Recent Drafts List unset( $wp_meta_boxes['dashboard']['side']['core']['dashboard_recent_drafts'] ); } add_action( 'wp_dashboard_setup', 'oxo_dashboard_widgets' ); ?> </code> Edit #2: Link to a debug plugin that offers time meassuring: Blackbox Bar
|
wordpress extremely slow on NAS
|
wordpress
|
I'm building a function in theme options to give the site owner more control over the post's "Tags" collection that I display at the bottom of each post page. Specifically, whether to add anchor text to them or not. However, since none of the available functions: the_tags(), get_the_tags(), etc will create an unanchored list with separators, I'm left to roll my own method (unless, as I'm hoping, I'm missing something) In the 1st part of the code branch below, once we determine the post has tags and the user has chosen to display them without links, I'm manually creating the tag list and adding a comma separator. How can I remove the separator from the last tag or from a single tag when that condition exists? (or better, is there a core method that will do it for me?) <code> function my_get_tags(){ $unlinkTags = get_option('my_unlinkTags'); $gotTags = get_the_tags(); if(!$gotTags) return; //we got tags, lets create a wrapper echo '<div><span class="tags">'; //no anchors and a separator? have to roll our own if($unlinkTags) { foreach($gotTags as $tag) {echo $tag->name . ', ';} } //they want anchors, easy peasy, use get tags else { echo the_tags('', ', ', ''); } echo '</span></div>'; } </code>
|
Try this: <code> $output = array(); foreach($gotTags as $tag) $output[] = $tag->name; echo implode(',', $output); </code>
|
get_the_tags with separator control?
|
wordpress
|
While coding WP I just wondered about this simple fact: <code> get_usermeta() </code> is deprecated since version 3.0. The warning suggests me to use <code> get_user_meta() </code> . Even the parameters are pretty similar, I wonder why the deprecated function is not making use of the new function as well. Isn't that a sign that the new function does not really does what the deprecated did? I'm wondering because I need to replace deprecated calls and wonder a bit. What makes me even wondering more is the simple fact that <code> get_user_meta() </code> is quite an alias of the 2.9 function <code> get_metadata() </code> with only a constant value'ed parameter 'user' given. Help ;) Edit: A counter-example is <code> clean_url() </code> - it's deprecated, the error message shows what this is about and the deprecated function aliases the new one: <code> esc_url() </code> , so it's clear what to do.
|
Indeed, <code> get_usermeta() </code> behaves differently from <code> get_user_meta() </code> and all the other <code> get_*_meta() </code> functions. That's why it was deprecated. Unfortunately, the subtle differences couldn't be explained properly in a deprecation notice.
|
get_usermeta() deprecated in favor of get_user_meta(). But why doesn't it make use of it?
|
wordpress
|
I've been puzzling over this one for two days. Still can't figure it out. I'm testing a theme release in multiple versions of WordPress using xampplite on localhost on a PC. I'm having a problem on WP 2.9.2 that does not occur on any other newer installations of WP. Take a look at the query below. As long as I leave the commented line in place, it works fine. However, when I uncomment the line, it crashes my xampplite Apache server. WTF? <code> $the_query = new WP_Query(array( 'posts_per_page' => 5, 'offset' => 0, 'order' => 'ASC', 'post__not_in' => get_option("sticky_posts"), // 'cat' => get_cat_ID('top-menu'), )); print "<p>header.php";exit; </code> I've even tried to hard code the cat attribute to a static number: <code> 'cat' => 3 </code> It still crashes! Is this a problem with the code, wordpress 2.9.2 or with my Xamplite setup? Seems odd that it works in all newer other versions of WP I've got set up on this same box.
|
The only thing I see as even close to syntactically questionable is that <code> showposts </code> could be replaced with <code> posts_per_page </code> .
|
Is there ANYTHING about this query that's incompatible with WordPress 2.9.2?
|
wordpress
|
Let's say I buy a custom domain myblog.com and I host at wordpress... if I access the dashboard page on my blog, will it have wordpress.com in the URL? I want to be able to manage my blog behind school firewall.. thanks
|
try blogging by email have your analytics and stats on google analytics or outside source have comments emailed to you that will leave very few things to be done thru administration to bypass security system try VPN or use of proxy
|
Does wordpress.com appears in the URL if I buy custom domain service from WP.com
|
wordpress
|
Are there any Wordpress themes that will just return a JSON object that can be processed by Javascript to display a list of postings?
|
Sounds like what JSON API plugin does.
|
Wordpress Theme that returns all posts as a JSON object?
|
wordpress
|
I have a mult-author site where the author page gets high traffic. People want to know more about them. I have modified the author page to show more info, some custom fields, etc. but what I'd really like to do is turn on Comments for the author.php page (so that OTHER logged in users can leave review-like messages for the Author), and ultimately offer a star-ratings type of effect so that Users can "rate" the author. I have searched for plugins and other functions but it seems like everything is for Posts or Products or something. Any insight is greatly appreciated!
|
just to add to what Rarst answered, you can create Custom Post Type not to emulate Comments but as stub posts with no ui. then to every Author on your site add a custom user metadata that will hold a post id of your newly made post type (one per each author) and in your author template before you call the comment loop\form set the global $post to that post id. something like: <code> <?php //save the true post id $true_id = $post->ID; // populate $post with the stub post $author_post_id = get_user_meta($user_id, author_post_id,true); query_posts("p=$author_post_id"); the_post(); //fool wordpress to think we are on a single post page $wp_query->is_single = true; //get comments comments_template(); //reset wordpress to ture post $wp_query->is_single = false; query_posts("p=$true_id"); the_post(); ?> </code> Now going back and updating all of your existing users could be a pain, but for newly create user you can create the stub post type id for user metadata on registration. and you can use any rating plugin that is based on posts now that you have a post (you custom post type) associated with each author. Hope this makes sense. Ohad.
|
Author page: Comments and Ratings?
|
wordpress
|
I'm trying to pull just the tag names as an array collection in order to write them out as a simple listing, without links, but the array that's returned does not send the name as an indexible item. <code> array(2) { [0]=> string(129) "<a href='#' class='tag-link-31' title='1 topic' style='font-size: 8pt;'>tag 1</a>" [1]=> string(127) "<a href='#' class='tag-link-30' title='1 topic' style='font-size: 8pt;'>tag 2</a>" } </code> Is there another method I can use to get the entire site's tag collection with just the tag names? This is my current code, but because of the array indexes, I get the links as well. <code> $tagNames = wp_tag_cloud('format=array'); echo implode($tagNames,", "); </code>
|
try : <code> function my_tag_list_123($sep){ $tags = get_tags(); foreach ($tags as $tag){ $ret[]= $tag->name; } return implode($sep, $ret); } </code> and call it when you need like this <code> echo my_tag_list_123(','); </code> hope this helps.
|
Using wp_tag_cloud('format=array') to print tag names without links?
|
wordpress
|
I've roughly followed the tutorial here on how to create "custom taxonomy input panels". I'm using a custom post type of <code> homes </code> and a custom taxonomy called <code> beds </code> (used to record the number of beds in a house). I've got the taxonomy terms showing up in a drop down menu, but cannot get them to save when the post is saved. I started to just post the code that is intended to save the term, but realized that I should post the code that creates and displays the metabox as well, for context. The custom post type name is 'homes' and the custom taxonomy name is 'beds'. The taxonomy is hierarchical (not that I think that matters in this case, but I could be wrong). <code> //adding metaboxes for the homes post type function add_homes_metaboxes() { add_meta_box( 'blackstone_homes_beds', 'Beds', 'blackstone_homes_beds', 'homes', 'side', 'default' ); } function add_homes_menus() { if ( !is_admin() ) return; add_action( 'admin_menu', 'add_homes_metaboxes' ); /* Use the save_post action to save new post data */ add_action( 'save_post', 'save_taxonomy_data' ); } add_homes_menus(); function blackstone_homes_beds( $post ) { echo '<input type="hidden" name="beds_noncename" id="beds_noncename" value="' . wp_create_nonce( 'taxonomy_beds' ) . '" />'; // Get all theme taxonomy terms $beds = get_terms( 'beds', 'hide_empty=0' ); $stuff = array( 'this', 'that' ); //print_r($beds); ?> <select name='homes_beds' id='homes_beds'> <!-- Display beds as options --> <?php $names = wp_get_object_terms( $post->ID, 'beds' ); ?> <option class='beds-option' value='' <?php if ( !count( $names ) ) echo "selected"; ?>>None</option> <?php foreach ( $beds as $bed ) { if ( !is_wp_error( $names ) && !empty( $names ) && !strcmp( $bed->slug, $names[0]->slug ) ) echo "<option class='beds-option' value='" . $bed->slug . "' selected>" . $bed->name . "</option>\n"; else echo "<option class='beds-option' value='" . $bed->slug . "'>" . $bed->name . "</option>\n"; } ?> </select> <?php } function save_taxonomy_data( $post_id ) { // verify this came from our screen and with proper authorization. if ( !wp_verify_nonce( $_POST['beds_noncename'], 'taxonomy_beds' ) ) { return $post_id; } // verify if this is an auto save routine. If it is our form has not been submitted, so we dont want to do anything if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return $post_id; // Check permissions if ( 'homes' == $_POST['post_type'] ) { if ( !current_user_can( 'edit_page', $post_id ) ) return $post_id; } else { if ( !current_user_can( 'edit_post', $post_id ) ) return $post_id; } // OK, we're authenticated: we need to find and save the data $post = get_post( $post_id ); if ($post->post_type == 'homes'){ $beds = $_POST['homes_beds']; wp_set_object_terms( $post_id, $beds, 'beds' ); } return $beds; } </code> I know there's another stackexchange-url ("very similar question") here already, but the solution to it uses the WPAlchemy class, and I'd rather not do so. Any suggestions on what I might have wrong? I've been staring at this all day, so I fully expect to find out I've just got a variable name off by one character or something. EDIT: Here's what I changed to get it working correctly: Instead of echoing the hidden field with the nonce, I used <code> wp_nonce_field( __FILE__, 'taxonomy_beds' ); </code> and when verifying the nonce, I used <code> if ( !wp_verify_nonce( $_POST['taxonomy_beds'], __FILE__ ) ) </code>
|
I believe your problem might be nonce-related. I see you're doing what I did at one point with stackexchange-url ("a problem I had") when I tried doing nonces the way you're using them. I'll quote @ EAMann on this: The standard way to create this field is using WordPress' <code> wp_nonce_field() </code> function. It will add the hidden field for you: <code> wp_nonce_field( __FILE__, 'argus_edit_visitor' ); </code> Try that, see if it works. I don't see anything else wrong with your code. If that doesn't work, try <code> print_r( $_POST['beds'] ) </code> to reveal what is being submitted in <code> $_POST['beds'] </code> .
|
Unable to save custom taxonomy terms in a custom-built metabox
|
wordpress
|
Hey there, I am sooo frustrated, asked and asked and can't seem to get an answer. Pleaseeeee help, I'll be very very clean whith my problem. I'll give hundreds of bears to the one who can help:) I have a blog installed http://www.myblog.com - it's part of a network, I use wordpress multisite I created a table called cars with 60 rows - it's not a wordpress table , it's my own custom table but I have created it inside the wordpress database. On my blog theme, editing index.php, I display the records from the table cars , 10 rows per page and I write a custom pagination script with no relation what so ever with my wordpress pagination. Now i have the following links: www.myblog.com/index.php?currentpage=1 www.myblog.com/index.php?currentpage=2 and so on untill ... www.myblog.com/index.php?currentpage=6 How can I rewrite them to pretty goole friendly links? Ideea one: since they are not actually related to the wordpress blog, should I edit htaccess? I believe wordpress .htacces rules override any custom rules i put there... if you know a solution please share... Ideea two: Tried to use wordpress rules and edited functions.php like so, with no luck: <code> add_action( 'init', 'wpa5413_init' ); function wpa5413_init() { add_rewrite_rule( '^/\?currentpage/(\d*)$', 'index.php?currentpage=$matches[1]', 'top' ); } add_filter('query_vars', 'wpa3537_query_vars'); function wpa3537_query_vars($query_vars) { $query_vars[] = 'currentpage'; return $query_vars; } </code> Please help me, honestly, I can even pay, I am soo frustraed... doing this work after my dayjob, it's been days of not sleeping, just need to make this happen, pleaseeeeeeeeeeeeeeeee PS don't vote down my question, i see others are struggeling with similar issues
|
Your rewrite rules must not start with the first slash, that is already stripped out. So the following code will add a rewrite rule that will set a query variable that we can later use: <code> add_action( 'init', 'wpse9016_init' ); function wpse9016_init() { add_rewrite_rule( 'currentpage/(\d+)/?', 'index.php?wpse9016_currentpage=$matches[1]', 'top' ); } </code> This query variable is ignored unless we add it to the list of public query variables : <code> add_action( 'query_vars', 'wpse9016_query_vars' ); function wpse9016_query_vars( $query_vars ) { $query_vars[] = 'wpse9016_currentpage'; return $query_vars; } </code> After you have done this, you can check for it and do whatever you want when it is set. A common use is to load a specific template file: <code> add_filter( 'template_include', 'wpse9016_template_include' ); function wpse9016_template_include( $template ) { if ( get_query_var( 'wpse9016_currentpage' ) ) { $template = locate_template( array( 'wpse9016_template.php' ) ); } return $template; } </code> Now, if you go to <code> http://www.example.com/currentpage/2/ </code> , the file <code> wpse9016_template.php </code> in your theme directory will be loaded, where you can read <code> get_query_var( 'wpse9016_currentpage' ) </code> to get the current page number.
|
Own code on index.php wordpress theme file, help with the rewrite rules
|
wordpress
|
I want to display a message like "You must be logged in to view this", with Private custom posts. Theoretically, I want to use something like this: <code> if (is_user_logged_in()) { // Page code goes here } else { echo "You must be logged in to view this page."; } </code> This code is in the single-custom.php page template. The <code> true </code> case works just fine. However, if the user is not logged in, instead of seeing "You must be logged in..." I get a 404 instead? What am I doing wrong?
|
Are you doing this inside The Loop? I'd try something like this myself: <code> if ($post->post_status == "private" && !is_user_logged_in()) { echo "You must be logged in to view this page."; } else if( $post->post_status == "private" && is_user_logged_in() ) { // Page code goes here } </code>
|
How do I display content to users who are not logged in instead of 404 on Private custom posts?
|
wordpress
|
I read that jQuery 1.5 has just been released . Do you think that replacing version 1.4.2 with this new release is worth in terms of pure performance (on the admin side because my current theme does not use jQuery a lot)? Any side effects or compatibility problems?
|
Well, as for performance release post says: In this release we’ve also been able to improve the performance of some commonly-used traversal methods: .children(), .prev(), and .next(). The speed-ups that we’re seeing are quite substantial (potentially many many times faster, depending upon the browser). On other hand replacing jQuery on admin side is rarely good idea, because it is getting merged into concatenated bunch of scripts and it's a mess to deal with. Unless you are suffering from considerable JS performance issues in admin, my personal opinion is that it isn't worth the trouble. PS WP 3.1 will have newer 1.4.4 jQuery version, don't know if they will bother to bring it up to 1.5 by final release. Update WordPress 3.0.5 was released at the same time as jQuery 1.5. Unfortunately, 1.5 has some backwards incompatible changes that appear to break a number of areas in the admin. The timing is awkward and it looks like it was us. It wasn’t. There’s nothing we can do about this even for WordPress 3.1, which is freezing at jQuery 1.4.4. ( Andrew Nacin ) So issues t31os desribed are definitely caused by jQuery 1.5 and it is definitely not recommended to use in admin area at moment.
|
Is it worth updating WP admin to jQuery 1.5?
|
wordpress
|
( Moderator's note: Original title was "Getting error: You do not have sufficient permissions to access this page. Trying to build custom plugin") I'm trying to write my own custom WordPress plugin, but as soon as I click on the menu I get the following error: You do not have sufficient permissions to access this page. My plugin is located under: <code> /wp-content/plugins/wp-e-commerce-group-pricing/wp-e-commerce-group-pricing.php </code> The code is below, I'm new to WordPress, so maybe I'm doing something wrong: <code> if ( is_admin() ) { // Hooks and admin menu setup add_action('admin_menu', 'add_options_gp'); function add_options_gp() { add_submenu_page('wpsc-sales-logs','WPEC - Group Pricing','Group Pricing',7, 'wp-e-commerce-group-pricing', 'price_options'); } function price_options(){ // Page content goes here... } } </code>
|
Hi @Roland: I think the issue may be in your call to <code> add_submenu_page() </code> : <code> add_submenu_page('wpsc-sales-logs',... </code> The first parameter needs to be a reference to your Menu Page's "slug", i.e. if you use <code> 'edit.php' </code> instead you'll see that you get a menu option under the "Posts" menu page: <code> add_submenu_page('edit.php','WPEC - Group Pricing','Group Pricing', 7, 'wp-e-commerce-group-pricing', 'price_options'); </code> Here's what it looks like: So you need to find out what URL fragment (the part past <code> http://yoursite.com/wp-admin/ </code> ) that your menu page uses. UPDATE For future readers, Roland's issue was a hook priority issue. Changing priority from 10 to 11 fixed it in his case: <code> add_action('admin_menu', 'add_options_gp',11); </code> P.S. You really don't need the <code> if </code> statement testing for <code> is_admin() </code> since you are using the <code> 'admin_menu' </code> hook; it only fires in the admin.
|
Menu Error in Admin Console with Custom Plugin: You do not have sufficient permissions to access this page
|
wordpress
|
In the script below i'm trying to pass category IDs to exclude, however, the category list still includes children of these categories and i can't figure what's wrong. Can anyone see what I could be doing wrong in this script? <code> $cat_args = get_option('show_empty_cats') ? 'exclude='.ce4_cat().'&exclude_tree='.ce4_cat().'&hide_empty=0' : 'exclude='.ce4_cat().'&exclude_tree='.ce4_cat().'';$categories=get_categories($cat_args); //$cat_args = 'exclude=1,31&exclude_tree=1,31&hide_empty=0'; $categories = get_categories($cat_args); for each..., etc </code>
|
Add before your code: <code> $test_me = ce4_cat(); var_dump($test_me); </code> Edit: Easier to read version: <code> $test_me = ce4_cat(); echo '<pre>'; print_r($test_me); echo '</pre>'; </code>
|
get_categories exclusion issues
|
wordpress
|
Have been trying to figure out the issue with this for the past hour, but hitting a wall. Basically I'm just trying to query my custom post type based on some custom date fields and then displaying each. Anyone have an idea where I'm going wrong? <code> <?php // - query - global $wpdb; $yesterday = strtotime("-1 day"); $querystr = " SELECT * FROM $wpdb->posts INNER JOIN {$wpdb->postmeta}postmeta m1 ON ( {$wpdb->posts}posts.ID = m1.post_id ) INNER JOIN {$wpdb->postmeta}postmeta m2 ON ( {$wpdb->posts}posts.ID = m2.post_id ) WHERE $wpdb->posts.post_type = 'tf_events' AND $wpdb->posts.post_status = 'publish' AND ( m1.meta_key = 'tf_events_startdate' AND m1.meta_value > $yesterday ) AND ( m2.meta_key = 'tf_events_starttime') ORDER BY m1.meta_key ASC, m2.meta_key ASC LIMIT 30 "; $events = $wpdb->get_results($querystr, OBJECT); if ($events): global $post; foreach ($events as $post): setup_postdata($post); // - variables - $custom = get_post_custom(get_the_ID()); $sd = $custom["tf_events_startdate"][0]; $ed = $custom["tf_events_enddate"][0]; $st = $custom["tf_events_starttime"][0]; $et = $custom["tf_events_endtime"][0]; $post_image_id = get_post_thumbnail_id(get_the_ID()); if ($post_image_id) { $thumbnail = wp_get_attachment_image_src( $post_image_id, 'post-thumbnail', false); if ($thumbnail) (string)$thumbnail = $thumbnail[0]; } // - output - ?> <div>Show the goodies</div> <?php endforeach; ?> <?php else : ?> <h2 class="center">Not Found</h2> <p class="center">Sorry, but you are looking for something that isn't here.</p> <?php endif; ?> </code> Thank you in advance :)
|
I would check the output of <code> $querystr </code> . It looks like you have the table name twice. <code> $wpdb->postmeta </code> resolves to something like <code> wp_postmeta </code> and then you have <code> postmeta </code> again. This gives you <code> wp_postmetapostmeta </code> which isn't a valid table. I highly recommend you try out Debug Bar . It greatly simplifies query debugging.
|
Custom Select Query with Custom Post Types
|
wordpress
|
I am looking for a way to make two separate register pages. One will automatically assign users up as a subscriber , while the other will sign them up as a contributor . The only thing I have thought of so far is to duplicate the *register_new_user* function in the wp-login.php file and customize it a bit. Any ideas? Thanks in advance.
|
Basically all you need to do is add an hidden field named role and set the value to whatever role you want on the register form. <code> add_action('register_form','show_role_field'); function show_role_field(){ ?> <input id="role" type="hidden" tabindex="20" size="25" value= "<?php if (isset($_GET['role'])){echo $_GET['role'];} ?>" name="role"/> <?php } </code> Next thing is to register that role when the user has submitted the registration form. <code> add_action('user_register', 'register_role'); function register_role($user_id, $password="", $meta=array()) { $userdata = array(); $userdata['ID'] = $user_id; $userdata['role'] = $_POST['role']; //only allow if user role is my_role if ($userdata['role'] == "my_role"){ wp_update_user($userdata); } } </code> Now all that is left to do is direct the user to the register url with the role that you want as a query var, for example <code> http://example.com/wp-login.php?action=register&role=my_role </code> You can read more http://www.jasarwebsolutions.com/2010/06/27/how-to-change-a-users-role-on-the-wordpress-registration-form/ And i would suggest that you check to validate the role is allowed to register before saving it so you wont get a few new admins in your site.
|
How do you create two separate Register pages?
|
wordpress
|
I have an ad rotate plugin installed to display a few ads on my site but the plugin is coded so that it uses the full directory in the ad count link. I would like to know if there's something easy to put in my htacces to cloak the link. So for example: http://mysite.com/wp-content/plugins/ad-rotating-plugin/rotate.php?trackerid=1 needs to look like: http://mysite.com/rotate.php?trackerid=1 (actually any variation of this is fine, I just don't want that full wp-content/plugins/ directory shown in the link). I've tried a few plugins but not getting the desired results. To recap, I want the link to SHOW as the bottom link, but when clicked, be taken to the top link, and I need that trackerid=# to stay the generated id, so I only want to cloak part of the link. Is there something I can put in my htaccess to do this? Thanks!
|
What you need to do is set up a custom rewrite. This can change something like <code> http://site.com/rotate/1 </code> to <code> http://site.com/wp-content/plugins/ad-rotating-plugin/rotate.php?trackerid=1 </code> Here is some untested code that might help: <code> <?php /* Plugin Name: Your Plugin Plugin URI: Description: Version: 0.1 Author: Author URI: */ // Add rewrite rule and flush on plugin activation register_activation_hook( __FILE__, 'ad_rotate_activate' ); function ad_rotate_activate() { ad_rotate_rewrite(); flush_rewrite_rules(); } // Flush on plugin deactivation register_deactivation_hook( __FILE__, 'ad_rotate_deactivate' ); function ad_rotate_deactivate() { flush_rewrite_rules(); } // Create new rewrite rule add_action( 'init', 'ad_rotate_rewrite' ); function ad_rotate_rewrite() { add_rewrite_rule( 'rotate/([^/]+)','/wp-content/plugins/ad-rotating-plugin/rotate.php?trackerid=$matches[1]','top' ); } </code>
|
htaccess or redirect to cloak portion of a link?
|
wordpress
|
I'm about to start working on a prototype for a client - and one of the required features is integration with an in-house user authentication / registration system. This system will act as the authoritative user database, and provides a RESTful interface for creating new users, and authenticating valid users. I need to be able to create new users in WP and as part of that process make a call to the external authentication API to either create / validate that user. A person who is a valid user but not known to WP should be able to login to comment, without needing to register on the WP site themselves. A person logged into the overall website should also automatically be logged in to WordPress. I'm thinking the following is the way to go. For (1) - is there a registration hook I can use? For (2) - I'm assuming i hook the authenticate filter - ie when someone tries to login, I trap that, make a call to the external system, and then either process the WP login or redirect them to the registration process where (1) takes oer. For (3) - read the login cookie set by the main site and proceed with (2) ? I guess I'll also need to insert a record into the users and usermeta table. So, does the above make sense - have I not thought about something. Anyone got any good resources for helping with this (@hakre - I saw you've done some work on this !!). Update So I'm still bashing my head against this a bit, essentially I'm trying to hook into the authenticate filter, and using that to: check if a login cookie for the 'master' site is set, and if it is, revalidate against their authentication API, and if valid, force a WP login with <code> wp_signon() </code> ,using the information contained in the master site cookie (email and hashed password) as credentials for WP if the cookie isn't set, redirect to the master site login page and get either a login / signup then back to step 1 if there isn't a WP user when an authenticated master site user exists, create it and then so a 'transparent' signon (ie so the user doesn't see a WP login form) Basically, I want to hide the WP login form entirely for users who are just going to be mainly commenting, and later find a way to allow authors and admin to access it directly. It's going fairly slowly, here's what I could use some help with: is the authenticate filter the right one to use? It doesn't seem to get called in all situations I would expect - eg the meta widget displays log in / log out links without the authenticate hook firing i can get <code> wp_signon() </code> to return a <code> WP_User </code> object (indicating success), but it doesn't affect the logged in status - ie the meta widget would still be showin "Login" even after refreshing. Any help gratefully received :)
|
OK, the approach that's working for me is as follows: Assume that the main site user database is authoritative. The main site login cookie contains an ID and a hash of the site password. Get the cookie from the main site and revalidate it against the main site's authentication API If valid, use the email address from the return value as the <code> 'user_login' </code> value for WP, and the hashed site password as the WP password. Test if this user exists in WP by using <code> wp_authenticate('user_login', 'user_pass') </code> . This returns a <code> WP_User </code> object on success, or a <code> WP_Error </code> object on failure. If <code> WP_Error/is_wp_error() </code> , then use use <code> wp_update_user() </code> to create a user (or update a user with a changed password). Login via <code> wp_set_current_user() </code> , <code> wp_set_auth_cookie() </code> and <code> do_action('wp_login, id) </code> (This is all contained in a function that's attached to the <code> 'init' </code> action) This seems to be working - valid site users unknown to WP are automatically created. Password changes are catered for, and if the site cookie is set, and the WP user exists, the SSO is automatic and pretty seamless.
|
SSO / authentication integration with external 'directory service'
|
wordpress
|
I've been trying to add a field to Quick Edit. Somehow it works: it is displayed and if you enter a value in the input field, the value is saved into a custom field. However, can't seem to find a way to retrieve the value of the custom field. Here's what I got so far: <code> add_action('quick_edit_custom_box', 'ilc_quickedit_show', 10, 2); function ilc_quickedit_show( $col, $type ) { if( $type != 'event' ) return; ?> <fieldset class="inline-edit-col-left"> <div class="inline-edit-col"> <div class="inline-edit-group"> <label for="eventdate" style="font: italic 12px Georgia, serif;">Event Date</label> <span class="input-text-wrap"> <input type="text" name="eventdate" id="eventdate" size="10" value=""> </span> </div> </div> </fieldset> <?php } </code> entered values are saved using: <code> add_action('save_post','ilc_quickedit_save',10,3); function ilc_quickedit_save($post_id, $post) { if( $post->post_type != 'event' ) return; update_post_meta($post_id, 'Event Date', $_POST['eventdate']); } </code> As you surely noticed, this is for a custom post type 'event'. However, I can't retrieve the values and populate the fields. AFAIK, this involves inline-edit-post.js but I can't find any way to use inlineEditPost to retrieve the custom field value. Even the post id is available in the JavaScript scope <code> add_action('admin_head-edit.php', 'ilc_quickedit_get'); function ilc_quickedit_get() { ?> <script type="text/javascript"> jQuery(document).ready(function() { jQuery('a.editinline').live('click', function() { var id = inlineEditPost.getId(this); alert("Post id: " + id); }); }); </script> <?php } </code> Downloaded the Custom Field Template plugin to dissect the code and found that they are redefining portions of the inlineEditPost function, so I thought about doing the same thing. However, they appear to be doing it through an options array where a duplicate is stored. If you have solved this, could you share what you're using to retrieve the values for each custom field?
|
Ok, I got it, here's the code: <code> function ilc_quickedit_save($post_id, $post) { if( $post->post_type != 'evento' ) return; if (isset($_POST['is_quickedit'])) update_post_meta($post_id, 'eventdate', $_POST['eventdate']); } function ilc_quickedit_get() { $html = '<script type="text/javascript">'; $html .= 'jQuery(document).ready(function() {'; $html .= 'jQuery("a.editinline").live("click", function() {'; $html .= 'var id = inlineEditPost.getId(this);'; $html .= 'jQuery.post("' . THEME_URI . '/library/admin/admin.php",{ post_id: id, modo: "ajaxget" },'; $html .= 'function(data){ jQuery("#eventdate").val(data); }'; $html .= ');});});'; $html .= '</script>'; echo $html; } </code> and the code at the beginning of the admin.php file (which is the same file where all this code is located): <code> if($_POST['modo'] == 'ajaxget'){ require_once('../../../../../wp-blog-header.php'); $post_id = $_POST['post_id']; echo get_post_meta($post_id, 'eventdate', true); return; } </code> So far so good, maybe there are other ways to do it. Still need to deal with saving while in bulk editing mode. Could use a hand there too :) Hope this is useful for someone.
|
Retrieving values of custom fields in Quick Edit mode
|
wordpress
|
I want to display the "latest x posts", like you see per default on the index-page, but on a completely different site. E.g. <code> /blog/ </code> Installing WP into the directory <code> /blog/ </code> is not an option, as the other pages will be managed with WP. Currently I'm using the <code> NuRelm Get Posts </code> plugin to get the content of the latest 10 posts, but the styling is really hard to recreate with it. So, is there any simple solution to use the "Show latest posts" on other sites? Edit : I'm using the <code> twentyten </code> theme as basis
|
You could insert the plugin's shortcode into another page, by following the directions here. http://wordpress.org/extend/plugins/nurelm-get-posts/ Alternatively if you don't necessarily need the plugin and simply want to create a page that displays posts, follow the example given here on the codex. http://codex.wordpress.org/Pages#A_Page_of_Posts Scribu, +1 .. as that's essentially what you were suggesting to.
|
Using the "Latest posts" feature on a different site
|
wordpress
|
Suddenly I am getting the following error on my website, I don't know why, but I think this is because of shortage of RAM or Memory in the host? Is it true? Error: Fatal error: Out of memory (allocated 12845056) (tried to allocate 311296 bytes) in /wp-content/plugins/WPRobot3/wprobot.php(1239) : eval()'d code(1) : eval()'d code(1) : eval()'d code(1) : eval()'d code(1) : eval()'d code(1) : eval()'d code(1) : eval()'d code(1) : eval()'d code(1) : eval()'d code(1) : eval()'d code on line 335 Fatal error: Out of memory (allocated 18874368) (tried to allocate 35 bytes) in /wp-includes/wp-db.php on line 1140 Is this because of insufficient memory with the host? or is it because of wp? Notices <code> Notice: get_settings is deprecated since version 2.1! Use get_option() instead. in wp-includes/functions.php on line 3237 Notice: register_sidebar_widget is deprecated since version 2.8! Use wp_register_sidebar_widget() instead. in wp-includes/functions.php on line 3237 Notice: register_widget_control is deprecated since version 2.8! Use wp_register_widget_control() instead. in wp-includes/functions.php on line 3237 Notice: register_sidebar_widget is deprecated since version 2.8! Use wp_register_sidebar_widget() instead. in wp-includes/functions.php on line 3237 Notice: register_widget_control is deprecated since version 2.8! Use wp_register_widget_control() instead. in wp-includes/functions.php on line 3237 Notice: register_sidebar_widget is deprecated since version 2.8! Use wp_register_sidebar_widget() instead. in wp-includes/functions.php on line 3237 Notice: register_widget_control is deprecated since version 2.8! Use wp_register_widget_control() instead. in wp-includes/functions.php on line 3237 Notice: register_sidebar_widget is deprecated since version 2.8! Use wp_register_sidebar_widget() instead. in wp-includes/functions.php on line 3237 Notice: register_widget_control is deprecated since version 2.8! Use wp_register_widget_control() instead. in wp-includes/functions.php on line 3237 Notice: register_sidebar_widget is deprecated since version 2.8! Use wp_register_sidebar_widget() instead. in wp-includes/functions.php on line 3237 Notice: register_widget_control is deprecated since version 2.8! Use wp_register_widget_control() instead. in wp-includes/functions.php on line 3237 Notice: register_sidebar_widget is deprecated since version 2.8! Use wp_register_sidebar_widget() instead. in wp-includes/functions.php on line 3237 Notice: register_widget_control is deprecated since version 2.8! Use wp_register_widget_control() instead. in wp-includes/functions.php on line 3237 Notice: Undefined index: page in wp-content/plugins/seo-booster-lite/seo-booster.php on line 980 Notice: has_cap was called with an argument that is deprecated since version 2.0! Usage of user levels by plugins and themes is deprecated. Use roles and capabilities instead. in wp-includes/functions.php on line 3321 Notice: has_cap was called with an argument that is deprecated since version 2.0! Usage of user levels by plugins and themes is deprecated. Use roles and capabilities instead. in wp-includes/functions.php on line 3321 Notice: has_cap was called with an argument that is deprecated since version 2.0! Usage of user levels by plugins and themes is deprecated. Use roles and capabilities instead. in wp-includes/functions.php on line 3321 Notice: has_cap was called with an argument that is deprecated since version 2.0! Usage of user levels by plugins and themes is deprecated. Use roles and capabilities instead. in wp-includes/functions.php on line 3321 Notice: has_cap was called with an argument that is deprecated since version 2.0! Usage of user levels by plugins and themes is deprecated. Use roles and capabilities instead. in wp-includes/functions.php on line 3321 Notice: has_cap was called with an argument that is deprecated since version 2.0! Usage of user levels by plugins and themes is deprecated. Use roles and capabilities instead. in wp-includes/functions.php on line 3321 Notice: Undefined index: page in wp-content/plugins/autoblogged/autoblogged.php on line 164 Notice: has_cap was called with an argument that is deprecated since version 2.0! Usage of user levels by plugins and themes is deprecated. Use roles and capabilities instead. in wp-includes/functions.php on line 3321 Notice: has_cap was called with an argument that is deprecated since version 2.0! Usage of user levels by plugins and themes is deprecated. Use roles and capabilities instead. in wp-includes/functions.php on line 3321 Notice: has_cap was called with an argument that is deprecated since version 2.0! Usage of user levels by plugins and themes is deprecated. Use roles and capabilities instead. in wp-includes/functions.php on line 3321 Notice: has_cap was called with an argument that is deprecated since version 2.0! Usage of user levels by plugins and themes is deprecated. Use roles and capabilities instead. in wp-includes/functions.php on line 3321 Notice: has_cap was called with an argument that is deprecated since version 2.0! Usage of user levels by plugins and themes is deprecated. Use roles and capabilities instead. in wp-includes/functions.php on line 3321 Notice: has_cap was called with an argument that is deprecated since version 2.0! Usage of user levels by plugins and themes is deprecated. Use roles and capabilities instead. in wp-includes/functions.php on line 3321 Notice: has_cap was called with an argument that is deprecated since version 2.0! Usage of user levels by plugins and themes is deprecated. Use roles and capabilities instead. in wp-includes/functions.php on line 3321 Notice: Undefined index: page in wp-content/plugins/seo-booster-lite/seo-booster.php on line 990 </code>
|
While this is clearly out of memory error, it seems to be caused by obfuscated code in plugin's file. There is rarely legit reason to run that many layers of <code> eval() </code> so either that code is obfuscated for not-so-good reason or some error is causing endless loop (which should trigget another error by exceeding recursion, but possibly memory runs out before that).
|
Fatal error, is this because of host?
|
wordpress
|
Anyone has any insight why http://www.quantnet.com loads fine in FF, Chrome but hangs in IE for 20 seconds or more? I have been hunting down the problem but reach an end.
|
Here's a waterfall chart showing your page load. Your page loads in 3.1 seconds, but doesn't fire the document.ready event for another 27 seconds. Aside from various room for optimization (you might split your .pngs across domains to make them load faster, for example) what this waterfall chart shows that it's not the page that is hung but the page content. It is not WordPress or WordPress content, rather the page your WordPress content is on or some 3rd party plugin (for example) failing to put scripts in the footer. This is probably in part because of the heavy usage of images without image sprites, but likely there is also some JavaScript blocking the onload event. I'd start with the JavaScript, debugging using a tool like Firebug .
|
Wordpress homepage hangs in IE browsers
|
wordpress
|
I'd like to use a LIKE %text% statement while still using the WordPress $wpdb class to sanitize and prepare input. <code> SELECT column_1 from `prefix_my_table` WHERE column_2 LIKE '%something%'; </code> I've tried something like this to no avail: <code> $wpdb->prepare( "SELECT column_1 from `{$wpdb->base_prefix}my_table` WHERE column_2 LIKE %s;", like_escape($number_to_put_in_like)); </code> How do you properly prepare a %LIKE% SQL statement using the WordPress database class?
|
The <code> $wpdb->esc_like </code> function exists in WordPress because the regular database escaping does not escape <code> % </code> and <code> _ </code> characters. This means you can add them in your arguments to <code> wpdb::prepare() </code> without problem. This is also what I see in the core WordPress code : <code> $wpdb->prepare(" AND $wpdb->usermeta.meta_key = '{$wpdb->prefix}capabilities' AND $wpdb->usermeta.meta_value LIKE %s", '%' . $this->role . '%'); </code> So your code would look like: <code> $wpdb->prepare( "SELECT column_1 from `{$wpdb->base_prefix}my_table` WHERE column_2 LIKE %s;", '%' . $wpdb->esc_like($number_to_put_in_like) . '%'); </code> You can also add <code> %% </code> in your query to get a literal <code> % </code> ( <code> wpdb::prepare() </code> uses <code> vsprintf() </code> in the background, which has this syntax ), but remember that your string will not be quoted , you must add the quotes yourself (which is not what you usually have to do in <code> wpdb::prepare() </code> .
|
How do you properly prepare a %LIKE% SQL statement?
|
wordpress
|
Many wordpress theme, plugin, and widget developers seem to think that the only way to use jquery on the page is to include their own copy. On some pages of the site I'm developing, there are as many as six different places where I see various different copies of jquery included. This is ridiculous. It increases loading time, and is totally redundant. Is there any easy way, either through a plugin or a bit of my own coding, to force only one copy of jquery to be included on each page? There's already a <code> jquery.js </code> in the <code> /wp-includes/js/jquery/ </code> directory, which should suffice for any plugin that needs it. How can I automatically remove all of the other references to it on the page?
|
There is no blanket solution to this. If developer has a clue - he will reuse bundled jQuery or re-register it to other copy (commonly done to load jQuery from Google's CDN). Otherwise there are a lot of [insane] ways to add jQuery and there is no way to handle them all without global output buffering or tweaking hooks/plugins individually. Overall it is often better plugins from stackexchange-url ("good developers") than waste time on tweaking poorly coded plugins. But if you already stuck with bunch of poor plugins - you are in for some manual cleanup. :(
|
Prevent five different copies of jquery from being included on every page
|
wordpress
|
I have a custom post type with several custom fields. I am looking to do some validation on these fields because they will be used downstream by other services. So, it is important that it can't be saved until it is correctly entered. The validation is reasonably complex and requires custom logic. Unfortunately, it also won't work to use a plugin in this particular case. Is there an ideal hook to use in this case? At a high level -- whats the best way to go about this.
|
Example code in <code> add_meta_box() </code> documentation uses <code> save_post </code> hook (at the very end of <code> wp_insert_post() </code> function) to add custom fields data from metabox. You must be using something like that already in your metaboxes, is it not appropriate place to validate your data?..
|
Correct Approach for Validating Custom Field Input
|
wordpress
|
I'm trying to use varnish with a wp 3.0.5 site with Network (Multisite), when I access the varnish URL, I get this message: <code> Multisite only works without the port number in the URL. </code> Do I need a custom VCL to make this work? I'm using the same backend config for other wordpress sites that work fine.. If I need to ask this on serverfault, let me know and I'll ask there.
|
I found a fix here: http://core.trac.wordpress.org/ticket/15936 You basically need to modify wp-includes/ms-settings.php like this (remove '-' lines; add the '+' line): <code> @@ -26,18 +26,8 @@ if ( !isset( $current_site ) || !isset( $current_blog ) ) { + $_SERVER['HTTP_HOST'] = preg_replace( '|:\d+$|', '', $_SERVER['HTTP_HOST'] ); $domain = addslashes( $_SERVER['HTTP_HOST'] ); - if ( false !== strpos( $domain, ':' ) ) { - .... - wp_die( /*WP_I18N_NO_PORT_NUMBER*/'Multisite only works without the port number in the URL.'/*/WP_I18N_NO_PORT_NUMBER*/ ); - } - } </code>
|
Multisite behind Varnish
|
wordpress
|
I am trying to find the best way to monitor which PHP code/functions, MySQL requests and/or plugins are slowing down pages on a site. I know there are a bunch of different options out there including wordpress plugins and solutions involving firebug (firephp) but what do you guys feel is the best approach? Personally I feel the ideal solution would be to have some type of code which can be installed by default with every wordpress install. Any debugging/monitoring/reporting would ONLY get executed if you added an optional entry to the end of the URL like ?=debug. For security purposes it would be even better if one would first have to login to the wordpress admin area and create a temp debug key which would create a hashed key and append it to the url (like debugkey=v09098v09aq2ov1a8923) which would only be available for 30 minutes. But getting back to the actual debug info... I feel using firebug is great in many situations but optionally I feel it would be valuable if one could append something else to any URL which would for example overlay all the functions, hooks or filters used on a specific page along with the execution time for each. In any case... I figured many of you here must have faced this issues as well and thus I would appreciate whatever solutions you are utilizing to solve your problems. Please do outline how any specifics for others that might read this describing any specifics on installation and how to use it correctly. UPDATED Running a Dedicated Linux Server
|
There are multiple tools and possibilities, and shure it would be nice to have something quick at hand. I know plugin authors who do offer debug flags so you can analyze what's going on quite easy. As for plugins, I have not tested it but looked at some screenshots and it is at least informative: Debug Bar (Wordpress Plugin) and the BlackBox Debug Bar (Wordpress Plugin) . Another one is a hooktracer that is not that well known: SJ Hook Profiler . I do heavily recommend xdebug for development and testing systems, it's a pleasure to have it if you need to profile or debug stuff.
|
What is the best way to monitor PHP functions/executions?
|
wordpress
|
When my script runs the 4th line below in WP 2.9.2, its causing my web app to throw an "Apache HTTP Service has stopped working" error <code> $cat=get_cat_ID('top-menu'); $catHidden=get_cat_ID('hidden'); $myqueryCurrent = new WP_Query(); $myqueryCurrent->query(array('cat'=>"$cat,-$catHidden",'post__not_in'=>get_option('sticky_posts'))); </code> Do you see something in that 4th line that's incompatible with WP 2.9.2? The code runs fine on the same server under WP 3.0.4 Here's the details of the error: Problem signature: Problem Event Name: APPCRASH Application Name: httpd.exe Application Version: 2.2.14.0 Application Timestamp: 4aeb9704 Fault Module Name: php5ts.dll Fault Module Version: 5.3.1.0
|
Executing the code you posted results in a crash inside the PHP module. I assume you're running PHP as module inside apache on windows, if the module crashes, apache crashes as well. Ensure that you're using the right PHP modules here. Are you sure you need the Thread-Safe variant of PHP for apache? Those are reported to not run stable under windows IIRC. So this might not be related to the wordpress version but to the server configuration. Hope this answer helps a bit tackling things down.
|
"Apache HTTP Service has stopped working" with WP Query in WordPress 2.9.2
|
wordpress
|
In functions.php I am adding a rewrite rule for this url: http://www.myblog.com/?currentpage=1 http://www.myblog.com/?currentpage=2 And so on... This is the code I use, can u please give me the rewrite rules to transform my urls into pretty ones? <code> add_action( 'init', 'wpa5413_init' ); function wpa5413_init() { // Remember to flush the rules once manually after you added this code! add_rewrite_rule( 'Please add my rewrite rule', 'Please add my rewrite rule', 'top' ); } add_filter('query_vars', 'wpa3537_query_vars'); function wpa3537_query_vars($query_vars) { $query_vars[] = 'currentpage'; return $query_vars; } </code> Ty!
|
if you are trying to get http://www.myblog.com/currentpage/1 http://www.myblog.com/currentpage/2 then your function should be <code> add_action('generate_rewrite_rules', 'currentpage_rewrite_rule_222'); function currentpage_rewrite_rule_222($wp_rewrite){ $newrules = array(); $new_rules['currentpage/(\d*)$'] = 'index.php?currentpage=$matches[1]'; $wp_rewrite->rules = $new_rules + $wp_rewrite->rules; } </code> and just keep your query_vars function the way it is. <code> add_filter('query_vars', 'wpa3537_query_vars'); function wpa3537_query_vars($query_vars) { $query_vars[] = 'currentpage'; return $query_vars; } </code>
|
Please give me the rewrite rules for my ugly urls
|
wordpress
|
I'm testing a version of my theme in WordPress 3.0 and it crashes Apache each time I try to preview it. Where can I look to trace the cause of the crash? WP_DEBUG is of no use in this case, since it never gets to that point. Can I trace errors in XAMPPLITE somewhere?
|
Survey said! Wolf Fence in Alaska . The basic idea is that you divide your problem space in half by inserting a <code> print "Hi, Mom!\n"; exit; </code> (insert your favorite phrase) somewhere near the "middle" of your code. If you get the message, then the bug is beyond where you put the print, so move it farther along in the execution. If you don't get there, move the print earlier. Lather, rinse, repeat. If you Choose Wisely about where to put the print you can narrow a 1,000,000 line program down to 1 line in just 20 tries. This is faster/easier to do from the command line, but it's possible to do it via FTP.
|
How can I find the cause of theme crashing Apache in Xampplite?
|
wordpress
|
I'm looking at the function and template references and I'm not seeing a way to test for whether a post is protected. Is there a theme function for (something like) <code> is_password_protected() </code> ? I'm already using <code> add_filter( 'the_password_form', 'custom_password_form' ); </code> to override the default form that shows up, but I want to customize some other aspects of the look when a post is password protected.
|
Yes there is. It's post_password_required: Whether post requires password and correct password has been provided.
|
Is there a theme function for is_password_protected()?
|
wordpress
|
I'd like to have the same pages assigned to two different parent pages, to save me making separate pages for two sections that contain mostly the same info. I'm using the WenderHost Subpages widget to generate the side menus.
|
Not possible natively, parent is simply single field in database. There are plugins that allow to create more complex relationships, such as Posts 2 Posts but it's unlikely to work with just any widget. Alternatively you can create custom menu with arbitrary structure and use native widget to display it in sidebar.
|
One page - Multiple parents?
|
wordpress
|
I use the following code to show the post thumbnail (only): <code> <?php // Create and run custom loop $custom_posts = new WP_Query(); $custom_posts->query('post_type=page_content&sections=ThemeCL'); while ($custom_posts->have_posts()) : $custom_posts->the_post(); ?> <div class="float-left"> <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_post_thumbnail(); ?></a> </div> <?php endwhile; ?> </code> But for some reason the title and content of the post is being shown (inside tags!): <code> <div class="block-2 border-top"> <h2><a href="http://localhost/wpac/?blocks=mainbar-2" title="Permalink to Mainbar" rel="bookmark">Mainbar</a></h2> <div class="float-left"> <a href="http://localhost/wpac/?blocks=mainbar" title="Permalink to Mainbar Left" rel="bookmark"><img width="160" height="150" src="http://localhost/wpac/wp-content/uploads/2011/02/showcase2.png" class="attachment-post-thumbnail wp-post-image" alt="showcase2" title="showcase2" /></a> <p><p>Hello this is the title Hello this is the post content</p> </p> </div> </code> I only want the post thumbnail (Featured Image) to be shown. Any suggestions?
|
Something like: <code> <?php //Get the Thumbnail URL $src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), array( 720,405 ), false, '' ); echo $src[0]; ?> </code>
|
Why is the post title and content automatically being displayed in the post thumbnail (Featured image)?
|
wordpress
|
I use the following to retrieve a post from a custom post type and custom taxonomies: <code> <?php // Create and run custom loop $custom_posts = new WP_Query(); $custom_posts->query('post_type=blocks&location=Front Page&section=Mainbar'); while ($custom_posts->have_posts()) : $custom_posts->the_post(); ?> <div class="block-2 border-top"> <h2><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2> <?php endwhile; ?> </code> In the Page, I want to create fields that will let the user customize the loop arguments like this: <code> $custom_posts->query('post_type=blocks&location=<Enter Location>&section=<Enter Section>'); </code> What's the easiest way of doing this? How would that code look like?
|
the easiest way would be to create a simple form : <code> <?php $nonce= wp_create_nonce ('my-nonce'); ?> <form name="user-query" method="post"> <input type="hidden" name="_wpnonce" id="_wpnonce" value="<?php echo $nonce; ?>"/> <p>Locations: <select name="location" id"location"> <option value="location1">location1</option> <option value="location2">location2</option> <option value="location3">location3</option> <option value="location4">location4</option> </select></p> <p>Sections: <select name="section" id"location"> <option value="section1">section1</option> <option value="section2">section2</option> <option value="section3">section3</option> <option value="section4">section4</option> </select></p> <input type="submit" name="create-query" value="create query"/> </form> </code> and catch that for submit and process <code> if (isset($_POST['create-query'])){ $nonce=$_POST['_wpnonce']; if (! wp_verify_nonce($nonce, 'my-nonce') ) die('Security check'); if (isset($_POST['location']) && isset($_POST['section']) ){ $args = array( 'post_type' => 'blocks', 'location' => $_POST['location'], 'section' => $_POST['section'] ); $custom_posts->query($args); } } </code> and i would add some security checks but this should get you going.
|
Letting the user define the arguments in a custom loop? (the "$custom_posts-> query(...)" part)
|
wordpress
|
I am trying to remove the "Click here to cancel reply" link from the Wordpress comment form on my posts. In the document there is an argument you can supply to the comment form function to remove the link, but it doesn't appear to be working. The documentation link: http://codex.wordpress.org/Function_Reference/comment_form I have tried different values for the cancel_reply_link value including double quotes, double quotes with a space between them, a zero and a value of false; all of which were to no avail. Surely I am overlooking something here as removing that link is pretty common in Wordpress installations. Here is the current function call with parameters that I am using at present: <code> <?php comment_form( array( 'comment_notes_before' => FALSE, 'comment_notes_after' => FALSE, 'cancel_reply_link' => FALSE ) </code> ); ?> Your help is gratefully appreciated.
|
<code> add_filter( 'cancel_comment_reply_link', '__return_false' ); </code> See <code> /wp-includes/comment-template.php#function get_cancel_comment_reply_link() </code> for more background. But if you do that the reply form will not move to the comment. The more interesting question is: Why doesn’t the link work for you? Do you have this line in your footer? <code> is_singular() and get_option( 'thread_comments' ) and wp_print_scripts( 'comment-reply' ); </code>
|
How To Remove The "Click here to cancel reply" Link From The Wordpress Comment Form
|
wordpress
|
I'm currently creating a plugin that requires me to overwrite one of the Wordpress admin panel javascript files. I have recreated the file with the changes, I need to know how to replace the existing file that gets loaded in load_scripts.php (the script needs to be added in the same order). I was hoping something like this would do the job: wp_register_script('admin-widgets', WP_PLUGIN_URL. '/oak-automated-sidebars/oak-widgets.js'); wp_enqueue_script('admin-widgets'); But it doesn't seem to work, the original script is still loaded. Any suggestions?
|
You need to first deregister the script using wp_deregister_script <code> wp_deregister_script( 'admin-widgets' ); </code> then use your code to re-register the script using your own js file: <code> wp_register_script('admin-widgets', WP_PLUGIN_URL. '/oak-automated-sidebars/oak-widgets.js'); wp_enqueue_script('admin-widgets'); </code> Hope this Helps
|
Replacing Scripts in Admin Load_Scripts
|
wordpress
|
Bear with me here.. The default posts per page in the admin area is 10. During some testing I wanted to change the posts per page for my custom post archive to 2 (in WP 3.1). The problem is that I only have 4 posts, so there should be 2 pages with 2 posts on each, but because the default is at 10, going to /page/2 returns error-404 (assuming because with 10 posts per page there wouldn't be a second page) The only way to get around this was to set the default in the admin area to 1, but it's not really ideal as i now have to do a custom query_post for all post type archives to set the posts per page. Does anyone have a better way to do this, or any ideas? Thanks. archive-project.php: <code> <?php get_header(); ?> <?php global $wp_query; query_posts(array_merge($wp_query->query, array( 'paged' => get_query_var('paged'), 'posts_per_page' => 2 ))); ?> <h1 class="title"><?php _e('Previous work', 'fullycharged'); ?></h1> <?php if (have_posts()): while(have_posts()): the_post();?> <a href="<?php the_permalink(); ?>" id="post-<?php the_ID(); ?>" <?php post_class('launch col col-' . $i); ?>> <span class="project-title"><?php the_title(); ?></span> <?php the_content(); ?> </a> <?php endwhile; endif; ?> <?php if ($wp_query->max_num_pages > 1): ?> <div id="nav-below" class="navigation"> <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'twentyten' ) ); ?></div> <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?></div> </div> <?php endif; ?> <?php get_footer(); ?> </code> register post type: <code> register_post_type('project', array( 'capability_type' => 'post', 'has_archive' => true, 'hierarchical' => false, 'labels' => array( 'name' => __('Projects', 'fullycharged'), 'singular_name' => __('Project', 'fullycharged'), 'all_items' => __('All Projects', 'fullycharged'), 'add_new_item' => __('Add New Project', 'fullycharged'), 'edit_item' => __('Edit Project', 'fullycharged'), 'update_item' => __('Update Project', 'fullycharged') ), 'menu_icon' => get_stylesheet_directory_uri() . '/images/monitor-off.png', 'menu_position' => 5, 'public' => true, 'publicly_queryable' => true, 'exclude_from_search' => false, 'rewrite' => array('slug' => 'work', 'with_front' => false), 'supports' => array('title', 'editor', 'thumbnail', 'custom-fields') )); </code>
|
There's a discussion on Wordpress.org support forums about this exact issue. The OP on that discussion has come up with an answer but is yet to post it. http://wordpress.org/support/topic/error-404-on-pagination-when-changing-posts_per_page-on-query_posts Thanks for your help anyway.
|
Setting posts per page in query_posts
|
wordpress
|
I have a client who wants to register users and give them a unique ID number when they complete registration. (Kind of a member number sort of thing) Can I just setup the WP member table to start id numbers in the high 10 digit range? User experience would be: user would visit the site user would register WP would issue an 10 digit id number
|
The <code> ID </code> column of the <code> users </code> table is <code> AUTO_INCREMENT </code> , so you can set the base counter to a high number : <code> ALTER TABLE wp_users AUTO_INCREMENT = 1000000000; </code> All new users will have an <code> ID </code> that is higher than this value. Calling this operation is safe, if you accidentally set it to a low number either nothing happens (in a <code> InnoDB </code> table), or it is set to the highest existing number + 1 (in a <code> MyISAM </code> table).
|
What is the fastest way to generate a unique id number when registering a user
|
wordpress
|
I know I have done this before, with a frontend post form anyways that used Ajax to send the form data to a php script that used wp_insert_post() then redirected to that post after a success message displayed, but I can't figure out how to do it with attachments. What I am trying to do is a bit hard to explain. Let me try. I have a metabox, that you can add/remove attachments using jquery to add another set of inputs, or remove them, and inturn delete that file from your site. That stuff works. What I would like to do is, when you add a new set of inputs, fill in the info, select the image file to upload, then click Save for that set of inputs (each set has it's own save button) the save button has an Ajax script that sends the data to post.php or whatever happens when you click the Publish button. If i fill in a couple attachments fields and click Publish, my action for 'save_post' is used to save that data. I want to create a function that uses admin-ajax.php and a custom hook. Currently i have a delete function that uses admin-ajax.php to delete the attachment file from the post and the media library. How can I create a function that adds the file. I'm so confused lol.
|
Here's my solution for creating an attachment ID with a temporary title and the post_parent which it is attached to. My jQuery psuedo code, without the needless stuff: <code> jQuery('.addImage').live('click', function() { jQuery.ajax({ type: 'post', url: ajaxurl, data: { action: 'save_attachment', _ajax_nonce: jQuery('#nonce_add').val(), post_parent: jQuery('#post_ID').val(), attach_title: 'Attachment ' + size }, success: function( res ) { var attID = res.replace(/0$/i, ''); alert('Success: ' + attID); } }); size++; return false; }); </code> My admin-ajax.php function and custom hook: <code> function save_attachment() { if ( $_POST['action'] == 'save_attachment' ) { $post_title = $_POST['attach_title']; $post_parent = $_POST['post_parent']; $attach = array( 'post_title' => $post_title, 'post_parent' => $post_parent, 'post_type' => 'attachment', 'guid' => '', 'post_mime_type'=> 'image' ); $attachID = wp_insert_attachment( $attach, false ); if( $attachID ) { print_r( $attachID ); } } } add_action( 'wp_ajax_save_attachment', 'save_attachment' ); </code> See what I have here is, there's a link with class .addImage, you click that, and it runs the ajax/php save_attachment() function returns the ID which i use in the chunk of code I prepend to my metabox (a group of inputs for new file) and the attachment ID returned is used as the value in the hidden input field within that chunk of code. There's also a save button in that chunk. Now, given that ID, i can use my already complete and working function for saving (or updating) the attachments with admin-ajax.php saving the data entered and file selected for each one. The remove button for each is also able to make use of the ID to remove the blank attachments if you have no use for them. This will soon be a sick ass plugin, once i get this working as a-jacksed up custom metabox.
|
How do you create an attachment ID with Ajax submit? No page refresh
|
wordpress
|
I'm working on a project for a monthly InDesign-based magazine that enables them to put their content online via WordPress. The current workflow is either: Copy/pasting from InDesign to a Word document (by the magazine staff with access to InDesign) and then copy/pasting from Word to the various fields in WP (by an intern without access to InDesign but access to Word) Create a CSV that contains all of the post data and use CSV Importer to import to WordPress. Thus, I have two questions: Is there a better InDesign => WordPress workflow than the ones I discuss above? If not, what a good way of pasting a large amount of multi-line HTML data into a spreadsheet? Massive gratitude to anyone who can help with this. Edit: The solution I'm looking for involves as little InDesign-side work as possible . I'll spend a month writing an XMLRPC plugin for InDesign from scratch or something similarly stupid if it means not having to retag page elements for a decade worth of issues -- so long as that really is the best possible route.
|
My boss decided it'd be way easier to outsource the content importing to an outsource group in India. In reality, I think that's probably the best solution for this kind of thing. I'm asking the mods to make this a community wiki question; seems like a common enough problem that it deserves a list of solutions instead of just one answer.
|
InDesign to WordPress workflow
|
wordpress
|
I've setup some theme options using this helpful guide as a template . I want to give my editors the option to update these theme options, so I granted the edit_theme_options capability as mentioned here . However when logged in as an editor I can see the options page, but when I go to save it I get the 'Cheatin uh?' message. I checked the wp-admin/options.php page and the code is: <code> if ( !current_user_can('manage_options') ) wp_die(__('Cheatin&#8217; uh?')); </code> So it seems you can't edit options without the manage_options capability, which makes sense. It makes me wonder how you differentiate between general options and theme options. Is there something I've missed?
|
You should be posting your data (via <code> <form action="" ...> </code> to your theme options page, rather than to the wp-admin/options.php file. The latter is for the stuff under Settings. Also, I don't mean to be tossing dirt at anyone in particular, but always take the tips that you read on the web with a grain of salt. This post on the same site, as an example, offers extremely bad advice: http://themeshaper.com/customize-blog-posts-touching-theme-files/ <code> function myblog_shareontwitter($content) { print $content; ?> <p><a href="http://twitter.com/home?status=Currently reading <?php the_permalink(); ?>" title="Click to send this page to Twitter!" target="_blank">Share <em><?php the_title() ?></em> on Twitter</a></p> <?php } add_filter('the_content', 'myblog_shareontwitter'); </code> The above code is completely broken: "the_content" is a filter, WP expects $content to be returned rather than echoed, and WP (not to mention plugins) expect $content to still be around after that function gets called. Moreover, the_title() will return garbage if you're not in the loop; this is problematic in that automatically generating an excerpt outside of the loop will call "the_content".
|
Theme option editing capability problems
|
wordpress
|
Is there any way to possibly force a redirection to the post (type's) listing page ( <code> edit.php?post_type=<post-type> </code> )? EDIT: Since I got a LMGTFY link, let me clarify before I downvote it. Is there anyway to redirect the user forcibly to the post type's listing page AFTER they've already submitted the form to either edit the post or create a new post?
|
global <code> $post </code> or <code> $post_type </code> to check for your CPT; Post Status Transitions hooks to redirect on specific changes to the post; <code> wp_redirect() </code> .
|
Create/Edit posts and auto-redirect back to listing page
|
wordpress
|
Am I smoking crack or why wouldn't this work? :/ This all seems pretty straightforward: <code> function admin_head() { ?> <link type="text/css" rel="stylesheet" href="<?php bloginfo('template_url'); ?>/css/jquery-ui-1.8.9.custom.css" /> <script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/jquery-ui-1.8.9.custom.min.js"></script> <script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/theme-admin.js"></script> <?php } add_action('admin_head', "admin_head"); </code> And then in theme-admin.js ... <code> jQuery(document).ready(function($) { $("#datepicker").datepicker({ changeMonth: true, changeYear: true, dateFormat: 'dd/mm/yy', showOn: 'button', buttonImage: plugin_path + '/images/icon-datepicker.png', buttonImageOnly: true}); }); </code> Thank you for any insight you can provide :) Cheers
|
Duh, if you're image path is bust and it's the only way it activates, it just won't load.
|
jQuery UI & Admin (Calendar)
|
wordpress
|
I have a (client) site located at http://internationalgateway.us/ . We are using the WPML Multilingual CMS plugin. When choosing another language from the homepage (in this case French, since that's the only one enabled), I encounter a redirect loop. This can also be experienced just by visiting http://internationalgateway.us/fr . It appears as though an extra trailing slash is getting added to the url, triggering the loop. However, adding extra trailing slashes to any other url on the site does not cause the same behavior - it just results in a redirect to the page without the slashes. I understand this may simply be a plugin issue, but I suspect that it is not, as the site was working fine previously. I'm wondering if this could be an issue with permalinks and/or .htaccess rules. Currently, my permalinks are set to <code> /%category%/%postname%/ </code> , and the contents of the .htacess file are as follows: <code> # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress </code>
|
I've discovered that the problem is an incompatibility between the WPML plugin and the Yoast WordPress SEO plugin. Specifically, enabling the "Redirect ugly URL's to clean permalinks" setting in the SEO plugin causes the redirect loop. I've contacted the plugin authors to inform them of the incompatibility and will try to help in getting the issue addressed with those two plugins.
|
Strange behavior with a redirect loop - involves WPML multi-language plugin
|
wordpress
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.