Using Walker To Add Menu CSS Class Functionality

I'm trying to add the ability to insert Custom CSS Classes to menu items. I believe I do this by extending the walker_nav_menu but I'm not sure how to call the custom classes. This seems like such a simple question but I've googled and searched here and couldn't find anything for simply adding the custom classes. Right now I just have:               <?php wp_nav_menu( array( 'theme_location' => 'top-menu', 'walker' => new future_walker_class() ) ); ?>      and               class future_walker_class extends Walker_Nav_Menu {     /*not sure what to put here*/     }      P.S. I'm fairly new to PHP/Wordpress. I tried to be as thorough as possible so I don't waste your time.


Query Posts Exclude Entire Category

I am using the standard wordpress loop that looks like:                   <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php the_title(); ?>
         <?php endwhile; else: ?>
We're sorry...there is no content.
         <?php endif; ?>      Then, what I wanted to do was exclude a certain category from my query, so my code became:                   <?php              $parent = get_cat_ID("Sports");             query_posts("cat=-".$parent);          ?>             <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php the_title(); ?>
             <?php endwhile; else: ?>
We're sorry...there is no content.
             <?php endif; ?>         <?php wp_reset_query(); ?>      Which I thought was right on the money... So I did some research and discovered this is only excluding the category, not the category and it's subcategories. Is there a way to exclude a specific category and all it's subcategories from the loop? Thanks, Josh


Search (Custom Form, Custom Search Result)

If I have a form:               <form class="search" action="<?php echo site_url(); ?>/page-search?category=2" method="get">         <input type="text" required name="search" placeholder="Search">         <button type="submit" class="sprite-psuedo"></button>     </form>      How would I add the custom page-search, The               <?php     global $query_string;          $query_args = explode("&", $query_string);     $search_query = array();          foreach($query_args as $key => $string) {         $query_split = explode("=", $string);         $search_query[$query_split[0]] = urldecode($query_split[1]);     } // foreach          $search = new WP_Query($search_query);     ?>      From Tutorial does not work. (Outputs nothing, it doesn't really seem to do anything). I tried too loop as well.. How do I process the form?


Wordpress custom metabox radio values using CMB

thanks for reading. Im using https://github.com/WebDevStudios/Custom-Metaboxes-and-Fields-for- WordPress to create custom metaboxes. I have created a radio metabox that looks like below.               $meta_boxes[] = array(             'id' => '_metabox_id',             'title' => __('metabox title', 'cmb'),             'pages' => array('page'),             'context' => 'normal',             'priority' => 'high',             'show_names' => true,             'fields' => array(                 array(                     'name' => __('metabox name','cmb'),                     'id' => 'some_metabox_id',                     'type' => 'radio',                     'options' =>  array(                         array( 'name' => __( 'option one', 'cmb' ), 'value' => 'one' ),                         array( 'name' => __( 'option two', 'cmb' ), 'value' => 'two' ),                      )),                      ));      No matter what I try I cant get this to work. The metabox shows fine on the page in the backend. Meaning the user can choose one of the two options. However I cant get the output to work.               global $post;     $key = 'some_metabox_id';     $ed = get_post_meta($post->ID, $key, true);     if ($ed == 'one'){     echo 'you selected one'; }     elseif ($ed == 'two'){     echo 'you selected two'; }     else {     echo 'nothing'; }      This just outputs nothing. what am I doing wrong, how should I get_post_meta for radio buttons. I have even tried a select box, but cant get that to work either. Checkboxes and text fields are working fine. Can someone please guide. Thanks again for reading. p.s I have also tried               $ed = get_post_meta($post->ID, $key, false);          foreach( $ed as $ed_option ) {         if ($ed_option == 'one') {             echo 'you selected one';                 } elseif ($ed_option == 'two') {             echo 'you selected two';         }        }      Thanks for reading.


Show dialog box in TinyMCE plugin and use WordPress php functions in it

I'm adding a TinyMCE button to my plugin. So far, I've been able to add the button and call my editor_plugin.js file and it's command. Not an easy mission btw... I want this button to show a Dialog box, which gives the user several options. These are dropdown boxes which I need to fill and some text boxes for the user to just write the input. Some of them needs info from WordPress functions, and others are just static info. After this dialog box is accepted, I want it to write the shortcode on the post for my plugin to display with the options selected in the box. The thing is, I want to use some of WordPress' functions in my php file. But it's sort of "out of context". I can't use WordPress functions, or even the `__()` functions for i18n. Here's the code I'm using from one of the TinyMCE examples:               ed.addCommand('mceExample', function() {                                 ed.windowManager.open({                                         file : url + '/box.php',                                         width : 500 + ed.getLang('example.delta_width', 0),                                         height : 300 + ed.getLang('example.delta_height', 0),                                         inline : 1                                 }, {                                         plugin_url : url, // Plugin absolute URL                                         some_custom_arg : 'custom arg' // Custom argument                                 });                         });      I'm also missing the way to actually write into the post. As you can see here, this code uses nothing to write into the post. I tried using this code I found on another example: `ed.execCommand('mceInsertContent', false, 'Hello World');` but haven't found out how to use it on my new script. Sorry if this has been answered before, but all the documentation regarding TinyMCE seams pretty confusing, and I've had a hard time integrating this into my plugins. Thanks in advance.


how to store values in database at hierarchical view

In my project i need to create restaurant menu card,i want to insert values given below               -menus(like dinner,lunch,breakfast)       .        -menu_group(like soup,juice)         .         .            -menu_item                   apple-juice...................... $10                   milk_shake_apple................. $15            -menu_item              -menu_group          -menu      which one is best custom field or taxonomy? or is there any plug in to use


Problem with Simple Facebook Connect

I'm seeing this box in the "Edit Post" page, using the Simple Facebook Connect plugin 0.25 and WordPress 3.0.4: > If you can see this, then there is some form of problem showing you the > Facebook publishing buttons... All other Facebook-related plugins are disabled. How can I debug this? Posted an issue.


Hold comments for moderation only if user is not logged in

Is there any way to allow logged-in users to post comments without them being held for moderation, while requiring that any comment from anonymous users be approved? I have developed a system for users who are members of our organization to log in automatically with their LDAP accounts, and would like for any of them to be able to comment without their comments being held for moderation. However, I want all anonymous third-party comments to be held for moderation. I don't see any way to do that with the current comment options - I can either hold all comments for moderation, hold all comments by users without 2 approved comments, or require users to log in to comment. How can I achieve this?


How to check if single.php has already called the_post_thumbnail function

I am creating a front end plugin to upload images and adding filter in `the_content()` to display post thumbnail but some templates already have `the_post_thumbnail` in `single.php` or `loop.php`. Is there any way I can check it?


Get template part based on custom taxonomy term

I have a custom post type and I'm trying to call up different variations of the navigation based on the custom taxonomy slug. I've done this fairly easily with normal posts, like so:               <?php          if ( is_category( 'mixers' )) {             include (TEMPLATEPATH.'/nav-mixers.php');         } elseif ( is_category( 'monitors' )) {             include (TEMPLATEPATH.'/nav-monitors.php' );         } elseif ( is_category( 'speakers' )) {             include (TEMPLATEPATH.'nav-speakers.php');         }     ?>      however this is proving challenging for a custom post type. I feel like I'm close but I need some help now. Here's where I currently am.               <?php         $terms = get_the_terms( $post->id, 'prodcat' ); // get an array of all the terms as objects.         $terms_slugs = array();             foreach( $terms as $term ) {                 $terms_slugs[] = $term->slug; // save the slugs in an array             }         if( $terms ) :            get_template_part( 'nav', slug );         else :            get_template_part( 'nav', 'home' );         endif;     ?>      Any help is much appreciated!


Possible to use wordpress as publishing platform but programmatically inject content?

I have user generated content that is created in a mobile app that is written to a SQL Database. I'd like to create a new site that allows this content to be viewed on a per user basis. So if I go to http://foo.com/user/TMC It'll show all the content I've created in the mobile app. i want to use wordpress to eliminate the need to recreated my own content publishing engine and get the benefits of all of the wordpress ecosystem with plugins, templates, etc. Even basic things like "search" are free vs. needing to build it myself if I roll my own content publishing system. To accomplish this, I think I need to:   1. Be able to programmatically create wordpress posts. I want code running on another server (e.g. Google App engine) to call onto my server hosting wordpress (e.g. regular shared hosting) and create a blog post for each time a user saves new content in my mobile app. In order to do this there needs to be an web service to do this or I write directly to the DB?   2. Be able to programmatically edit the blog post once it's saved, if the user edits the content in my mobile app. Same need for a web serices   3. Need to be able to have unique URLs for each user of my mobile app and show only their blog posts, but it's still all part of the same instance of wordpress. So http://foo.com/users/UserA vs. http://foo.com/users/UserB. Both on same blog, each URL will show a filtered view of posts only done by that user.   4. I need to create real or fake user accounts. Since the content is really in my mobile app, my users have accounts with me and stored in SQL. So when I push the content to Wordpress to create the content, it's not really the user that is doing it. So if I wanted to push content for userA and userB, how would the user accounts get created? Or should I overload the use of tags and say set a tag as `user=UserA` then when I need to accomplish what I describe in #3 above, I just use `/tags/user=UserA`? (I'm clearly open to suggestions) Is what I need even remotely possible or am I on drugs?


Issue with pre_get_posts on custom post type archive pages

**Overview**   1. I am creating a theme which has 2 custom post types (as custom plugins):     1. Articles      2. Reviews   2. I have also created `single-articles.php` and `archive-articles.php` templates inside the plugin. Same for Reviews CPT.   3. BOTH the custom post types use the **default** WordPress Taxonomies (categories and tags)   4. My Reading Settings are set to "A Static Page"     1. Front page: Home ( a Custom `front-page.php` file I created)     2. Posts Page: The "Site News" page (which I want to show _BOTH_ posts _AND_ CPT's) **The Problem** After creating a regular post _and_ a post based on the Articles CPT, I went to the Main Posts page (The Site News) wherein I did **not** see the custom post type (only the post using the standard `post` type). After some searching (i'm a noob) I understood that if I wanted to display CPT's on the main posts page, I would have to write a filter using `pre_get_posts`. So, to recap: I wish to show   1. BOTH regular posts AND Custom Post Types (CPT's) on the Main Posts page   2. BOTH regular posts AND Custom Post Types (CPT's) for the Category Archives pages **Here's What I Did**               // Add custom post types to the default loop (ref: http://bit.ly/1bqeBJC)     function odigbs_add_custom_types( $query ) {         if ( !is_admin()  && !is_preview() ) {             if ( (is_home() || is_category() || is_tag() || is_archive()  || is_feed() ) && $query->is_main_query()  ) {                 $query->set( 'post_type', array( 'post', 'articles', 'reviews') );                 return $query;             }         }     }     add_filter( 'pre_get_posts', 'odigbs_add_custom_types' );      I'm sure this is **not the right way** to craft this filter, but I cannot find any article that explains this concept thoroughly... so i'm _wingin it_. **The Results**   1. If I go to: `http://site.dev/the-site-news/` (the main posts page from Reading Settings), I now **_DO_** see all of my custom post types **_and_** it does use the `single-{post_type}.php` file inside the plugin.    2. If I click on any of the taxonomy terms the page goes to: `http://site.dev/category/{some term}/` **_and_** it does use the `archive-{post_type}.php` file inside the plugin.  _**But..._**   1. If I point my browser to `http://site.dev/{custom_post_type}`, (i.e. not using the category) to see the archives for that CPT, the site throws all kind of errors.   2. But if I disable the filter, then I **_can_** now go to `http://starter.dev/{custom_post_type}/`, but I'm right back where I started with only default posts showing on the main posts page. No custom Post types. **Questions**   1. Is (as I suspect) the problem is in the filter?   2. If so, how **should** it be written?  I hope I clearly articulated the drama... Thanks in advance


Priority for Categories, Tags, Taxonomies, Posts, Pages and Custom Posts with same url

I have been reading dozens of posts and honestly, I have many doubts on how this work. Furthermore, I think that with WP3.1 more issues have been added here because I am having even more problems now than before. The point is that I am using the same slug for different kind of taxonomies and posts. Let's use loans as the slug for my problem. Until now, I had the page /loans/ and also the category /loans/ and subs /loans/fixed-rate/ and /loans/variable-rate/. In /loans/ I displayed the page where I had a custom template showing different things and in /loans/subcategories/ I had archives for the posts in that given category. Furthermore, my posts had the strucutre /%postname%/. Now, in WP3.1, in /loans/, I see the archive of all the posts in /loans/ and its children and I have been forced to create a category template "copying" what I had in the page before. I want now, taking advantage of WP3.1 features, to create a custom post called also /loans/ so I can define a new template for these posts. I also want to create a new taxonomy called /loans/ (instead of the category) being non- hierarchical so I can have dozens of subcategories /loans/loans-bank-X/, loans/loans-X-rate/, /loans/loans-X-years/ :   * /loans/ -> Page with a custom template   * /loans/fixed-rate/, /loans/bank-of-america/, /loans/30-years/ -> Taxonomy   * /loans/30-years-fixed-rate-loan-of-bank-of-america-review/ -> Custom Post with a review of the product ¿Is there a way of doing this correctly? I had read before thag pages had priority over categories but not now in 3.1. I believe it would also be nice if someone write down the current priority of these slugs. This can be solved using different slugs for the taxonomies, etc but from a SEO and UX point of view it is much better to do it with the same slug. Thanks a lot and regards.


Working with l10n contexts (_x etc)

Basic l10n from a .mo file generated out of PoEdit works fine. But as soon as I introduce `_x`, or variants, the link breaks, because as best as I can tell, PoEdit, completely ignores the context, and does not generate the corresponding `msgctxt` line in the .po/.mo files. `_x`, `_ex` and other variants are all added to the keywords, and PoEdit **is** finding and parsing `_x()` occurrences within my source code. It's just not capturing the context and it is not generating the `msgctxt` line in the resulting .po file. What's the workaround ( _other_ than manually editing the .po or .pot file?)


How to add classes in the wp_list_category parent link

How do I add classes in the wp_list_category , I know the wp_list_categories('title_li='); generates classes , but I want to add a class in the parent category link

 link1

link2

link3     <---how do I add a special class here

link3 children

 link3 children

       Im planning to use a jquery UI accordion in here,   please help. thank you -edit-- problem solved by Paul , thanks man


Can anything go wrong if I let users change their usernames?

We are using email addresses as usernames in a current WP 3.1 project. I need to allow users to change their usernames and email addresses, and will build in the option to do so. I am just wondering why this is not allowed by default in WP? What can go wrong if I let our users change their passwords?


How to move an image in a plugin to the upload directory and make it as a media of wordpress? I would like to use them in posts. **Expand question:** I would like to generate images using other programs and saved in the temporary folder of my plugin directory. _eg._ plugin-name/tmp/image_01.jpg Then, I would like to upload the image to the upload directory an use it as a media source. Is that possible?


Introductory paragraph only in list of blog posts

My blog is displaying the full post of my latest blog post, instead of an introductory paragraph only. How do I make it show an introductory paragraph only, so readers need to click into the full post? Here's the blog: http://richardclunan.com/blog/ (I haven't posted on it in a while and I can't remember how to do this.)


Custom Rewrite Problem

I'm creating some custom rewrites using the code below. Everything works fine, as far as urls such as this: example.com/reviews/showname Tells my theme to use the special archive page and passes the parameters I need. The problem I run into is with pagination. Wordpress generates the links properly: example.com/reviews/showname/page/2/ but the result is a page not found. My first thought was to add a second rewrite:                'reviews/(.+)/(.+)/(.+)' =>  'index.php?reviews=1&showarchive=1&category_name=' . $wp_rewrite->preg_index(1) . '&pgd=' . $wp_rewrite->preg_index(2) . '&pgn=' . $wp_rewrite->preg_index(3),      So that I could capture the 'page' and the page number and use those to code an offset into the query and set the paged query var, but I find when I add this it cancels out the other so that: example.com/reviews/showname Now returns page not found but example.com/reviews/showname/page/1/ Works. For SEO purposes I'd like to keep the example.com/reviews/showname Style url without /page/1 — is there any way to get the rewrites working for both conditions?               add_filter('query_vars', 'eparchive_queryvars' );          function eparchive_queryvars( $qvars )     {       $qvars[] = 'showarchive';       $qvars[] = 'reviews';       $qvars[] = 'pgd';       $qvars[] = 'pgn';       return $qvars;     }              add_action('generate_rewrite_rules', 'custom_add_rewrite_rules');              function custom_add_rewrite_rules( $wp_rewrite )          {           $new_rules = array(                    'reviews/(.+)' =>  'index.php?reviews=1&showarchive=1&category_name=' . $wp_rewrite->preg_index(1)              );           $wp_rewrite->rules = $new_rules + $wp_rewrite->rules;         }


Insert PHP code in Text

I have this code for insert a permalink but doesn't work, return exactly code:               $text = '<form>Permalink to: <?php the_title();?>	<textarea cols="85" rows="2" readonly="readonly" onclick="select()"/><?php echo $permalink = get_permalink( $id ); ?></textarea></form>';        This is what currently shows up: ![Screenshot](http://i.stack.imgur.com/13sl6.png)


Search Custom Post Type & Taxonomies

The site I'm building has a directory element, which has a lot of different business listings; this is a custom post type. It has a Custom Taxonomy called Trades under which are different types of businesses, e.g plumbers, electricians, decorators, accountants etc. I've written a search form and put it into `searchform.php`, which is then called by `get_search_form()`, here it is:               <form role="search" class="main-search" action="<?php bloginfo('home') ?>" method="get">
             <input type="text" class="main-search-field" placeholder="Search for a service..."  name="s" id="s">
         <input type="hidden" name="post_type" value="directory">
             <button type="submit" class="main-submit-btn">Search</button>
     </form>      As you can see, I have narrowed the search down to my Custom Post Type ('directory') but I'm not sure how to narrow it down further. Essentially, when text is entered into the search box, and the user presses enter, I want it to search all my Trade terms, instead of searching post titles/content. Does anyone know how I'd go about doing this? Thanks for any help :)


Mailing list sign up box

I'd like to add a sign-up box with name and email fields to my site. I'll want to add a title so people know it's for my mailing list, and a note to say that i only send mails out occasionally. What would be an easy and solid way to add this? With a plugin? If a plugin is the way to go, waht would be a good plugin for this? I'd like the sign-up-box to appear in the right-hand column on every page -- the non-blog pages as well as the blog pages. It's for this site: http://richardclunan.com/ (I'll need to alter the margins on the non-blog pages.)


Programmatically log in a wordpress user

I am trying to programmatically log in a wordpress user, using the following function for that.                   public function auto_login( $user ) {             $username = $user;                 if ( !is_user_logged_in() ) {                 $user = get_user_by( 'login', $username );                     wp_set_current_user( $user->ID, $user->user_login );                     wp_set_auth_cookie( $user->ID );                     do_action( 'wp_login', $user->user_login );                 }          }      Unfortunately it seems not to be working. That function is called from within a shortcode. Could this be the explanation ? Should I rather hook my function to some filter, before any content is output ? Also I would like to redirect the newly logged in user to a specific post based on a $_GET parameter, can I simply add a header redirect at the end of the function ? Thank you in advance for your help !


Woocommerce - adding variations to variations

I am setting up a store whereby I have variations for products. I want to configure it so that when a customer selects a variation they see a range of other variations for that variation. As an example: they're buying a product and selecting a colour. If they choose to have black they can't have any further options. If they choose the colour as white they are then given additional variation options. Is this even possible within Woocommerce? Thanks in advance, Stu.


exclude category from get_posts?

getting posts by cat with get_posts but need to exclude another cat called london or id 10. is this possible? best, Dc.               //  array(7,-10)         $laargsM = array('category' => 7, 'posts_per_page'=>300, 'orderby'=>'title', 'order'=>'asc' );         $la_shapes = get_posts( $laargsM );


Multiple multisite instances connecting to the same database

I like the idea of making developers connect their copies to the same database and just set `WP_HOME` and `WP_SITEURL` to configure the domain name as they like it. In this model, we don't need to keep migrating databases between servers, and the content will be kept in sync between developers. We also use this for staging, as each version has its own `wp-config.php` file. If we try to make the same with multisite installs it won't work because it relies much more in the database values for domain names. So, what would be the best way of making multiple multisite development copies with different domains connect to the same database for development purposes like the non- multisite sites we're already dealing with?


How to disable main query?

I don't use The Loop, because I use different queries to fetch posts (I use 3 queries instead of one). How to disable main query for home, category and search pages?


Do WP_debug notices explain why my site runs so slow?

When I enable WP_DEBUG, I get lots of the following kinds of notices (see below). Of course, I normally don't have the debugging turned on, but I'm wondering if these are a clue as to why it takes so long _before_ my pages load. To be extra clear, my site is fine once the pages start loading (so it's NOT about loading big resources). I'm also on a very fast dedicated server, running mod_php, so I'm pretty confident the server isn't the bottleneck. The slowness is almost definitely related to MySQL/PHP taking a long time, and I'm having trouble figuring out why. If these notices aren't useful, is there something else I can do to check this? I installed the debug bar plugin and it's showing around 8.5MB of memory usage, which I think is fairly standard for a WP site. I'm not sure how to interpret the object cache data but I've included that also below. CLARIFICATION: I'm not suggesting that generating the errors is slowing down the site, rather I'm wondering if these errors are the result of a problem that might be slowing down the site. The ones I understand don't appear to be relevant, but I don't recognize all of them. Thanks in advance!               Notice: load_plugin_textdomain was called with an argument that is deprecated since version 2.7 with no alternative available. in /Applications/MAMP/htdocs/mysite.com/wp-includes/functions.php on line 2714          Notice: load_plugin_textdomain was called with an argument that is deprecated since version 2.7 with no alternative available. in /Applications/MAMP/htdocs/mysite.com/wp-includes/functions.php on line 2714          Notice: Undefined property: FacebookWidgets::$pluginDirectory in /Applications/MAMP/htdocs/mysite.com/wp-content/plugins/facebook-social-widgets/facebook-social-widgets.php on line 25          Notice: A session had already been started - ignoring session_start() in /Applications/MAMP/htdocs/mysite.com/wp-content/plugins/ipaper/ipaper.php on line 11          Notice: Undefined index: updatelocalip in /Applications/MAMP/htdocs/mysite.com/wp-content/plugins/wp-complete-backup/wp-complete-backup.php on line 32          Notice: A session had already been started - ignoring session_start() in /Applications/MAMP/htdocs/mysite.com/wp-content/plugins/wp-custom-admin-bar/custom-admin-bar-functions.php on line 8          Notice: register_sidebar_widget is deprecated since version 2.8! Use wp_register_sidebar_widget() instead. in /Applications/MAMP/htdocs/mysite.com/wp-includes/functions.php on line 2628          Notice: register_widget_control is deprecated since version 2.8! Use wp_register_widget_control() instead. in /Applications/MAMP/htdocs/mysite.com/wp-includes/functions.php on line 2628          Notice: automatic_feed_links is deprecated since version 3.0! Use add_theme_support( 'automatic-feed-links' ) instead. in /Applications/MAMP/htdocs/mysite.com/wp-includes/functions.php on line 2628          Notice: wp_enqueue_script was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or init hooks. Please see Debugging in WordPress for more information. (This message was added in version 3.3.) in /Applications/MAMP/htdocs/mysite.com/wp-includes/functions.php on line 2748          Notice: Trying to get property of non-object in /Applications/MAMP/htdocs/mysite.com/wp-includes/link-template.php on line 243          Notice: Trying to get property of non-object in /Applications/MAMP/htdocs/mysite.com/wp-includes/link-template.php on line 270          Notice: Trying to get property of non-object in /Applications/MAMP/htdocs/mysite.com/wp-includes/link-template.php on line 274          Notice: Undefined index: hl_twitter_cron in /Applications/MAMP/htdocs/mysite.com/wp-content/plugins/hl-twitter/functions.php on line 96          Notice: load_plugin_textdomain was called with an argument that is deprecated since version 2.7 with no alternative available. in /Applications/MAMP/htdocs/mysite.com/wp-includes/functions.php on line 2714      ![enter image description here](http://i.stack.imgur.com/GBEiW.png)


using ACF datepicker to filter posts on a page

i’m using a wp-query to display posts from a category on a custom post type page. it works fine, and I’ve been also abble to sort my posts depending of datepicker field called “date_debut”. my posts are events posts, so i’m using a start date field (“date_debut”) and a end date field (“date_fin”). here is my code :               <?php           // args     $today = date("Ymd");              $args = array (          'category' => 1,                 'posts_per_page' => -1,                 'meta_key'       => 'date_debut',                 'orderby'       => 'meta_value_num',                 'order'          => 'ASC',     );               // get results     $the_query = new WP_Query( $args );          // The Loop     ?>     <?php if( $the_query->have_posts() ): ?>         <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>          /* MY POST CONTENT */              <?php endwhile; ?>          <?php endif; ?>          <?php wp_reset_query(); ?>      now I’m trying to display only posts that are in the future, or today. but it’s not working, and I can’t find out why… here is my code :               <?php           // args     $today = date("Ymd");              $args = array (          'category' => 1,                 'posts_per_page' => -1,                 'meta_key'       => 'date_debut',                 'orderby'       => 'meta_value_num',                 'order'          => 'ASC',        'meta_query' => array(             array(                 'key'       => 'date_debut',                 'compare'   => '<=',                 'value'     => $today,             ),              array(                 'key'       => 'date_fin',                 'compare'   => '>=',                 'value'     => $today,             )         ),     );               // get results     $the_query = new WP_Query( $args );          // The Loop     ?>     <?php if( $the_query->have_posts() ): ?>         <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>          /* MY POST CONTENT */              <?php endwhile; ?>          <?php endif; ?>          <?php wp_reset_query(); ?>      “date_debut” and “date_fin” format is the default ACF format : yymmdd I don’t understand what I’m doing wrong, when using the second code, nothing is displayed, my query is empty. I tried to change date format, both for th today date and for the custom fields but without success… can anybody help me with this ? thanks a lot,


How to get the password and username of the add new user form (admin back end) in wordpress

I am trying to get the username and password that entered by the wordpress admin in the add new user screen to use those into creating a webmail account using cpanel api. How to do that? is there is any hook for it? Also, When the user id changing his password, I want to get the new and old password and use it to change the one for the webmail account.   * I am not looking for the cpanel part, just the wordpress part.


when using add_user_to_blog getting error "Call to undefined function get_userdata"

I am working on WordPress MU and trying to build one plugin to add user to multiple sites. so far did everything to loop through sites. But while assigning user to site as below using add_user_to_blog am getting error see below. add_user_to_blog( $blogid, $amsuserid, $urole ); Getting the following error: Fatal error: Call to undefined function get_userdata() in wp-includes\ms- functions.php on line 181 if I disable the line "add_user_to_blog" no errors. full function here:               function amsAddUsertoSites()     {              $siteslist=$_POST['updatesites'];         $urole=$_POST['setrole'];         $addtoallblogs=$_POST['allsites'];         $amsuserid=$_POST['userid'];                     if($addtoallblogs) {           //add_user_to_blog( $blogid, $user_id, "administrator" );                 $blogs = get_blogs();                 foreach($blogs as $blog=>$blogid)                    {                         add_user_to_blog( $blogid, $amsuserid,$urole );                 }                 }            else {                 foreach($siteslist as $blog=>$blogid)                    {                         add_user_to_blog( $blogid, $amsuserid,$urole );                 }                      }          }


How to get the first post and second post in a wordpress blog?

is there a way I can retrieve the first and second post in wordpress... I have tried using get_post() but with that I have to put in a id. What if I don't know the posts id?


On Subdomain comments need user login

I have a problem with comments on subdomain sexy.doucheapied.fr On main domain www.doucheapied.fr everything work fine, but on subdomain, visitors are redirected to login page when they comment on an article. The option "Users must be registered and logged in to comment" is turned OFF. I tried to desactivate all plugins but it didn't work.


Redirecting when changing custom post type slugs?

I changed the name of two of my custom post types. The original slugs for them did not properly reflect the post type. So I need to redirect requests for posts beginning with `designer_lingerie` (the old post type slug) to just `designer`. All of the posts are the same just the post type slug has changed. I am sure I'll need to use `.htaccess` but am unsure of what to tell it to change. Basically what URL should I use to do this? The WordPress pretty URL or the default URL?


use get_posts to get custom field data, but in one array

I've run a get_posts query in WordPress and need to pull a pair of custom fields and get all of them into one array. The get_posts query provides an array of posts, but when I use foreach to access the custom fields, I end up with separate arrays for each result. **The Query**               $c_query = get_posts(                         array(                             'post_type' => 'page',                             'paged' => get_query_var('paged'),                             'order' => 'ASC',                             'orderby' => 'meta_value',                             'meta_key' => 'concert_date',                             'meta_query' => array(                                      array(                                     'key'   => '_wp_page_template',                                      'value' => array('rock.php', 'pop.php', 'jazz.php'),                                     'compare' => 'IN'                                 )                                 array(                                   'key'   => 'concert_date'                                   'value'  => date('m/d/Y')                                 )                                   )                         )                     );        **Foreach** To access the concert date, I used foreach:               foreach($c_query as $post) : setup_postdata($post);                   $c_query['concert_date'] = $concert_date = get_post_meta(get_the_ID(),      'concert_date', true);             $c_query['concert_city'] = $concert_date = get_post_meta(get_the_ID(),      'concert_city', true);           endforeach;      and the result pulls the correct data, but I get separate arrays for each concert date and city pair (because of foreach): **Resulting Arrays**                Array ( [0] => 01-11-2012 [1] => New York)       Array ( [0] => 03-23-2013 [1] => Boston)       Array ( [0] => 06-09-2014 [1] => London)       What can I do to get these result arrays into one big array? Trying to get an array of the concert date and city pairs.


How to load/include category templates based on conditionals?

I have this lines to get different template, I can get the desired template but also i'm getting the default template at the end of theme. I tried to skip the code with goto but this fuction is unavailable :D (old resourse) and breaking the code shows the malfuction message > >     "Fatal error: Cannot break/continue 1 level in... bla bla" >                 <?php {if (in_category('diario') ) {  include (TEMPLATEPATH . '/diario.php');             } if (in_category('predicacion')) {  include (TEMPLATEPATH .'/predicacion.php');            } if (in_category('audio')) { include (TEMPLATEPATH .'/audible.php');            } if (in_category('video')) { include (TEMPLATEPATH .'/video.php');            } else {      include (TEMPLATEPATH .'/single_default.php');       }} ?>      I also tried this lines, a copy from WP tutorial.               <?php if ( in_category('diario') ) { ?>     <?php include (TEMPLATEPATH . '/diario.php'); ?>               <?php } if (in_category('predicacion')) { ?>     <?php include (TEMPLATEPATH .'/predicacion.php'); ?>          <?php } if (in_category('audio')) { ?>     <?php include (TEMPLATEPATH .'/audible.php'); ?>          <?php } if (in_category('video')) { ?>     <?php include (TEMPLATEPATH .'/video.php'); ?>          <?php } else { ?>      <?php include (TEMPLATEPATH .'/single_default.php'); ?>      <?php } ?>      When no selected desired template the `single_default` is displayed correctly.


How can I call a thumbnail/featured image to be a background image?

I activated the post thumbnail by putting this in the `functions.php`: `add_theme_support( 'post-thumbnails');` And this in the `loop.php`: `<?php the_post_thumbnail('full', array ('class' => 'rollover')) ; ?>` And voila, the featured image appears on the main page, hopefully with the class of "rollover." But what I want to do is turn this into a sprite. On my static HTML markup I wrote:               a.rollover: {         display:block;         width:300px;         height:200px;         text-decoration:none;         background:url(images/oldtable.jpg);         arollover:hover {background-position:-300px 0;     }      It works, but how do I make this dynamic (is that the word?) What do I substitute for the url so that the background url changes for each thumbnail? I tried this and it didn't work: `background:url(<?php wp_get_attachment_image_src());` Can someone help? Thanks.


Default Wordpress settings API data sanitization

It looks to me that when saving data to the database via the settings API Wordpress sanitizes data by default. By that I mean that if I look at the raw settings options in the database they have (at the very least) been through the wordpress equivalent of htmlentities(). Is there any documentation of the exact sanitization process? I don't want to repeat any of it in my own validation function, and want to make sure I'm using the data correctly when I call it back..... **UPDATE:** In response to Christopher Davis's great answer, here is a bit more detail. I am using `register_setting` to register a group of settings. This group is set using the `add_settings_field`. The array of all settings is passed (using the register_settings callback) to a single validation method, which just checks that everything looks right (i.e. reg exp checking that an email is an email, an integer is an integer etc). I am doing no sanitisation, or referencing any of the Wordpress sanitisation methods. However one option value contains a tag, which when viewed in the database has been converted to HTML entities. I assumed Wordpress was doing (at least) this by default for any options stored in the database. Perhaps just by the way it converts an array to a string to store it in the database?


show count author post today

i want show user count post today or yesterday post in wordpress. example: xxxx = published 2 Posts yyyy = published 40 Posts please help me.


Limit tag cloud terms by date

I've been looking for a plugin that limits the tags dislayed in the tag cloud by date. Basically, I want all tags from a certain date forward. I've searched current plugins and haven't found anything that limits by date. Doing some research, I think I just need to modify the following line from:               $tags = get_terms(          $args['taxonomy'],          array_merge(              $args,              array( 'orderby' => 'count', 'order' => 'DESC' )          )      ); // Always query top tags      to:               $tags = get_terms(          $args['taxonomy'],          array_merge(              $args,              array( 'orderby' => 'date', 'order' => 'DESC' )          )     ); // Always query top tags      in the `wp_tag_cloud()` function, but I'm still missing how to limit by the date. Suggestions? Thanks!


Change loop.php for empty search customization

I've been stumped for days wondering why when I submit an empty string as a search term, it redirects to part of `loop.php` where I have the following code inserted:               <?php /* If there are no posts to display, such as an empty archive page */ ?>     <?php if ( !(have_posts()) && !(is_search()) ) : ?>
<?php _e( 'Not Found', 'twentyten' ); ?>

<?php _e( 'Apologies, but no results were found.', 'twentyten' ); ?>
     <?php elseif ( !(have_posts()) && (is_search()) ): ?>
<?php _e( 'Not Found Search', 'twentyten' ); ?>

<?php _e( 'Apologies, but no results were found.', 'twentyten' ); ?>
         <?php get_search_form(); ?>     <?php endif; ?>      I'm probably not including the `is_search()` correctly. But I'm working on this site: http://www.cirkut.net/wp/libertyguide and I want to show the search form when nothing is submitted (i.e. just clicking search from the homepage). Any ideas as to what to do? Thanks for any help!


Between functions.php, widgets and plugins, which is loaded first?

Customer asks if a specific carousel plugin he uses can be widgetized. That means i should create a widget inside functions.php which calls the plugin's function. That means that the plugin's code has to be loaded first so taht the function be available to wordpress when the functions.php file is loaded, right? Would that work?


Using an "IF" statement based on the existence of custom field

I wish to use a function which is run only when a specific custom field is available. Something like:               if (custom_field_x_exists("name_of_the_custom_field")) :                            <Do some things>;             endif;      How might it be done?


How to apply wordpress css styles to a jQueryUi dialog?

Im devloping a wordpress plugin, and I succeded in showing a modal dialog using jQuery. Problem is that I also show a list and buttons into that dialog, and i would like that those buttons and list look like the ones in wordpress. In other words I would like my dialog to 'inherit' WP styles so buttons and list look nice. I would appreciate a LOT your help cause(call me stupid if you want) I have already spent 3 days with this. Thanks


Why do the menu titles change with the renaming of pages?

I've created a custom menu using pages. For a lot of the list items, I've specified a custom menu title for the page... So, the _About Us_ page becomes _About_ on the menu, for example. Then, when the page title is changed, it's changing the title on the menu as well. So if I change _About Us_ to _About Our Company_ the menu is getting changed from _About_ to _About Our Company_. Is there a way to change the default in WordPress, so those custom menu titles are the default instead of the page name? From `header.php`:               <?php      wp_nav_menu( array(         'theme_location' => 'primary',          'sort_column' => 'menu_order',          'container_id' => 'nav',          'container' => 'div'      ) );      ?>      From `functions.php`:               register_nav_menu( 'primary', 'Primary Menu' );


How to get the term description in a taxonomy term archive query?

I'm creating a template for a custom taxonomy for my theme. At the beginning of the page, **before the loop** that lists all the posts associated to a **term** of that taxonomy, I want to output the **description** for that term. I have tried with               term_description()      but it doesn't work, no output... get_the_terms and other functions I know are meant to work within a loop for individual posts (with post->ID)... Anyone has a clue on how to achieve this? many thanks


Check if term is in a taxonomy?

Is there a function that does something like:               is_in_taxonomy($term, $taxonomy)      Where it returns true if `$taxonomy` has that `$term`. ???? Thanks!


Displaying Portfolio Filter by Category Order (alphabetically)

I have created a custom post type to display churches in Europe. I used this tutorial to make it filterable: http://wp.tutsplus.com/tutorials/creating-a- filterable-portfolio-with-wordpress-and-jquery/ Everything on my site works as normal: http://globalicn.com/preview/regions/europe/ My question is, I would like the posts to be organized by the Country not the post of the title.               <?php     $loop = new WP_Query(array('post_type' => 'europe', 'posts_per_page' => -1, 'orderby' =>         'title', 'order' => 'asc'));     $count =0;     ?>      What can I do?


Require Capability to View Woocommerce Product

I am using Woocommerce and I have products in a category called B2B whose single_product.php is only to be shown to people with the capability read_b2b.               <?php if ( have_posts() ) : ?>     <?php do_action('woocommerce_before_shop_loop'); ?>     <?php if (is_product_category('b2b')) && if current_user_can('read_b2b') { ?>       //*** In this case show the PRODUCT with the LOOP ***            <?php while ( have_posts() ) : the_post(); ?>            <?php woocommerce_get_template_part( 'content', 'single-product' ); ?>            <?php endwhile; // end of the loop. ?>     <?php } else {        //*** show error message ***       echo '
You have to be a registered b2b user to see this product
';     ?>      Can you help me get this hack to work for single-product.php?


Wordpress' work or execution flow manipulating $wpdb

I have read about overwriting global variable `$wpdb` and connecting to a second database this way ( Search another database with wp_query using new wpdb ) so one could e.g. use WP_Query on 2nd DB. After that $wpdb is "restored" with $wpdb_backup. See code below from @Tom J Nowell               global $wpdb;     // backup wpdb     $wpdb_backup = $wpdb;          // new db     $newdb = new wpdb($user, $password, $db, $host);          // pretend newdb is actually wpdb     $wpdb = $newdb;          // do stuff          // reset wpdb back     $wpdb = $wpdb_backup;      It's a theoretical question, maybe independant of hooks, only focused on execution-flow. Will PHP (or WP engine in general) primary execute and finish this script-part, where `$wpdb`'s parameters are set to 2nd database's connection details and after doing stuff on 2nd DB will it later switch back to old $wpdb ($wpdb_backup) before a second website visitor clicks a post link right before $wpdb is changed (or any other possible action handling DB1) and PHP reacts after $wpdb is changed to $newdb? If so, in this scenario, WP displays a post from DB2 though the visitor expects (well, it's probably less him - it's WP) the certain Post from DB1. If such a post does not exist in DB2 WP throws an error. Am I wrong? Thank you for your explanations. **edit** Is it about priority with hooks? I know there is `add_action ( 'hook_name', 'your_function_name', [priority], [accepted_args] );` for hook priority. * * * **edit2** Short question: Does WP execute one action after another or does it handle them simultaneously (so that there can be conflicts manipulating $wpdb and after doing some stuff change it back)?


Using multiple variables to assign categories to an array

I have php set up in a template file to check a form and see if 1 or more of 5 categories is selected. Based on which one is selected, I want the custom query I'm using to change in that the array for "category_name" changes depending on what is selected. I have gotten as far as defining the variables from the form but I can't figure out how to get the multiple variables to put themselves into an array. Here is an example of what I'm trying to do:                       if (isset($_POST['showvideo']) && ($_POST['showvideo'] == 'true')) :             $video='user-video,';         endif;         if (isset($_POST['showimage']) && ($_POST['showimage'] == 'true')) :             $image='user-image,';         endif;         if (isset($_POST['showaudio']) && ($_POST['showaudio'] == 'true')) :             $audio='user-audio,';         endif;         if (isset($_POST['showwriting']) && ($_POST['showwriting'] == 'true')) :             $writing='user-writing,';         endif;         if (isset($_POST['showevent']) && ($_POST['showevent'] == 'true')) :             $event='user-event';         endif;      And then, I don't know how to get each of those values to put themselves into a correct array to use inside my custom query as the 'category_name' array. This is obviously wrong:               $upostcat= array ($video . $image . $audio . $writing . $event);      Can someone help me with how to do this? Updated WORKING code based on answer below (thanks!):                   if (isset($_POST['showvideo']) && ($_POST['showvideo'] == 'true')) {         $cats[]='user-video';     } elseif (isset($_POST['showimage']) && ($_POST['showimage'] == 'true')) {         $cats[]='user-image';     } elseif (isset($_POST['showaudio']) && ($_POST['showaudio'] == 'true')) {         $cats[]='user-audio';     } elseif (isset($_POST['showwriting']) && ($_POST['showwriting'] == 'true')) {         $cats[]='user-writing';     } elseif (isset($_POST['showevent']) && ($_POST['showevent'] == 'true')) {         $cats[]='user-event';     };          if (!empty($cats) {       $upostcat = implode(',',$cats);     };


Maintain user profile data in a non-Wordpress database

I have an existing MySQL database (not Wordpress) containing user profile information. I am looking for a way to allow these users to log in to a Wordpress site and edit their profile. It is most likely I will need to write a plugin to do this, however I'm hoping that others have had the same requirement and a solution already exists. I've looked at using BuddyPress and GravityForms as possible vehicles but they don't seem to allow connection to an existing database. The remote database user profiles contain things like clothing sizes and profile pictures; more than the Wordpress profile. About the only thing that is not in the profiles is an email address and password. The remote database is large and is used by other software clients, so it can not be imported or migrated into Wordpress.


Wordpress media upload multiple images

Media popup opens but faling to insert the images . After selecting images it goes page not found instead of closing the popup and returning to tb_unload. I found below code from the template which calls the tb_show to upload the multiple images and gets the count of the attached images.                  $('.theme-interface-option .upload_button, .theme-tax-form-field .upload_button')         .live('click',function() {           formfield = $(this).attr('id');           media = 'image';               formID = post_id;           no_tabs = '&no_tabs=1';           tb_show ( tfuse_title, 'media-upload.php?post_id='+formID+'&type='+media+'&             amp;formfield='+formfield+'&tab='+tab+no_tabs+'&TB_iframe=1' );            $('#TB_window,#TB_overlay,#TB_HideSelect').one('unload',killTheUnloadEvent);                $($('#TB_window').find('iframe')).load(function(){         var _image_form = $(this).contents().find('#image-form');         _image_form.attr('action',_image_form.attr('action')+no_tabs);         var _gallery_form = $(this).contents().find('#gallery-form');         _gallery_form.attr('action',_gallery_form.attr('action')+no_tabs);       });                $("#TB_window").bind('tb_unload', function () {               var attachments  =                $(this).find('iframe').contents().find('#attachments-count');                 var _placeholder = button.closest('.upload_button_div');                });     });      I have checked the url path of the iframe src it is correct and opens in another window. What is the error in the above code why it goes to page not found? and also when I check the console log it show the typenow not defined


Convert wordpress posts to products in Woocommerce

Is there anyway I could convert all the posts e have right now on our Worpdress install into products using some mysql query or something like that?


Download user generated data from Wordpress

I have created a Wordpress site which I allow users to enter information about themselves such as name, age, sex and address etc. Now that I have this n formation I would like to know the steps I should use to download all of the information from all registered users on my site using an objective c NSURLConnection library. I know how to use NSURLconnection, I am used to doing a query where the information is returned in xml or Json format.. However I don't know how to interface this request on my server? For instance do I create a php file that dose the query for me? Or something else? Ay help would be greatly appreciated.


Creating a custom menu/widget area

I'm looking to create a /menu/widget area like the following site: http://www.microsoft.com/en-gb/default.aspx please see sections under downloads, security, support, about is this considered a footer menu as well? my theme's footer menu is just a standard menu on the bottom right corner of the theme like the example site as well but i want to creat a similar area just above it. thanks


Extending wordpress search to include excerpts and taxonomies?

Apologies for the lack of code, but I have no idea where to start with this - is it possible to extend Wordpress's search function to include excerpts and (custom) taxonomies as well as the standard title and post content in search results? i.e. search results don't include posts that contain keywords found in excerpts or taxonomies, is it possible to include them? Ideally, I'd like to do this without a plugin if possible, is there a way to extend it via functions.php? Thanks for any pointers. Osu


Find out if request is for custom post type archive before query runs

I am writing a plugin that is modifying the RSS2 feed for a podcast that uses a custom post type. After the query runs (on action hook `template_redirect`; See this question for why), I'm checking to see if the request is for an archive of my custom post type. If so, I add actions and filters to modify the RSS2 template. Now I would like to make some modifications that affect the query. Without using the `is_post_type_archive` function, which is only updated after the query runs, how do I check that the request is for an archive of the custom post type? On which hook would I add this? Here is the relevant code I have so far:               add_action('template_redirect', 'myplugin_frontend_init_after_query');          function myplugin_frontend_init_after_query() {         if ( is_post_type_archive('myplugin_custom_type') ) {             add_action('rss2_ns', 'myplugin_podcast_ns');             add_action('rss2_head', 'myplugin_podcast_head');             add_filter('the_excerpt_rss', 'myplugin_podcast_description_filter');             // other actions and filters here             // The next one is the one I'm having trouble with:             add_filter('option_posts_per_rss', 'myplugin_podcast_number_filter');             // I'm attempting to alter the number of posts in the feed, but of course after the query runs, it is too late.         }     }


Conditional custom field query

I'm working on a job board-type site, and the client want to sell featured posts. They want the featured posts to expire from showing up in the "featured" section after a predetermined period of time, but continue to show up in the rest of the site. My solution to this problem would be to assign a custom field to posts in the "featured" category stating the number of days it's to be featured for, say, 15. So the logic of the query would be something like: IF the post is category "featured" AND the custom field "featuredexpiredays" IS LESS THAN days since publication, get the post. I have a script for calculating the number of days since publication, I'm just failing completely at figuring out how to glom all this together into a single query. Do you have any suggestions on how to do this, or alternately, suggestions of a different way make my site behave in this way? Thanks so much!


How much effort to migrate from .com to .org

I am launching an education and awareness site on Federal budget. Obviously less effort to use .com and can get going faster -- but would like characterization of effort required to migrate later to .org as will need plug-ins for beta. THANKS


Preventing session timeout

Not sure if this is a bug or by design, but it's damn annoying. Every so often, more so after updating the core, while in the admin section, I get booted out with the infamous "Your session has expired" message. Strange in itself since apparently WP doesn't use sessions. The login prompt comes with a "remember me" checkbox, why isn't it remembering? I guess there's a distinction between "remember me" and "keep me logged in" here. I've disabled all plugins, deletes cookies, tried other browsers and even yelled at my screen, but I keep getting booted out. Does WP set a no activity time limit in the admin section? Could somebody explain what exactly WP is doing to keep users logged in.


Jquery script not loading on site Front page

I've been working on updating a site which was running on an old version of WordPress, I've had to update the theme, most of the plugins and finally got the WordPress up to date. I've had to do a few customisations including using plugins to replace old theme functions that the site used which are not present/working in the updated theme. The theme is now not supported by the developer. The only thing stopping the site going live is that a scroll up button doesn't work properly on the Home page. The scroll up button appears after a user scrolls down a page and when clicked on smooth scrolls to the top of the page and disappears. This is acheived using a bit of jQuery that has been added to the theme's custom.js file. The custom.js file starts with the line:               jQuery(document).ready(function($) {      The button script works fine on all the other pages but not on the front page where it seems the jQuery script has not been loaded. Here's the bit of jQuery:                   /* --------------------------------------------------------------------------- */     /*  13. Back to Top     /* --------------------------------------------------------------------------- */          $("#back-top").hide();          $(window).scroll(function () {         if ($(this).scrollTop() > 100) {             $('#back-top').fadeIn();         } else {             $('#back-top').fadeOut();         }     });          $('#back-top a').click(function () {         $('body,html').animate({             scrollTop: 0         }, 600);         return false;     });          });      I'm at the point where I'm just going to wpenqueue the required script to make it work anyway but I'd rather fix the problem which may be obvious to some but now has me going in circles. The site can be seen at http://just7.co.uk/latinlink/ UPDATE 28/10/2013: I've copied the jQuery code and put it into its own script and enqueued the script via functions.php. I can see the script (backtotop.js) loading but it still isn't working on the home page but works on all others. Here's the script:               jQuery(document).ready(function() {         jQuery("#back-top").hide();              jQuery(window).scroll(function () {             if (jQuery(this).scrollTop() > 100) {                 jQuery('#back-top').fadeIn();             } else {                 jQuery('#back-top').fadeOut();             }         });              jQuery('#back-top a').click(function () {             jQuery('body,html').animate({                 scrollTop: 0             }, 600);             return false;         });          });      The site is at http://www.just7.co.uk/latinlink


Adding Meta box to thrid-party plugin

I am about to write a custom plugin that is intended to »extend« a third party plugin, in this case it is: »EME Events made Easy«. I would like to add a Metabox to the »edit event« screen, from within my plugin, so that I do not have to modify the events-plugin code. How can I do that? Thanks in ahead, philipp **EDIT** Since my Questions seems to lack some details I am gonna add them now: I have installed and actived the Plugin: »EME Events made easy«. In the admin section, I can navigate to: `wp-admin/admin.php?page=events- manager&action=edit_event&event_id=<some_id>` I would like to add a Meta Box to this page, so that I am able to store meta data for each event. There are some hooks, shown here, I can use to actually store the data. So far I have written a Plugin, which also activated and running and I am searching for a way to display the metabox, or inject some custom html at a suitable hook. I have tried:               function sw_contact_add_events_meta_boxes()     {         add_meta_box( 'css-id', 'my-title', 'sw_contact_display_meta', 'events-manager', 'advanced', 'high', array() );     }     add_action( 'add_meta_boxes', 'sw_contact_add_events_meta_boxes' );          function sw_contact_display_meta( $test )     {         die();     }      but the page did not die, so the hook did not work.


301 redirect for wordpress permarlink

on `.httaccess`, we use like this.               RedirectMatch 301 ^/food/(.*)$ http//:domain.com/food-for-healthy/$1      It works good. but we have a problem with 1 old link. we used to have a multi- site and the name is "food". it changed to "food-for-healthy" Therefore we have changed like these.               RedirectMatch 301 ^/food/(.*)$ http//:domain.com/food-for-healthy/$1      and as you know,               http//:domain.com/food/      and               http//:domain.com/food      are same. The problem is `http//:domain.com/food` which needs to go to `http//:domain.com/food-for-healty/` I have tried several things but it gets redirect error.               RedirectMatch 301 /food http//:domain.com/food-for-healthy      this gets a redirect error. how can I change it to work properly?


Getting URL Variables with a Rewritten Page (Login Page)

As part of a larger project, I am attempting all login activity to occur at the following address: www.url.com/login So, a link that should lead to a form that would allow a user to reset their password would be found at the following: www.url.com/login?action=lostpassword However, the wp-login.php is not reading this correctly, and when I go to the above address, I get the normal log-in form. This is how I have it set up:               add_action( 'init', 'add_virtual_page_template' );     function add_virtual_page_template()     {         global $wp, $wp_rewrite;              $wp->add_query_var( 'template' );              add_rewrite_endpoint( 'login', EP_PERMALINK | EP_PAGES );         add_rewrite_rule( 'login/?', 'index.php?template=login', 'top' );              add_rewrite_rule( 'login/?', 'index.php?template=login', 'top' );              $wp_rewrite->flush_rules();     }          add_action( 'template_redirect', 'add_virtual_page_redirect' );     function add_virtual_page_redirect()     {         global $wp;              $queryvar = get_query_var('template');              if ($queryvar && $queryvar == 'login')         {             include(site_url('wp-login.php'));             exit();         }              if ($queryvar == 'mylogin')         {             include( get_stylesheet_directory() . '/page-login.php' );             exit();         }     }      What am I missing?


How do you create a default template?

I have several custom templates. When I create a new page, custom templates (Thesis Skin Custom Template) shows "No Custom Template". There are several to choose from in the drop down. The problem is that any dynamic page will not use a template. Is there a way to make a custom template the default for new pages?


Gain loyalty point in WordPress account when do some activity on other website - possible?

I'm very curious if it is possible to create a loyalty point in WordPress account when we do some activity in other website? I have a WordPress account and I already installed a plugin for gaining loyalty points called "myCRED". It will give points to the registered users when they click on the given links of a website. But, in my case, I want to make the points will be given when the users DO SOME ACTIVITIES in the given links' websites (like this one) after clicking it such as clicking other links in the website or clicking like button on the website. Is there any PHP codes that can do like that? Please help me. I'm totally stuck right now.


cPanel login from WordPress

Do I need a cPanel login username and password to go to cPanel from WordPress or only WordPress login is enough to go to cPanel through cPanel Manager (from WORPIT)?


Post_per_page -1 returns only half the results

I have a custom post type which I created in functions.php.               function codex_custom_init() {       $labels = array(         'name'               => 'Restaurantes',         'singular_name'      => 'Restaurante',         'add_new'            => 'Añadir Nuevo',         'add_new_item'       => 'Añadir Nuevo Restaurante',         'edit_item'          => 'Editar Restaurante',         'new_item'           => 'Nuevo Restaurante',         'all_items'          => 'Todos los Restaurantes',         'view_item'          => 'Ver Ver Restaurante',         'search_items'       => 'Buscar Restaurantes',         'not_found'          => 'No se encontraron restaurantes',         'not_found_in_trash' => 'Restaurantes no encontrados en la Papelera',         'parent_item_colon'  => '',         'menu_name'          => 'Restaurantes'       );            $args = array(         'labels'             => $labels,         'public'             => true,         'publicly_queryable' => true,         'show_ui'            => true,         'show_in_menu'       => true,         'query_var'          => true,         'rewrite'            => array( 'slug' => 'restaurante' ),         'capability_type'    => 'post',         'has_archive'        => true,         'hierarchical'       => false,         'menu_position'      => null,         'supports'           => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' )       );            register_post_type( 'restaurante', $args );     }     add_action( 'init', 'codex_custom_init' );      I am trying to display all items belonging to this custom post type in an archive page. I have 460 entries of this custom post type. I created the file `archive-restaurante.php` I am trying to display all results order by a custom field called `restaurante_municipio`               <?php      query_posts(          wp_parse_args(              $wp_query->query             ,array('post_type' => 'restaurante',                    'posts_per_page' => -1,                     'meta_key' => 'restaurante_municipio',                    'orderby' => 'meta_value',                    'order' => 'ASC')         )     );     global $wp_query;      $total_results = $wp_query->found_posts;      echo '
Restaurantes: '.$total_results.'';     ?>          if(have_posts() ) {          ?>     ...     ..     .     <?php while (have_posts()) : the_post(); ?>     ...     ..     .     <?php endwhile; ?>     ...     ..     .      The number of displayed items is 230 the total number of results (460) divided by 2. If I change the posts_per_page to 100, the number of results displayed is 50. Again post_per_page divided by 2. If I change the post_per_page to 920, the number of results displayed is 230 again. What am I doing wrong? Thanks in advanced for your help.


$wpdb is queried but results don't show

I am trying to show a list of custom post types on a page template. When I view the page, instead of seeing the different posts, I see the actual page repeated. For example, If I have 5 posts, the actual page (head content footer) will be display five times. It seems like the query is working...in some way but I am not sure what is wrong. Here is the template code:               <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>              <div id="post-<?php the_ID(); ?>" <?php post_class('page'); ?>>
<?php the_title(); ?>

                     <?php the_content(); ?>                     <?php wp_link_pages('before=
&after=
'); ?>

          <?php endwhile; ?>                    <?php     //query_posts('post_type=listing&orderby=title&order=ASC&posts_per_page=9999');     ?>          <?php     $querystr = "     SELECT *      FROM $wpdb->posts, $wpdb->postsmeta     WHERE wp_posts.ID = wp_postmeta.post_id     AND wp_postmeta.meta_key = 'listing_open'      AND wp_postmeta.meta_value = 'YES'     AND wp_posts.post_status = 'publish'      AND wp_posts.post_type = 'listing'     ORDER BY post_title     ";                                   $pageposts = $wpdb->get_results($querystr, OBJECT);                              if ($pageposts):                         foreach ($pageposts as $postdata):     setup_postdata($postdata);     ?>          <?php //if (have_posts()) : while (have_posts()) : the_post(); ?>              <?php include_once(get_bloginfo('template_url')."/layout-listings.php?id=".$postdata->ID); ?>                 <?php //endwhile; endif; rewind_posts(); wp_reset_query(); ?>          <?php     endforeach;     endif;     ?>          <?php     $querystr = "     SELECT *      FROM $wpdb->posts, $wpdb->postmeta     WHERE wp_posts.ID = wp_postmeta.post_id     AND wp_postmeta.meta_key = 'listing_open'      AND wp_postmeta.meta_value = 'NO'     AND wp_posts.post_status = 'publish'      AND wp_posts.post_type = 'listing'     ORDER BY post_title     ";                                   $pageposts2 = $wpdb->get_results($querystr, OBJECT);                                 if ($pageposts2):                         foreach ($pageposts2 as $postdata2):     setup_postdata($postdata2);     ?>          <?php //if (have_posts()) : while (have_posts()) : the_post(); ?>              <?php include_once(get_bloginfo('template_url')."/layout-listings.php?id=".$postdata2->ID); ?>                <?php //endwhile; endif; rewind_posts(); wp_reset_query(); ?>          <?php     endforeach;     endif;     ?>


Proper way to create an administration page without adding it to the menu

From what I've seen around the code, you can do this by hooking a function on `admin_init`, do you stuff and then `die()`. Is there a better way that follows "WP best practices" I'm missing here? The page should not have any default body content, like the dashboard sidebar, but the admin scripts/CSS should be loaded normally.


retain querystring values when savincustom options in admin

Quick question, I have a custom options page which posts to options.php, however I have a few sections to my options page where i change the post url like so: `<form action='options.php?section=sectionname' ..>` when the options page reloads I need to check which section was just saved i.e. get the sectionname from the querystring, however the options.php page redirects to the options-general.php page and does not retain my query string. can anyone think of either a way to retain the QS or tell me a better way to do this? Thanks


How do I add a promotional message to my posts?

I'm sure this is a dup, but I honestly can't find an answer. I'd like to add a message to the start and end of my posts:               "Check out my new startup: Facebook For Dogs!"      Is there a simple way to do this, hopefully using a plugin?


How to remove duplicate blog title

My blog is www.theprinterdepo.com/blog. The blog title its in the beginning and at the end, which looks bad for seo efforts, I have a pluggin called ALL In one SEO. Which puts the title of the blog at the end, which is fine. But I cant find how to remove it from the start of the meta title. thank you I suppose this is the code you need:               <title><?php wp_title('|', true, 'left'); ?></title>


hook a functions to change wp-config from functions.php

is there a way to hook / filter or add action that would be printed in the wp- config file? lets say i want to add some simple command like "empty the trash" aka               define('EMPTY_TRASH_DAYS', 1 );       This should be changes in the wp-config but i want it to go with theme.. Any way to do that?


How can I detect if a user changes their password?

I would like to track when a user changes their password. Is there a way to detect when a password has been changed?


Display only page specific sub menu items using Custom Walker

I've just implemented the technique described at http://wordpress.org/support/topic/wp_nav_menu-list-only-2nd-level-separate- submenu/page/2 when implementing a theme for a client. When I run the theme locally on my Wordpress stack it behaves as expected displaying only the children of the parent menu item. When I deploy this to the server it displays all menu items including parents and children which obviously isn't the desired result. My code is as follows:- From functions.php:-               class Custom_Walker_Nav_Sub_Menu extends Walker_Nav_Menu {            var $found_parents = array();          function start_el(&$output, $item, $depth, $args) {                  global $wp_query;                  //this only works for second level sub navigations             $parent_item_id = 0;                  $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';                  $class_names = $value = '';                  $classes = empty( $item->classes ) ? array() : (array) $item->classes;                    $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );             $class_names = ' class="' . esc_attr( $class_names ) . '"';                    if ( ($item->menu_item_parent==0) && (strpos($class_names, 'current-menu-parent')) ) {               $output.= '
';              }                       // Checks if the current element is in the current selection             if (strpos($class_names, 'current-menu-item')                 || strpos($class_names, 'current-menu-parent')                 || strpos($class_names, 'current-menu-ancestor')                 || (is_array($this->found_parents) && in_array( $item->menu_item_parent, $this->found_parents )) ) {                      // Keep track of all selected parents                 $this->found_parents[] = $item->ID;                      //check if the item_parent matches the current item_parent                 if($item->menu_item_parent!=$parent_item_id){                          $output .= $indent . '
ID . '"' . $value . $class_names .'>';                          $attributes  = ! empty( $item->attr_title ) ? ' title="'  . esc_attr( $item->attr_title ) .'"' : '';                     $attributes .= ! empty( $item->target )     ? ' target="' . esc_attr( $item->target     ) .'"' : '';                     $attributes .= ! empty( $item->xfn )        ? ' rel="'    . esc_attr( $item->xfn        ) .'"' : '';                     $attributes .= ! empty( $item->url )        ? ' href="'   . esc_attr( $item->url        ) .'"' : '';                          $item_output = $args->before;                     $item_output .= '';                     $item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;                     $item_output .= '';                     $item_output .= $args->after;                          $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );                 }                       }         }              function end_el(&$output, $item, $depth) {           // Closes only the opened li           if ( is_array($this->found_parents) && in_array( $item->ID, $this->found_parents ) ) {               $output .= "
\n";         }       }            function end_lvl(&$output, $depth) {         $indent = str_repeat("\t", $depth);         // If the sub-menu is empty, strip the opening tag, else closes it         if (substr($output, -22)=="
\n") {           $output = substr($output, 0, strlen($output)-23);         } else {           $output .= "$indent
\n";         }       }          }      From the template:-

              <?php wp_nav_menu( array('theme_location' => 'primary', 'menu_class' => 'nav-menu', 'container' => '', 'depth' => 1,  )); ?>

         <?php         $menu_args = array(       'walker'          => new Custom_Walker_Nav_Sub_Menu(),       'container'       => '',       'menu_class'      => 'sister-pages',     s);     wp_nav_menu($menu_args);     ?>

           The generated source:-

     Our Products

     Existing Members

     Business Directory

     Our Products

     Overview

     Tenant Lifestyle Referencing

     Tenant Credit Referencing

     Insurance

     Existing Members

     Register a Tenant

     Tenant Lifestyle Search

     Tenant Credit Search

     Discuss

     Business Directory


Multisite: should /blog go to a 404 page?

I have a WP multisite installation. All the posts for the default blog are in the subdirectory /blog. All those URLs are fine, all the category and archive links work well. However, visiting the "www.domain.com/blog/" URL leads to a 404. Is this expected behaviour? I thought it might be something to do with my particular install, but I checked another and it seems to be the same. I'm running version 3.2.1


Shared functions.php across multiple WordPress websites

I find myself using many of the same snippets of code for my `functions.php` file in new websites. Is there a method I can use to create a few different shared `functions.php` files to use across my websites? I am not referring to a WPMU installation, but completely separate installations of WordPress with separate databases, possibly on different hosts. For example, if there are functions I want to add to a specific site, I would just add them to the site's own `functions.php`, but also have a shared `functions.php` file for all my multi-author sites and one for all my single author sites. Another situation would be to group together all similar functions into separate `functions.php` files. # UPDATE Here is an update with an example I found in a premium theme's `functions.php`. This is the only code in the `functions.php`, so I assume all the functions are pulled from other files.               $themename = 'CoolTheme';     $shortname = 'cooltheme';          include_once TEMPLATEPATH.'/cool_framework/plugins/pagination.php';     include_once TEMPLATEPATH.'/cool_framework/plugins/cool_widgets.php';     include_once TEMPLATEPATH.'/cool_framework/plugins/sidebar_generator.php';     include_once TEMPLATEPATH.'/cool_framework/cool_comments.php';     include_once TEMPLATEPATH.'/cool_framework/cool_functions.php';     include_once TEMPLATEPATH.'/cool_framework/cool_navigation.php';     include_once TEMPLATEPATH.'/cool_framework/cool_panel/cool_panel.php';     include_once TEMPLATEPATH.'/cool_framework/cool_shortcodes/cool_shortcodes.php';      Is something like this possible, except calling the functions from a completely separate domain or cloud storage? If so, what are the issues, if any, I can expect?


Limit the size of the post excerpt

I am using this filter for Custom excerpts               <?php echo excerpt(90); ?>      http://bavotasan.com/2009/limiting-the-number-of-words-in-your-excerpt-or- content-in-wordpress/ but this filter not working in first featured post showing default 55 words else it's working fine               <?php      $count = 1;     if (have_posts()) : while (have_posts()) : the_post(); if($count == 1) : ?>

     <?php woo_get_image('image',455,245,' '.$GLOBALS['align']); ?>

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

**<?php echo excerpt(90); ?>**
     (<?php _e('आगे      पढे ', 'shreshthbharat'); ?>)

          <?php else : ?>

     <?php woo_get_image('image',455,245,' '.$GLOBALS['align']); ?>

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

**<?php echo excerpt(90); ?>**
     (<?php _e('आगे      पढे ', 'shreshthbharat'); ?>)

      please guide.


translate the_title() with .po & .mo

i need to translate the_title(). I am using code:               <?php _e(the_title()); ?>      but not working ... any ideas ?


theme_locals in CherryFramework

Im using a theme based on the cherry framework and need to edit some text which is echo'd out. The echo'd string is called like this:               <?php echo theme_locals('privacy_policy'); ?>      But I cant find anything that this relates to and I cant seem to find any info regarding what these theme_locals are and where to edit the content. Any ideas?


hijacking home_url for root relative paths

I'd been having trouble with the full domain name being written into the path of links and assets. Basically localhost:XXXX works fine, until I try to reach my site from a Virtual Box install of XP or in my local network, where the domain changes to computername.local:XXXX I managed to solve this problem with a tip from http://www.deluxeblogtips.com/2012/06/relative-urls.html (code below) The problem is that home_url which is referenced throughout my theme still returns the full domain, rather then just "/" as root. is there a way to filter home_url to do this? yes I could `define('WP_HOME', '/' );` which will brute force the path, but causes other issues with feed readers and plugins - it also probably wont work with subdirectory installs. thanks for your thoughts               add_action( 'template_redirect', 'rw_relative_urls' );         function rw_relative_urls() {         // Don't do anything if:         // - In feed         // - In sitemap by WordPress SEO plugin        if ( is_feed() || get_query_var( 'sitemap' ) )          return;         $filters = array(         'post_link',         'post_type_link',         'page_link',         'attachment_link',         'get_shortlink',         'post_type_archive_link',         'get_pagenum_link',         'get_comments_pagenum_link',         'term_link',         'search_link',         'day_link',         'month_link',         'year_link',          );          foreach ( $filters as $filter )     {         add_filter( $filter, 'wp_make_link_relative' );     }         home_url($path = '', $scheme = null);     }


Adding a custom field/property to wp_nav_menu object

i'm a noob with wp, and have been trying to search around to find a way to add a option/setting/custom meta field to a navigation menu object where i can flag it as being a global nav; this is to be used in a multisite set up. i figured i shouldn't be reliant that the navigation exists in the parent site and that any sites can define a global navigation, which could be query for, if needed. i've seen the other solutions out there, but this seems the most elegant in terms of not statically defining the blog id as an argument, or reliant that the global navigation exists in the parent 'unused' site, in a multisite set up. thank you in advance for your help!


show current item in custom menu, when inside a custom post type

I have a custom post type "product". I need to have its index accessible from the main menu, so i 've added a Custom Menu entry, simply stating "/works/" as url value. Problem is: if i'm looking at a single product, the main index menu link does not receive the current_menu_ancestor class. Any idea how to fix that?               register_post_type( 'product',                           array(                 'labels' => array(                     'name' => __( 'Works' ),                     'singular_name' => __( 'Work' ),                     'add_new' => _x('Add New', 'Work'),                     'add_new_item' => __('Add New Work'),                     'edit_item' => __('Edit Work'),                     'new_item' => __('New Work'),                     'view_item' => __('View Work'),                     'search_items' => __('Search Works'),                     'not_found' =>  __('No Work found'),                     'not_found_in_trash' => __('No Work found in Trash'),                      'menu_name' => 'Works'                 ),                 'public' => true,                 'publicly_queryable' => true,                 'exclude_from_search'=>false,                 'show_ui '=>true,                 'query_var' => true,                 'show_in_menu '=>true,                 'show_in_nav_menus '=>true,                 'has_archive' => 'works',                 'rewrite' => array('slug'=>'work','with_front'=>false),                 'menu_position' => 2,                 'menu_icon' => get_stylesheet_directory_uri() . '/library/images/custom-post-icon.png',                 'capability_type' => 'post',                 'hierarchical' => false,                 'supports'=>array('title','editor','thumbnail','excerpt'),                 'taxonomies'=>array('post_tag')             )         );


Which method to use when deleting posts from the front-end

I am trying to enlist all my posts on the front-end along with delete and edit links (using the shortcode API). I am having difficulty with the delete links. To me the most obvious way to handle deletion is to use query variables and $_GET for deletion. However, if the user keeps reloading the page, WordPress will try to delete the post on every page load. Another solution that comes to mind is to make each delete link a button and embed it in a form along with hidden fields containing post id and nonce etc. However this could potentially result in hundreds of form elements and an even higher number of hidden fields on a single page, which seems messy. The last solution that I can think of is to use redirection. I could use query variables but intercept the page load, delete the post and redirect the user to the page without the query variables. However I can't seem to find the right hook for this. I want my function to run early enough so that I don't get any "headers already sent" messages. I'd like to know which method is the correct one? And is there a hook that I can use for that last solution (something like the load hook but for the front-end). Many thanks.


How do i import email addresses into WordPress.com subscriptions?

I have a CSV file with email addresses i want to import into Wordpress.coms Jetpack subscriptions.