Best approach for loading a sidebar Only if the screen max-width is >900px?

I have been playing around with media queries quite a bit lately and I love the concept. It is so easy to display images or change div floats depending upon what the users screen max-width is. I'm trying to find a way of displaying a custom sidebar on my template Only if the users screen size is large enough to permit it. i.e. max-width is >900px. So far every solution I have found simply uses css to hide/show a div via the media query. example:               @media screen and (max-width: 880px) {     #secondary-nav  {         display: none;     }      The 'problem' with this approach is that I am still sending the data to devices that can't see it due to my hiding it. Creates unnecessary bloat for mobile users. What I am looking for is the best approach to loading the sidebar only if it fits my 'rules'. Also, it needs to readjust itself if the viewer changes the browser window size, like when snapped to side in win7. I did find one concept of using javascript to check the screen width, and save that to a cookie: http://www.yiibu.com/resources/scripts/default.js I'm guessing at that point, there would be a way of checking the cookie 'width' data and then serving up the sidebar or not. The only problem with that is what happens if cookies are not enabled? also, what happens when screen size changes, does that mean the cookie is being set/unset over and over again? Anyhow, I am really open to ideas on this one, as this is virgin territory for me. The primary idea here is to serve up device appropriate wp templates without sending data to the users device that is hidden for smaller screens. After all, mobile data is kind of expensive, so I want to do all I can to help my users out.


Add excerpt and post thumbnail to Buddypress blog directory page

I wonder if anyone can help me, I am trying to display excerpt and thumbnail for the posts shown in the buddypress blog directory page. By default only avatar thumb and title link to the posts are shown. I have created a function based on the function `bp_blog_latest_post()` used in the blogs loop but I am not sure how to proceed. I can see that the blog template class is accessed but don't know how to access further information, if this is not possible then do I need to use the buddypress excerpt filter as well? Here is the slightly customised function so far..               <?php          function bp_blog_latest_post_excerpt() {         echo bp_get_blog_latest_post_excerpt();     }          function bp_get_blog_latest_post_excerpt() {              //global variable carying data used in blog templae         global $blogs_template;         //if no posts then return nothing (and default to message I assume)         if (null == $blogs_template->blog->latest_post)             return false;         //otherwise..     return apply_filters( 'bp_get_blog_latest_post', apply_filters( 'the_excerpt', $blogs_template->blog->latest_post->post_excerpt) );     }     ?>


how would I change background color of a theme using a plugin?

I would like to change themes background color using a plugin. For when I use this code,               function change_background_of_theme(){     ?>     <style>          #main{background: yellow;}          </style>          <?php     }     add_action('init','change_background_of_theme');      This code only changes the bg color of the theme that use #main id. This basically leads to another question, is there a common id that themes use for background or something close to that. I appreciate your assistance. :) -Ron.


How to rate a post from Admin Side / Manually?

I am working on a Mini Job Site. i want to give rating to posts manually from admin / editor side Best rated people will be on top. so visitor'll get better choice. visitor are not allowed to rate posts like this ![please have a look](http://i.stack.imgur.com/ZnUBX.jpg) how to do this ? {1} Meta-box uses {2} Custom Field help me please


Incorrect redirect after commenting

I noticed not too long ago that after posting a comment the user is redirected to a page with this url               http://twwr.alexismejias.com/situations/athome/tocome/?author=&email=&location=&comment=&submit=Submit&comment_post_ID=8&comment_parent=0&recaptcha_challenge_field=03AHJ_VuvDbmyP7Fmp8Noq3DoqrQX6yddkVFOz9wqVJxs4saFGsgtvnC9Dd7TmxwYEBxGH9L-YnJQGfNPqbXvVxrHuCeLi4LOTOTNKGDsdobvj0C-jY_jPb4A-F2r7dEHSQLFYWz8S4qScqhplBFWILLXKVmX8Qe_SZw&recaptcha_response_field=      Not sure what went wrong but I am assuming that it has something to to with my functions.php or comments.php this is my .htaccess               # BEGIN WordPress     <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /twwr/     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /twwr/index.php [L]     </IfModule>      php_flag display_errors on     # END WordPress


Buddypress shortcode for tabs

I want to add some more tabs like photos, videos on the user profiles of my buddypress site. Is there any shortcodes or functions to add the tabs?


Disable new user notification to admin email

I get an email notifying me of every new user registration on my site and now that it gets hundreds or thousands of new users a day, it's getting a little out of hand. It seems like it'd be a Wordpress setting to disable it, but I can't seem to find anything. Do I really need a plugin to do this?


Show menu based on parent & ancestor

Trying to show a wp menu based on parent. Works great on parent / child pages, but on grandchildren pages its failing. How should i restructure the menu selector to include the sub nav menu based on the main parent?               <?php     if ( wp_get_nav_menu_object( $post->post_title ) ) {     wp_nav_menu( array(      'menu' => $post->post_title,     'menu_class' => 'subnav',     'container' => ''     ) );     } else {             if ( wp_get_nav_menu_object( get_the_title( $post->post_parent ) ) ) {     wp_nav_menu( array(      'menu' => get_the_title( $post->post_parent ),     'menu_class' => 'subnav',     'container' => ''     ) );     }      }      ?>


How to change "Registration complete. Please check your e-mail." in wp-login.php

I want to override the phrase "Registration complete. Please check your e-mail." without modifying the core code in wp-login.php Does anyone know what the add_filter() or add_action() might look like? Thanks.


wp_enqueue_scripts wont load my scripts

I am trying to add my custom scripts to my project but can seem to get them to load. I've never had this issue and am stumped. This is what I have in my functions.php:               function ex_scripts() {         wp_enqueue_script( 'jquery' );         wp_enqueue_script( 'backgroundJS', get_template_directory_uri() . '/js/background.js', array('jquery'), '1.0.0', true );         wp_enqueue_script( 'superJS' , get_template_directory_uri() . '/js/supersized.core.3.2.1.js', array('jquery'), '1.0.0', true);     }          add_action( 'wp_enqueue_scripts', 'ex_scripts' );      I know the ex_scripts function is running. I added a `echo "hello"; die();` statement to the top of the function and it worked. I also know the js filepaths are correct and that they are accessible. jQuery will load both with or without its enqueue script (because it's listed as a dependency of the lower two), but my custom scripts aren't being added.


marking a post that was sticky on category template

i want some how to mark the post that has been featured (was a sticky post) in the category template. in wordpress logic it should be something like -               was_sticky();      anybody?


Removing leading zeros from custom permalink structure

My WordPress website currently uses this custom permalink structure: %author%/%year%/%monthnum%/%day%/%postname% In this case, %monthnum% instantiates numbered dates with a leading zero -- e.g., "09" for September. So, a sample URL might look like this:   mywebsite.com/username/2012/09/12/post-name Is there a function I can add or .htaccess change that I can make which will remove the leading zeros from my permalink stucture? So, using the example above, my URLs would ideally look like this:   mywebsite.com/username/2012/9/12/post-name Thank you! I've read up on WordPress' structure tags documentation (http://codex.wordpress.org/Using_Permalinks), but I can't find any solutions or plugins for the above-mentioned problem.


Custom Post Type Query issue

I have a conflict issue with 2 custom post types. I have a template file archive-media.php and have created the related 'media' custom post type. This all works well, however in the sidebar I have a list of events from a second (events) custom post type, which also works perfectly in every respect, **including on this page** , except when there are no media items (eg if i set them all to draft), strangely the **events** list shows no events ( `if ( have_posts() )` fails ). I cant seem to figure out why. My loop on the archive page is fairly standard, and doesnt use WP_query or query posts, roughly it's:               <?php if(have_posts()) :  ?>                         <?php while(have_posts()) : the_post(); ?>      .... LOOP ...     <?php endwhile; else : ?>     ..... No media items ....     <?php endif; ?>      The events list is generated via the following function ( I left the two arguments in to save dismantling the code entirely but they are not being used at the moment). Also I cant remember off hand why i was globalising $post, It's in the original code, but i've tried it both in and out and it makes no difference. Another thing I've tried is various placements of `wp_reset_query and wp_reset_postdata`               function display_events($events_shown, $days_historical){       // global $post;            $args =  array(               'post_type' => 'events',               'posts_per_page' => 5,               'order' => 'ASC'               );             $events_query = new WP_Query( $args );            if ( have_posts() ) : while ( $events_query->have_posts() ) : $events_query->the_post();               the_title();               endwhile;  else :          echo "no events";                    endif;          wp_reset_postdata();       }      Also I created a third test custom post type and archive page and the exact same problem occurred when I was on that archive page, and adding a new media item did not fix the problem, however adding a new test custom post type did, so somehow the secondary query is getting influenced by the fact that there are no items of the custom post type of the template on which the page is running ( ie no media items when on archive-media or no test items when on archive-test ) **EDIT** I just realised I could take the archive pages out of the equation by renaming them so as to force archive.php to display the media archive instead. Doing this gave me the exact same result.


WP Editor, save content and category on frontend

I'm creating a plugin that shows a frontend editor that will be the content of the current post. But I don't know who to save the content from the wp_editor to the post content; I tried using on form action admin_url('post.php'), but I didn't work. I have been checking around but I didn't find any solution. Thanks! Here's what I have now:               function front_end_editor(){         //if(is_user_logged_in()){             $settings = array(                 'wpautop' => true,                 'media_buttons' => true,                 'tinymce' => true,                 'textarea_name' => 'fe_content'             );             if(is_single() || is_page()){                 //admin_url('post.php')                 echo '<form action="' . get_permalink() . '" method="get">';                 wp_editor(esc_html(get_the_content()), 'textarea_post', $settings);                 echo '<input type="hidden" name="save" value="true"/>';                 echo '<input type="submit" value="Submit" /></form>';                      if($_REQUEST['save'] == true){                     global $post;                     $post->post_content = '$_REQUEST['fe_content'];                 }             }         //}     }          add_action('the_content', 'front_end_editor');


How to remove RSS feeds from Wordpress theme

I am a newbie at WordPress and wanted to know if their is a way to remove RSS notifications from the theme I am using. I tried looking for a functions.php file but have not had any luck. I am using the Opulus Sombre theme.


add_query_vars and add_rewrite_rules

I am looking for some clarity on what `add_rewrite_rules` does. If I type in, or submit variables from a form, is it supposed to change the query variables to the pretty url? Currently when I type in the pretty url, the page acts how I want. When I submit a form which redirects to a page with the query variables in the url, it also works fine. But I had thought that if I had typed in a url with the query variables, it would switch to the pretty url. It does not do that. Should it? Am I doing this wrong?               function add_query_vars($aVars) {         $aVars[] .= 'var_state';         $aVars[] .= 'var_clubs';     }     add_filter('query_vars', 'add_query_vars');          function add_rewrite_rules($aRules) {         $aNewRules = array(             'rv-clubs/([^/]+)/([^/]+)/?$' => 'index.php?pagename=rv-clubs&var_state=$matches[1]&var_clubs=$matches[2]'         );         $aRules = $aNewRules + $aRules;         return $aRules;     }     add_filter('rewrite_rules_array', 'add_rewrite_rules');      Any help would be appreciated.


<!--more--> quicktag breaking FancyBox plugin on my blog's front page

I use a plugin on my blog that allows the user to click on an image to enlarge it in a pop-up window. My plugin of choice for this task is the FancyBox for WordPress plugin. Most of the time the plugin works as expected. However, I have discovered that it doesn't function on images found on the front page of my blog if the image is part of a post which contains the `<!--more-->` quicktag. For posts _without_ the `<!--more-->` quicktag the FancyBox functionality is working as expected. Also, on the corresponding _single-post page_ of a post with the `<!--more-->` quick tag, the FancyBox functionality is working as expected. This makes sense since (I believe) the `<!--more-->` quicktag is completely ignored on single- post pages. I can see from examining the HTML page source that the `class="fancybox"` and `rel="fancybox"` attributes are missing from the images' `<a>` tags on the problem posts. I know that the plugin normally inserts these attributes. But I don't understand why the attributes are not inserted when the `<!--more-->` quicktag is utilized. I'm using a custom theme but I have tried a couple of other generic themes and it didn't seem to help. I have also tried two other FancyBox plugins (Easy FancyBox and Fancybox) and they both exhibited the problem. My site is http://www.untamedimages.com/blog I'm a bit of a noob when it comes to php and WordPress coding and I don't really know where to start troubleshooting this problem. I'm happy to provide any additional information if that would help lead to a solution. Any help would be greatly appreciated.


Trying to use shortcode for a plugin on custom homepage of Responsive theme

The Responsive theme has a custom home page option, with a feature content div that is defaulted to an image. I cannot get shortcode for my slideshow plugin to work in this. I can insert html just fine, but no shortcode. Also, major noob here.


Modify custom post type rewrite rules in a separate function

I want to modify the rewrite rules for a custom post type, `tribe_events`, which is registered as a post type within "The Events Calendar" core plugin files (the-events-calendar.class line 24):                   protected $postTypeArgs = array(             'public' => true,             'rewrite' => array('slug' => 'event', 'with_front' => false),             'menu_position' => 6,             'supports' => array('title','editor','excerpt','author','thumbnail', 'custom-fields'),             'capability_type' => array('tribe_event', 'tribe_events'),             'map_meta_cap' => true         );      What I would like to do is modify the line:                       'rewrite' => array('slug' => 'event', 'with_front' => false)      To: 'rewrite' => array('slug' => 'event/%lugares%', 'with_front' => false) Where "%lugares%" is the name of a custom taxonomy. Then my plan is to use the following function to complete the rewrite process:               add_filter('post_type_link', 'events_permalink_structure', 10, 4);     function events_permalink_structure($post_link, $post, $leavename, $sample)     {         if ( false !== strpos( $post_link, '%lugares%' ) ) {             $lugares_term = get_the_terms( $post->ID, 'lugares' );             $post_link = str_replace( '%lugares%', array_pop( $lugares_term )->slug, $post_link );         }         return $post_link;     }      The issue is that I don't want to modify the core plugin files. Is there a way to modify the custom post type rewrite argument in a seperate function from inside my theme's functions.php?? Thanks!


Exclude Parent Name from wp_terms_checklist

I'm creating a term checklist that is meant to only show decendants of one term_id. In the below example $category->term_id is the term id of the parent               $args = array(     'descendants_and_self'  => $category->term_id,     'taxonomy' => 'school_category',          );          wp_terms_checklist($post->ID, $args);      This works byt the problem is that the parent name is also showing in the list - ie. For the term name Type, the id of Type gets passed to the function and what outputs is -Type \--type1 \--type2 \--type3 I only want -type1 -type2 -type3 There doesnt seem to be any include or exclude arguments for this function though. Any clues of how i woudl go about doign this. Is there a filter that can be applied?


Can't sort get_posts by post_mime_type

I'm trying to run a query to get all attachments and I'd like to sort by the post mime type. This query isn't working. Any ideas?               $query_args = array(     'post_type' => 'attachment',     'numberposts' => -1,     'post_status' => null,     'post_parent' => null, // any parent     'orderby' => "post_mime_type"     );  $attachments = get_posts($query_args);


Create three unique tag page templates

On my site, users can view content on the blog or on a cartoon index page. Both these pages aggregate posts and custom post-types. The cartoon index differs in that it has an image slider before blog-style content. We want to create tag.php pages that take into account whether a person is in the cartoon archive or in the blog in general when clicking a tag link. I couldn't attach images of each page (I don't have enough reputation), but message me if you want to see examples. Right now every call to tag.php results in the same page, regardless of if that call came from the blogstream or elsewhere. How could I produce a tag page that is sensitive to where the visitor was when being called. Or can anyone see any alternatives? Regards, \-- EDIT: Thank you George for suggesting custom taxonomies. That has almost got me to a solution. Before nailing myself to that path, however, I want to think about alternatives. I'll post the alternatives as answers below. To try to clarify, my problem is that I want to display tag results using two or three unique templates. One template is a blogstream, and the other two have an image slider with a blogstream beneath it. These last two differ in that they display different categories of images. And when a person is viewing, for example, the blogstream when they click a tag link, I want them to be given a tag page that looks only like a blogstream (meaning without an image slider).


Trigger refresh for new media manager in 3.5

I'm trying to figure out how it's possible to 'refresh' the media library in the new media dialogue in 3.5. I'm adding images from an external image library to the WordPress library (via a tab/iFrame combo in the media dialogue) which works ok, but I have to close and reopen the dialogue in order to show the newly added images (which _have_ successfully been aded to the library). I know there are `wp.media.editor.open()` and `wp.media.editor.close()` methods, but I can't quite manage to find a `sort()` or `refresh()` (or whatever) in the source. Truth be told, the source code is pretty intense reading and `console.log` doesn't seemingly help much with backbone.js. Any ideas?


Make shortcode work with nested double quotes

I have following shortcode:               function infobox_shortcode( $atts, $content = null ) {              extract( shortcode_atts( array(           'src' => '',           'title' => '',           'text' => '',         ), $atts, 'infobox' ) );              $return = '

 ' . $title . '

' . $text . '

';              return $return;          }     add_shortcode( 'infobox', 'infobox_shortcode' );      This works fine, when the user uses it simple like so:               [infobox src="http://www.google.com" title="Google" text="Some description"]      **But:** As soon as the users tries to add e.g. a link with quotes to the shortcode, it - of course - breaks:               [infobox src="http://www.google.com" title="Google" text="Some description - see more: More here"]      Issue is that my user uses the WP Editor to add a link and this makes double quotes. Alsor WordPress seems to delete single quotes for attributes by default and adds double quotes which then again break my shortcode. Right now I see 2 solutions for this, but both are not quite satisfying. a) Tell WP not to convert single quotes to double quotes in a href links while saving a post or b) To make the shortcode work with double quotes. Any other hints or workarounds I can go with this? Thanks! Mike


Loosing all my text and entries on ColorWay Theme

I have hosted my website on a ec2. So when the ec2 goes down and I reboot it, I need to change the dns from the old to the new dns (micro instance). Until now I was taking a manual backup of my wordpress page. I tar'ed the /var/www/website files to a tar, and mysqldump of the database to a sql file. And when I need to restore, I do a search replace in the sql file all localhost to that dns (where I am restoring) and untar the tar file to /var/www/website of my new host. But with ColorWay theme, all my settings are lost. I wonder where else will a theme store all its data ? Am I missing something basic here ? Infact any theme, I loose some setting or the other. Sometimes the menu choice, sometimes a few other settings.


post_class remove tag- or category- from slug

I've got this in my theme               <article <?php post_class('archiveMain'); ?>>      But for tags and categories it adds tag- or category- before the slug, any way to remove that? Example: tag-sales would just be sales, category-webinar, just webinar


Custom wpdb query - how to sort post by another table meta_count

Custom wpdb query code below works well but I need sort by > **stt2_meta** table **meta_count** ,                <?php          $querystr = "             SELECT ID, post_title FROM $wpdb->posts                         WHERE post_type = 'post'                             AND post_status = 'publish'                             AND ID IN ( SELECT post_id FROM ".$wpdb->prefix."stt2_meta )                         ORDER BY post_date DESC LIMIT 10;";          $pageposts = $wpdb->get_results($querystr, OBJECT);              ?>      Thanks in advance


changing site domain name. Is this a bad solution?

I have just built a wordpress website and now my partner has advised me that she has bought a different domain name and wants me to swap it for the current one. She has purchased the new domain from the same company she has hosting with for the current site. There support team said the easiest way would be for me to forward the new domain name so that it is pointing at the current site. However this will not change the url's right? So my site will still show the old domain name in the url? What's the best way around this issue? I don't really want to setup a new hosting package under the new domain name and have to migrate the site across.


Hide unapproved comments on front end of wordpress

I used this post I modified it to hide rather than show to contributors unapproved comments. This goes for unapproved comments on the contributor's own posts. I also used Adminimize to hide comments as Adminimize alone did not work. The problem is, it works in the backend but not the front end. I need it to work in both. Any ideas please?               <?php     //Restrict user access to unapproved     function show_portfolio_comments( $post_ID ) {         // NOT approved         $comments_unapproved = get_comments( array( 'status' => 'hold', 'post_id' => $post_ID ) );         foreach ( $comments_unapproved as $comments) {           if ( current_user_can( 'delete_users' )) // maybe you'll have to switch to some other cap           {           ?>

Unapproved Comments on your portfolio

<?php echo $comment->comment_author; ?>

<?php echo $comment->comment_content; ?>

           <?php           } // endif; - current_user_can( 'edit_published_posts' )         }                   // ALREADY approved         $comments_approved = get_comments( array( 'status' => 'approve', 'post_id' => $post_ID ) );         foreach ( $comments_approved as $comments)         {           ?>
           <?php if ( current_user_can( 'delete_users' )) { ?>
Approved Comments on your portfolio
           <?php }  // endif; - current_user_can( 'edit_published_posts' ) ?>
<?php echo $comment->comment_author; ?>

<?php echo $comment->comment_content; ?>

           <?php         }     }     ?>


How to echo data after a WP_Query

I would like to display data from a post that has custom fields in a metabox. One of the fields is the URL for an image. How do I create an echo to display the image? The other field I want to call is a link. I have one field for the URL and one field for the link text. How do I echo this to diplay the link. Thanks, 14ner


How to remove Broken Link Checker widget from admin menu

I'm trying to clean up the Admin Dashboard widgets so that only the administrator level users can see the various meta boxes, but no matter what i've tried the Broken Link Checker widget will not go away (see example code below). I'm using **WordPress 3.1 MultiSite Network** and working with this code in the **MU plugins folder** ... not sure that matters ... i've also tried **Adminimize** plugin but that did not work for me on the widget either.               /* Turn off Dashboard Widgets */          if( is_admin() )         add_action('wp_dashboard_setup', 'remove_dashboard_widgets' );          function remove_dashboard_widgets() {         global $wp_meta_boxes;         unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']);         unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']);         unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']);         unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);         unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_recent_drafts']);         unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']);         unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);         unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']);         unset($wp_meta_boxes['dashboard']['normal']['core']['blc_dashboard_widget']);     }      Thanks in advance for any pointers ... cordially,   Chuck Scott


Include doesn't work, getting strange path: (/usr/local/php53/lib/php) - Whats wrong? (WPAlchemy)

I´m using WPAlchemy which is a helper class for metabox creation. I´m trying to include it through my functions.php but I´m getting strange errors when I have WP_Debug set to true. For some reason Wordpress is including a lot of stuff in the url that it shouldn't, this is the warning I get.               Warning: include_once(/customers/d/d/4/mydomain.com/httpd.www/nysida/wp-content/themes/aaa/WPAlchemy/MetaBox.php): failed to open stream: No such file or directory in /customers/d/d/4/mydomain.com/httpd.www/nysida/wp-content/themes/aaa/functions.php on line 58 Warning: include_once(): Failed opening ‘/customers/d/d/4/mydomain.com/httpd.www/nysida/wp-content/themes/aaa/WPAlchemy/MetaBox.php’ for inclusion (include_path=’.:/usr/share/php’) in /customers/d/d/4/mydomain.com/httpd.www/nysida/wp-content/themes/aaa/functions.php on line 58 Notice: Use of undefined constant   – assumed ‘ ’ in /customers/d/d/4/mydomain.com/httpd.www/nysida/wp-content/themes/aaa/header.php on line 53      What´s up with the strange url?


Default comments file and how to copy it

I have a custom theme. There is no comments.php file, Wordpress is using whatever the default is. I need to modify the comments area, but I want to base my changes off of the default template. Where is the default template and how can I copy it into my own theme's comments.php? UPDATE Sorted it out for myself. The following directory contains default fallbacks if a file is not specified in your custom theme - `\wordpress\wp- includes\theme-compat\` I copied the comments.php file from there over to my custom theme and am ready to rock. I was told in a WordPress forum that this file is deprecated though and I should really be building my own.


Loading a newer version of jQuery within WordPress

I've read about the WP enqueue_script() function, but if I wanted to use a newer version of jQuery than what my WP installation is using, can I load it through this & WP will use the latest version? or will it load both? or what will happen? Thanks!


Custom loop request based on custom field

I have many post, all categorized. So 100 post, 40 in cat=4. All those 40 post have a custom field name point with a rating in there (how many point win). Si the question How to loop through all the post, and get ONLY the post with cat=4, and sort those post base on the point score in the custom field, and display, post title, and point. So the output will look like :   * john : 134pt   * paul : 124pt   * kim : 100pt   * joe : 90 pt


AJAX and -1 response

I know this has come up a number of times but it is driving me nuts. I've spend hours trying to debug it. My AJAX isn't working for non-logged in users. Here's me action:               add_action('wp_ajax_nopriv_ah_update', array($tracker, 'update_tracking'), "1");     add_action('wp_ajax_ah_update', array($tracker, 'update_tracking'), "1");      I've placed them inbetween is_admin and out of it. I've taken the server side code out of the class and put it in its own function. But nothing works. I should state that it works fine for all logged-in users I've done a var_dump() on $_GET['request'] and it all looked fine.               if ( !empty( $_REQUEST['action'] ) )         do_action( 'wp_ajax_nopriv_' . $_REQUEST['action'] );          die('-1');      If I change the admin-ajax.php code to this it works fine:               if ( !empty( $_REQUEST['action'] ) ) {              do_action( 'wp_ajax_nopriv_' . $_REQUEST['action'] );          } else {              die('-1');          }      I'm a total loss as to what is causing this to happen. Perhaps there is something else in the script that is blocking no-logged in user access, but I can't see it.


Sidebar Generator? :)

I'm tired of editing functions.php every time I want to add/remove a sidebar. I know there is Sidebar Generator plugin, but I wanted to develop something on my own that will work out of the box without plugins. Anyways, I already know how to list all sidebars, how to register them and remove, but I'm not sure how to do this automatically from options page (I have one already of course). I've analyzed the plugin's code but my PHP sucks so I don't understand half of it or even more. Maybe someone here developed own sidebar generator and can help me with basics like how to register new sidebar using $_POST etc.? I was thinking about fopen("functions.php", "r+"), but I'm not sure about this method, because it could even wipe out the whole functions.php file if used wrong, searching for already registered widgets could be painful too. I believe it'd be very useful to have something like that, and that's strange there's no in built sidebar generator in WP.


Wordpress custom search url

I'm trying to chang my custom search url for SEO purpose. I found an article about how to change `mydomain.com/?s=query` to `mydomain.com/search/query`. However, i prefer to have a custom search url such as `mydomain.com/something/query`. Is this achievable? Thank you for any help!


Word spacing disappears after pasting Bangla and Arabic text

On my WordPress site, I need to copy and paste a few articles from both a Joomla site and MS Word docs. When I paste the articles into my TinyMCE editor, spacing between several words disappears. Also, the parentheses around Arabic words go haywire. In my theme, I have used the following CSS for the default font:               div#whitewrap {         font-family: 'palatino linotype',palatino,serif,sans serif,solaimanlipi;       }      The problem persists even if I paste the text into Notepad first and then copy-paste it into WordPress' TinyMCE editor. What could I be missing out?


Best way to include wp-config.php

I was wondering what way is the best to include wp-config.php into a plugin. I have read about relative paths that can fail if the plugin files are situated somewhere else.


How to access WOrdpress functions from within a class

I am working with Wordpress 3.6 and am building a custom class. I need some of the Wordpress functionality and settings in my class. I could add the info I need 1 bit at a time when the class is created, but that is going to require adding new data each time I decide I need to use it. Is there a way to create a reference or something that will allow me to access the WP functionality and settings from within my class?


How to dynamically change the locale?

Sorry about making this so lengthy. I just want to explain everything clearly and walk you through what I have tried so far to solve this problem. There is an English and a Spanish version of the website, which hopefully can be toggled between. I have a session variable $_SESSION['language_code'] that I am trying to use to dynamically set the locale and use a different language file. I should note first off that the session is working properly. I have $_SESSION['language_code']='es_US' hard set for testing, which is echoed at the top of the < body > just so I can see that it is working. I also know that the language files are working, because I can set the defined variable in wp- config define('WPLANG', 'es_US'); and I can see that translations work from my .po/.mo files. Instead of changing WPLANG, I can also use a filter to get this to work, like so:               function spark_change_language( $locale ){         return 'es_US';     }     add_filter( 'locale', 'spark_change_language' );      or:               function spark_change_language( $locale ){         $locale = 'es_US';         return $locale;     }     add_filter( 'locale', 'spark_change_language' );      I can do all this and see the translations work properly on the website. The problems arise when I try to change the locale dynamically. I can set the $_SESSION variable to a different language code and try to change the locale using that, but for whatever reason the filter function gives some very odd behavior. I'm trying to do this like Setting WPLANG from a plugin or Change locale at runtime? Here is what I tried first:               function spark_change_language( $locale ){     return $_SESSION['language_code'];     }     add_filter( 'locale', 'spark_change_language' );      That should do it right? Especially if $_SESSION['language_code']='es_US'. Well, in this example it just generates an error: **Notice: Undefined variable: _SESSION** ... Alright, so $_SESSION clearly isn't created by the time the filter runs for 'locale'. _OR IS IT?_ If I add some conditionals, it seems to act like $_SESSION is totally available:               function spark_change_language( $locale ){         if( isset($_SESSION['language_code']) ){                  if( $_SESSION['language_code']=='es_US' ){                 $locale = 'es_US';             }         }              return $locale;     }     add_filter( 'locale', 'spark_change_language' );      No errors here, but 'es_US' is still not being returned as the language code, or at least the website is not being translated. Now I can already hear you, it's because isset() is returning false since I got that "Undefined variable" notice, so it just skips that part and goes straight to `return $locale;`, right? _RIGHT?_ Well, I added a way to test how far it gets into the conditionals, and the conditionals are returning TRUE. In my header.php, right after the opening < body> tag I have `<?php do_action('spark_body_start'); ?>` and I created a function like so:               function test_alert(){ ?>         <script>alert('ohai');</script>     <?php        }      ... and I used add_action() in the locale function, like so:               function spark_change_language( $locale ){         if( isset($_SESSION['language_code']) ){                  if( $_SESSION['language_code']=='es_US' ){                 $locale = 'es_US';                 add_action('spark_body_start','test_alert');             }         }              return $locale;     }     add_filter( 'locale', 'spark_change_language' );      Now upon refreshing the page, I get a javascript alert that says "ohai". But wait, that's within the conditionals that check if $_SESSION['language_code'] exists and if it's set to 'es_US'. So since the javascript alert appeared, I know that the add_action() ran, which means `$locale = 'es_US';`, which means both of the conditionals were TRUE. So $_SESSION _does exist_ by the time this function runs, even though the previous example gave an undefined variable notice? And the page still doesn't get translated into Spanish. Alright, well maybe I just can't return a variable, maybe it has to be a string. That's fine, I can write the function like this:               function spark_change_language( $locale ){         if( isset($_SESSION['language_code']) ){                  if( $_SESSION['language_code']=='es_US' ){                 add_action('spark_body_start','test_alert');                 return 'es_US';             }         }              return $locale;     }     add_filter( 'locale', 'spark_change_language' );      Now I refresh the page and the 'ohai' alert appears, so it must get to the `return 'es_US';` line. However, the page still isn't translated. What, then, is actually getting returned by this filter?! Why is $_SESSION defined in conditionals, but not outside of them? Why does the filter work when I set a return value outside of conditionals, but it doesn't work if the return value is set within conditionals? And for my main problem, is there actually a way to get the language to change dynamically, using the .po/.mo files? We don't want to use Google Translate due to accuracy concerns. A dynamic solution is also preferable since we will end up having over 200 languages. * * * **UPDATE** * * * Alright, I think I figured this out. I think my problem was that I was using the “standard” way of starting a session in my functions.php: `function myStartSession() { if(!session_id()) { session_start(); } } add_action('init', 'myStartSession', 1);` I don’t think it made session available “soon enough”. I followed another example (http://codeblow.com/questions/how-you-can-alter- the-value-wplang-in-wordpress-by-visiting-a/) and reworked it into my wp- config.php file:               if(!session_id()) {         session_start();     }          //First check if the $_GET value is there. This occurs when someone clicks the link to change the language...     if ( isset($_GET['lang']) ){              // Check that it's either 'es_US' (USA Spanish/Espanol) or 'en_US' (USA English), and set the $_SESSION['WPLANG'] accordingly.         if( $_GET['lang']=='es_US' ){             $_SESSION['WPLANG'] = 'es_US';              } elseif( $_GET['lang']=='en_US' ){             $_SESSION['WPLANG'] = 'en_US';              } else {             //Fall back to the default if it's not es_US or en_US.             $_SESSION['WPLANG'] = '';         }         // Once the $_SESSION['WPLANG'] is set, define it's value to WPLANG.         define ('WPLANG', $_SESSION['WPLANG']);          //... otherwise if $_GET wasn't set, check if $_SESSION['WPLANG'] was already set previously...     } elseif( isset($_SESSION['WPLANG']) ){              // If it's es_US or en_US, define WPLANG as such.         if( $_SESSION['WPLANG']=='es_US' || $_SESSION['WPLANG']=='en_US' ){             define ('WPLANG', $_SESSION['WPLANG']);              } else {             //Fall back to the default if it's not es_US or en_US.             define ('WPLANG', '');         }          //... and finally just set WPLANG to a blank string (default value).     } else {         define ('WPLANG', '');     }      So it’s not as nice as using the filters/actions, but it works.


Is the built-in updater the "best" way to upgrade WP installations?

With the release of WordPress 3.1, I'm about to update my own WP installation. I've had a thought about the different ways one can do the update: by hand (ugh), via Subversion checkout on the server, and using the built-in updater. To this point I've used the SVN route, not sure why, possibly that was from before WP added the auto-update feature. It's a minor hassle though, as I have to log in to the server and run `svn up` to get the new release - admittedly that's not a big deal, but it's an extra step over logging into WP to apply the update. I would imagine that the WP folks have worked hard on the auto update feature and kept it as smooth as possible. With that in mind, should I just not bother with an SVN checkout to run my site, and just use the updater? Or is there any reason why I should keep using the SVN method?


User levels and post visibility

I'm having a bit of trouble detecting the view-ability of post types. I've created a front end plugin which lists posts/pages by the author. Testing if a user can edit a certain post type is easy but I can't figure out how to test if a user (taking their logged-in and role into account) can view another user's posts. Here's what I have:               $custom = get_post_types( array('_builtin' => false),'names');     foreach ( $custom as $type ) {         $object = get_post_type_object($type);         // TODO - is this check enough?         if ( user_can($user,$object->cap->edit_posts) && current_user_can($object->cap->read_posts) )             $types[] = array( 'title' => $object->labels->name, 'id' => $type );     }      Where `$user` is an author. The `$object->cap->read_posts` is not set so it always fails. This code should add a post type to an array if the author can create posts of that type and the user can read them. There are further privacy checks on a post by post basis later in the code, but that is not the issue here. How can I solve this? Please, no plugin recommendations.


How to add logo in Thematic

I've done my sharing of hacking themes before, especially to replace the site title with a logo, but for newest thematic theme, I can't figure out where to edit the code to add my logo. I've checked header.php and the style.css but can't figure it out. http://wordpress.org/extend/themes/thematic Appreciate any help!


help intercepting save_post through plugin

I use stackoverflow very often and just found out in google about this one, Nice :D Well, i want to save my every post i write from wordpress to my 3rd (OEXChangeble) website aswell at the same time, so i need to send the info to my website, developing a plugin iguess I need basically the **permalink** (and i would be able to extract the rest of the params from my wesite), but better if i can get title, tags, permalink and description(or some of it) i understand by my google research that all i need to do is add something like               <?php          //header of plugin        function myFunctionThatSendsMyWebsite($url){     // procedure containing a file_get_contents('myqwebsite?url=') request to my website     }     add_action('page_post', 'myFunctionThatSendsMyWebsite', $permalink));          ?>      I have problems thoug finding the name of variables i have missing (marked by ???). I know that $post contains all objet, how to extract the info from it (if there is), or if it's complicated, it would be enought for me with permalink Any tip? Thanks!


How to fix broken upgrade to 3.1

As soon as i saw the message on WPSE about the 3.1 release i immediately went a did a switch on my local installation(SVN switch). Only issue is the `wp-settings.php` is trying to include a non-existant file. Basically i'm stuck seeing the following two error messages. > Warning: require(MYPATH/wp-includes/classes.php) [function.require]: failed > to open stream: No such file or directory in MYPATH\wp-settings.php on line > 68 > > Fatal error: require() [function.require]: Failed opening required > 'MYPATH/wp-includes/classes.php' > (include_path='.;MYPATH/usr/local/php/includes;MYPATH/local/php/pear;MYPATH/home/admin/www/plugins/pear/PEAR') > in MYPATH\wp-settings.php on line 68 MYPATH is actually a real path, i've removed that from the above quoted errors. 3.1 does not contain any such file, and i've checked my trunk installation to confirm(it's not in trunk). So what's the deal, why is the settings file still trying to include this file? Maybe an oversight with the release? I could go grab a copy from 3.0.5, just want to hear what you guys have to say first(had this problem yourself?). **Looks like this is a local issue, i should be getting an updated wp- settings.php file, but for some reason SVN up is giving me an older copy(must be some caching issue somewhere, i assume).** I'll update the question if i figure out the problem. **UPDATE**   No idea why, but seems the switch didn't quite take, wiping the svn folders and doing the checkout procedure again(like i first did when i set the directory to pull from the SVN) seems to have resolved the problem.


How to set/change another post author by custom fields or something else?

I need help! (sorry for my poor English, I'm from Russia) How I can to set/change another post author by custom fields or something else? For example: I want to public post, but define another post author by author login.


WordPress Template Part in iFrame

(As a preface, I know this is going to sound absurd, but please bear with me. I'm aware this is unideal and atypical.) What I need to do is put wp_nav_menu inside an iFrame so I can view it on a non-WordPress-powered site. (Essentially, I have a WP-powered site where the user will have to leave the site to make a purchase. However, on that site, I'd like the page to look, feel and function -- primarily from the backend -- in the same way the rest of the WP-powered site would.) I would create a separate nav.php and try to embed that in an iFrame, but WP blocks direct access to a file in the theme folder. Is there somewhere else I could put it? Or is there some other way I can unblock access to this file? (Not the route I'd prefer to go, but if it works, I'll take it) My only other option is using something like a nav.html page, but I have no idea how I can run the usual WP PHP functions within this .html page. Any and all help will be much appreciated. Thanks in advance.


Javascript to open new window

I'd like to have a link open in a new pop-up browser window. In non-WordPress with JavaScript I would do it some like this (but I would add some underlink/color to make it look like a link).               <span      onClick="myRef = window.open('/Paid_Videos/AudioGenerator01.html','mywin',     'left=20,top=20,width=500,height=500,toolbar=1,resizable=0');     myRef.focus()">My Video Blah Blah Blah</span>      In WordPress, this shows up on my page like this:               onClick="myRef = window.open('/Paid_Videos/AudioGenerator01.html','mywin',     'left=20,top=20,width=500,height=500,toolbar=1,resizable=0');     myRef.focus()">My Video Blah Blah Blah       What can I do to make it work in WordPress?


Display search results within the same page

# Problem I have a page on my site where I need to do additional searching within that page. I am using the default way of WordPress searching with `<?php get_search_form(); ?>` for my main header search, which works great. I created another HTML form on my page, not using the default PHP method, for the additional searching like so:               <form action="<?php bloginfo('siteurl'); ?>" id="searchform" method="get">
             Search for:             <input type="text" id="s" name="s" value="" />             <input type="hidden" name="post_type" value="photo_group" />              <input type="submit" value="Search" id="searchsubmit" />
     </form>      I use the `type=hidden` for getting the custom post type that I want to search through:               <input type="hidden" name="post_type" value="photo_group" />      which gives me a link that looks similar to:               http://mywebsite.com/?s=search&post_type=photo_group      # Question When I use the new search form created on the page, it uses the default search.php to display the results. How can I display the search results of the custom post type search, lets say in a `div` on the same page? I've tried creating a new page template that would display the results with no success, could this be the right way of doing it and I just did it wrong? # * **Edit** * I'm trying the solution of sanchothefat. Does this look right? This is my whole div for my search results and search query.

Search Photos:
         <form action="<?php the_permalink(); ?>" id="searchform" method="get">
                 Search for:                 <input type="text" id="search" name="search" value="" />                 <input type="hidden" name="post_type" value="photo_group" />                  <input type="submit" value="Search" id="searchsubmit" />
         </form>              <?php if( isset( $_REQUEST['search'] ) ) {             query_posts( array(             's' => $_REQUEST['search'],             'post_type' => $_REQUEST['photo_group'],             'paged' => $paged             ));                  if( have_posts() ) : while ( have_posts() ) :                 the_title();                 the_content();                                   endwhile; endif;                  wp_reset_query();              }         ?>
      I get 404 error page not found when running through the search.


Multisite multidomain

I have a wordpress multisite. I'm using a single domain, but **I want to use multiples domains. I want to allow the user choose a domain for his subdomain.** I was searching, but i don't found nothing about this... only a domain mapping plugin and is for singles sites.


How to achieve this permalink -> category-name/custom-post-type-name/post-name

I am trying to use categories to provide the structure for my site. I will create sections on my site called England, Wales, Scotland and Ireland . These will be categories. My posts will use custom post types - Video, Guide, Event, Clubs etc. So, if I create a post called 'Trouble down south' using the 'Video' CPT, attach it to the 'England' category, I would like the slug format to be: **category-name/custom-post-type-name/post-name** _e.g. mysite.com/england/video/trouble-down-south_ I would also like the following permalinks to work like so - **mysite.com/england/** \- show all posts in that category regardless of CPT **mysite.com/video/** \- show all Video CPT posts regardless of category Sticking with my example, I create my Video CPT like so:               add_action( 'init', 'register_cpt_video' );          function register_cpt_video() {              $labels = array(              'name' => _x( 'videos', 'video' ),                  some code...              );              $args = array(                   some code...                  'taxonomies' => array( 'category' ),                  some code...                  'has_archive' => true,             'rewrite' => array(                  'slug' => 'video',                  'with_front' => false,                 'feeds' => true,                 'pages' => true             ),             'capability_type' => 'post'         );              register_post_type( 'video', $args );     }      This almost does what I need. I get the correct listings at **mysite.com/england** (i.e category archive page) _and_ **mysite.com/video** (i.e CPT archive page) Unfortunately when I click through to the actual post, the slug shows as **mysite.com/video/trouble-down-south** I would like **mysite.com/england/video/trouble-down-south** I've tried using the following rewrite slug               'slug' => '%category%/video',      This does not work. **%category%** gets literally inserted into the url without being converted into the actual category name. I have searched this site for a solution but haven't found any. Most related answers seem to address appending taxonomies to the CPT slug. i.e **mysite.com/video/england/trouble-down-south** They seem to achieve this by explicitly prefixing the CPT name to the taxonomy rewrite slug which exploits the cascade-like nature of the rewrite rules (plus some other wizardry I don't understand.) Anyhow, nothing I have found has addressed my requirement of **category- name/custom-post-type-name/post-name** , plus the archive pages I require. Any ideas how to achieve my desired permalink structure?


Adding a 'mega menu' to my site without a plugin

Can anyone suggest the best way to go about adding a 'mega menu' to my wordpress navigation without using a plugin? The content in the mega menu itself does not need to be editable via the CMS HOWEVER does need to be active when the user hovers over a certain li in the main navigation. I've looked on Google but everything is geared towards the plugin route, which I'd liek to avoid. Thanks


Multiple homes for multiple languages

I want to have multiples homes, for use multiples languages. For do for example:               if($_SERVER['SERVER_NAME'] == 'en.bz6.org')         defime('WPLANG', 'en');     else         efime('WPLANG', 'es');


How to get the post-ID in my plugin?

I am trying to write a little plugin which allows me to add a different theme to each page. well.. still trying.. ;) code: http://pastebin.com/dP1GH43E When I put `return 'mytesttheme';` at the end it works just perfect! when I add an ID (`$page_theme = get_post_meta('66', [...]`) it also works.. when I write `echo $page_theme.', ';` before the return, it outputs: `, , , mytesttheme, mytesttheme, mytesttheme, mytesttheme,` The empty spaces are the problem I think. in wp-backend it shows "mytesttheme" as post meta content in wp-core post meta content box.. so the saving works as it should.. Any ideas how to solve the problem? :S


Posts vs Pages and categories

I am creating a largely static site for the collections/archives office of a library. Since I am expecting most content to be created once and slowly appended or modified over time, instead of regular posts, my first inclination is to make everything a page. On the other hand, I have pages/posts that exist in two or 3 categories that I would really love to be able to generate listings of and I cannot think of a good way to do this except by using categories and posts. I know that there is a plugin allowing you tag pages with categories, but get_posts does not always work when I do this. Is the fact that I have content that needs multiple categories and have overlaps with each other more important than the fact that this content should largely be static? I have an collection that is made up of sites dedicated to specific topics. If I made each of those mini sites a post type, I could then make the main page loop through those posts to create entries on the collections main page and now that as long as they were tagged properly, items would show up there. So, is static content the only determiner of whether something is a page or a post?


Remove fields from Media Uploader (frontend)

I am struggling removing/hiding fields of the Media Uploader that I use in a frontend form. I want to remove all 'meta-information' fields like 'Title','Caption','Description' etc. I got this snippet, but it does not modify anything in my Media Uploader window. Any ideas what could cause this problem? Also can someone point me to an overview of the field names? I would like to remove several others (e.g. "Tags" and "Categories" which were introduced to images by the JustifiedGrid plugin)               add_filter('attachment_fields_to_edit', 'remove_media_upload_fields', 10000, 2);     function remove_media_upload_fields( $form_fields, $post ) {              // remove unnecessary fields         unset( $form_fields['post_excerpt'] );         unset( $form_fields['post_content'] );         unset( $form_fields['post_title'] );         unset( $form_fields['description'] );         unset( $form_fields['url'] );         unset( $form_fields['image_url'] );              return $form_fields;     }      Thank you


Yearly category archive pagination broken

I found code that will show posts by category and year, but then the pagination doesn’t work. The default WP widget “Category Archive" also has broken pagination and, in any case, I need to add the code to display programmatically, not in a sidebar widget. The url displays like this: > http://example.com/2013/?cat=11 but the pagination breaks because it is using > http://example.com/2013/?cat=11/page/2/ instead of > http://example.com/2013/page/2/?cat=11 which works perfectly to link to the next page. This is the code I am using from this question:               global $wpdb, $wp_locale;         $query = "select YEAR(post_date) AS `year`, count(ID) as posts from $wpdb->posts,  $wpdb->term_taxonomy, $wpdb->term_relationships              WHERE $wpdb->posts.post_status = 'publish'              AND $wpdb->posts.post_type = 'post'             AND $wpdb->term_taxonomy.term_id = 11             AND $wpdb->posts.ID = $wpdb->term_relationships.object_id             AND $wpdb->term_taxonomy.term_taxonomy_id = $wpdb->term_relationships.term_taxonomy_id             GROUP BY YEAR(post_date) ORDER BY post_date DESC";              $arcresults = $wpdb->get_results($query);              foreach ($arcresults as $arcresult):              $text = sprintf(__('%1$s %2$d'), $wp_locale->get_month($arcresult->month), $arcresult->year);?>
<a href="<?php bloginfo('url') ?>/<?php echo $arcresult->year; ?>/?cat=11"><?php echo $text;  ?>
     <?php endforeach; ?>       Any ideas on how I can change the pagination links to put the `/page/#/` in the right place?


Wordpress Login and Register Link

I am finding difficulty in returning the wp_login_form() and register link at the same time. Here is my code which i am working to make shortcode. How to send the login_form and **_register link_** if user is **_not logged in_**?               function add_login_form() {         if(!is_user_logged_in()){             return wp_login_form();         }         else {             return;         }     }


Exclude empty fields from custom field calculation (Average)

I'm using some code I found online to calculate the average value across all posts for [a_custom_field]. Does anyone know how to exclude (from calculation) any instances where the custom field = 0 or if the custom field has not been filled in? Or maybe there's a better method to get the same result.                   global $wp_query;             $real_query = $wp_query->query; //save reall query             //create new query for all posts of the tag/category/whatever             $args = array_merge( $wp_query->query, array( 'posts_per_page' => '-1' ) );                  $average_q = new WP_Query($args);             $price_count = 0;             $total_price = 0;             while ($average_q->have_posts()){             $average_q->the_post();             $total_price = $total_price + get_post_meta($post->ID,'60mins',true);             $price_count = $price_count + 1;}                  wp_reset_query();             $average = $total_price / $price_count;                        echo 'The average is' . round($average);             query_posts($real_query);


How to stop the deduction in "wp_term_taxonomy" count, when the post is deleted?

In wordpress, the normal behavior is, when you delete a post, the system automatically performs a deduction of a post (-1) in `wp_term_taxonomy` table in `count` field from a taxonomy row which it belongs to. **FINAL RESULT** :   * Basically, I am looking to stop this behavior, where it could not perform the deduction when a post is deleted so I could build up the statistics. What I am looking for is a function which I could use to stop this behavior. Probably with the help of filter/hook at the end when the post is deleted.


Excluding a Custom Post Type with a specific tag using pre_get_posts

I have an archive page that lists a custom post type called 'event'. I have event posts with the tag 'regular', (the tag has an id of 53). I'd like to exclude these. I tried using pre_get_posts and then $query->set(('tag__not_in', array('53')) but I don't think tag__not_in will work with custom post types. Is there any way to fix this?               add_action( 'pre_get_posts', 'exclude_regular_tag');     function exclude_regular_tag( $query ){         if ( is_admin() || ! $query->is_main_query() )             return;         if ( is_home() ) {             return;         }              if ( is_post_type_archive( 'event' ) ) {             $args = array('53'); //id of 'regular' tag in custom post type 'event'             $query->set('tag__not_in', $args);             return;         }     }


conditional tags- how to use with shortcodes

I have a salon website with a gallery page wherein the user must first select a stylist prior to viewing their individual gallery. I planned on using NextGen to house the images in stylist specific galleries, and using the NextGen shortcodes(ex: `[nggallery id=1]`) to determine which gallery gets shown on the specific page. After doing a bit of research, I think WP's conditional tags (I'm thinking `is_page( # )`) might be the best route to take for this, I'm just not sure how to integrate the conditional tags to specify/define the page and the NextGen shortcodes. Any tips, help, advice, etc. is greatly appreciated.


Maintaining plugin addons while upgrading

I'm developing a freemium wordpress plugin where "skins" will be available for purchase to customize the appearance of the plugin. If I commit an update to my plugin, it sounds like the contents of the "skins" folder inside of my plugin would be removed (since the skins don't come bundled with the core plugin), and the user would lose any skins they may have purchased. What can I do to circumvent this issue? Should I look into moving the skins folder temporarily while upgrading, or somehow utilize the database? Thanks!


order users with drag'n'drop?

There are many plugins out there that let you order Pages and/or Posts with drag and drop. Is there something similar to order users? Or if not, is it possible to create a plugin for that (i.e. are there sufficient filters, actions etc. in place?


Advanced Custom Fields: query posts filtered by multiple field values

I have the following: custom post type: q-and-a   custom taxonomy: q_and_a_category   taxonomy terms: design, engineering, project-management I'm creating three separate pages that filter the custom post types by their terms. I.e., one page for Design, one for Engineering, and another for Project Management. I'm accomplishing this with three separate page templates, like this:               <?php          $args=array(     'post_type' => 'q-and-a',     'q_and_a_category' => 'design' //the slug for the custom taxonomy term     );     $my_query = null;     $my_query = new WP_Query($args);     if( $my_query->have_posts() ) {     while ($my_query->have_posts()) : $my_query->the_post();          ?>          <?php the_title(); ?>          <?php endwhile; }?>          <?php wp_reset_query(); ?>      But I'm trying to create a single page template where the taxonomy term is inputted via a "select" menu that I've set up using advanced custom fields. I tried following the ACF plugin tutorial for this, example 3: http://www.advancedcustomfields.com/resources/how-to/how-to-query-posts- filtered-by-custom-field-values Like this:               <?php           // args     $args = array(     'numberposts' => -1,     'post_type' => 'q-and-a',     'meta_query' => array(         'relation' => 'OR',         array(             'key' => 'q_and_a_category',             'value' => '%design%',             'compare' => 'LIKE'         ),         array(             'key' => 'q_and_a_category',             'value' => '%engineering%',             'compare' => 'LIKE'         ),         array(             'key' => 'q_and_a_category',             'value' => '%project-management%',             'compare' => 'LIKE'         )     )     );              // get results     $the_query = new WP_Query( $args );          // The Loop     ?>     <?php if( $the_query->have_posts() ): ?>          <?php the_title(); ?>          <?php endif; ?>          <?php wp_reset_query();  // Restore global post data stomped by the_post(). ?>      When I try this, the page loads on the front end but no posts are displayed. Any suggestions? Thanks in advance.


wp_tag_cloud() and the_taxonomies() work but not the_tag()

wp_tag_cloud() and the_taxonomies() work in a widget I built but I can not get the_tags() to work. I want to display the tags assigned to the current post. I built a widget to do this. the widget works fine but as I mentioned, wp_tag_cloud() and the_taxonomies() will display. I have tried every possible code snippet I could find. Whats happening and do I display the posts tags?


Listing Specific Categories from Current Post with Depth

I've been on this for sometime and been having a ton of issues to find a proper way to do what I'm trying to achieve. An Example would be as follows: I have a featured Image with a rollover and I want it to show a single category child from under the parent category that has a depth of 2 for the location. It would look something like this: > Places -> USA -> Washington D.C I am trying to achieve to just get the Washington D.C or whatever City would be selected in the post for the category. I would be reusing this in the loop for different information which each one might have their own depth and need to be in a list. At the moment I have been using this code, which does not work as intended since it will pull all the child categories under the specified parent.               <?php        foreach((get_the_category()) as $childcat) {          if (cat_is_ancestor_of('51', $childcat)) {             echo '
 cat_ID).'">'; echo $childcat- >cat_name . '
';             }         }      ?>      Any help would be super helpful i've been stuck on this for the past 3 days. Tried:               <?php        $categories = get_the_category();      if ( $categories ) :      $deepChild = getLowestCategory( $categories );       ?>      <a href="<?php echo get_category_link( $deepChild->term_id ); ?>" title="<?php echo sprintf( __( "View all posts in %s" ), $deepChild->name ); ?>"><?php echo $deepChild->name; ?>      <?php       endif;     ?>      with the function from the other post.


the paged param is allways 0

I am listing a custom post_type called `ad` using `get_posts` wich works fine, Problem that I have is that I am not able to read the `paged` param, wich I need in order to enable pagination, The thing is that: `get_query_var('paged')` or `$paged` are allways `0` The url looks like this: `http://webiste.com/ads/?paged=2` I even tried to add to the `query_vars`               function query_vars($public_query_vars) {         $public_query_vars[] = "paged";     }     add_filter('query_vars', 'query_vars');      Any idea what am I missing here? -EDIT- This is what I am actually doing: In `functions.php`               function get_anunciantes($params,$debug = false) {         if ($debug ) {             echo '
 ';             print_r( $params );             echo '
';         }         $area_slug = $params['area_slug'];         $category_slug = $params['category_slug'];         if ( !empty ( $category_slug ) ) {             $category_params = array(                 'taxonomy' => 'category',                 'field' => 'slug',                 'terms' => array("$category_slug")             );           } else {             $category_params = array();         }         if ( !empty ( $area_slug ) ) {             $area_params = array(                 'taxonomy' => 'area',                 'field' => 'slug',                 'terms' => array("$area_slug")             );           } else {             $area_params = array();         }              if ( !empty( $area_params ) && !empty( $category_params ) ){             $tax_params = array(                 'relation' => 'AND',                 $area_params,                  $category_params             );         } else if ( !empty( $area_params ) ){             $tax_params = array($area_params);         } else {             $tax_params = array();         }              $today = time(); /* 1407375843 */         $current_page = $params['current_page'];         /*$ipp = 5;         $offset = $current_page * $ipp;*/         $myposts = get_posts( array (                 'posts_per_page'   => 5,                 'paged'     =>  $current_page,                 /*'showposts' => -1,*/                 'post_type' => 'ad',                 'post_status' => 'publish',                 'tax_query' => $tax_params,                 'meta_query' => array(                         array(                             'key' => 'wpcf-start-date',                             'value' => $today,                             'compare' => '<=',                             'type' => 'NUMERIC'                         ),                         array(                             'key' => 'wpcf-end-date',                             'value' => $today,                             'compare' => '>',                             'type' => 'NUMERIC'                         )                     )              )         );              $data = array(             'myposts' => $myposts,             'pages' => 6 /* static, i haven't done it yet */         );         return $data;               }      And in the Template `ads.php` that uses the page:
         <?php the_content(); ?>         <?php echo $area_slug.' > '.$category_slug; ?>
             <?php              $params = array(                 'area_slug' => $area_slug,                 'category_slug' => $category_slug,                 'current_page' => get_query_var('current_page')             );             $result = get_anunciantes($params,false);             $myposts = $result['myposts'];             foreach ($myposts as $mypost) { ?>

<a href="<?php echo get_permalink($mypost->ID ); ?>"><?php _e( $mypost->post_title ); ?>
                     <?php echo get_the_post_thumbnail($mypost->ID, 'thumbnail'); ?>
<?php echo $meta['wpcf-phone'][0]; ?>

             <?php } ?>
            Paged <?php echo get_query_var('paged'); echo '-'.$paged /* ALLWASY 0 */ ?>         <?php         for ($i = 1; $i <= $result['pages']; $i++) {             echo ''.$i.'';         } ?>


First article : single column; Other articles : 2 columns

I'm building a website (with Wordpress 3.6) and would like to put the news/articles arranged as follows:   * The first article was with the maximum size (one column);   * The following articles were arranged in two columns. Appears only 5 or 7 articles per page. How to do this?


WPML : how to pick a featured image only once for different languages?

I've got 3 languages on my site. Picking the same featured image 3 times for the 3 versions of each article is boring. Is there any way to do it only once ? (same for picking a tag)


Paginate Links not working

For the life of me I cannot get Paginate links to display pagination, but using 'userp' in the url works for paging. I just need the links to show up.                   <?php     /**      * @package WordPress      * @subpackage themename      * Template Name: Vendors Page      */          get_header(); ?>     <?php          $url = $_SERVER['REQUEST_URI'];         $tokens = explode('/', $url);         $usernameCheck = $tokens[sizeof($tokens)-2];         if ($usernameCheck != 'vendors') {             $username = $usernameCheck;             $username = str_replace("-", " ", $username);         }              if(isset($_POST['gform_submit'])):     ?>              <? endif; ?>     <?php          $currentUserID = get_current_user_id();          $page = (!empty($_GET['userp'])) ? $_GET['userp'] : 1;         $per_page = 10;         $offset = ( ($page -1) * $per_page);     ?>

                          <?php the_post(); ?>
                          <article id="post-<?php the_ID(); ?>" <?php post_class(); ?> role="article">
<?php if (!empty($username)) {echo $username; ?> Click Here To Edit Your Profile<?php }  else {the_title();} ?>
                              <?php if (!empty($username)) { ?>                               <?php                                 // WP_User_Query arguments                                 $args = array (                                     'exclude'        => array( 1 ),                                     'count_total'    => true,                                     'fields'         => 'all_with_meta',                                     'meta_query'     => array(                                         array(                                             'key'       => 'user_business',                                             'value'     => $username,                                             'compare'   => 'LIKE',                                         ),                                     ),                                      );                                      // The User Query                                 $user_query = new WP_User_Query( $args );                                      // The User Loop                                 if ( ! empty( $user_query->results ) ) {                                     foreach ( $user_query->results as $user ) { ?>                                 <?php if ( $currentUserID == $user->ID ) { ?>
<?php echo do_shortcode('[gravityform id="4" title="false" description="false"]'); ?>
<?php } ?>
                                     <?php if (isset($user->user_pic)) { ?>                                                     <img src="<?php echo get_template_directory_uri(); ?>/thumb.php?src=<?php echo $user->user_pic; ?>&w=235&h=147" title="<?php echo $user->user_business; ?>" alt="<?php echo $user->user_business; ?>" class="profilePic" />                                     <?php } else { $imgURL = get_template_directory_uri() . "/images/vendor_placeholder.jpg"; ?>                                                     <img src="<?php echo get_template_directory_uri(); ?>/thumb.php?src=<?php echo $imgURL; ?>&w=235&h=147&zc=2" title="<?php echo $user->user_business; ?>" alt="<?php echo $user->user_business; ?>" class="profilePic" />                                     <?php } ?>
Owner Name:
                                     <?php echo $user->first_name; ?> <?php echo $user->last_name; ?>

                                          <?php if ($user->user_address_show == 'Yes') { ?>
Address:
                                         <?php echo $user->user_address_street; ?>
<?php echo $user->user_address_city; ?>, KS <?php echo $user->user_address_zip; ?>

                                     <?php } ?>
Phone:
                                     <?php echo $user->user_phone; ?>                                          <a href="mailto:<?php echo $user->user_email; ?>" class="contactVendor">Contact Us Via Email
Markets We Attend:
                                     <?php if (isset($user->we_attend_east)) { ?>
East Wichita
Green Acres Market
<?php } ?>                                     <?php if (isset($user->we_attend_west)) { ?>
West Wichita
Sedgwick County Ext. Office
<?php } ?>                                     <?php if (isset($user->we_attend_delano)) { ?>
Delano in Wichita
Lawrence Dumont Parking lot
<?php } ?>                                     <?php if (isset($user->we_attend_derby)) { ?>
Derby, Kansas
<?php } ?>                                          <?php if (isset($user->attend_this_week_east) || isset($user->attend_this_week_wast) || isset($user->attend_this_week_delano) || isset($user->attend_this_week_derby)) { ?>
We will be at the                                      <?php if (isset($user->attend_this_week_east)): ?>East Wichita Market<?php if (isset($user->attend_this_week_west) || isset($user->attend_this_week_delano) || isset($user->attend_this_week_derby)): ?>,<?php endif; ?><?php endif; ?>                                     <?php if (isset($user->attend_this_week_west)): ?>West Wichita Market<?php if (isset($user->attend_this_week_delano) || isset($user->attend_this_week_derby)): ?>,<?php endif; ?><?php endif; ?>                                     <?php if (isset($user->attend_this_week_delano)): ?>Delano in Wichita Market<?php if (isset($user->attend_this_week_derby)): ?><?php endif; ?><?php if (isset($user->attend_this_week_derby)): ?> and<?php endif; ?><?php endif; ?>                                     <?php if (isset($user->attend_this_week_derby)): ?>Derby, Kansas Market<?php endif; ?>                                     this week!
                                     <?php } ?>
Items sold at market:

                                         <?php if (isset($user->product_1)){ ?>
<?php echo $user->product_1; ?>
<?php } ?>                                         <?php if (isset($user->product_2)){ ?>
<?php echo $user->product_2; ?>
<?php } ?>                                         <?php if (isset($user->product_3)){ ?>
<?php echo $user->product_3; ?>
<?php } ?>                                         <?php if (isset($user->product_4)){ ?>
<?php echo $user->product_4; ?>
<?php } ?>                                         <?php if (isset($user->product_5)){ ?>
<?php echo $user->product_5; ?>
<?php } ?>
                                          <?php if (isset($user->user_organic)){ ?>
Organic | Chemical Free
                                     <?php } ?>                                          <?php if (isset($user->user_producer)){ ?>
100% Producer
                                     <?php } ?>

About Us:

<?php echo $user->user_about; ?>

                                     <?php if (isset($user->user_profile_pic)){ ?>
View Our Photos
<?php } ?>                                          <?php if (isset($user->user_profile_pic)){ ?>
                                             <img src="<?php bloginfo('template_url'); ?>/images/user_pics_prev.png" class="prev"/>                                             <img src="<?php bloginfo('template_url'); ?>/images/user_pics_next.png" class="next"/>

<a href="<?php echo $user->user_profile_pic; ?>" class="fresco" data-fresco-caption="<?php echo $user->user_profile_pic_c; ?>"><img src="<?php echo get_template_directory_uri(); ?>/thumb.php?src=<?php echo $user->user_profile_pic; ?>&h=134&w=119" alt="<?php echo $user->user_profile_pic_c; ?>" title="<?php echo $user->user_profile_pic_c; ?>" />
                                                          <?php if (isset($user->user_pic_1)){ ?>
<a href="<?php echo $user->user_pic_1; ?>" class="fresco" data-fresco-caption="<?php echo $user->user_pic_1_c; ?>"><img src="<?php echo get_template_directory_uri(); ?>/thumb.php?src=<?php echo $user->user_pic_1; ?>&h=134&w=119" alt="<?php echo $user->user_pic_1_c; ?>" title="<?php echo $user->user_pic_1_c; ?>" />
<?php } ?>                                                          <?php if (isset($user->user_pic_2)){ ?>
<a href="<?php echo $user->user_pic_2; ?>" class="fresco" data-fresco-caption="<?php echo $user->user_pic_2_c; ?>"><img src="<?php echo get_template_directory_uri(); ?>/thumb.php?src=<?php echo $user->user_pic_2; ?>&h=134&w=119" alt="<?php echo $user->user_pic_2_c; ?>" title="<?php echo $user->user_pic_2_c; ?>" />
<?php } ?>                                                          <?php if (isset($user->user_pic_3)){ ?>
<a href="<?php echo $user->user_pic_3; ?>" class="fresco" data-fresco-caption="<?php echo $user->user_pic_3_c; ?>"><img src="<?php echo get_template_directory_uri(); ?>/thumb.php?src=<?php echo $user->user_pic_3; ?>&h=134&w=119" alt="<?php echo $user->user_pic_3_c; ?>" title="<?php echo $user->user_pic_3_c; ?>" />
<?php } ?>                                                          <?php if (isset($user->user_pic_4)){ ?>
<a href="<?php echo $user->user_pic_4; ?>" class="fresco" data-fresco-caption="<?php echo $user->user_pic_4_c; ?>"><img src="<?php echo get_template_directory_uri(); ?>/thumb.php?src=<?php echo $user->user_pic_4; ?>&h=134&w=119" alt="<?php echo $user->user_pic_4_c; ?>" title="<?php echo $user->user_pic_4_c; ?>" />
<?php } ?>                                                          <?php if (isset($user->user_pic_5)){ ?>
<a href="<?php echo $user->user_pic_5; ?>" class="fresco" data-fresco-caption="<?php echo $user->user_pic_5_c; ?>"><img src="<?php echo get_template_directory_uri(); ?>/thumb.php?src=<?php echo $user->user_pic_5; ?>&h=134&w=119" alt="<?php echo $user->user_pic_5_c; ?>" title="<?php echo $user->user_pic_5_c; ?>" />
<?php } ?>                                                          <?php if (isset($user->user_pic_6)){ ?>
<a href="<?php echo $user->user_pic_6; ?>" class="fresco" data-fresco-caption="<?php echo $user->user_pic_6_c; ?>"><img src="<?php echo get_template_directory_uri(); ?>/thumb.php?src=<?php echo $user->user_pic_6; ?>&h=134&w=119" alt="<?php echo $user->user_pic_6_c; ?>" title="<?php echo $user->user_pic_6_c; ?>" />
<?php } ?>                                                          <?php if (isset($user->user_pic_7)){ ?>
<a href="<?php echo $user->user_pic_7; ?>" class="fresco" data-fresco-caption="<?php echo $user->user_pic_7_c; ?>"><img src="<?php echo get_template_directory_uri(); ?>/thumb.php?src=<?php echo $user->user_pic_7; ?>&h=134&w=119" alt="<?php echo $user->user_pic_7_c; ?>" title="<?php echo $user->user_pic_7_c; ?>" />
<?php } ?>                                                          <?php if (isset($user->user_pic_8)){ ?>
<a href="<?php echo $user->user_pic_8; ?>" class="fresco" data-fresco-caption="<?php echo $user->user_pic_8_c; ?>"><img src="<?php echo get_template_directory_uri(); ?>/thumb.php?src=<?php echo $user->user_pic_8; ?>&h=134&w=119" alt="<?php echo $user->user_pic_8_c; ?>" title="<?php echo $user->user_pic_8_c; ?>" />
<?php } ?>                                                          <?php if (isset($user->user_pic_9)){ ?>
<a href="<?php echo $user->user_pic_9; ?>" class="fresco" data-fresco-caption="<?php echo $user->user_pic_9_c; ?>"><img src="<?php echo get_template_directory_uri(); ?>/thumb.php?src=<?php echo $user->user_pic_9; ?>&h=134&w=119" alt="<?php echo $user->user_pic_9_c; ?>" title="<?php echo $user->user_pic_9_c; ?>" />
<?php } ?>

                                     <?php } ?>                                          <?php if (isset($user->user_twitter) || isset($user->user_facebook)){ ?>
Socialize With Us
<?php } ?>                                          <?php if (isset($user->user_twitter)){ ?>
                                             <img src="<?php bloginfo('template_url'); ?>/images/twitter_prev.png" class="prev"/>                                             <img src="<?php bloginfo('template_url'); ?>/images/twitter_next.png" class="next"/>
                                                 <?php echo do_shortcode('[twitter-user]'); ?>

                                     <?php } ?>                                          <?php if (isset($user->user_facebook)){ ?>                                         <iframe src="//www.facebook.com/plugins/likebox.php?href=<?php echo urlencode($user->user_facebook); ?>&width=588&height=590&show_faces=true&colorscheme=light&stream=true&show_border=true&header=true&appId=172839226207438" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:588px; height:590px;" allowTransparency="true">                                     <?php } ?>
                                      <?php } } ?>                                                                                <?php } else { ?>                                                           <?php                                 // WP_User_Query arguments                                 $args = array (                                     'exclude'        => array( 1 ),                                     'count_total'    => true,                                     'fields'         => 'all_with_meta',                                     'number' => $per_page,                                     'offset' => $offset,                                 );                                           // The User Query                                 $user_query = new WP_User_Query( $args );                                      // The User Loop                                 if ( ! empty( $user_query->results ) ) {                                     foreach ( $user_query->results as $user ) { ?>
                                             <a href="<?php bloginfo('url'); ?>/vendors/<?php echo str_replace(" ", "-", strtolower($user->user_business)); ?>">                                                 <?php if (isset($user->user_pic)) { ?>                                                     <img src="<?php echo get_template_directory_uri(); ?>/thumb.php?src=<?php echo $user->user_pic; ?>&w=235&h=147" title="<?php echo $user->user_business; ?>" alt="<?php echo $user->user_business; ?>" />                                                 <?php } else { $imgURL = get_template_directory_uri() . "/images/vendor_placeholder.jpg"; ?>                                                          <img src="<?php echo get_template_directory_uri(); ?>/thumb.php?src=<?php echo $imgURL; ?>&w=235&h=147&zc=2" title="<?php echo $user->user_business; ?>" alt="<?php echo $user->user_business; ?>" />                                                 <?php } ?>

<?php echo $user->user_business; ?><a href="<?php bloginfo('url'); ?>/vendors/<?php echo str_replace(" ", "-", strtolower($user->user_business)); ?>" class="viewProfile">View Profile
                                                     Item(s) sold at market:
<?php $productCounter = 0; ?>                                                         <?php if (isset($user->product_1) && $productCounter == 0) { $productCounter = 1; ?>
<?php echo $user->product_1; ?>
<?php } ?>                                                         <?php if (isset($user->product_2) && $productCounter == 0) { $productCounter = 1; ?>
<?php echo $user->product_2; ?>
<?php } ?>                                                         <?php if (isset($user->product_3) && $productCounter == 0) { $productCounter = 1; ?>
<?php echo $user->product_3; ?>
<?php } ?>                                                         <?php if (isset($user->product_4) && $productCounter == 0) { $productCounter = 1; ?>
<?php echo $user->product_4; ?>
<?php } ?>                                                         <?php if (isset($user->product_5) && $productCounter == 0) { $productCounter = 1; ?>
<?php echo $user->product_5; ?>
<?php } ?>
                                                     Market(s) we attend:<?php $marketCounter = 0; ?>                                                     <?php if (isset($user->we_attend_east) && $marketCounter != 2) { $marketCounter++ ?>
East Wichita
Green Acres Market
<?php } ?>                                                     <?php if (isset($user->we_attend_west) && $marketCounter != 2) { $marketCounter++ ?>
West Wichita
Sedgwick County Ext. Office
<?php } ?>                                                     <?php if (isset($user->we_attend_delano) && $marketCounter != 2) { $marketCounter++ ?>
Delano in Wichita
Lawrence Dumont Parking lot
<?php } ?>                                                     <?php if (isset($user->we_attend_derby) && $marketCounter != 2) { $marketCounter++ ?>
Derby, Kansas
<?php } ?>

                                      <?php } } ?>                                                            <?php } ?>                          <?php                     $page_args = array(         'base'         => get_permalink( get_the_ID() ). '%_%',         'format'       => add_query_arg(array('userp' => '%#%')),         'total'        => ceil($users->total_users / $per_page),         'current'      => $page,         'show_all'     => True,         'end_size'     => 2,         'mid_size'     => 2,         'prev_next'    => True,         'prev_text'    => __('« Previous'),         'next_text'    => __('Next »'),         'type'         => 'plain',     );          echo paginate_links($page_args);     ?>

                     <?php if (!empty($username)) { ?>
<?php if ( dynamic_sidebar('profile-sidebar') ) : else : ?><?php endif; ?>
<?php } else { ?><?php get_sidebar(); ?><?php } ?>

     <?php get_footer(); ?>


Pagination on with query_posts in custom post type template

I know there about a thousand pagination issue questions on here, and I've looked at them, but I can't seem to figure out what's going wrong with mine. This is a loop on a custom post type archive template, but it should call ALL POSTS since I'm using it as a blog. At the very top of the template, is a query for a specific page, but I don't think that's what's causing the problem. What happens is that on the second page I get a 404 error.               <?php get_header(); ?>     <?php // query post #4606     $post_id = 4606;     $queried_post = get_post($post_id);     $title = $queried_post->post_title;?>     <?php echo $title;?>          <?php $post = $posts[0]; $c=0;     $args = array(         'post_type'=> 'post',         'posts_per_page' => 7,         'paged' => ( get_query_var('paged') ? get_query_var('paged') : 1),         );     query_posts($args);     while (have_posts()) : the_post();     ?>          <?php $c++;     if( !$paged && $c == 1) :?>                     <?php if ( has_post_thumbnail()) : ?>                         <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >                             <?php the_post_thumbnail('archive-featured-img', array('class' => 'aligncenter')); ?>                                              <?php endif; ?>                               <?php else :?>                                               <?php endif;?>     <?php endwhile; ?>               <?php if (  $wp_query->max_num_pages > 1 ) : ?>

<?php next_posts_link('Next Page »', 0); ?>

<?php previous_posts_link('« Previous Page', 0); ?>

     <?php endif; ?>     <?php     wp_reset_query();  // Restore global post data     ?>
<?php echo $title;?>
                     <?php echo $queried_post->post_content;?>                      <?php dynamic_sidebar( 'Main Blog Page Sidebar' ); ?>          <?php get_footer() ?>


How to make gravatar.com avatars conditional?

**Problem:** I am using custom avatars for registered users and my own locally-hosted image as the default gravatar. I want to stop WordPress making HTTP requests to check for gravatar.com images on every comment. Where my custom avatars are used, the scr result still includes a hashed link to gravatar.com with a redirect appended to the scr URI back to my own image. Even without using a custom default avatar, there are two HTTP requests sent out. For default avatars this looks like: http://1.gravatar.com/avatar/9cf9ecff0dd6eed9a1ea0948c61dc3c2?s=44&d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D44&r=G I neither want, nor need, this kind of bloat in my pages. **Goal:** What I want to do is to override the gravatars function in pluggable.php so that it only runs when a checkbox is checked. I have added a form field to my comments form so commenters can specify if they want to use their gravatar image from gravatar.com, their Twitter profile image, or (if left unchecked) if default, locally-hosted images apply. If the checkbox for gravatar.com avatars isn't selected then it shouldn't run at all. I'm stuck on how to tie the get_avatar function to run only if the checkbox input returns true.


Query users based on posts in Taxonomy A and Taxonomy B

When you are on the "sorority" OR "school" taxonomy page, ALL of the users in either the "sorority" or "school" taxonomy page display.               <?php     $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );     $term_parent = $term->parent;     $term_slug = $term->slug;     $user_query = new WP_User_Query(array(       'role'         => 'stylista',         // or whatever your target role is       'meta_key'     => $term_parent,        'meta_compare' => 'like',        'meta_value'   => $term_slug,          // or "%{$term->name}%" ?      ));      $users = $user_query->get_results(); ?>     <?php if (!empty($users)) {?>         <?php foreach($users as $user) : ?>                 <a rel="<?php echo $user->first_name; ?> of <?php echo $user->sorority2; ?>" href="<?php echo get_author_posts_url($user->ID); ?>"><?php echo get_avatar($user->ID, 70); ?>             <?php endforeach; ?>     <?php } else {?>     <?php }?>      What I am trying to do is display all users in BOTH "sorority" and "school" (on the search page, which pulls in search results from two taxonomies, "sorority" and "school"). This is the code I use to pull in the parent and term of each taxonomy - what I cannot figure out is how to pull in USERS who have posted (they also have post meta linked to the taxonomy) and tagged their articles as both Sorority A and School B.                 <?php         $available_taxonomies = get_taxonomies('','objects');         $output = ''; // and prepare our output buffer         if(count($_GET)>1){ // don't even bother if filter hasn't been submitted             foreach($available_taxonomies as $taxonomy){ //loop through all available taxonomies                 if(isset($_GET[$taxonomy->query_var]) && in_array($taxonomy->name, array('sorority')) ){ // and when you find one that's present in the current query              $output = "";                     $output .= $taxonomy->label.": "; // display the name followed by ":"                      $terms = preg_split('/[, +]/',urldecode($_GET[$taxonomy->query_var])); // and get all the terms (slugs) of that taxonomy present in the query (GET)                      foreach($terms as $term_slug){ // now loop through all the slugs                         $term = get_term_by('slug',$term_slug,$taxonomy->name); // and based on that slug, get the term object                         $output .= $term->name.', '; // and add the term's name to our output buffer followed by a comma (,)                                             }                     $output = rtrim($output, ", ")." | ";  // when we're finished with terms, remove the last comma                 }//endif             }//endforeach             echo rtrim($output, " | "); // when we're finished with taxonomies, remove the last '|'         } else {//endif               //If filter has not been submitted display the default title             wp_title( '|', true, 'right' );         }          ?>      **Any thoughts?**


Custom Login and Registration form in Ajax

How to create the custom login/Registration form using AJAX.


Set post_parent from URL params in post-new.php

I'm trying to create a set of buttons on wordpress Page post types that allow the end user to create a new page that is a sibling (same parent page) or a child page of the current page. In order to do so, i'm creating a link post-new.php and populating the parameter parent_id in the URL. In my functions.php, I've hooked wp_insert_post ... the problem I have now is how to actually set the post_parent on the $post object ... I dont see any Wordpress functions to do so; I've tried using wp_update_post ... but this doesnt seem to work for me ... here's the code in my functions.php:               add_action('wp_insert_post','grey_templater_set_post_parent',10,2);          function grey_templater_set_post_parent($postid,$post) {                  if ( ! $parentid = grey_get_post_parent_by_url()                     or 'auto-draft' !== $post->post_status )                     return;                  $mypage = array();             $mypage['ID'] = $postid;             $mypage['post_parent'] = $parentid;             wp_update_post( $mypage );          }          function grey_get_post_parent_by_url() {                  if (! isset( $_GET['parent_id'] ) )                     return FALSE;                  return array_map('sanitize_title', explode(',', $_GET['parent_id']));     }


Custom Taxonomy in plugin and template

I have a plugin that I am developing that is using custom post types and taxonomies. My question is this. How can I load the content/theme data from my plugin on to the page when the go to the custom url of the taxonomy? EDIT I am trying to use the plugin's template files and not the themes for my custom taxomony.


Does doing an export moves all my posts or just a copy of it?

I want to move from Wordpress hosting to self-hosting. I have installed wordpress on my self-host account. Now I want to play with it for a while with themes,plugins, etc. and see how it goes. So I am thinking of bringing all my post to my account. I would like my original blog on wordpress to work as usual for now until I am ready to redirect it to my own domain/host. **Question:** So when I use the Export facility (All post) will the posts get permanently removed from my blog or will it be just a copy of my posts?