Frontend file upload works, but I get error "Constant ABSPATH already defined"

I am uploading files from the frontend. It works perfectly, yet I am getting the error: > Constant ABSPATH already defined This is at the top of my file upload script:               require ($_SERVER['DOCUMENT_ROOT'] . "/wp-load.php");     // require two files that are included in the wp-admin but not on the front end.  These give you access to some special functions below.     require ($_SERVER['DOCUMENT_ROOT'] . "/wp-admin/includes/file.php");     require ($_SERVER['DOCUMENT_ROOT'] . "/wp-admin/includes/image.php");      `wp-load.php` is not being loaded anywhere else manually, only here. The file upload works as expected, the only issue is the Notice that PHP is spitting out. If I use `require_once` then I get more errors (though it does still upload as expected?). Any ideas? **Edit: more information** A search through /wp-content/* shows the term wp-load only once - that is from the above code. Maybe there is a way to autoload wp-load.php without including the phrase wp- load?? The code requiring wp-load is within a theme template (not a plugin). Specifically, within a page-template that allows a custom post to be added/edited from the frontend. If I remove the line that requires wp-load.php, then the image upload still works. However, I get the following errors (sensitive info in directory structure has been omitted):               Notice: Undefined offset: 1 in /<Path to file>/file_upload.php on line 25          Notice: Undefined offset: 1 in /<Path to file>/file_upload.php on line 26          Notice: Undefined offset: 1 in /<Path to file>/file_upload.php on line 27          Notice: Undefined offset: 1 in /<Path to file>/file_upload.php on line 28          Notice: Undefined offset: 1 in /<Path to file>/file_upload.php on line 29          Notice: Undefined offset: 2 in /<Path to file>/file_upload.php on line 25          Notice: Undefined offset: 2 in /<Path to file>/file_upload.php on line 26          Notice: Undefined offset: 2 in /<Path to file>/file_upload.php on line 27          Notice: Undefined offset: 2 in /<Path to file>/file_upload.php on line 28          Notice: Undefined offset: 2 in /<Path to file>/file_upload.php on line 29          Notice: Undefined offset: 3 in /<Path to file>/file_upload.php on line 25          Notice: Undefined offset: 3 in /<Path to file>/file_upload.php on line 26          Notice: Undefined offset: 3 in /<Path to file>/file_upload.php on line 27          Notice: Undefined offset: 3 in /<Path to file>/file_upload.php on line 28          Notice: Undefined offset: 3 in /<Path to file>/file_upload.php on line 29          Notice: Undefined offset: 4 in /<Path to file>/file_upload.php on line 25          Notice: Undefined offset: 4 in /<Path to file>/file_upload.php on line 26          Notice: Undefined offset: 4 in /<Path to file>/file_upload.php on line 27          Notice: Undefined offset: 4 in /<Path to file>/file_upload.php on line 28          Notice: Undefined offset: 4 in /<Path to file>/file_upload.php on line 29          Notice: Undefined offset: 5 in /<Path to file>/file_upload.php on line 25          Notice: Undefined offset: 5 in /<Path to file>/file_upload.php on line 26          Notice: Undefined offset: 5 in /<Path to file>/file_upload.php on line 27          Notice: Undefined offset: 5 in /<Path to file>/file_upload.php on line 28          Notice: Undefined offset: 5 in /<Path to file>/file_upload.php on line 29      This error is referencing the $file_array array from here:               if ($count_files > 0) {         foreach ( range( 0, $count_files ) as $i ) {                  // create an array of the $_FILES for each file             $file_array = array(                 'name'      => urlencode($_FILES['logo']['name'][$i]),                 'type'      => $_FILES['logo']['type'][$i],                 'tmp_name'  => $_FILES['logo']['tmp_name'][$i],                 'error'     => $_FILES['logo']['error'][$i],                 'size'      => $_FILES['logo']['size'][$i],             );                  if ( !empty( $file_array['name'] ) ) {                      $uploaded_file = wp_handle_upload( $file_array, $upload_overrides );                      $wp_filetype = wp_check_filetype( basename( $uploaded_file['file'] ), null );                         $attachment = array(                     'post_mime_type' => $wp_filetype['type'],                     'post_title' => preg_replace('/\.[^.]+$/', '', basename( $uploaded_file['file'] ) ),                     'post_content' => 'logo',                     'post_author' => $logged_in_user,                     'post_status' => 'inherit',                     'post_type' => 'attachment',                     'post_parent' => $_POST['post_id'],                     'guid' => $uploads['baseurl'] . '/' . date( 'Y/m' ) . '/' . $file_array['name'],                     'post_date' => date( 'Y-m-d H:i:s' ),                     'post_date_gmt' => date( 'Y-m-d H:i:s' )                 );                           $attach_id = wp_insert_attachment( $attachment, '/' . date( 'Y/m' ) . '/' . $file_array['name'], $_POST['post_id'] );                      $attach_data = wp_generate_attachment_metadata( $attachment_id, $uploaded_file['file'] );                      wp_update_attachment_metadata( $attachment_id,  $attach_data );                      set_post_thumbnail( $_POST['post_id'], $attach_id );                  }         }     }


wp_editor content not being saved when used in a theme customizer option

I am replacing one of the default Customize options for the Formation theme (https://wordpress.org/themes/formation) in order to add the WYSIWYG content editor to it. I've succeeded in removing the parent theme's option and adding the one from my child theme instead. The content editor shows up and functions mostly as expected. The problem I'm having is when I type in the content editor, the "Saved" button stays grayed out and will not change to "Save & Publish." Even if I edit another option that causes the button to change, the content is not saved. However, the corresponding "featured_button_url_child" option is still saved. Here is the relevant code from my child theme's function.php file: http://pastebin.com/et1ZirW3 The method I'm using is mostly based off the information in the following link, along with the theme's existing customize options: https://github.com/paulund/wordpress-theme-customizer-custom-controls I'm new to setting up Customize options, so maybe I'm missing something fundamental when it comes to saving or handling the values? I appreciate any help!


$args Orderby The number

I have this code               $cat_args=array(     'include' => '42,210,21',     'orderby' => '42,210,21',     'order' => 'asc'      );     $categories=get_categories($cat_args);       foreach($categories as $category) {         $args=array(          'showposts' => 1,          'category__in' => array($category->term_id),          'caller_get_posts'=>1      );      I want the `orderby` to be the same order of `include`, not by name or id


Can I use widgets & shortcode if I need to return an array?

I'm trying to achieve the following functionality. I have several widget 'areas' that I can place widgets into. I programmed these widget areas into the theme of my site and I can turn them on and off in the admin panel. The widget areas are basically sections on my site and I place text widgets into them and ads into those text widgets. The widget areas are also filled with other assorted content (newsletter sign up form, most popular posts, ect..). I am using a plugin to do my ad management ( http://wordpress.org/plugins/ads- by-datafeedrcom/ ) and it has very nice functionality. I place the shortcode into my text widgets and the ads show up as expected. I need to be able to exclude ads from the db queries that this plugin makes. I can pass in the ads to be excluded as attributes in the shortcode - this is not an issue. My problem is I need to get the ID of the ad being displayed by the shortcode. I want the shortcode to return both the shortcode textual content and an array of excluded ads containing the current ad along with any previous ads (this would prevent duplicate ads from appearing on the site). I would then pass this array of excluded IDs into the next shortcode via attributes and a global variable. My question is this: Can shortcodes return anything other than strings? Is my setup (shortcodes to call ads, text widgets, managing ad placement by enabling widget areas) untenable? I've gotten as far as this `[dfads params='groups=1234&ad_class=sidebar- ad&limit=1&orderby=random&excluded_ads=1,4,6']` which calls this `function dfads_shortcode( $atts ) { return dfads( $atts['params'] ); }` `dfads` returns `get_ads` and `get_ads` returns this `return array($this->output( $ads, $this->args ), $excluded_ads);` So I am returning an array containing a string ($this->output) & array ($excluded_ads) and I want to display the string and capture the array to pass on to the next shortcode. Should I be doing this all in code in the loop? Is it possible to get this functionality out of widgets & shortcode? -- Update 1 I noticed there are [methods]http://www.emanueleferonato.com/2011/04/11/executing-php-inside-a- wordpress-widget-without-any-plugin/ for running php code inside widgets. Is this a safe if it's an admin only feature? Do I still have access to global variables? Is the execution flow basically the same as if I had the php code in my page flow where the widget appears instead of in the widget? I could execute all this within the page being displayed but it seems a lot cleaner for administration by having this stuff in the widgets/dashboard.


Change order of posts

I made a post recently that did not explained myself right! Come again, but with better explanations. I need the "Select Option" change the order of query_posts. My current code is:               <select>         <option selected="selected">Select order of posts</option>         <option>Highest price</option><!-- hypercart_meta_price  "order=DESC" -->         <option>lowest price</option><!-- hypercart_meta_price  "order=ASC" -->         <option>Discount in%</option><!-- hypercart_meta_discount  "order=DESC" -->         <option>Release Date</option><!-- date  "order=DESC" -->     </select>     <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; ?>     <?php query_posts( 'post_type=products&orderby=meta_value_num&order=DESC&meta_key=hypercart_meta_discount&key=price&cat=' .get_query_var('cat')."&paged=".$paged); ?>     <?php get_template_part("loop-products"); ?>      I just need to know how to change the query_posts using the "Select box" Thank you for understanding. Hug! **UPDATED MY ISSUE** , sorry for the inconvenience.


How do I make my function add variables/values to the $post object?

How do I add `$tzDesc` and `$tzEmbed` (and other variables) to the `$post` object in the following function so that I can display the values in my theme files by inserting `<?php echo $tzDesc; ?>`?               add_action( 'the_post', 'paginate_slide' );          function paginate_slide( $post ) {              global $pages, $multipage, $numpages;              if( is_single() && get_post_type() == 'post' ) {              $multipage = 1;         $id = get_the_ID();         $custom = array();         $pages = array();         $i = 1;              foreach( get_post_custom_keys() as $key )             if ( false !== strpos( $key, 'slide' ) )                 $custom[$key] = get_post_meta( $id, $key, true);              while( isset( $custom["slide{$i}-title"] ) ) {                  $page = '';             $tzTitle = $custom["slide{$i}-title"];             $tzImage = $custom["slide{$i}-image"];             $tzDesc = $custom["slide{$i}-desc"];             $tzEmbed = $custom["slide{$i}-embed"];                  $page = "
{$tzTitle}
";             $pages[] = $page;             $i++;         }              $numpages = count( $pages );         }     }      If you know and can provide an answer can you please be very detailed in how the code should be structured because my knowledge of php is very minimal and I have tried to do this numerous already without any success. Thanks.


Custom SQL Query for Wordpress page

I'm quite new to wordpress. I'm trying to build a tableview within a wordpress page. Therfore I need a custom SQL Query to my MySQL Database.   1. Query data from my MySQL Database   2. Get the result somehow in a HTML format in order to display it in a table view within a wordpress page. My question is: How can I use the wpdb_class in a wordpress page when it is not an option to put php code in a page?


Integrate Facebook comments with native comments

I've finally installed the Facebook Comments plugin to allow readers to comment using their Facebook identity. After the installation, I got two different comment sections, with two separate comment chronologies, two comment counters and two comment text boxes. Is there a way to integrate the two comment sections?


Include custom post type in "all posts"

(Working of off an existing team that the client already purchase.) I have a WordPress install with a couple of custom post types:   * portfolio   * testimonials I've set the taxonomy to `hierarchical' => false,`, the tagging options are available in the backend and I can display them on the front-end. However, when I click one of the tags, I go to the list of standard posts with that tag, not to the list of custom posts (portfolio or testimonials) with that tag. Is it possible to display both regular and custom posts in the same taxonomy?


Replace a word with a word in the URL string

I'm trying to replace a word on every page for example "Denver" with a word from a URL string, so I'll have like `?city=Atlanta` in the URL. So I was thinking of using PHP's GET to just get the city from the URL string and `str_replace` to replace it, but which action/hook in WordPress do I have to attach it to? The word will appear throughout the entire page, including title, logo description, content, footer, etc... so it can't just replace content only.


Minimum Word Count Before A Post Can Be Made Pending Review

I'm looking for a way to check that a post has a minimum word count before allowing it to be sent for review (added to the pending post status). Below is the code I have:               if (current_user_can('contributor')) {     function minWord($content){             global $post;             $num = 150; //set this to the minimum number of words             $content = $post->post_content;             if (str_word_count($content) <  $num)                 wp_die( __('Error: your post is below the minimum word count.') );     }     add_action('draft_to_pending', 'minWord');     }      This appears to "work", in that it brings up an error message when the word count is indeed below 150. However, the post is still saved as a "pending". Is there any way to prevent the post from being made pending, but instead keep it saved as "draft". Cheers Peter


Website Broken on Activating Child Theme!

My website (at http://japanaddicts.org) breaks down in a rudimentary pro-HTML form when I try to activate the child theme. My parent theme is Codilight. Just explain to me why is this happening. I am not looking for Codilight-specific premium support, but a reason that any knowledgeable person will know. I have prepared my child theme with nothing but this:               /*           Theme Name:   Codilight Child         Theme URI:             Description:  A modified and more specific version of Codilight.         Author:       Prince         Author URI:   http://japanaddicts.org/         Template:     codilight         Version:      1.0.0         Tags:         pink, lesser social buttons         Text Domain:       */     @import url("../codilight/style.css");      I've uploaded it to a new directory wp-content/themes/codilight-child. When I activate it and open my website, it opens in a broken format (not fully HTML neither fully Codilight style). I had to revert back to the original/parent Codilight. I've read the guide at WordPress Codex and it doesn't help. Here's a screenshot of how my website looks under the child theme: ![Screenshot of the website under the child theme](http://i.stack.imgur.com/315I4.png)


How do display gallery embedded to the custom post type

I have a custom post 'events'. For each post there is a gallery attached. On a main galley page i am displaying featured images from each post . Now i want that when person clicks on this featured image , he should be taken to a new template where images from the embedded gallery of the post are displayed using get_post_gallery(). I can't use permalink because it will take me to the 'single-event'. How can i do it ? Please help me out.


How to create a WP theme that use BootStrap?

I am pretty new in WordPress and totally new in BootStrap development (I have beginning to study BootStrap yesterday) and I have the following doubt about how create a custom WP template that use BootStrap from 0. For example I have the source of this page made using BootStrap: http://www.html.it/guide/img/bootstrap/demo/home.html and I want try to create a WP template starting by it. Some time ago I have realized a standard HTML\CSS template for WP, can I use the same tecnique dividing the previous page into (header, footer, content, etcetc) and the put in these section the WP php code to show articles and other WP functions? Is it the right way? The other doubts is related to the upper slideshow, in this slideshow the immage are fixed and definied in a static way:

        Lorem ipsum
        sit dolor
        adipiscing elitur

        Lorem ipsum
        sit dolor
        adipiscing elitur

        Lorem ipsum
        sit dolor
        adipiscing elitur

      And what can I do if I want that the administrator can choose the immages that should be displayed from the backend (I think in the theme configuration panel) Can you give me some ideas about how do these things? Tnx Andrea


How to add a new variable to blog creation form?

I'm trying to add a new INPUT field to the blog creation form on Buddypress. Adding the front-end element is the easy part. I'm having some hard time trying to save it. The variable is a string, and I've added `wpmu_new_blog` a function that adds the variable as an `option` (`add_option('name','value');`). Despite the fact I've specified `global $variable` in the function, the variable won't pass. Ideas? Thanks!


a better search?

hi how to create advanced search with out plugin, create with form * Support for "+" (must have) and "-" (must not have) * Search title, content, excerpt, taxonomies or comments (or any combination thereof) * Search within a date * Search for at least one word in phrase * Search exact phrase * Search for combinations of exact phrase and any words


Auto 301 to full post permalink? (using : /archive/%post_id% to %post_name% )

I have updated my permalink structure to `/archive/%post_id%`, but if someone uses a URL like `/archive/456857` instead of the full URL of `/blog-test`, WordPress shows the post without giving a 301 to the full URL. Isn't this poor SEO? Sites like tumblr and stackexchange automatically send a 301 to the full URL. Any hacks/code/plugins/settings/etc to fix this? `/archive/456857` does get a 301 to `/blog-test` but `/archive/456857` does not and ends up in two separate URLs to the same content. My permalink structure is `/archive/%post_id%`.


Need help cleaning up a wordpress site after being hacked

_Off Topic? Maybe, point me to where this would be On Topic!_ Hi All, My daughter attends a private school. Recently their wordpress website was hacked and they need some help cleaning it up. I don't have the experience with wordpress to help. Are there services or websites that they could use to find the expertise to help with this? Of course they would be compensated. Here is a description of the problem: Thanks! -DF5 > Thank you for getting back to me. We are trying to detect any possible back > door vulnerabilities in our Wordpress installation that may be allowing > scripts or bots to place malicious code on our website. We have been hit by > a specific drug company. This code seems to turn up in our pHp files. The > original problem was that people who clicked twice on any page of our site > were redirected to this drug website!! > > We have cleaned the installation manually, but there may still be scripts > running in the database or remaining vulnerabilities because we did not want > a re-installation of a clean version of Wordpress. We have scanned the > database and there appear to be no known rogue files, but we are concerned > that there may still be scripts running that are very well hidden. We > basically need someone to start by looking through our files to see if there > is something we and the scan missed. > > There is a lot of customization we did on our website and are trying to > avoid a clean install. We are also in contact with Dream Host (our hosting > company) to see if it is a server issue as we are uncertain if this is a > Wordpress vulnerability via a plugin or a server issue that Dream Host can > resolve. > > The website seems to be functioning well now, we are mainly trying to > prevent another problem and to eradicate any malicious code so we are not > penalized in the search engines.


Can anyone recommend a wordpress based CRM/Project Management system or plugin?

Hello I am wandering if anyone can recommend, from first hand experience, a reasonably simple CRM or project management plugin for wordpress. I have read this question on the topic. But am looking for slightly more detail and if possible someone who has actually used one of these. The functionality I am looking for is to be able to store contacts, share files, have a forum/message board or even chat type area and some simple task/project management functions such as assigning cases to team members. One more thing, if possible users should be able to select their preferred language, preferably at least with English and Simplified Chinese, although I accept this may not be possible or may require manual translation. I have used both sugarcrm and vtiger, but have found that them to be a bit bloated and was wondering if any of the wordpress option available would be suitable for our needs. Thanks.


if statement on database query

Part of a voting script I'm working on: I'm checking a custom table in my WP database to see if a user already voted for a post by checking the IP address and the post id. If the user's IP already exists for the post they voted, I want to echo "Already voted!" otherwise add the IP. This is what I came up with..               global $wpdb;     $voter_ip = $_SERVER['REMOTE_ADDR'];      $post_id = $_POST['post_id'];          if (!($wpdb->get_row("SELECT voter_ip FROM wp_voter_ips WHERE post_id = $post_id AND voter_ip = $voter_ip") ) ) { //if IP address for matching post id not found in wp_voter_ips table     $wpdb->insert( $wpdb->prefix . 'voter_ips', array( 'post_id' => $post_id, 'voter_ip' => $voter_ip ) ); //add IP and post_id     echo "voted!";     }     else //if IP already exists     {     echo "Already voted!";     }      I triple checked to make sure the variables and column names are correct. Regardless of the if statement, it inserts the voters IP even when it already exists.


Grouping related postmeta data via SQL query

I am using someone else's WP plugin which stores lots of related data in `wp_postmeta` using an "artificial key". So effectively we hijack `wp_postmeta` to create a nested relational database. So one row will have                meta_id = 999        post_id = 130        meta_key = 'event_id'        meta_value = '19'        Then 4 other actual wp_postmeta rows that share that post_id contain the rest of the information for that virtual "row" of data. For example                meta_id = 989      post_id = 130      meta_key = 'Name'      meta_value = 'Fred'      And we will have lots of "virtual rows" (hundreds) that all share that `event_id` of 19 (and of course lots of others with different `event_id`s of their own. I have tried many SQL queries, but I am stumped. How can I get a table that has grouped info for a common event_id? It doesn't have to have _all_ the data, just one piece, such as the 'Name' field. I tried a subquery like this:               SELECT meta_value from wp_postmeta      WHERE meta_key='name' AND      post_id IN      (SELECT post_id FROM wp_postmeta      WHERE meta_key='event_id' AND meta_value='19');      That probably looks laughably stupid - it also doesn't work. I also tried JOIN. This seems like something that would come up a lot in WP coding, but I have searched and come up pretty much empty.


How to place an image after Nth number of posts in query_posts

I am using the following code to print out the last 8 published post in columns of 3 so 3 column and 3 rows :               <?php       $args = array(                    'post_type' => 'post',                    'posts_per_page' => 8,                    'paged' => ( get_query_var('paged') ? get_query_var('paged') : 1)                    );       query_posts($args);       $x = 0;       while (have_posts()) : the_post(); ?>                  <?php if($x == 2) { ?>
         <?php } else { ?>
         <?php } ?>           <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('featured-home-portfolio'); ?>           <a href="<?php the_permalink(); ?>">
<?php the_title(); ?>
           <?php the_excerpt(); ?>
                <?php if($x == 2) { echo '

'; $x = -1; } ?>            <?php $x++; ?>       <?php endwhile; ?>       <?php wp_reset_query(); ?>       now I want to place an image after 5th post . which is row 2 column 3. I modified this code for so many times but I can not get that image to show up after post 5 only. I added this :               <?php if($x == 2) { ?>
         <?php } elseif($x == 5) { ?>      // image      <?php } else { ?>      but does not work . I really appreciate if someone help me to figure out this. thanks


How can I locate the single buddypress forum post template?

I have been trying for ages to locate the template that shows a single forum post template and I cannot find it. Does anyone know where this is located? Thanks


Why isn't my rewrite rule working when there is no second parameter?

Here is my rewrite rule code:               add_rewrite_rule('tides/([^/]+)/([^/]*)', 'index.php?page_id=4348&location=$matches[1]&month=$matches[2]', 'top');     add_rewrite_tag('%location%', '([^&]+)');     add_rewrite_tag('%month%', '([^&]*)');      This works great for the following URL:               /tides/mylocation/mymonth/      but 404's on the following:               /tides/mylocation/      I'm flushing the rewrite rules every time I change the code. I tried changing `*` to `+` but no help there. Any ideas? **Edit:** Some answers were suggesting adding another rewrite rule so I added:               add_rewrite_rule('tides/([^/]+)/$', 'index.php?page_id=4348&location=$matches[1]', 'top');      before my other rule, but still no luck.


I'm running into issues on my localhost where when I navigate to my registration page I get the following error message _User registration is currently not allowed._ What I've tried so far:   1. I've checked my settings menu under `wp-admin/network/site-settings.php?id=1` and under _Users can register_ I have a `1` entered.   2. I've tried turning my plugins on and off.   3. I've checked `wp-admin/admin.php?page=bp-page-settings` and all necessary pages exist and are listed.   4. I've tried echoing `wp_register('','',false);` to see if that lends any clues and it just turns up blank. This isn't the case on my other server (which I had thought was configured identically to my localhost). Registration is allowed and the echo above provides the link. No idea what's going on here and am working against a deadline (aren't we all, right?) so any ideas would be greatly appreciated.


Plugin allowing for artists, events and venues

I'm working on a music festival website and up until now have used WordTour. I really like WordTour's artists > events > venues content hierarchy, but am having difficulties transitioning from last year's festival to this year's. Ultimately, I'm finding I may need to move on to something else. I need to ultimately do two things: a. Create a listing for each artist playing at the festival b. Assign each artist timeslots at the festival's three stages. Some artists play more than one stage. With WordTour, I did this by assigning an Artist to an Event (i.e., a specific time), which was then assigned a Venue (i.e., a specific stage). ## Is there any way I could do something similar to WordTour with custom post types? If so, any suggestions how? It seems like I could create a custom post type — Artists — which would have a meta box allowing me to pick multiple timeslots (how, I'm not at all sure) and a custom taxonomy for festival year. I could create a second post type for Stages, but how would I reference the second post type from the hypothetical date picker meta box? Any help at all with this would be very much appreciated. Many thanks!


Cache previous versions of website?

I'm working on a new site for a charity. They publish a printed magazine & we would like the website to always reflect the current issue of the magazine. So far I have a front page (home page) with excerpts from 3 most recent lead articles (wp posts). For layout purposes, the articles are categorized as frontpage-left, frontpage-right-top & frontpage-right-bottom. We also have a sidebar with a menu to all the articles in the current issue (posts list). Now looking for advice on the best way to store old/previous "issues" of the website as a complete, working archive so visitors can view them?


Pagination: /tags/tag_name/?paged=2 gives a 404 error

I need to paginate an archive page. Pagination works perfectly fine for everything except tag/category archives. Basically if I use /tags/tag_name/?paged=2 it gives me a 404 error. But if I use /tags/tag_name/?page=2 it works fine. Unfortunately I need to use /tags/tag_name/?paged=2 I reckon it has to do with rewriting. These are the existing rules WP has:               tags/([^/]+)/page/?([0-9]{1,})/?$   index.php?tag=$matches[1]&paged=$matches[2] post_tag     tags/([^/]+)/?$ index.php?tag=$matches[1]   post_tag      I have tried all the combinations of rewrite rules I could think of to make /tags/tag_name/?paged=2 work. No success. How can I make it work? === What I found out it is only ?paged=2 that gives me trouble. /tags/tag_name/?abc=2 doesn't give a 404. Makes no sense to me. === ok, so what I decided to do is unset $_GET['paged'] in functions.php and set it's value back in header.php. Then I changed all the code to avoid using WP's get_query_var. Works for now.


Tag Posts showing in wrong places

Am using a custom template (tag.php) to show posts related to tag. So when someone clicks on say tag ‘A’ then he/she gets redirected to my tag.php layout instead of default template for archives. I did this by making a tag.pho in my child theme. Now the problem is some of my posts are marked with multiple tags. for example - Tag ‘A’ – 15 posts Tag ‘B’ – 5 posts Tag ‘A’ & ‘B’ – 20 posts. Now when someone clicks on Tag ‘A’ from sidebar tag list, then it gets the list of 15 posts which is right. But when someone clicks on Tag ‘B’ then also the user gets the list of same 15 posts. The problem do not ends here, am also using ‘paged’ option, so when user (while seing Tag ‘A’ posts) clicks on next page, then it is shown as blank. But when user sees posts of Tag ‘B’ then also there is pagination visible (but it should not be because there are only 5 posts) and when user clicks next page, then it shows 404 error. Here is the code -               <?php           function uttt_custom_loop()       {         global $post;         $tags = wp_get_post_tags($post->ID);         $first_tag = $tags[0]->term_id;         // arguments, adjust as needed         $args = array(             'post_type'      => 'post',             'tag__in' => array($first_tag),             'post_status'    => 'publish',             'paged'          => get_query_var( 'paged' )         );              global $wp_query;         $wp_query = new WP_Query( $args );             $cnt=1;         if ( have_posts() ) : while ( have_posts() ) : the_post();          ?>             <div id="post_page_grid" style="<?php echo (isset($cnt) && $cnt==7)?'clear:both':'';?>">                  <?php $link_to_pic = post_custom('restro-pic'); ?>

                             <?php                             if ($link_to_pic !='')                              { ?>                                 <img src="<?php echo $link_to_pic; ?>" alt="restaurant-pic"/>                                 <?php                              }                              else if ($link_to_pic =='')                                  { ?>                                  <?php                                  } ?>

                             <?php echo do_shortcode('[starrater tpl=10 read_only=1]'); ?>

                         <a href="<?php the_permalink(); ?>"><?php the_title(); ?>                         <?php the_excerpt(); ?>

              <?php     $cnt=$cnt+1;         endwhile;             do_action( 'genesis_after_endwhile' );         endif;         wp_reset_postdata();     }     remove_action( 'genesis_loop', 'genesis_do_loop' );     add_action( 'genesis_loop', 'uttt_custom_loop' );          genesis();


Display Custom Taxonomy in Sidebar in Two Columns

I have a custom post type (photos) with a custom taxonomy (categories) and I'd like to display the taxonomy list in my sidebar in two columns. I have a modified snippet that I found elsewhere to do this, but it doesn't generate the current class for the particular category it is on. Maybe it is not the best way to list the taxonomy to begin with, so I hope someone will suggest a better solution. Here's what I have now:               <?php $term = get_term_by( 'name', 'categories', 'photos' );           $cat_term_id = $term->term_id;          $cats = explode("
",wp_list_categories("title_li=&echo=0&child_of=$cat_term_id&depth=1&style=none&taxonomy=categories"));     $cat_n = count($cats) - 1;     for ($i=0;$i<$cat_n;$i++):     if ($i<$cat_n/2):     $cat_left = $cat_left.'
'.$cats[$i].'
';     elseif ($i>=$cat_n/2):     $cat_right = $cat_right.'
'.$cats[$i].'
';     endif;     endfor;     ?>
     <?php echo $cat_left;?>

     <?php echo $cat_right;?>
      Thanks!


Single post - display list of all posts + specific post

my single post looks like that: http://pastebin.com/KdEbs82P I want to display on single post two things:   * list of ALL posts in general   * single post title    * content What I achieved right now is not satisfing because I AM displaying all posts (and it works ok) but the second part (connected with showing only specific post title and content) don't work. By don't work I mean - it shows only the newest one;/ So giving it into real example: I have 2 posts called "News about IT" and "TV series". Post about TV is the newest one. After clicking on News about IT i will see all posts in the top and as a main part - title and content of NEWS ABOUT IT. Right now using my solution it shows TV series as a newest post.. how to achieve my solution?


Load js/css files only on specific admin UI pages

How do I adapt this solution to work with my plugin? (Please see the link). I enqueue my css and js script as follows:               function my_plugin_init() {      wp_enqueue_script('my_plugin_script', plugins_url('js/the_filepath.js', __FILE__), array('jquery'));      wp_enqueue_style( 'my_plugin_css', plugins_url( '/css/the_filepath.css', __FILE__ ) );     }          add_action('init', 'my_plugin_init');      I tried putting this in the theme's functions.php, but it didn't work:               function remove_my_plugin_extras() {         remove_action('init', 'my_plugin_init');     }          if( !is_page('My_Page') ) {         add_action('wp_head', 'remove_my_plugin_extras');     }      The script and css still loaded. How do I adapt the solution in this case?


How to display sorted posts in the 'All Posts' page

I've been following this tutorial to build a sorting page for my posts: http://soulsizzle.com/jquery/create-an-ajax-sorter-for-wordpress-custom-post- types/ The sorting works fine, but the new sorting is not reflected back in the 'All Posts' section under 'Posts', it only displays sorted under the 'Sort Posts' submenu created by this code in the tutorial. How would I extend this further to also sort the posts correctly under 'All Posts', as it is a bit confusing for the user as it is? Also, does anybody know why there is no functionality for sorting, especially for pages and custom post types (I can imagine posts being more date- oriented), built into the WP Core?


Permalinks: custom post type -> custom taxonomy -> post

I am having trouble working with wordpress' rewrite rules, and could use some help. I have a custom post type called _shows_. All _shows_ have a single custom taxonomy category _show-category_. A _show_ will never have more than one _show-category_. I would like my urls to route in this manner: www.mysite.com/shows/ => archive-shows.php www.mysite.com/shows/%category%/ => taxonomy-show-category.php www.mysite.com/shows/%category%/%postname%/ => single-shows.php So as a real world example, lets say we have a _show-category_ "Foo" and a _show_ post titled "Bar" that has "Foo" as it's _show-category_. I would expect my wordpress app to look like this: www.mysite.com/shows/foo/ => shows all posts under the foo category www.mysite.com/shows/foo/bar => shows the indivual post I try to avoid plugins when possible, but am open to any solution. Thanks.


Translation for plugin

I modified a .po file, basically I opened as txt file and made the changes, however I uploaded it and is changes are not working. I wonder if I need an special software for doing and generate a new .mo each time I make a change, or what am I missing? Thank in advanced


How to prefill the username/password fields on the login page

For a demo environment, I would like to pre-fill the username and password fields of the wp-login form with respectively "demo" and "demo" string. Thus users will just need to click on the "Log-in" button to connect to the admin area. There is a way to do that ? Maybe with a hook ? Thanks for your advises


How to add .htaccess code through a function?

I need to add the following .htaccess code through a function                   <IfModule mod_deflate.c>     # Insert filters     AddOutputFilterByType DEFLATE text/plain     AddOutputFilterByType DEFLATE text/html     AddOutputFilterByType DEFLATE text/xml     AddOutputFilterByType DEFLATE text/css     AddOutputFilterByType DEFLATE application/xml     AddOutputFilterByType DEFLATE application/xhtml+xml     AddOutputFilterByType DEFLATE application/rss+xml     AddOutputFilterByType DEFLATE application/javascript     AddOutputFilterByType DEFLATE application/x-javascript     AddOutputFilterByType DEFLATE application/x-httpd-php     AddOutputFilterByType DEFLATE application/x-httpd-fastphp     AddOutputFilterByType DEFLATE image/svg+xml          # Drop problematic browsers     BrowserMatch ^Mozilla/4 gzip-only-text/html     BrowserMatch ^Mozilla/4\.0[678] no-gzip     BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html          # Make sure proxies don't deliver the wrong content     Header append Vary User-Agent env=!dont-vary     </IfModule>          ## Expires Caching ##          <IfModule mod_expires.c>     ExpiresActive On     ExpiresByType image/jpg "access 2 week"     ExpiresByType image/jpeg "access 2 week"     ExpiresByType image/gif "access 2 week"     ExpiresByType image/png "access 2 week"     ExpiresByType text/css "access 2 week"     ExpiresByType application/pdf "access 2 week"     ExpiresByType text/x-javascript "access 2 week"     ExpiresByType application/x-shockwave-flash "access 2 week"     ExpiresByType image/x-icon "access 2 week"     ExpiresDefault "access 2 week"     </IfModule>          ## Expires Caching ##       In my themes function.php               function add_htaccess     {     //the above code to add     }      I just don't want to add it manually.


Gettext for custom field checkbox values

I have a custom field (created with ACF) that allows the author to choose from several options (in admin) and where these choices are displayed on the front- end. The code producing the custom field is :               array (     'key' => 'field_52dcf154e272e',     'label' => __('Selling Points', 'mytheme' ),     'name' => 'selling_points',     'type' => 'checkbox',     'instructions' => __('Check 4 items', 'mytheme' ),     'choices' => array (         'Bed linens included key' => __('Bed linens included value', 'mytheme'),         'Full bed linens included' =>__('Full bed linens included', 'mytheme'),         'Free WIFI and Internet Access' => __('Free WIFI and Internet Access', 'mytheme' ),         'Free (in-room) WIFI' =>__('Free (in-room) WIFI', 'mytheme' ),          'Breakfast included' => __('Breakfast included', 'mytheme' ),         'Safe provided in room' => __('Safe provided in room', 'mytheme' ),         'Individual room key' => __('Individual room key', 'mytheme' ),         ),     'layout' => 'vertical',     ),      The problem is that the value is displayed in the admin choices and the key is currently displayed on the front-end. In teh page template I have the following code:               $count= 0;     $points = get_field_object('selling_points');          foreach ( $points['value'] as $point ){         if($count < 4 ){             printf(__('
%s
', 'mytheme' ), $point);             $count++;         }     }      when I `var_dump($points)` I get:               Array     (         [key] => field_52dcf154e272e         [label] => Selling Points         [name] => selling_points         [_name] => selling_points         [type] => checkbox         [order_no] => 1         [instructions] => Check 4 items         [required] => 0         [id] => acf-field-selling_points         [class] => checkbox         [conditional_logic] => Array             (                 [status] => 0                 [allorany] => all                 [rules] => 0             )              [choices] => Array             (                 [Bed linens included key:] => Bed linens included value                 [Full bed linens included] => Full bed linens included                 [Free WIFI and Internet Access] => Free WIFI and Internet Access                 [Free (in-room) WIFI] => Free (in-room) WIFI                 [Breakfast included] => Breakfast included                 [Safe provided in room] => Safe provided in room                 [Individual room key] => Individual room key             )              [layout] => vertical         [default_value] =>          [value] => Array             (                 [0] => Bed linens included key:                 [1] => Free WIFI and Internet Access                 [2] => Petit déjeuner inclus                 [3] => Safe provided in room             )          )      So apparently AFC is getting the value based on the key. How can I then take the values in the array `[value]` and convert them into a gettext calls?


Make taxonomy terms appear in the order they were made

IS it possible to make taxonomy terms appear in the order they were made, in the backend? They keep appearing in alphabetical order. I tried using `sort` but it doesn't seem to be working. This is my code for creating custom taxonomies:               $taxonomies['size'] = array(                 'hierarchical' => true,                 'query_var' => 'size',                 'sort' => true,                 'rewrite' => array(                     'slug' => 'size',                 ),                 'labels' => array(                     'name' => 'Size',                     'singular_name' => 'Size',                     'update_item' => 'Update Color',                     'edit_item' => 'Edit Size',                     'add_new_item' => 'Add Size',                     'new_item_name' => 'Add New Size',                     'all_items' => 'All Sizes',                     'search_items' => 'Search Sizes',                     'popular_items' => 'Popular Sizes',                     'popular_items_with_comments' => 'Separate sizes with commas',                     'add_or_remove_items' => 'Add or remove sizes',                     'choose_from_most_used' => 'Choose from most used sizes'                 )             );


Pulling Twitter RSS feed not working as expected (fatal error)

I'm trying to get some of the latest posts from a Twitter account, without a plugin. According to Botcrawl.com's tutorial, this should be enough:
     <?php     include_once(ABSPATH . WPINC . '/feed.php');     $rss = fetch_feed('https://api.twitter.com/1/statuses/user_timeline.rss?screen_name=BarackObama');     $maxitems = $rss->get_item_quantity(4);     $rss_items = $rss->get_items(0, $maxitems);     ?>
     <?php if ($maxitems == 0) echo '
No items.
';     else     // Loop through each feed item and display each item as a hyperlink.     foreach ( $rss_items as $item ) : ?>
     <a href='<?php echo $item->get_permalink(); ?>'>     <?php echo $item->get_title(); ?>
     <?php endforeach; ?>
      However, I get the following error:               Fatal error: Call to undefined method WP_Error::get_item_quantity() in /Users/username/Desktop/journal_wp/wp-content/themes/Journal_theme/index.php on line 155      Has anyone had any experience with this, and know _why_ it is calling a fatal error?


XML-RPC Response from server does not contain valid XML

I have previously succeeded in making 200 post via XMLRPC, but strangely 3 days ago I got the error message "Response from server does not contain a valid XML". I've been looking for solutions of various site for 3 days but no result. I was reinstalling my wordpress site and the problem is still same. I think my code is right because I'm using it for 1 month. I used vb.net to post, see below:                   Public Structure category         Public categoryId As Object         Public parentId As Object         Public description As Object         Public categoryName As Object         Public htmlUrl As Object         Public rssUrl As Object     End Structure     <XmlRpcUrl("http://nullgames.com/xmlrpc.php")> _        Public Interface IWP         Inherits IXmlRpcProxy              <XmlRpcMethod("wp.getCategories")> _         Function getCategories(ByVal args() As String) As category()     End Interface     Public Structure blogInfo              Public title As String         Public description As String         Public mt_keywords As String()         Public categories As String()          End Structure              Public Interface IgetCatList             <CookComputing.XmlRpc.XmlRpcMethod("metaWeblog.newPost")> _             Function NewPage(ByVal blogId As Integer, ByVal strUserName As String, ByVal strPassword As String, ByVal content As blogInfo, ByVal publish As Integer) As String         End Interface          Sub SendPost(ByVal titlepost_ As String, ByVal bodypost_ As String, ByVal categorypost_ As String)         Dim proxy As IWP = XmlRpcProxyGen.Create(Of IWP)()         Dim args() As String = {"http://nullgames.com", "Admin", "xxxxxxxxx"}          Dim categories2() As category         categories2 = proxy.getCategories(args)         For Each category In categories2             Debug.Print(category.categoryId)             Debug.Print(category.categoryName)             Debug.Print(category.description)             Debug.Print(category.htmlUrl)             Debug.Print(category.rssUrl)         Next         Dim result As String = Nothing         Dim newBlogPost As blogInfo = Nothing         Dim categories = CType(XmlRpcProxyGen.Create(GetType(IgetCatList)), IgetCatList)         Dim clientProtocol = CType(categories, XmlRpcClientProtocol)         clientProtocol.Url = "http://nullgames.com/xmlrpc.php"              newBlogPost.title = titlepost_         newBlogPost.description = bodypost_         newBlogPost.mt_keywords = New String() {p_tags}         newBlogPost.categories = New String() {categorypost_}         result = ""         Try             result = categories.NewPage(1, "Admin", "xxxxxxxxx", newBlogPost, 1)             idPost = result         Catch ex As Exception             MessageBox.Show(ex.Message)          End Try     End Sub      When I use the same code to post via xmlrpc in my other wordpress site, it works... Any Idea?


Make posts automatically from an Online XML file through wp cron job

I want to import posts from a RSS feed using the WP Cron API. Here is the link to the XML Feed. I activated different Feed Aggregator wordpress plugin but it gives error.               Problem:     FeedWordPress encountered the following error when trying to retrieve this feed:     A feed could not be found at http://www.propspace.com/feed/xml.php?cl=1371&pid=8245&acc=8807. This does not appear to be a valid RSS or Atom feed.     If you think this is a temporary problem, you can still force FeedWordPress to add the subscription. FeedWordPress will not be able to find any syndicated posts until this problem is resolved.      A guy told me to write a php code to update the values in MySQL and then call in WP. I have no clue with this.


Multiple Categories under one URL, where 'Front Page' is used already

I couldn't find an answer relating to this, maybe I just didn't come across it yet. So the setup of the site I am working on at the moment: The Front Page is not set, is default. I can't change this because of the way the template functions, it would be too much work for me to change it. The site already has categories setup, but none are called 'Blog'. The client wants there now to be a 'Blog' category which see can assign posts to as her personal 'Blog' - away from the rest of the site's categories. The thing is she also wants to have a number of other categories' posts show up when navigating to that '/blog/ URL. How would I go about doing this?   1. Would I duplicate the existing 'archive.php' file and make modifications, and somehow point the /blog/ URL to it?    2. Do I have to modify the 'archive.php' file to pick up the URL and modify the query?   3. Create a filter/action for his purpose. The page would display like any other archive, as in posts are listed in date order back. **Note:** I can't move the existing categories, they must stay where they are. I'm wondering by doing this at all will it have repercussions i.e. will it cause other issues? Thanks for your time, much appreciated.


How to get postname in custom page?

I'm adding custom pages in WordPress and trying to handle WordPress with my own CMS. I'm using all WordPress' hooks to manage all these things. Now, I can make a custom post saying "a new album" but I don't know how to give a post name to it. The database entry of `post_name` in the `wp_posts` table remains blank now as I don't know what to put there.


WP-e-commerce (getshopped) - Annoying permalink issue

i’m using wp-ecommerce (getshopped) and WPML on a website, all pages display correctly when i use the default (/ugly…) permalink structure, but when i try to use the much desired permalink structure /%category%/%postname%/ something weird happens:   1. product categories list page displays the homepage   2. single category and single product pages show the main blog page (list of post) This prevents me from using my desired permalink structure, which is a major issue for me. I tried updating WPEC to the latest beta version (didn’t help) and i tried switching to twenty ten to see if the problem is related to my theme (and it isn’t) Questions: 1. Could this be related to the fact that i use hebrew words in my slugs? 2. Is there any known issues related to WPEC and permalinks that i should be aware of? 3. Can anyone point out the solution? Thanks in advance


How to get WordPress term attached to the Post?

How to retrieve all WordPress terms attached to the Post and Other Post type? Assumed I don't know/don't care about the taxonomy, term name/term id etc, the only thing I know is post_id. Thank you.


Custom Post type - how to get checkbox to update meta field to null

I have 7 meta fields for a custom post type in Wordpress. These 7 in particular are days of the week (Sunday thru Saturday) and have checkboxes for each. I've successfully gotten the checkbox to POST when the value is "On", however when I return to the edit page and try to deselect, the value stays the same in the database. Here is what I have for each item input:
<input type="checkbox" name="sunday" <?php if( $meta_sunday == true ) { ?>checked="checked"<?php } ?>" /> Sunday

      And my update lines:               if(!isset($_POST["sunday"])):         return $post;         endif;         update_post_meta($post->ID, "sunday", $_POST["sunday"] );


Rich Custom Field for Custom Post type not saving

I am new to creating meta boxes and I am trying to create a custom field meta box that is connected to a custom post type which is created by WooTheme Sensei (Post type = lesson). I am trying to use wp_editor, but the issue is I can't seem to get the field to save. I have checked many similar questions here and Google a lot, trying different solutions but nothing seems to work, I must be missing something! These are the 3 functions I am using, I tried to turn debugging on but nothing seems to stand out. Any help is appreciated!               add_action( 'add_meta_boxes', 'add_educadme_related_resources_metabox' );     add_action('save_post', 'save_educadme_related_resources', 10, 2);          // Add the Custom Fields Meta Boxe     function add_educadme_related_resources_metabox() {         add_meta_box('educadme_related_resources', 'Related Resources', 'display_educadme_related_resources', 'lesson', 'normal', 'high');     }               // The Custom Fields Meta Metabox     function display_educadme_related_resources() {         global $post;         // Get the resources data if its already been entered         $educadme_resources = get_post_meta($post->ID, 'Related_Resources', true);         wp_editor( $educadme_resources, 'related-editor', array( 'textarea_name' => 'related_resources', 'media_buttons' => false ));     }          function save_educadme_related_resources(){         // Is the user allowed to edit the post or page?         global $post;         if ( !current_user_can( 'edit_post', $post->ID ))             return;         // check autosave         if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {             return;         }         // OK, authenticated: we need to find and save the data         update_post_meta($post->ID, "Related_Resources", $_POST["Related_Resources"]);          }


Multisite: use media from one site vs. copying the same media to all language sites?

This is a business site with product images. I have a multisite installation with 3 languages in 3 directories which will later be mapped to completely separate domains by the host when it's finished. The media (EDIT: in one of the sites) currently consists almost completely of large images (EDIT: total 1.8GB) that are not language-dependent, and editors will need to add the same images when creating pages with the texts in their language. However, their media library is currently empty. Do you recommend the language sites somehow using media from just one of the sites since the content is virtually identical, or do you recommend copying the same media to all the language sites? I have languages as separate sites because they will differ in structure, but they will use the same images. If you recommend using one site's media library, how is it achieved? Network Shared Media plugin doesn't work for me because its tab doesn't appear for the Add Image button of a plugin that I must use. If you recommend copying images, can you recommend the most efficient way of doing this that won't cause a PHP timeout?


Developing a Wordpress plugin like a component in Joomla

My mission:   I have a system that could have been a standalone website, but I would like to be a part of an existing CMS so that I can avoid writing my own user management system, forum, blog system, etc. I could have made it as a component in Joomla! as I have been working with that before, but unfortunately I do not like Joomla! and have therefore chosen Wordpress. My problem:   My system should both have admin pages and front end pages available inside my Wordpress page. I have been able to create a plug-in and add admin pages, but I have yet to find out how to make the front end. One solution could be to create a page-template in my chosen theme, but as I want to seperate my component from Wordpress as much as possible, and also want it to be theme- independent this is a bad solution. How can you help:   Please provide me with a simple example or guide me towards either a tutorials or an existing Wordpress plug-ins for me to look at to be able to make my plug-in. Bear in mind that this plug-in should only be used on my page and that I only want to use Wordpress as a shell for the plug-in.


jquery conflict with widget page

I'm trying to create a widget plugin that uses a jQuery code to show/hide divs in the widget form based on the selected option of a select drop menu. The jQuery code I'm trying to implement is working fine everywhere else, but in the widgets page it makes the widgets not working (not expandable or dragable). This is my code on jsfiddle: http://jsfiddle.net/fj63g/111/ /* update */ The full plugin code can be found here: http://jsfiddle.net/qNc62/


Collaborate on wordpress local website, share files via dropbox?

How can one share and sync files of a WordPress website with users that can edit (collaborate on) the website locally on their own instance? Can Dropbox be used to share the WordPress website files and database data? If so which directories should be shared? Or should one use a Distributed version control system like Mercurial to do this? I think if the files are shared than there will be a copy of WordPress database files for each user. The website is under local development and is not hosted with WordPress . Can multiple user accounts be used on the shared WordPress files or just a single user account is allowed to edit the WordPress website? Also what about plugins, can they be shared with its contents for a WordPress website?


Is there any way I can get the search results to a variable in search.php file? Now I have the following code in my search.php file.               <?php if (have_posts()) : ?>
<?php _e( 'Search Results', 'buddypress' ) ?>
             <?php while (have_posts()) : the_post(); ?>             ......      I know the while loop uses some variable that contains the search results. Now I want to use this variable before the loop. I need this variable to do some processing before displaying the results.


How to validate a user from ouside wordpress/php?

I'm working on an ajax application that will be embedded in a wordpress page. The ajax app exchanges data with servlets running on tomcat. Now the servlets need a way to determine if a request comes from a user that is logged in to wordpress. And if the user is logged in, the servlets also must be able to determine the users id in order to be able to query the database. If the user is not logged it, the request will be denied. So in other words, I need to let a servlet perform a request only if the user who caused the request is logged in to wordpress (version 3.3.x). Both, the servlet (tomcat) and wordpress (apache2) run on the same physical machine and share the same database. In theory this could easily be solved by doing the following:   1. During wordpress logon, some user token gets stored in a javascript variable.   2. The ajax app forwards the user token to the servlets on every call.   3. The servlets use the token to query wordpress if it is valid (i.e. if the user is logged in) and perform or deny the request. The question is how can this be implemented on the wordpress side?   Because, what makes the theory so complicated is the fact that i have not yet done any php programming. First I was thinking of transmitting the wordpress_logged_in (auth) cookie to the servlet and let the servlet query wordpress if the auth cookie is still valid. But as it seems, this can't be done, as wp_validate_auth_cookie() always fails, even if cookie-data of a logged on user is passed. An other solution could be to develop a plugin that stores the sessionid and userid in a table, which could easily be queried by the servlets. Or maybe there's an other solution...


help with rewrite_tag and rewrite_rule for custom page GET variables

> **Possible Duplicate:**   >  custom htaccess rewrite rule for page ok i made another post and i got pointed to the Rewrite API however, when i do print_r($_GET) on the page, it echos an empty array heres my code in my themes function.php file using the Rewrite API:               function add_video_rewrite() {         add_rewrite_tag("%video_id%", '([^/]*)');         add_rewrite_tag("%video_src%", '([^/]*)');         add_rewrite_tag("%video_title%", '([^/]*)');         add_rewrite_rule('^video/([^/]*)/([^/]*)/([^/]*)', 'video/?video_id=$matches[1]&video_src=$matches[2]&video_title=$matches[3]', 'bottom');     }     add_action( 'init', 'add_video_rewrite' );      im trying to get this to work for an url like this: mysite.com/video/102230/MTAyMjMw/FC+Emmen+v+AGOVV+ApeldoornAyMjEx/ but when i visit that URL, my GET variables are coming up empty it works perfect when i visit this url: mysite.com/video/?video_id=102230&video_title=FC+Emmen+v+AGOVV+Apeldoorn&video_src=MTAyMjMw


Post editor loads empty

I am running WordPress 3.8 and I recently switched server, so didn't realize when the problem creep in but most likely its the server change and I need some help figuring it out. When I open post edit screen, the editor is empty. Switching context in Visual / Text happens but as if the editor is totally empty. There are no JS errors either. ![enter image description here](http://i.stack.imgur.com/gVhkE.png) Two things that I see happening: 1) The edit page screen always show this message when moving away from it or closing it, as if there is some pending request awaiting completion. ![enter image description here](http://i.stack.imgur.com/AHuXy.png) 2) There are weird characters in a post output now. This is happening for a lot of posts. ![enter image description here](http://i.stack.imgur.com/HIuaZ.png) If I dump the post content using `get_post()`, its shows up fine without any weird characters. Also if I dump the database and import on my local, everything works just fine. So I think there is some issue with the server only, perhaps a charset encoding issue? Ruled out any plugin causing it by disabling all plugins. Also not sure if its related, but there was some issue with concatenation of scripts and I had to add `define('CONCATENATE_SCRIPTS', false );` to make scripts load correctly. I am not sure where to look. Any ideas?


Migrating site, only header shows

I have copied my file structure to a new server, and exported the relevant tables to an SQL file. I have imported the tables to the new database. When I visit the new URL, only the header of the site is showing. If I log in I can see all pages and posts. I have tried turning php error reporting on in `wp-config.php` and `php.ini`, but nothing shows up when visiting the pages. Any idea what could be wrong or how to troubleshoot this? This is the latest error in the site log:               2012/11/01 23:17:06 [error] 23354#0: *309 FastCGI sent in stderr: "PHP Fatal error:  Call to undefined function dropdown_menu() in /home/nginx/domains/haz-ed.com.au/public/wordpress/wp-content/themes/uber/header.php on line 63" while reading upstream, client: 220.233.123.171, server: haz-ed.com.au, request: "GET /wordpress/ HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "haz-ed.com.au"      Could that be the source of the problem? What would cause this function to not be found?


Convert this relative path to absolute

In the .js script below, the ajaxPath reference breaks when the containing page is off the root directory of the site. Is there a workaround to make this path absolute?               jQuery(document).ready(function($){         initContentEditable();              var dir = ContentEditableSettings.content_editable_url;         var ajaxPath = 'wp-admin/admin-ajax.php'; //THIS RELATIVE PATH BREAKS OUTSIDE ROOT DIRECTORY              function initContentEditable(){                              $('.contenteditable.furniture').blur(updateContentEditable);             $('.contenteditable.custom').blur(updateContentEditableCustom);             $('.contenteditable.title').blur(updateContentEditableTitle);             $('.contenteditable').each(function(){                 var parent = $(this).parent();                 var display = parent.css('display');                 $(this).css('display', display);             });         }                 function updateContentEditableTitle(e){             e.preventDefault();             var span = $(this);             var data = new Object();             data.pid = span.attr('data-pid');             data.title = span.find('.saver').text();             data.action = 'ce_update_title';             data.security = ContentEditableSettings.nonce;             $.post(ajaxPath, data, onContentSaved); //AJAXPATH BREAKS AS RELATIVE REF         }


Why would changing a child theme to a normal theme pass a Template is missing. error

I have what used to be a child theme but I added to it to the point where its a theme on its own. I pulled out the Template line in the style.css and now I get the: This theme is broken. Template is missing. error. Why is this happening?


How to reduce the number of queries?

I have meta key "Due" for posts....if a post has expired (past the current date or not equal to it) then it will not be displayed in the count. This is my code, which works perfectly. My only problem is that it creates over 100 queries. Is there any way to reduce this number? I am not sure how to optimize it....               /**      * Function to list all category with thumbnail custom link, etc..      *      * How to use this function:      * Add in template: <?php my_category_list(); ?>      *      */     function my_category_list(){          /* LIST OF CATS DATA */     $cats_data = array();          /**      * Get Categories      * @link http://codex.wordpress.org/Function_Reference/get_categories      */     $cat_args = array(         'hide_empty'    => 0,         'exclude'       => '13,1,1460'     );     $categories = get_categories( $cat_args );          /* If category found, load list of category */     if ( !empty( $categories ) ) {         $i = 0;              /* Foreach category: display the data */         foreach ( $categories as $cat) {                  /* ======= HTML CLASS ========= */             /* dynamic class (?) need fix */             $class = ( $i % 3 ) ? 'span4' : 'span4';             $classes = $class . ' ' . 'category-' . $cat->term_id;                  /* ======= POST COUNT ========= */             /* Get all posts in category + in due date              * this only to get the post count.              * @link http://themehybrid.com/support/topic/issue-with-filtering-due-meta-key              */             $query_args = array(                 'post_type'       => 'post',                 'category_name'   => $cat->slug,                 'meta_query' => array(                     array(                         'key'        => 'Due',                         'value'      => date( 'Ymd' ),                         'type'       => 'DATE',                         'compare'    => '>=', // greater than or equal to                     )                 )             );             $my_query = new WP_Query( $query_args );             $post_count = $my_query->found_posts;                  /* ====== CATEGORY THUMBNAIL ======== */             $thumbnail_id = get_option('seamless_term_thumb_' . $cat->term_id);             $image = wp_get_attachment_url($thumbnail_id);                  /* ====== LINK TO SEARCH: no need fields ======= */             $link_to = 'http://www.scholarships360.org/discover/?search_query=&orderby=blank&tax_category=' . $cat->slug .'&wpas=1';                  /* MERGE DATA IN ARRAY */             $cats_data[] = array(                 'classes'      => $classes,                 'post_count'   => $post_count,                 'image'        => $image,                 'name'         => $cat->name,                 'link'         => $link_to,             );                  $i++;         } // end foreach              /**          * NOW THE FUN PART          * =================          */              /* Sort Cat Data by Post Count */         usort($cats_data, 'my_sort_cat_data');              /* Cut only 6 item to display */         $cats_data = array_slice( $cats_data, 0, 6 );              /* Display it */         foreach ($cats_data as $cat_data ){ ?>                  <div class="<?php echo $cat_data['classes'];?>">
                     <a href="<?php echo $cat_data['link'] ?>">
<?php echo  $cat_data['post_count'] . ' Scholarships' ?>
                                          <a href="<?php echo $cat_data['link'] ?>">                         <img src="<?php echo $cat_data['image']; ?>" alt="<?php echo esc_attr( $cat_data['name'] ); ?>" class="item-image">

         <?php          }     }     /* No category found */     else {         echo '
No category found...
';     }     }           /**      * Sort Cat Data Helper Function      * @link http://stackoverflow.com/questions/2699086/sort-multidimensional-array-by-value-2      */     function my_sort_cat_data( $a, $b ){      return $b['post_count'] - $a['post_count'];     }


How to add an inline style to the <p> tag outputted in the_content() using PHP?

I am trying to add an inline style to my paragraph tags which are ouputted using `the_content();` I've tried string replace, see question I did earlier. But it won't because the_content echo's it and does not return it. If I return the content using `get_the_content();`, it does not output in paragraph tags. Can anyone help me with this?


How can I assign post a specific ID on creation?

I'm migrating content from an existing site into wordpress. The old site has cross links that I'd like to maintain in the new site. I can convert the old links to wordpress format links (based on post-id), but in order to do that I need to assign the posts their own ID's on migration. is there any way to do that ? The old site is NOT wordpress based...


How can I set a default category for a custom post type in wordpress?

I am trying to put together some functions in wordpress which will allow me to add a custom post type _and_ associate a default category _and_ post on the posts page. So far I have been able to create a custom post type, and as far as I can tell I am associating a default category. However, the posts do not show up in the post feed. Here is the code I have pieced together:               add_action( 'init', 'create_prayer_request' );          function create_prayer_request() {         register_post_type( 'prayer_request',             array(                 'labels' => array(                     'name' => __( 'Prayer Requests' ),                     'singular_name' => __( 'Prayer Request' ),                     'add_new' => __( 'Add New Prayer Request' ),                     'add_new_item' => __( 'Add New Prayer Request' ),                     'edit' => __( 'Edit' ),                     'edit_item' => __( 'Edit Prayer Request' ),                     'new_item' => __( 'New Prayer Request' ),                     'view' => __( 'View Prayer Requests' ),                     'view_item' => __( 'View Prayer Request' ),                     'search_items' => __( 'Search Prayer Requests' ),                     'not_found' => __( 'No prayer requests found' ),                     'not_found_in_trash' => __( 'No prayer requests found in Trash' ),                 ),                 'public' => true,             )         );     }          function save_custom_post ( $post_id, $post = null ) {         if ( !$post ) $post = get_post($post_id);         if ( !current_user_can( 'edit_posts', $post->ID ) ) return;         if ( 'prayer_request' != $post->post_type ) return;         if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;              wp_set_object_terms( $post->ID, 'prayer-request', 'prayer_request' );     }     add_action( "save_post", "save_custom_post", 10, 2 );


Wordpress Featured Image function recreate

I am facing a problem of recreating a featured image function to show different images in different section. I was trying to modify the existing function "Featured Image" and duplicate the post meta box but I am failed... Could any one help me to sort this out, or give me an idea of how could I set up the Image meta box which I could apply to different page. Thanks,


featured image not showing up with mysql_connect

i noticed a certain problem with the featured image issue, i had everything work nicely until i added a mysql connection to another database to retrieve certain information, the featured image stop showing up, but the post are there, just the featured image. after i close the connection, i load the page again and notice the place where the featured image should be has an error message               Warning: mysql_error(): 21 is not a valid MySQL-Link resource in      C:\xampp\htdocs\wordpress\wp-includes\wp-db.php on line 1206          Warning: mysql_real_escape_string(): 21 is not a valid MySQL-Link resource in      C:\xampp\htdocs\wordpress\wp-includes\wp-db.php on line 880          Warning: mysql_error(): 21 is not a valid MySQL-Link resource in      C:\xampp\htdocs\wordpress\wp-includes\wp-db.php on line 1206      anyone know how i can solve this issue :( ? as requested, here's my codes for openconn.php               <?php          $server = "localhost";          $username = "root";          $password = "";          $database = "regreg";          $connId = mysql_connect($server,$username,$password) or die("Cannot connect to server");          $selectDb = mysql_select_db($database,$connId) or die("Cannot connect to database");          ?>      while for closing the connection, in closeconn.php               <?php          $server = "localhost";          $username = "root";          $password = "";          $database = "regreg";          $connId = mysql_connect($server,$username,$password) or die("Cannot connect to server");          mysql_close($connId);     ?>


Not able to give editors acess to new admin menu item

I'm adding an extra menu item in admin menu by using add_menu_page. `add_menu_page('Calendar', 'Calendar', 'edit_posts', 'wp-eventcal/eventcal- manager.php');` Still my editors do not see the menu item. Why not? Any user that can edit a post, should now be able to see the menu item. **Update** This is the code:                 // Define some constants       define('WP_CAL_PLUGIN_DIR', trailingslashit( str_replace("\\","/", dirname(__FILE__) ) ) );       define('WP_CAL_PLUGIN_URL', trailingslashit( str_replace("\\","/", dirname(__FILE__) ) ) );                 // Plugin activation / deactivation script       register_activation_hook(__FILE__,'event_cal_install');            // create custom plugin settings menu       if ( function_exists('add_action') ) {         add_action('admin_menu', 'event_cal_menu');         add_shortcode('eventcal', 'shortcode_display_event');       }          function event_cal_menu() {         //create new top-level menu         add_menu_page('Calendar', 'Calendar', 'read', 'wp-eventcal/eventcal-manager.php');     }      Could it be `admin_init` in `add_action` that gives me problems? **Update 2**   If I log in as administrator, I can see the menu item.


Synchronizing Two WordPress Sites Content

I've googled a lot, and I do have found answers at WordPress SE and at stackoverflow.com. However, the answers are somewhat incomplete or doesn't work at all. Here I'll explain my problem in detail, give my progress on the problem and the obstacles I'm facing in solving the problem. **Assumptions:-**   1. Plugins and themes at both the websites are pre-installed, and they are exactly same.   2. Uploads folder is also same. _Assumptions indicate the current status of the folders. It doesn't assumes that they are being synchronized as the following process starts._ **Problem:-**   1. There is a site A and site B.   2. If any posts, pages, products, images, slider images, menus, menu items, categories, SEO settings etc of site A or site B is changed then it should be changed for the other website too.   3. If a post or product is published with a category containing a prefix ABC- (e.g. ABC-Windows Tips) then that post or product should only appear on site B.  **Current Progress:-** I didn't come up with a reasonable solution, but I connected site B to site A's database by editing wp-config.php. I also copy pasted the following code for both of the sites respectively:- Site A:-               define('WP_HOME','http://siteA.com');     define('WP_SITEURL','http://siteA.com');      Site B:-               define('WP_HOME','http://siteB.com');     define('WP_SITEURL','http://siteB.com');      **Obstacles:-**   1. My admin password for site B has been changed to the site A's password. (I'm not sure if this is going ALRIGHT or MESSED UP. If you can help me in this then that would be great.)   2. The uploads folder is not being synchronized. Media items uploaded via Site A are only visible at Site A. Featured images of posts are going 404 on site B. We can either make the uploads folder to synchronize between two different web hostings. Or make it such that site B starts picking images from site 'A' uploads folder. Something like defining constants like we did for home and siteurl i.e. WP_HOME and WP_SITEURL.


Adding class atribute to wp_nav_menu ul

**Update:** this was caused by the fact that i didn't have a menu created in the menu page. I want to add a class to the ul of wp_nav_menu. I tried this code:               <?php          $defaults = array(         'menu_class'      => 'menu',         'items_wrap'      => '
%3$s
',     );          wp_nav_menu( $defaults );          ?>      According to wordpress codex changing the _menu_ from 'menu_class' => ' _menu_ ', should change the class of the ul, but instead it changes the class of the div wrapping the ul. `<div class="this class is changed"><ul><li class="page_item page-item-2"><a href="http://domain.tld/">Sample Page</a></li></ul></div>`


Wordpress - Image href for home menu nav not working

I have an image linked to a li element from a navbar in wordpress. All is working fine but when i hover mouse on image, it also shows a menu element hover in the list. How can i hide that when it is linked to the image? This is the php code for that (from nav-menu-template.php):               if( $args->theme_location == 'primary' )     return "

".$items;      I attach an image to show what it is doing: ![enter image description here](http://i.stack.imgur.com/4uioq.png)


What are the main parts of a Wordpress Template?

This may sound like a stupid question, but... What are the main parts of a Wordpress template, and which parts are mandatory and which parts are optional? So far I am aware of:   * Posts (mandatory)   * Pages (mandatory)   * Page Templates (optional)   * Tags (optional)   * Categories (optional)   * Search / Search Results (mandatory)   * Archives (mandatory)   * Widgets (optional) Is there anything else?


3 different mail notifications

I'm building a small tracker and need to send mail notifications on specific actions. Thought-out notifications:   * Administrator gets a notification email when a new ticket is published   * Author gets a notification email when the ticket is updated   * Author gets a confirmation mail when the ticket is published Each notification email will have different content. I've got one of these three notifications to work, the one where the author gets a notification when a ticket is updated (code below). The other two I can't figure out. Some background on posting in my tracker. The posting takes place in a front end form. If a user is logged in, his user details is used as the ticket author meta. If the user is not logged in, the name and email will be saved as custom fields.               //**************************************************     // Send mail to user when a ticket is updated     //**************************************************     function trac_authorEditNotification($post_id) {        $post = get_post($post_id);        $author = get_userdata($post->post_author);             if ($author->ID == '2') {            $message = "Hej ".get_post_meta($post->ID, 'ticket_poster', true).",\nDin rapport '".$post->post_title."' har just uppdaterats.\n\nDu kan besöka den uppdaterade rapporten på: ".get_permalink( $post->ID )."\n\nMvh\nTeamet";            wp_mail(get_post_meta($post->ID, 'ticket_poster_mail', true), "[Trac] Rapport uppdaterad (#".$post->ID.")", $message);        } else {            $message = "Hej ".$author->display_name.",\nDin rapport '".$post->post_title."' har just uppdaterats.\n\nDu kan besöka den uppdaterade rapporten på: ".get_permalink( $post->ID )."\n\nMvh\nTeamet";            wp_mail($author->user_email, "[Trac] Rapport uppdaterad (#".$post->ID.")", $message);        }     }     add_action('edit_post', 'trac_authorEditNotification');      Basically what I need is something similar to the above code for the other two notifications. I've tried a bunch of action hooks but nothings seems to do the trick. I'm getting no email at all or multiple hooks gets triggered and I'm ending up with to many emails. Suggestions?


Best practice to separate translate Backend and Frontend

I currently building wordpress themes, using customizer for almost all part of themes it self. also bundling it with own themes option. i wonder how the best practice to translating backend but separate it with front end. customizer and theme option having alot of option need to be translated. and i don't think people who using another themes need to translate it. this is what i currently done :               load_theme_textdomain('jeg_textdomain', get_template_directory() . '/lang/');     load_theme_textdomain('jeg_backend_textdomain', get_template_directory() . '/langbackend/');          any thought how the best way to separate backend translation with frontend translation? Thank you!


Is there a simple way to only show ads on a WordPress page once it becomes popular?

I am looking for a simple way to minimize ads on a website I'm developing in WordPress by only showing ads (Google Adsense, to be precise) on the site upon a large influx of traffic. A large influx as defined as, say, more than 2x the normal hourly traffic (though the exact metric used to determine popularity is not that important to me). In other words, if ever the site sees a huge influx of traffic, I would like to begin delivering ads (to attempt to cover the incremental server costs). Otherwise, I would like to keep the site ad-free for the casual visitors. Is there a simple way, or plug-in, to do this in WordPress?


What determines initial file permissions when a WP theme folder is uploaded manually with an FTP client?

## Intro This is a question that has bugged me for a really long time and I realize this it isn't necessarily related to WordPress, however I wanted to start by asking the WordPress community. I've been selling WordPress themes for a couple of years now and this is an issue that has come up repeatedly in dealing with customer support but have never really known how to address it, or if it's something I'm doing wrong or not. ## The problem that leads me to ask Every once in awhile when someone installs one of my themes, they decide to go the route of unzipping it and manually uploading the theme folder to wp- content/themes/ of their site with their FTP client. When people do this they often run into the same issue and it is this: Things on their site will end up not working because it ends up turning out that there are certain files of the theme that when uploaded received permissions that are not readable on their web server... For example maybe a javascript file doesn't have readable file permissions, so it it's as if it doesn't exist on the front end of their site when called in the head of the site, and thus breaks all the javascript on the frontend of their site. For the longest time I've chalked this up to inexperience on the user's part. I tell them to change the file permissions with their FTP program. They figure out what the heck that means, and all is right. However this is continuing to happen to people, and I'm having to give the same responses again and again. Now I'm starting to see more of a pattern with which files it's happening to for people and seeing that it's the same files again and again. Another thing to note is I've noticed that this happens the most with files I've pasted into the theme. For example, I include the pretty photo jQuery plugin where I've just pasted the folder from prettyPhoto in there and users often end up with the pretty photo CSS and JS file that have non-readable file permissions. ## My Question I understand that users are not experienced with troubleshooting these issues and are not savvy with finding a file that has been give improper permissions, but the fact that users keep facing this with the same files leads me to believe that this is something I'm doing on my end with the files. So, is this possible? What theoretically could I being doing with plain 'ol CSS, JS, and PHP files on my end that could result in a user uploading the theme on their end with these certain files receiving weird file permissions? ## System Info I'm not sure if this is relavant or not, but I do all my work with these files in Coda on Mac OS 10.7, working with MAMP on my localhost.


A unique wp_schedule_single_event() for each post?

I'm building a site for a client that requires sending out emails about each post at various dates (i.e. two weeks before after the post was published, then again four weeks after the post was published, etc). It seems that the best way to do this is with wp_schedule_single_event() with a unique event name, but I'm not quite sure how to properly call **add_action** on these single events when **each event has a unique name**. I am scheduling the events like so:               add_action('wp_insert_post', 'cron_emails');     function cron_emails()  {         global $post;         $meta = get_post_custom($post->ID);              // one day before event         wp_clear_scheduled_hook("one_day_before_event_" . $post->ID);              if(!empty($meta["_start-date"][0]))  {             $newdate = strtotime ( '-1 day' , strtotime ( $meta["_start-date"][0] ) );             wp_schedule_single_event($newdate, "one_day_before_event_" . $post->ID);             }     }      This schedules a single event with the unique name **one_day_before_event_[POST_ID]**. Works great, no complaints. But now, when the cron rolls around, how do I trigger this unique event with an add_action? I don't really understand how to dynamically do an add_action when each post has a unique event name, like so:               add_action('one_day_before_event_[POST_ID]','some_function');      The two options I can think of are (1) Loop through every single post id on the blog or (2) only call the action on single.php with:               is(is_single()) add_action('one_day_before_event_' . $post->ID, 'some_function');      Would anyone have any better ideas on how I might dynamically call an add_action for a unique event name?


Proper way to trigger a MySQL query via link in a plugin

I am trying to develop a module in my WordPress plugin that will delete an entry from the database. The only issue is related to the trigger action. I've tried to send my users directly to the page using `plugins_url('path/to/page.php?del_message=53`. My thoughts were to send the users to my page and use a basic `$_GET` variable to retrieve the message ID. Unfortunately I can do that, but it will not load the WP header or any other functions. What is the proper way to send a variable and retrieve a value? This is my current code on the page I attempted to send my users.               global $wpdb;     $table_name = $wpdb->prefix . "authordiscuss";          if(isset($_GET['del_message'])){         // CHECK IF CURRENT USER IS AUTHOR         echo 'Checking...<br />';         $messageid = $_GET['del_message'];         $authorid = $wpdb->query("SELECT userid FROM $table_name WHERE id=$messageid");              if(get_current_user_id() == $authorid){             // Delete message             echo $authorid . ' ' . $messageid;             $wpdb->query("DELETE FROM $table_name WHERE id=$messageid");         }else{             echo 'DIE!';             wp_die("You are not the message's author!");         }     }


Query Users by post count, last 30 days and display each users post count according to post type

I'm almost done, the code below does everything but display post count for each user broken down into post types, and also I'm like to filter it last thirty days. I'm trying to get the post for each user fr the custom post type 'music'.
          <?php foreach ( get_users('orderby=post_count&number=5') as $user ) : ?>
     <?php echo get_avatar($user->ID, '64'); ?>
         <?php echo $user->display_name; ?> (<?php echo count_user_posts( $user->ID, $post_type='music' ); ?> Posts)

          <?php endforeach; ?>
      What am I missing, is the even the right way to do the query? Pardon the HTML mixed in.


Update Loop with Form

I have a photo gallery I'm developing using WP as a means for content management. I'm relying heavily on some jQuery plugins to manage the UI styling and manipulation (via sorting). My problem is there are too many damn posts! 737, and each has a thumbnail which is displayed on the page. This inevitably bogs down any browser. Especially since the sorting plugin "clones" the images when it sorts them. The posts are built using a Wp_query script;               <?php      $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;      $post_per_page = 15; // (-1 shows all posts) SETS NUMBER OF IMAGES TO DISPLAY!      $do_not_show_stickies = 1; // 0 to show stickies      $args=array(     'post_type' => array ('post'),     'orderby' => 'rand',     'order' => 'ASC',     'paged' => $paged,     'posts_per_page' => $post_per_page     );     $pf_categorynotin = get_post_meta($wp_query->post->ID, true);     if($pf_categorynotin){         $args['tax_query'] = array(             array(                 'taxonomy' => 'category',                 'field' => 'slug',                 'terms' => $pf_categorynotin,                 'operator' => 'NOT IN'             )         ); //category__in     }     $temp = $wp_query;  // assign orginal query to temp variable for later use     $wp_query = null;     $wp_query = new WP_Query($args);          if( have_posts() ) :         echo '
';         $r = 0;         while ($wp_query->have_posts()) : $wp_query->the_post();             $post_cat = array();             $post_cat = wp_get_object_terms($post->ID, "category");             $post_cats = array();             $post_rel = "";             for($h=0;$h<count($post_cat);$h++){                     $post_rel .= $post_cat[$h]->slug.' ';                     $post_cats[] = $post_cat[$h]->name;                 }         $r++;         echo'
';         if (get_post_meta($post->ID, 'port_thumb_image_url', true)) { ?>     <a  class="tozoom" href="<?php echo get_post_meta($post->ID, 'port_large_image_url', true); ?>" rel="example4" title="<?php echo $post->post_title; ?>">     <img src="<?php echo get_post_meta($post->ID, 'port_thumb_image_url', true); ?>" class="portfolio_box" alt="<?php the_title(); ?>" width="199px" height="134px" />         <?php } ?>
         <?php endwhile ?>
      and the items are sorted by their html5 tags with a menu in the sidebar. You can see it working here; http://marbledesigns.net/marbledesigns/products Right now it randomly loads 15 posts and displays them. I want to be able to reload posts based on my selection from the menu (via categories) and then update the list of images without refreshing the page. I want to be able to change not only which posts from which category are displayed, but also the posts per page as well. I think AJAX is the way to do this, but I don't want to undo a whole bunch of code in the menu in order to get it working. Right now the menu is styled radio buttons. Isn't there a way I can take the same input from that form and update the parameters of the loop? Looking for an efficient solution! Please help!


Convert link in Wordpress 3.2.1

How can I convert links (url displayed in the browser) from :               www.mywebsite.com/?p=13      to something like this :               www.mywebsite.com/title_of_the_topic


Set max title length - similar to excerpt length for outside of single.php

I've been searching for a code snippet that lets me limit the title length similar to what you can to with the_excerpt and then just display "(...)" if the title is too long. I'd like to use that in loops outside of single.php, e.g. in my sidebar where an extremely long title would harm the layout. All I could find was this code snippet, but that does obviously not what I want.               function maxWord($title)     {     global $post;     $title = $post->post_title;     if (str_word_count($title) >= 10 ) //set this to the maximum number of words     wp_die( __('Error: your post title is over the maximum word count.') );     }     add_action('publish_post', 'maxWord');      Is it possible at all? I'm looking for something similar like this, just not for the excerpt, but the title:               function excerpt($limit) {           $excerpt = explode(' ', get_the_excerpt(), $limit);           if (count($excerpt)>=$limit) {             array_pop($excerpt);             $excerpt = implode(" ",$excerpt).' (...)';           } else {             $excerpt = implode(" ",$excerpt);           }            $excerpt = preg_replace('`\[[^\]]*\]`','',$excerpt);           return $excerpt;         }              function content($limit) {           $content = explode(' ', get_the_content(), $limit);           if (count($content)>=$limit) {             array_pop($content);             $content = implode(" ",$content).' (...)';           } else {             $content = implode(" ",$content);           }            $content = preg_replace('/\[.+\]/','', $content);           $content = apply_filters('the_content', $content);            $content = str_replace(']]>', ']]>', $content);           return $content;         }


How do i change the footer?

I downloaded a free theme and I changed everything except the footer I can't change it. I opened the file **footer.php** and there was only written as shown:

<?php wp_footer(); ?>
         <?php wp_list_pages('title_li=&depth=1' ); ?>

                     I can not find a way to change the `wp_footer ();`.   Did there is an external file that I need to change?


Multisite sites output on a single page

Basically I have a multisite setup where each site is just one single page (each has a different theme). How can I output that page content of any site on a page of the main site programmatically? Like I have multisite on domain.com and I have sites like `a.domain.com` and `b.domain.com`, then how can I show the content on lets say `domain.com/api/main` programmatically? I need clues on how can I go about it? Output buffering in some way? Mainly I only need the widgets to work. Don't need the `is_*` functions as its just one page site. Its like I want to view the content of diff sites on a single page by passing on parameters upon checking of which it is figured out which site of the multisite needs to be shown at this request & then that site is shown as if it was opened by its URL. Right now upon receiving the request on `domain.com/api/main`, I am redirecting to the site URL (`a.domain.com` or `b.domain.com`) but I would like to render the output on a single URL only. Any clues?


Theme localization of "slugs" (custom post types, taxonomies)

in my theme I want to define a series of custom post types and custom taxonomies, each one having its own customized slug; the base language of my theme is english, therefore the slugs will be in English language for example while defining the slug of custom post type "product" args:               'rewrite' => array( 'slug' => 'product' ),      is there any way to translate the "slug" through po/mo files? can I put it as:               'rewrite' => array( 'slug' => __('product', 'mytextdomain') )      or it won't work? what's the current practice to localize slugs?


Why dont i see pingbacks?

I installed two wordpress software on my site. One is wp1.site.com and the other is wp2.site.com. Now, i made a post on wp1 and then linked to it on wp2. I didnt see anything about pingbacks. I tried several pages/post and saw no pingbacks. Why? Where should i be seeing them and why dont i see them? I saw someone mention "enabled for that post" and i checked if there are any post settings for pingback. I didnt see any. I just left the defaults and notice pingback were set to enable by default in my settings. Whats the problem here? -edit- i see pingbacks if i link to a post on my site but not from either sites to the other.


Integrate open graph protocol without plugin?

What is the right way to put in Open Graph Protocol into a wp theme in order to when someone likes or shares on facebook to show hihm as thumbnail the featured image of the post or the page? Which is the metadata that need to be written in the header.php or function.php?


Using Variables in Shortcodes

I'm trying to create a Shortcode to display scores between to teams. I've got this far, but I can't seem to get variables into the damn thing. I thought the arrays where used for that, but apparently it doesn't work like that.                function get_gamecentre($atts, $content = null) {         extract(shortcode_atts(array(                 "HOME-IMG" => '',                 "AWAY-IMG" => '',                 "HOME-NAME" => '',                 "AWAY-NAME" => '',                 "HOME-POINTS" => '',                 "AWAY-POINTS" => '',         ), $atts));         return '
';         return '
';         return '
';         return '
';         return '	';         return '	';         return '	';         return '
';         return '
';         return '[box color=red]'.$HOME-NAME.'[/box]	';         return 'VS	';         return '[box color=red]'.$AWAY-NAME.'[/box]	';         return '
';         return '
';         return '[box color=green]'.$HOME-POINTS.'[/box]	';         return 'VS	';         return '[box color=red]'.$AWAY-POINTS.'[/box]	';         return '
';         return '
';         return '
';     }     add_shortcode("gamecentre", "get_gamecentre");