Turn off ms-files.php after network setup

I have a multisite that was setup on WordPress 3.4. That means that uploads for sub-sites are stored in `wp-content/blogs.dir/{blog_id}/files` and are served through ms-files.php. In WordPress 3.5, ms-files.php was disbanded completely for new installs and uploads are stored and accessed at `wp-content/uploads/sites/{blog_id}`. Is there anyway I can switch my install from the pre-3.5 way of serving/uploading files to the new way? I would like to continue serving uploads through `files/` for current blogs.


Help splitting a custom post type archive into "past" and "upcoming"

I'm working on a wordpress site that keeps track of a series of `event` posts (custom post type), and I'd like to split up my `archive-event.php` page into two sections – "upcoming events" and "past events," based on today's date. Using `meta_query`, I've been able to successfully show only events which have not yet happened, based on today's date. Changing my query to show past events instead of future ones should not be difficult. What I don't understand is how to enable both of these queries at the same time. Is there a way to create a second `archive-post-type.php` page for my custom post type? Alternatively, is there a way to create a new page template (ex. `past-events.php`) and somehow connect add it into the site's template hierarchy? By way of context, the page I'm trying to modify is here: http://artsrestore.la/events/ And you can see the `archive-event.php` code here: https://gist.github.com/egardner/7324310 Many thanks, Eric Also – I'm pretty new at wordpress and PHP generally, so explanations of code are greatly appreciated!


Load more posts with Ajax and masonry

I'm using this method to load more posts with Ajax: http://www.problogdesign.com/wordpress/load-next-wordpress-posts-with-ajax/ I'm also using masonry for the posts layout. Masonry works fine for the first set of posts, but not for the next set of posts that are appended after clicking load more posts. How can I make masonry work after loading more posts?"


Use comments as notes, visible for comment author only

My question is exactly the same as this, not sure if it can be bumped so thought I'd post again. Basically I'm trying to create a scenario similar to how comments work. On a page, a registered user can submit a comment, except, only they can see it, no one else. These comments would be called notes. Is it possible to change the comments so that only the submitted user can see it? I am mainly looking for something that's right under a post, page, that I can put in a template.


How do I find out where my website is being directed to on a mobile phone? Mobile site is redirected to the wrong page

I cannot find where the site is being redirected on the wordpress.org site but can tell on my phone that it is trying to go to the wrong address. I did not originally try to make it mobile but am trying to fix it - there are no mobile plugins or redirects that appear to be responsible. Please Help!


Sub category templates

I've inherited a Wordpress site that my company built before I started working here. I would go and ask this question of the guy who built it, but he has now left the company. My query relates to custom templates for wordpress categories. I know that you're able to create a template file called category-.php, and when that category is accessed, it'll use that custom template. In this instance, the file is called 'category-limousin-magazine.php' That is working fine - my issues relates to the sub-categories of this category, i.e. under Limousin Magazine, I've got categories of 2011, 2010, 2009, 2008, 2007 and 2006. Somehow, when building the site, he was able to get all of these sub-categories to use the template of 'category-limousin- magazine-templates.php' - but I can't figure out how he did it, as when I run the current site, next to an archive copy of the site previously, the category-limousin-magazine-templates.php file is being totally ignored. So I have one of two questions - first of all, is there an easy way to get multiple categories to use one single template file, or failing that, what is the best way of getting multiple (potentially dynamic) categories from using a custom template. Thank you.


Comment form - different title if no comment yet

this isn't major but would be nice. Would like to have 2 titles for the comment form, one that says "no comments yet start the discussion" and another that says "join the discussion". I've had a good look around but I can't see anything already posted about doing this. Can anyone assist? Skip. (I may use different phrases but you get the general idea I'm sure).


JS script not being included

I am trying to enqueue a js file in functions.php but its not working. Following is my code                add_action('init','shopswing');     function shopswing(){              if(!is_admin()){             wp_register_script('swing',get_stylsheet_directory_uri(). '/js/swing.js',array('jquery'));               wp_enqueue_script('swing');         }     }      and somehow, my site stop responding when i include the code of swing.js               jQuery(document).ready(function() {             $("ul>li>img").mouseenter(function(){             $(this).parents("ul")             .find(".toolTip")             .animate({ 'height':'200px'})             //.css({"display":"block"});         })         .mouseout(function(){             $(this).parents("ul")             .find(".toolTip")             .animate({ 'height':'0'})             //.css({"display":"none"});         });     });


If custom field is empty, use one from a previous post

Let's say you have a few custom fields (I use the advanced custom fields plugin for it). There is an extra field in posts called 'afbeelding_onder'. It is not required but on `index.php` within the loop the custom field 'afbeelding onder' from the last post will be printed. If it is possible, is there a way to check if the custom field is empty, if it isn't than it will print the value, but else (when the custom field is empty) the value of the last post which contains a value in that box will be printed. Hope my question was clear enough, my English grammar is not that good.


Top admin bar / toolbar not showing even when logged in, but empty top margin showing?

I wrote a theme and the top admin / tool bar is not showing. I still see an empty margin. Any ideas? Here the top margin I never set anywhere in my files. I actually want to show the toolbar completely. ![enter image description here](http://i.stack.imgur.com/eS93f.png)


How to use wp_insert_user on Wordpress Multisite?

I previously had a WordpressMU install, but this is deprecated and I'm trying to find my way around multisite. I need to programatically create a new user account for a particular site. wp_insert_user looks like it does everything except say which site the user is _for_ (perhaps it takes this from the domain the request was sent to?). It's important that the created user is a member on one blog (site), but not the other(s).


How to query categories with Advanced Custom Fields?

I'm currently using Advanced Custom Fields and I was wondering if anyone know how to filter categories by custom fields? I have a custom field in my categories using the checkboxes field. I want to make a page that will list categories that contain a specific checkbox field that is ticked. For example I have 3 checkboxes in my categories which are Romance,Action & Drama. I have ticked checkbox Action and I want to list categories on the page that have ticked checkbox Drama. It is kind of similar to this tutorial http://www.advancedcustomfields.com/resources/how-to/how-to-query-posts- filtered-by-custom-field-values/ except I want to get categories instead of posts. What’s the easiest way to do this cause I’m not a programmer?


Setting a Default 'Theme Location' When Creating a Menu

I'm trying to create a theme which when activated, sets up a primary navigation, adds the homepage to it and then enables it in the correct location. Here's what I've got so far:               register_nav_menu('Primary', 'Primary Navigation');          $primary_nav_menu_id = wp_create_nav_menu('Primary');          wp_update_nav_menu_item($primary_nav_menu_id, 0, array(         'menu-item-title' =>  __('Home'),         'menu-item-classes' => 'home',         'menu-item-url' => home_url( '/' ),          'menu-item-status' => 'publish'     ));      The above creates the menu, adds a link to the homepage but how would I go about automatically assigning this menu a theme location of 'Primary Navigation'? Is this possible?


Media Library Custom Taxonomy Archive

I have added two custom taxonomies to wordpress media library audio_cats and audio_tags. Using a plugin, I have uploaded some mp3s and have attached to these two taxonomies. My media library structure looks like this               Taxonomy audio_cats has these categories          -MJ             --album1 (3songs)             --album2 (4songs)             --album3 (1 song)     Taxonomy audio_tags has these tags            -mp3            -MJ      what I want is.   1. index.php -> show all audio_cats (parent only) as a link with total number of child_cats inside and total number to audio assigned to it. For example MJ (3 albums and 8songs) to be shown on MJ cats   2. taxonomy.php -> When a parent category is clicked, it should take to the page where 1) if there are sub cats assigned, it should list them all otherwise list all the songs assigned to it as a link   3. attachment.php -> if song name is clicked it runs the player.   4. audio_tags is displayed as a tag cloud  I hope I make myself clear and anticipate your feedback. Regards


Is there any plugin development framework

Since I am new to wordpress plugin development I have been examining internal structure of many plugin's and I could find most of them doesnt fit any pattern and understanding how they works is pretty much difficult. I was wondering if there is more generalised way of plugin development, possibly with a framework, other than the methods discribed in official documentation.


Upload PDF and other files from the Front-End

I am trying to create a medical website, where logged-in doctors can actually upload pdfs and other files (such as jpg) from the front-end in posts. Then, after reloading the page, the uploaded files should be retrieved within the same post, so other users can easily find the info, without any access to the back-end whatsoever. Can this be done in WP? Thanks in advance! Miguel


Multiple authors with different "author roles"

I´m using Co-Authors Plus plugin to manage multiple authors in a e-magazine, but I´m trying to go further and credit "text authors", "photography authors" and "video authors", so I´m adding a new field in the author´s profile to specify a role (writer, photographer, videographer) and trying to show the extra meta information in single.php and in the frontpage (through a widget). This is the new function in functions.php:               // Add Twitter, Facebook and Role profile field in user profiles.     function add_twitter_contactmethod( $contactmethods ) {     // Add Twitter     $contactmethods['twitter'] = 'Twitter';     // Add Facebook     $contactmethods['facebook'] = 'Facebook';     // Add Role     $contactmethods['role'] = 'Role (writer / photo / video)';     return $contactmethods;     }     add_filter('user_contactmethods','add_twitter_contactmethod',10,1);      And this is the output in single.php and in the widget, which is intended to show the role before the author´s name and a link to the Twitter or Facebook account (e.g. Text: John Doe @johndoe · Photo: John Williams @photowilliams):               <?php $i = new CoAuthorsIterator(); ?>           <?php while($i->iterate()){ ?>     <?php if(get_the_author_meta('role') == "writer"){ ?>     <?php _e('Text:','alegria'); ?>     <?php } else { ?>     <?php _e('Photo:','alegria'); ?>     <?php } ;?>     <?php the_author_posts_link(); ?>     <?php if(get_the_author_meta('twitter')) : ?>     <a href="http://twitter.com/<?php echo the_author_meta('twitter'); ?>" class="author-twitter" title="Follow <?php echo $authorname; ?> on Twitter">@<?php echo the_author_meta('twitter'); ?>      <?php endif ;?>      This works fine, but I´ve been trying to add a third possibility, which involves the role "video" (if the role is "video", then show "Video:" before the author´s name. I´ve been dealing with new instances of "if(get_the_author_meta('role')" and "elseif", but in a intuitive way, since I´m not a programmer and know very little about PHP and conditional sentences. Could anybody point me in the right way to achieve what I´m looking for? Thank you.


Hooks are not executing

Based on my understanding of hooks, you create a hook, by doing do_action('hook_name'); then add something to said hook and call the method where you want it to do the hook, so:               public function hook_name(){         do_action('hook_name');     }      some where you do something like:               add_action('hook_name', 'some_hook');      and then some where in the theme you call:               hook_name();      and there ya go, where you call that function your hook will execute. Well I attempted to create a class to simplify this, because what if you have a theme with say 50,000 hooks (dont ask why, I am going with the extreme), thats 50,000 functions much like the one I did above. So based on: This previous post I attempted to create a class such as:               <?php          class AisisCore_Hooks{              protected $_hooks;              public function __construct($hooks){             $this->_hooks = $hooks;                  $this->_setup_hooks($this->_hooks);                  $this->init();         }              public function init(){}              protected function _setup_hooks($hooks){             foreach($hooks as $hook=>$param){                 if(is_array($param)){                     do_action($hook, implode(',', $param));                 }else{                     do_action($hook);                 }             }         }          }      I then tried doing:               $array = array(         'hook_name_one'     );          $hooks = new AisisCore_Hooks($array);          function test(){         echo "I am a test for this idea";     }          add_action('hook_name_one', 'test');      But soon realized that I am doing an action which has nothing attached to it. So my question is: Do I, in my class, Want to pass in a action name and a function and do add action and then out side call do_action(); ? so:               protected function _setup_hooks($hooks){         foreach($hooks as $tag=>$action){             add_action($tag, $action);         }     }      then do: do_action(//what ever the tag is);


Conditional based on the User Role of the Current Profile the user is viewing - BuddyPress

I'm using BuddyPress and need a certain block of code to show up on user role Store Owner profiles only. I'll be putting it in member_header.php, so it's just a template file. I've been digging for a long time now and just can't seem to figure this out. I found a way to target _current_ user role, but that makes it show up on everyone's profile for a user in the Store Owner user role. I understand I need a conditional, but I just can't seem to find the _right_ conditional... Am I missing something, somehow? Thanks so much!! ## **Edit** : OK, so I've been fiddling around and moved on to something a little different... I still need similar help, just in a slightly different and less flexible setting. I've changed my mind and moved this block of code to a separate profile page entirely. I have the page built and linked to in the profile menu. So what I need the conditional for is to show this menu item based on the user role of the profile being viewed. Here's the code that works and shows up on every single user's page:               // Set up Custom BP navigation     function my_setup_nav() {            global $bp;           bp_core_new_nav_item( array(                 'name' => __( 'Calendar', 'buddypress' ),                 'slug' => 'calendar',                 'position' => 20,                 'screen_function' => 'calendar_template'            ) );                // Change the order of menu items           $bp->bp_nav['messages']['position'] = 100;     }          add_action( 'bp_setup_nav', 'my_setup_nav' );      Here's the code that I've been playing with, but it causes the menu item to just not show up _anywhere_.               // Set up Custom BP navigation     function my_setup_nav() {           if(user_can($user->ID, "store_owner")) {           global $bp;           bp_core_new_nav_item( array(                 'name' => __( 'Calendar', 'buddypress' ),                 'slug' => 'calendar',                 'position' => 20,                 'screen_function' => 'calendar_template'            ) );                // Change the order of menu items           $bp->bp_nav['messages']['position'] = 100;     }     }          add_action( 'bp_setup_nav', 'my_setup_nav' );      My site is: http://www.pureplayhaven.com And the user "sample" is a "Store Owner" user. Thank you so much!!


If/Else Statement for Advanced Custom Fields

I'm still trying to wrap my head around PHP (no pun intended) and am trying to get something to work using the Advanced Custom Fields plugin in WordPress. So, I've got a repeater field that's made up of two Number Fields and a True/False field. I'm basically trying to write a statement like this: If the True/False field is `true` then `echo` both `sub_field_1` and `sub_field_2`, else echo just `sub_field_1`. So far, I've got this:               <?php            while(has_sub_field('parent_repeater')) {              if( the_sub_field('true') ) {            echo '
' . get_sub_field('sub_field_1') . get_sub_field('sub_field_2') . '
';         }              else  {           echo '
' . get_sub_field('sub_field_1') . '
';         }     }     ?>      What am I doing wrong? I'm currently going through the ACF documentation, if anyone could point me in the right direction, I'd really appreciate it. Thanks in advance! **EDIT:**
          <?php while ( have_rows('blend') ) : the_row(); ?>              <?php             $field = get_sub_field_object('blend');             $value = the_sub_field('blend');             $label = $field['choices'][ $value ];         ?>
             Pct: <?php the_sub_field('percentage'); ?> Mix: <?php the_sub_field('mix'); ?>
          <?php endwhile; ?>
          <?php else :          echo '
No Rows found
';          endif; ?>


Wpdb generates too many queries

I googled for hours, then found some codes on stackexchange (http://wordpress.stackexchange.com/a/108279/108270) and created the codes below. I'm trying to get alphabetical A-Z posts lists (e.g. A B C D E ...). Everyting works fine but this code generates too many queries. When there is only post titles, page generates 15 queries but when I add `the_permalink()` it jumps to 33. I suspect there is something wrong here. Can anybody advice me a more efficient way to do what I want? Thanks in advance!                global $wpdb;      $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;      $postsperpage = 10;           $posts = $wpdb->get_results( $wpdb->prepare(          "SELECT * FROM $wpdb->posts          INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id)          INNER JOIN wp_term_taxonomy ON (wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id)          WHERE          wp_term_taxonomy.term_id = 107          AND post_type = 'post'          AND post_status = 'publish'           AND post_title LIKE %s ORDER BY post_title ASC",          $letter . '%'        ));      }           echo '
';      foreach ( $letters as $l) {        $param = $l;        printf('
%s
',$page_link, $param, $param);      }      echo '
';           if ($posts):           $i = $postsperpage * ($paged-1);        while ( $i < $postsperpage*$paged ):           $post = $posts[$i];           setup_postdata($post); ?>
<a href="<?php the_permalink();?>"><?php the_title(); ?>
      <?php      $i++;      endwhile; endif;      ?>


Filter multiple different main queries on custom pages

Ok so I have multiple different page templates with a main query that I want to filter the loop for. In my example I try to use a function to filter the main loop of my site and also the main loop for the page 'new'. Now this works fine for the main page but makes the 'new' page return a 'page not found' not taking the custom template that's assigned to it. What's the right way to do this?               function fod_filter_main_query( $query ) {              if( is_front_page() && is_main_query() ) {                       $query->set('meta_key', 'hotness');             $query->set('meta_value', 0 );             $query->set('meta_compare', '>');             $query->set('orderby', 'meta_value_num' );             $query->set('order', 'desc');             $query->set('cat', -1 );             $query->set('posts_per_page', 16 );             $query->set('post_type', array( 'post','fod_videos','fod_music','fod_articles', 'fod_albums'  ));              } elseif  ( is_page('new') && is_main_query() ) {                  $query->set('cat', -1 );             $query->set('order', 'asc');             $query->set('posts_per_page', 16 );             $query->set('post_type', array( 'post','fod_videos','fod_music','fod_articles', 'fod_albums'  ));              }          }     add_action('pre_get_posts', 'fod_filter_main_query', 9999);


Redirect posts to sub domain except pages

We have a WordPress site, which contains posts and pages. Now we moved posts into sub domain but we kept pages into root domain. Only Posts has `.html` extension and there is no difference in the URL for Posts & Pages. Sample Post: `www.mydomain.com/sample-posts.html` need to redirect with `blog.mydomain.com/sample-posts.html`. Sample Page: `www.mydomain.com/sample-pages` How to redirect only posts in to sub domain?


Error post_type link admin pagination

I have an error with bad links on all my specials post_type created by the plugin "magic-fields-2". on the admin link (pagination, eg: go to page 2) i can see : http://myserver.cl/cedennatest/wp- admin/edit.php?post_type=integrantes%3Fpost_type%3Dintegrantes&paged=2 like you can see i have two times the same variable post_type and two time the character "?" How i can modify this link in wordpress ? Process with "magic-fields-2" :   1. created a new type   2. the new type is now present in the lateral bar (where there is "Dashboard" etc)   3. when the number of this special type exceed the maximum of autorised post i see a arrow for pagination   4. this link for ALL new type created have the problem


Highlight current post title on a page

In my menu I have a page that is called `Campaign`. When the user enters to `Campaign` the page displays the last custom post type of `campaign-post`. In the sidebar of `Campaign` page, I'm displaying a list of all `campaign- post` custom posts. The problem is that I don't know how to highlight (add `current` class) to the last post title in the list that is displayed when the user enters to `Campaign` page. This is how I'm displaying the list:
         <?php $query = new WP_Query( array( 'post_type' => 'campaign-post' ) );                      while ( $query->have_posts() ) : $query->the_post();             echo '
';             the_title();             echo '
';         endwhile; ?>
      Any ideas?


Order by optional meta key?

I'm building the sorting functionality for a custom post type, and I have a custom meta value for "Featured" posts. This value is set when you tick the checkbox, otherwise it is not set. Using the default `orderby=meta_value` with `meta_key=featured` makes it so that the screen only displays posts that have the meta key. If they don't, they don't even appear. I want it so if it is not set, they do appear, but they appear last. I assume I need to use `meta_query` instead, but I couldn't get that to work either. **How do I allow empty, false, or non-existing meta keys in the WP_Query arguments?** My code is below. This is for sorting columns in the dashboard, so it is modifying the default WP Query args.               function featured_sortable_order( $vars ) {       if ( isset($vars['orderby']) && $vars['orderby'] == 'featured' ) {              $vars = array_merge( $vars, array(           'meta_key' => 'featured',           'orderby' => 'meta_value',           'order'     => isset($vars['order']) ? $vars['order'] : 'asc',         ) );            }       return $vars;     }     add_filter( 'request', 'featured_sortable_order' );


How to list all external URLs that I have posted on my WordPress blog?

I want to list all the external links of my posts in a single place/file. How can I achieve this?   * Is it possible to achieve this via a plugin?   * Is it possible to achieve this with a built-in wordpress api?   * Is it possible to achieve this via some free 3rd party tool? What approach should be followed for achieving this?


How to display custom taxonomies at multiple levels

I have built a custom post for products, as well as a custom taxonomy for it. I am attempting to have a main product page that lists the top level categories. That works fine. Then that page links to the corresponding sub category, using a custom archive template, where this code is. Goal is to display each sub category, and it works for the first level only. It displays proper, then when clicking on a link to go to its child category list, it just goes back to the initial products page. Any thoughts on how to do this? This is the code for where I output the child categories. Thank you!
         <?php         $current_cat = get_query_var('products_category');         $args = array(                         'hide_empty'    => false,                         'parent'        => get_cat_ID( $current_cat )                     );              $categories = get_terms( 'products_category', $args);              foreach ($categories as $category ) { ?>
             <?php             $cat_img = get_field('category_image', 'products_category_'.$category->term_id);             $cat_link = get_term_link( $category,$category->slug ); ?>                      <a href="<?php echo esc_url( $cat_link ); ?>" title="Category Name">                     <img src="<?php echo $cat_img ?>" alt="<?php echo $category->name ?>"/>                              <?php } ?>


How to replace settings in WordPress plugin from a theme

I created an array with some default settings in a plugin, and want to allow it to be replaced from functions.php in a theme without using stored data (eg. add_option). I want this to be just a hook with new values. example array inside plugin:               $default_settings = array(        'key_one' => 0,        'key_two' => 1     );      I need to allow this to be changed from a theme's functions.php, so a developer can add something like this:               add_filter('the_hook','my_function');     function my_function(){       $default_settings = array(            'key_one' => 1, //changed value            'key_two' => 1       );     }      If a developer makes this call, then I want the new values replacing the old array inside the plugin. Any help is appreciated.


Attaching a media file to email link from webpage? How?

When someone clicks a link on my webpage I want it to come up as an email with a document from my media folder already attached to it. How do I do this? Thanks!


Super simple shortcode not working

Have been looking at various tutorials and answers here and elsewhere and just can't get this to work. Just trying to display a simple output from a shortcode as below, but it is just outputting the actual shortcode tag to the page instead of the content from the shortcode **Functions.php**               <?php      function welcome_roundels_func(){         return "testing";     }     add_shortcode( 'welcome_roundels', 'welcome_roundels_func' );     ?>          add_action( 'init', 'register_shortcodes');      **Usage**               [welcome_roundels]      Is there anything else I have to do to enable shortcodes, or should the above work? **Edit** I am also using the below code to output the content               $welcomePage = get_post( 5 );      echo $welcomePage -> post_content;


Why my custom post posts aren't showing (404 error / page not found)

I just installed a new wp installation. I have created a new child theme based on the TwentyTwelve theme. In the child theme functions.php, I have created a new custom post called "news". I have added two posts in the "news" and when I view either of them, I get a "page not found" error. See screenshot: http://pasteboard.co/dtIOK6g.jpg I am expecting the posts to be displayed but am getting a 404 page. why. **Update** (to make my question clear): From installation, I have done very little work, apart from the following:   * Added a new child theme (of Twenty Twelve)   * I have applied the new child theme   * I have created a new custom post by updating the creating a functions.php in the child theme and ading in this code here (http://pastebin.com/DKny8QH1)   * In WP admin, I have created a 2 new posts under news (new custom post created above)   * if I try to access the post, i get 404 (as shown in screenshot above). However, I can access the posts created normally. Thanks **RESOLVED** : This is really weird but I have resolved it. It appears I needed to reselect the "Post name" option for my permalinks settings even though it was already selected. Selecting this option again solved my problem. Sorry about any confusion.   * I went to settings > permalink


Import tumblr post to wordpress blog

When I add a new post in my tumblr account, automatically that post of tumblr would be sync with my wordpress account. Its not necessary that at sync time I have to be logged in wordpress. In simple words, tumblr post will be automatically shown to wordpress blog. I donot know how it will work. If any body have any plugin or api which match to my requirement. I will very much thankful. i am using this plugin :- http://wordpress.org/extend/plugins/tumblr-importer/ But problem is that i have to import every time post is added in tumblr.Hope that makes sense. Its really annoying for me. TIA


WordPress calendar hook to filter days that are marked with posts

The `get_calendar` function returns a calendar and is part of the core widgets that come with WordPress. But I've written a custom solution for controlling the visibility of posts based on user associations. (Certain posts are visible only to users with certain terms associated with them; for example, users who belong to the "associates" term of the "groups" taxonomy see posts that are targeted towards associates, while they are invisible to other users and guests.) This works for the post view and the archive view. But if I include a calendar widget, it marks days incorrectly. For instance, on December 3rd, only one post was made and it is only visible to associates. But the number 3 on the calendar is a link. When I click on it, it goes to the archive, which is empty for that day. I have overridden the `posts_where` hook, but when I viewed the source of `get_calendar`, it doesn't appear to use that hook. Is there something I'm missing? Should I use a calendar plugin instead, or try to manipulate the resulting HTML code using the `get_calendar` filter?


WordPress htaccess

I got the following from the html5 boilerplate htaccess file. Is this safe to add to my wordpress htaccess? And will it help?               <IfModule mod_deflate.c>          # Force compression for mangled headers.     # http://developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping     <IfModule mod_setenvif.c>         <IfModule mod_headers.c>             SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding             RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding         </IfModule>     </IfModule>          # Compress all output labeled with one of the following MIME-types     # (for Apache versions below 2.3.7, you don't need to enable `mod_filter`     #  and can remove the `<IfModule mod_filter.c>` and `</IfModule>` lines     #  as `AddOutputFilterByType` is still in the core directives).     <IfModule mod_filter.c>         AddOutputFilterByType DEFLATE application/atom+xml \                                       application/javascript \                                       application/json \                                       application/rss+xml \                                       application/vnd.ms-fontobject \                                       application/x-font-ttf \                                       application/x-web-app-manifest+json \                                       application/xhtml+xml \                                       application/xml \                                       font/opentype \                                       image/svg+xml \                                       image/x-icon \                                       text/css \                                       text/html \                                       text/plain \                                       text/x-component \                                       text/xml     </IfModule>


WordPress and Git Workflow

I know this question has been asked a thousand times, but I'm really trying to work out how to get the best out of Git when working with WordPress. I've scoured the web and read dozens of articles, all that seem to cover the topic briefly. Here's a few of the most notable one's I've read recently. \- Version Controlling WordPress \- Managing WordPress Theme Deployments with Git \- Manage your custom WordPress theme using git instead of FTP Currently, my workflow looks like this.   * Install WordPress locally   * Develop Theme   * Export WordPress Databases from local server   * Import WordPress Database to remote server   * Upload WordPress files and theme via FTP   * _Client makes changes_   * Download WordPress files and theme via FTP and export WordPress Databases from remote server   * Replace files locally   * _Make development changes_   * Re-upload via FTP, export and import database to remote server I realise Git can streamline this process. It seems the best way to do this is to have a .gitignore file that ignores certain directories that don't need to be tracked, as well as having both a local and remote wp-config.php file. But how do you handle the databases? Clients will usually make changes (posts/pages/plugins). Do I still need to export from the remote database and import back on my local server? Can someone suggest the best workflow for me here? And walk me through the steps. Also, I'd probably like to use Bitbucket as private repos with them are free, unlike GitHub. Any help would be appreciated. Thanks in advance!


404 error with nested WordPress installations

I'm making changes to a site that someone else built in the root directory of their server and trying to add another directory with wordpress onto the root of the server, it gives me a 404 error from the wordpress site that is installed onto the root. The theme has a setting where you can edit the .htaccess file... right now it has the code at the bottom in it, if I add this to the top of it will it screw up the website. Last thing I need is for this main site to go down. WANT TO ADD THIS...               RewriteEngine On RewriteBase / RewriteCond %{REQUEST_URI} ^/subdirectoryname1/(.)$ [OR] RewriteCond %{REQUEST_URI} ^/subdirectoryname2/(.)$ [OR] RewriteRule ^.*$ - [L]      TO THIS.... (already there)               BEGIN WordPress          RewriteEngine On RewriteBase / RewriteRule ^index.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L]          END WordPress


How to include first assigned category in the post URL?

What are the options for creating URLs like: _site.com/category-name/post-name_ Where, "category-name" is the first category that the post was assigned to (in the event that the post is assigned to multiple categories) Note: if the post is assigned to "uncategorized", I don't want to display the category name in the URL, so in that case, I just want _site.com/post-name_ PS: it will also require the removal of the word "category" from the URL. I was able to get that done with the plugin "no category base", however, it does not include the parent category name in the URL to a post.


Installing WP twice in same Directory?

I have a website that has Wordpress installed in the root directory `/` I have another website, that's contents is within that root directory, `/seperatesite/` that stores a separate, small, splash page type website, with a separate domain pointing to it. I want to setup another Wordpress install inside of this folder. Is it hazardous to have two Wordpress installs setup this way? I'm wondering as I currently don't have the host credentials to create a separate database within the host area if need be, is this simple enough to move without this - or still a sensitive setup? **Thanks for any pointers!**


Standard wordpress importer seems to be missing blog images

I have 2000+ images and I've used the importer both locally and on my hosted site, the hosted site seems to have 100 less images though. I'm importing from blogger. I've ran the importer a few times and it still hasn't picked them up. These images are supposed to get downloaded and stored locally from a blogger website but I'm short ~100. Anyone else ran into this problem and know of a fix?


Can the Twenty Eleven theme have a Main Sidbar at all?

After pulling my hair trying to find out why my Main Sidebar disappeared, I performed as a last act of desperation a complete wipeout of the database and the entire wordpress directory, then I restored them from the earliest backup of my totally fresh install of WordPress, which includes **only the home page and the original sample page** and **no plugins!**. That didn't help displaying the Main Sidebar. But when I switch to `Twenty Ten`, the Main Sidebar, with the calendar in it, is there! This is insane, as I am now beginning to doubt my memory that I ever saw the Main Sidebar on `Twenty Eleven`. Can the Twenty Eleven theme have a Main Sidebar at all? If so, what am I doing wrong?


How to play amazon S3 videos in wordpress 3.6?

The latest release of WP has its own media player (mediaelement.js), to include and play a video we no more need a separate media player now. My question is How can I make the `[video]` shortcode work with videos uploaded on S3 which are protected. I try using this               [video mp4="http://xyz.s3.amazonaws.com/test.mp4?AWSAccessKeyId=AKIAIFXXXXXXG7A7A&Expires=1375464588&Signature=ZimqpfuYZQwQIrPaVnodi4WASO0%3D"]      But that doesn't seem to work. The URL I created has expire time of 300s, if I try to run the test.mp4 in a new tab, it works. But it doesn't play in wordpress. Any help would be appreciated.


custom url rewrite

I have a custom search, one database out of WP, I store the page in wordpress admin panel: http://localhost/wp/wp-admin/post.php?post=96&action=edit&message=1 Then the page's url looks like `http://localhost/wp/directory/view?search=moto&number=12` Now I want to modify it into `http://localhost/wp/directory/view/moto/12`. I tried the method with `RewriteRule ^directory/view/(.*)/(\d+)/$ directory/view?search=$2&number=$3`, and the whole `.htaccess` is:               # BEGIN WordPress     <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /wp/     RewriteRule ^index\.php$ - [L]     RewriteRule ^directory/view/(.*)/(\d+)/$ directory/view?search=$2&number=$3      RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /wp/index.php [L]     </IfModule>     # END WordPress      but it does not work, need a work code, thanks, EDIT: I tried `add_rewrite_rule` still not worked... To avoid page name infection, the better way use `directory/view`.               function add_directory_rewrite() {         add_rewrite_tag("%search%", '(.+)');         add_rewrite_tag("%number%", '(\d+)');         add_rewrite_rule('^directory/view/(.+)/(\d+)/', 'directory/view?search=$matches[1]&number=$matches[2]', 'top');     }     add_action( 'init', 'add_directory_rewrite' );


Custom Search Not Consistent with Results

I've set up a custom search to use the `s` GET variable on a URL. I want it to fetch certain results but I've come across an odd problem. First, here's my code:               $search_term = $_GET['s'];          if($search_term!=''){         $s = new WP_Query(array('s' => $search_term));         $search_array = array();              if($s->have_posts()){             while($s->have_posts()){                 $s->the_post();                      $title = get_the_title();                 $permalink = get_permalink();                 $search_identifier = $title.$permalink;                      array_push($search_array,$search_identifier);             }         }     }      Essentially, I'm creating an array of unique values for each post because I need to use them for a function immediately after that. I have a post titled 'Kitchen Assistant.' When I search 'kitchen', it shows up. When I search 'assistant' it does not show up. I have other posts with the word 'assistant' in the title and content and those show up when I search 'assistant'. I'm curious as to why it would show up with one search term and not the other? Any help would be greatly appreciated. Thanks! ## EDIT Here is my code in a greater context for clarification. I've created a standalone template PHP page as a new search page because of the customizations I am looking to do. It's a search form that searches for two different terms. One is a search term and the other is a location term. I first do a WordPress query for the search term and add them all to an array (if a search term exists). I then do a search for the location (if the location exists). I then cross-reference them if both exist, otherwise I just do a search depending on the variable that exists. It all seems to work EXCEPT the search part in WordPress. It doesn't affect the location search at all and the location search doesn't really seem relevant to why the Wordpress query is failing to pick up the right variables but everyone keeps asking about the context of it so I figured I'd share. Let me know if this sheds more light on the situation or if you'd like me to clarify any other elements of it. Thanks!               <?php     //DIRECT CONNECTION TO DATABASE     include('job-parsing/connect.php');     //WP CONNECTION TO DATABASE     include('wp-config.php');          get_header();          $search_term = $_GET['s'];     $real_loc = $_GET['location'];     $location = urlencode($_GET['location']);          //QUERY SEARCH TERM INITIALLY     if($search_term!=''){         $s = new WP_Query(array('s' => $search_term));         $search_array = array();              if($s->have_posts()){             while($s->have_posts()){                 $s->the_post();                 //var_dump($s);                      //I ADD POST LONGITUDE AND LATITUDE FIELDS BECAUSE THESE POSTS ARE ENTERED DAILY ON A CRON JOB WITH THOSE VALUES; THESE WILL BE NEEDED LATER DURING A GEOLOCATION TEST BELOW                 $post_latitude = get_post_field('post_latitude');                 $post_longitude = get_post_field('post_longitude');                      //CURRENTLY SOME POSTS DON'T HAVE LONGITUDE AND LATITUDE SO I DON'T WANT TO HAVE THOSE INCLUDED IN THE SEARCH, THEY ARE IN A LIST ON THE SITE BUT DON'T HAVE LOCATIONS SO IT DEFEATS THE PURPOSE OF WHAT WE ARE DOING AND WILL BE EXCLUDED FROM SEARCH                 if($post_latitude && $post_longitude){                 $id = get_the_ID();                 $search_identifier = $id;                      //IF POST LATITUDE AND POST LONGITUDE EXIST ON TERM THAT MATCHES SEARCH TERM                 array_push($search_array,$search_identifier);                 }                }         }     }          //SEARCH RESULTS ARRAY IS NOW SET          //IF LOCATION IS FILLED OUT, RUN GOOGLE API CODE (POSTCODE/TOWN IS THE DEFAULT VALUE/PLACEHOLDER ON THE FORM SO IN THE CHANCE THAT SOMEONE SUBMITS WITH THAT STILL IN THE INPUT, I DON'T WANT IT TO RUN THROUGH THE GOOGLE API     if($location!="Postcode%2FTown" && $location!="" && $location!="Postcode/Town"){         //TAKE THE LOCATION SEARCH TERM AND CONVERT IT INTO LATITUDE AND LONGITUDE COORDINATES         $url='http://maps.googleapis.com/maps/api/geocode/json?address='.$location.'&sensor=false';         $source = file_get_contents($url);         $obj = json_decode($source);         $LATITUDE = $obj->results[0]->geometry->location->lat;         $LONGITUDE = $obj->results[0]->geometry->location->lng;              $center_lat = $LATITUDE;         $center_lng = $LONGITUDE;         $radius = $_GET['radius'];              $query = sprintf("SELECT ID, post_title, post_latitude, post_longitude, post_date, ( 3959 * acos( cos( radians('%s') ) * cos( radians( post_latitude ) ) * cos( radians( post_longitude ) - radians('%s') ) + sin( radians('%s') ) * sin( radians( post_latitude ) ) ) ) AS distance FROM wp_posts HAVING distance < '%s' ORDER BY distance",           $mysqli->real_escape_string($center_lat),           $mysqli->real_escape_string($center_lng),           $mysqli->real_escape_string($center_lat),           $mysqli->real_escape_string($radius));         $result = $mysqli->query($query);         $found_num = mysqli_num_rows($result);     //END GOOGLE MAPS API CALL     }     ?>

<?php echo $found_num; ?> Jobs found for <?php echo $real_loc; ?>"

          //BEGIN JOB LIST
          <?php     //IF LOCATION WAS ENTERED AND A SEARCH QUERY USING GOOGLE MAPS API WAS USED SUCCESSFULLY     if($result){     //INITIALIZE NEW ARRAY         $new_search_array = array();         while ($row = $result->fetch_assoc()){             $post_id = $row['ID'];             $permalink = get_permalink($post_id);             $title = $row['post_title'];                  //IF SEARCH TERM EXISTS, CREATE ARRAY THAT MATCHES LOCATION AS WELL             if($search_array){                 foreach($search_array as $value){                     if($value==$post_id){                         array_push($new_search_array,$post_id);                     }                 }             }             //ELSE IF SEARCH DOESN'T EXIST, JUST DO LOCATION SEARCH             else{             echo $row['post_title'];             }         }         }              //IF SEARCH TERM DID EXIST AND LOCATION TERM DID EXIST, NEW SEARCH ARRAY INITIALIZED AND WE USE THAT TO DISPLAY RESULTS             if($new_search_array){             foreach($new_search_array as $value){                 get_the_title($value);             }         }         else if($search_array){         foreach($search_array as $value){             get_the_title($value);         }     }     ?>
          <?php     get_footer();     ?>


How to exclude posts ordered by comment_count from subsequent wordpress loops using WP_Query?

My page has three separate loops on it. The first retrieves the most commented post. The query then resets for the second loop and retrieves the 3 most recent posts, then resets again to get the three most recents posts after that. What I want is for the post that has the most comments to a) only be chosen from the last 24 hours and b) to be excluded from showing up in the 2nd and 3rd queries to prevent duplicate posts showing up. How would I achieve this?                <?php get_header(); ?>

                                  <?php                                   $args = array(                             'posts_per_page' => 1,                             'orderby' => 'comment_count'                                       );                                  $the_query = new WP_Query( $args );                                  ?>                                  <?php if ( have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>                                      <a href="<?php the_permalink();?>">
<?php the_title(); ?>

Published on <?php the_date(); ?> by <a href="<?php echo the_permalink();?>"><?php the_author(); ?><a href="<?php the_permalink();?>"> <?php comments_number(); ?>
                                      <?php the_excerpt(); ?>                                  <?php endwhile; else: ?>                                       <?php endif; ?>                                  <?php wp_reset_postdata(); ?>
                                       <?php                                   $args = array(                             'posts_per_page' => 3,                             'orderby' => 'most_recent'                             );                                  $the_query = new WP_Query( $args );                                  ?>
                                  <?php if ( have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>                                      <a href="<?php the_permalink();?>">
<?php the_title(); ?>

Published on <?php the_date(); ?> by <a href="<?php echo the_permalink();?>"><?php the_author(); ?>
                                 <?php the_excerpt(); ?>                                  <?php endwhile; else: ?>                                  <?php endif; ?>                                            <?php wp_reset_postdata(); ?>
                                  <?php                                   $exclude = $most_recent;                                       $args = array(                             'posts_per_page' => 3,                             'orderby' => 'most_recent',                             'offset'  => 3                             );                                  $the_query = new WP_Query( $args );                                  ?>
                                  <?php if ( have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>                                      <a href="<?php the_permalink();?>">
<?php the_title(); ?>

Published on <?php the_date(); ?> by <a href="<?php echo the_permalink();?>"><?php the_author(); ?>
                                 <?php the_excerpt(); ?>                                  <?php endwhile; else: ?>                                  <?php endif; ?>                                  <?php wp_reset_postdata(); ?>

                                  <?php get_sidebar(); ?>
              <?php get_footer(); ?>


How do I display a custom field from a custom taxonomy in single.php?

I know that the following mysql query produces the exact results I wish to echo within single.php:               SELECT meta_value     FROM `wp_taxonomymeta`     WHERE `taxonomy_id` =565     AND `meta_key` LIKE 'baseurl'      First, I need to be able to use $wpdb to output that result, and no matter what I try I can't get it to work. My final try:               <?php global $wpdb;         $toc = $wpdb->get_row("     SELECT meta_value     FROM `wp_taxonomymeta`     WHERE `taxonomy_id` =565     AND `meta_key` LIKE 'baseurl'     ");          echo $toc; ?>      produced the following error: Catchable fatal error: Object of class stdClass could not be converted to string in /wp-content/themes/new/single.php on line 22 Second... and it's important. The value 565 I am using for the taxonomy_id was only for testing... the actual value I need to insert in place of the number 565 can be displayed in single.php using:               <?php $term = get_term_by('id', $termID, 'dataset'); echo $term->term_id; ?>      For reference, so you can understand what I'm trying to do... I have assigned a custom field to a taxonomy and am trying to get the results of that custom field to display in single.php... while I found a plugin (Ultimate CMS) that would do this for me, it also chooses to display a filter for all taxonomies at the top of my Post Screen... when you have 50,000+ rows in your taxonomy that causes way to much page load in the admin, and I can't find a way to suppress it. Any help with my NOOB try at coding would be appreciated! Thanks


Upload a custom csv file, read contents and delete that file

Can someone please direct me to a resource or give me some pointers on:   * How to upload a csv file to wordpress (media uploader or alternate methods, ajax powered preferred)   * Access that file so I can read the contents I am not looking for a plugin as this is a custom file that I need to read and process inside a plugin. Ideally, this workflow is desired: **Choose a file** > **Click Upload** > **Plugin accesses the file after upload** and processes file content > **Plugin deletes the file**. Bold steps interest me the most.


Add a excerpt to a custom WYSIWYG

I have a secondary WYSIWG on my post and I am using it to display content under a thumbnail. I am trying to figure out how to limit the amount of words I can display with the code I am using to display the secondary WYSIWG. I know how to do it using excerpt when it triggers the_content, but the same effect does not happen when I assign it to my code. Here is my code that display the content on my post                <?php echo wpautop( get_post_meta( get_the_ID(), $ingredients . '_cmb_fe_wysiwyg', true ) );?>      I do not know if this matters but this is the code I am using in my function to display the WYSIWG                function cmb_sample_metaboxes( array $meta_boxes ) {             $prefix = '_cmb_';             $meta_boxes['fe_metabox'] = array(                'id'             => 'fe_metabox',                'title'          => __( 'Post Scope', 'cmb' ),                'pages'          => array( 'post', ), // Post type                'context'        => 'normal',                'priority'       => 'high',                'show_names'     => true, // Show field names on the left             // 'cmb_styles' => true, // Enqueue the CMB stylesheet on the frontend      'fields'       => array(      array(           'name' => 'Test wysiwyg',           'desc' => 'field description (optional)',           'id' => $prefix . 'fe_wysiwyg',           'type' => 'wysiwyg',           'options' => array(),      ),      Is there also a way to only display the content instead of the images in the WYSIWG as well?


Get content from one page and show it on another page

So, I've been googling and reading and testing and failing. I'm fairly new to php, so don't expect to much :) I'm working on a new design, and I want to show content from the about page on my homepage, which is dynamic. So, I've been looking into that the_content thing, but I havent gotten any luck so far.               <?php        $id=about;        $post = get_page($id=);        $content = apply_filters('the_content', $post->post_content);        echo $content;     ?>      the ID of the page is "about", if that is any help. Please get back to me :)


YARPP php question

I'm trying to put a border under `related_posts()` ,it works, but the border is showing even when the there are no posts. How do I make the border show only when there are related posts to show?


Prevent Authors from viewing each others Posts

I am setting up a site where there will be multiple users as Author, the owner doesn't want the authors to be able to view each others posts, since there are some meta fields with information he'd rather not have shared between the authors. Is there a way to remove the ability to view other authors posts? Thanks, Chuck To clarify a bit more, this is for the admin side, at the top underneath Posts, there are links for mine, all, and published. I only want Authors to see "mine".


Taxonomy template for all taxonomies attached to certain post type

For instance, I have a product post type and I would like all the taxonomies associated w/ this type, such as size, color, material etc to display using the same template without having to 1. create a catch all taxonomy.php that might interfere w/ taxonomies on other post types and 2. without having to manually create taxonomy-size.php, taxonomy-color.php, etc since new taxonomies can be created at any time. can i do this by hijacking template redirect?


Is this robots.txt making Google not to show some of my content?

http://chineselearnonline.com/               User-agent: *          Disallow: /feed/     Disallow: /trackback/     Disallow: /wp-admin/     Disallow: /wp-content/     Disallow: /wp-includes/     Disallow: /xmlrpc.php     Disallow: /wp-          Sitemap: http://chineselearnonline.com/sitemap.xml      I just changed to a new server. And my site started to not to appear in the top search results s before. I was wondering if the robots.txt above is blocking some of my WordPress content? **EDIT:** I changed the path from `http://chineselearnonline.com/v4` to `http://chineselearnonline.com/` also, not sure if this is the real problem and no `robots.txt`


Multiple Loops Homepage?

I have been pretty impressed with the recent redesign at WebDesignerDepot and I am curious about the mechanics of their homepage. I like how they have featured post sections that break up the monotony of the page, but I haven't figured out how to incorporate something similar in my own designs. I'm guessing that they are using multiple loops and it seems like it's something like [main loop chronological] --- > [custom loop] ---> [main loop continues chronologically]. How would I break off into a custom loop and then continue where I left off in the main loop?


Wordpress Search not picking up text provided by a Plugin

I have a site plugin that fills in text on pages remotely. Wordpress does not search the pages created by the plugin. I tried Google custom search engine code, no good. How can I search this text? Also how can I show search snippets not entire posts listed out? Site is at www.SiteNamePro.com. The domains listed are filled in by the plugin. I want users to find domain names by search, not using CTRL+F, just using normal Wordpress search, or by what appears to them to be normal WP search. Thanks!


Custom wp_query time filter on meta_value

My goal is to only show posts with opening hours after business hours, for a given day. So, e.g. I have a (custom) post with following meta_key and meta_value: meta_key = 'monday, meta_value = '14:00 - 22:00' The business hours are fixed: '08:00 - 18:00' I'd like to add a filter to my custom wp_query. Only, I am getting stuck at defining a function. My logic input (definitely not correct & complete) for the function:               $from_std = strtotime("08:00");     $to_std = strtotime("18:00");                             $open = $my_meta['monday'];     list($from, $hyphen, $to) = explode(' ', $open);     $from_bus = strtotime($from);      $to_bus = strtotime($to);          if ($from_bus < $from_std) { $show = 1; } // before standard starting time - so SHOW       else {if ($to_bus > $to_std) { $show = 1; }} // after standard closing time - so SHOW          if (empty($from_bus)) { show = 0; } // $var is either 0, empty, or not set at all - so do NOT show      Help on a function is very much appreciated.


How to get a list of all users registered before a given date?

I was expecting to be able to do something like the following which I thought would return all users that have registered before a given date:               $args = array(         'post_type' => 'post',         'date_query' => array(             array(                 'before' => current_time( 'mysql' )             )         )     );     $query = new WP_User_Query( $args );      However, unlike `WP_Query`, `WP_User_Query` doesn't support the `date_query` parameter so the above code doesn't work. How can I get a list of all users registered before a given date?


Gist shortcode is not working

I freshly installed a brand new Wordpress for testing purpose as I am intending to refresh my current website. One of the requirement I have is to be able to embed code from Gist. Following the Wordpress documentation, newer version comes with a specific shortcode for Gist : Gist Shortcode The issue is that it does not work at all. I tried pasting simply the url on a single line or wraping it around [gist] tags but nothing works. The url simply displays as raw text inside the post. I do know that some plugins provide the same functionality but I really wish to use the Wordpress builtin functionality. My site has been automatically hosted and installed on an Azure website, is running PHP 5.4 and Wordpress 3.8.1. Thanks for your help.


Post metadata deletes itself

I'm using a custom post type for a portfolio. I have a few option in there, bring saved by `update_post_meta()`, it seems to work fine, but then out of the blue (within the hour), the data deletes its self. I have looked in the DB and all custom metadata values are empty. I'm a little stumped really. Here's the code that's saving one of the options.               function update_colour_palette(){         global $post;         $color = get_post_custom($post->ID);      $palette = $color["palette"][0];         update_post_meta($post->ID, "palette", $_POST["palette"], $palette);     }      Any help, tips & tricks would be useful.


Display additional page templates and a sidebar on plugin activation

I'm developing a child-theme off of the Twenty Twelve (1.1), using Wordpress (3.5.1) and the Woocommerce plugin (1.6.6). I've noticed that the problem with creating the online shop, single product page and the taxonomy pages (categories and tags), is that it uses it's own templates to display these pages ( _which can be customized_ ), but making changes to the other pages such as the checkout, cart, my account etc. won't be affected because they are referenced from the theme’s `page.php` template. Because of this, I would like to display additional template pages to choose from when the Woocommerce plugin is activated in the Page Attributes list and hidden/not displayed otherwise. For example, by default: >   * Full-Width >   * Full-Width, Sidebar Right >   * One-Third, Two-Thirds Columns >   * Three Columns, Sidebar Right > And when the Woocommerce is activated: >   * Full-Width >   * Full-Width, Sidebar Right >   * One-Third, Two-Thirds Columns >   * Shop, Sidebar Left <\------- >   * Shop, Sidebar Right <\------- >   * Three Columns, Sidebar Right > Is this possible and can an additional sidebar in the widgets menu (Shop Sidebar) also be created on the plugin activation? Thank you.


get_post_meta not working inside a function in functions.php but works outside

function notify_new_posts($post_id) {               $keyval = get_post_meta( $post_id);                 $buyer_wdistance   = get_post_meta( $post_id, 'cf_wdrive');               //$buyer_wdistance   =   $keyval['cf_wdrive'][0];     $buyer_location    =   $keyval['cf_address'][0]." , ".$keyval['cf_zipcode'][0];               //$buyer_location    = '3302 23rd street, astoria, ny';     //$buyer_wdistance   = '10';                  $post          = get_post($post_id);             $author        = get_userdata($post->post_author);             $author_email  = $author->user_email;             $email_subject = " New car request posted ";          $blogusers = get_users( 'blog_id=1&orderby=nicename&role=dealership' );          foreach ( $blogusers as $user ) {               $target_email    =  $user->user_email;          $current .= " targetemail: ".$target_email ." | " ;                    $dealer_location = get_usermeta($user->id,'company_name')." , ".get_usermeta($user->id,'rep_name') ;                      $current .= " dealerlocation: ".$dealer_location . " | " ;                $from = $buyer_location;     //echo "
";      $to   = $dealer_location;               $from = urlencode($from);     $to   = urlencode($to);     $data = file_get_contents("http://maps.googleapis.com/maps/api/distancematrix/json?origins=$from&destinations=$to&language=en-EN&sensor=false");     $data = json_decode($data);     $time     = 0;     $distance = 0;          foreach($data->rows[0]->elements as $road) {         $time += $road->duration->value;         $distance += $road->distance->value;     }          $distance = round($distance*0.000621371);     $time = round($time/60);     //echo "distance to this dealer in miles ".$distance."
";          $current .= " distance: ".$distance . " | " ;               if ($distance  <= $buyer_wdistance ){                    ob_start(); ?>                  <title>New post at <?php bloginfo( 'name' ) ?></title>
Hello <?php echo $author->user_firstname ?>,

A new lead was posted: <a href="<?php echo get_permalink($post->ID) ?>"><?php the_title_attribute() ?> .
                                   <?php                  $message = ob_get_contents();   ob_end_clean();             wp_mail( $target_email, $email_subject, $message );          } //end of if statememnt          }          $file = 'people.txt';     // Open the file to get existing content     //$current = file_get_contents($file);     // Append a new person to the file          $current .= " postid: ".$post_id." | " ;     $current .= " author: ".$post->post_author       . " | " ;     $current .= " author_email ".$author_email       . " | " ;     $current .= " buyerlocation: ".$buyer_location.$buyer_wdistance  . " | " ;          $current .= " buyerwdistance: ".$buyer_wdistance . " | " ;                    // Write the contents back to the file     file_put_contents($file, $current);                         }          add_action( 'publish_post', 'notify_new_posts', 10, 2 );      so the problem is               $buyer_wdistance   = get_post_meta( $post_id, 'cf_wdrive');     //$buyer_wdistance   =   $keyval['cf_wdrive'][0];         $buyer_location    =   $keyval['cf_address'][0]." , ".$keyval['cf_zipcode'][0];      these values work perfectly in a template.php file. but inside functions.php function hook they dont work. $post_id returns a value. all the other variables return values besides those metas. I checked them manually in phpmyadmin and their all have values for the appropriate post id.


wp_enqueue_scripts in a plugin's class

I'm trying to enqueue jQuery UI in a plugin under a class method. I have this so far:               class AV_Slider {          function slider_load_js(){             wp_register_script('jquery-ui-core', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.5.3/jquery-ui.min.js');             wp_enqueue_script('jquery-ui-core', array('jquery') );             wp_enqueue_script('av_slider_js', AV_SLIDER_BASE_URL . 'includes/js/av_slider.js', array( 'jquery' ));     }               function __construct(){         $this->hooks();     }     function hooks(){         add_action('wp_enqueue_scripts', 'slider_load_js');     }      And I get this error on the page: > Warning: call_user_func_array() expects parameter 1 to be a valid callback, > function 'slider_load_js' not found or invalid function name I'm not sure how __construct() works other than that it creates a new Simple XML object. I also tried adding the action `add_action('wp_enqueue_scripts', 'slider_load_js');` after the function but this caused an error as well. Any help?


Import media to online WordPress from local development

I have a site being developed locally and I want to import the contents to an online installation. I used wordpress "import" but it cant get the media files. Is there any "wordpress" was of doing this or will I have to get access to my LDE from outside or upload the entire installation which I would rather avoid?


Display Related Posts by Category in Random

I use one of smthemes and there is this code in theme to show related post. it shows the last created related posts, but I want to show related post by random, How can I do that?               global $SMTheme;     if ($SMTheme->get( 'layout', 'related' )) { ?>

<?php echo $SMTheme->_( 'relatedposts' )?>:

         <?php         $postid=$post->ID;         $showed_posts=array();         $tags=get_the_tags($postid);         $categories = get_the_category($postid);         $post_cnt=0;         $first=0;              if ($categories&&($post_cnt<$SMTheme->get( 'layout', 'relatedcnt' ))) {             $category_ids = array();             foreach($categories as $individual_category) $category_ids[] = $individual_category->term_id;             $showed_posts[]=$postid;             $args=array(             'category__in' => $category_ids,             'post__not_in' => $showed_posts,             'showposts'=>$SMTheme->get( 'layout', 'relatedcnt' )-$post_cnt,             'caller_get_posts'=>1);             $posts=get_posts($args);             if( count($posts)>0 ) {                 foreach ($posts as $p) {                     $ttl=iconv_substr( $p->post_title, 0, 150, 'utf-8' );                     ?>                     <li<?php echo (!($first%4))?" class='first'":""?>><?php                     $post_cnt++;                     if ($SMTheme->get( 'layout', 'colors' )) {                         $r=rand(1,150);                         $g=rand(1,150);                         $b=rand(1,150);                     } else {                         $r=$g=$b=1;                     }                     $first++;                if(has_post_thumbnail($p->ID))  {                     ?><a href="<?php echo get_permalink($p->ID); ?>" title="<?php printf( $SMTheme->_( 'permalink' ), $p->post_title ); ?>" class='img'><?php                     echo get_the_post_thumbnail($p->ID,array(126,126), array('title'=>$p->post_title, 'alt'=>$p->post_title));                     ?><?php                   } else {                     ?><a href="<?php echo get_permalink($p->ID); ?>" title="<?php printf( $SMTheme->_( 'permalink' ), $p->post_title ); ?>" class='img'><img src='<?php echo get_template_directory_uri(); ?>/images/smt/article_related.png' width='126' height='126' alt='article' /><?php                   }             ?>
<a href="<?php echo get_permalink($p->ID) ?>" title="<?php printf( $SMTheme->_( 'permalink' ), $p->post_title ); ?>" rel="bookmark" class="related-ttl"><div class='related-bg' style='background:rgb(<?php echo $r.",".$g.",".$b?>)'>
<?php echo $p->post_title ?>
                     <?php                 }             }         }              if (!$post_cnt) {             ?>
<?php echo $SMTheme->_( 'norelatedposts' )?>
<?php         }         ?>

     <?php } ?>


Removing title from page

Hello attempting to remove the title from static front page using the following code is (not working) in my functions.php                   function remove_page_title() { if (is_front_page() )     {           add_filter( 'the_title', '__return_false' );     }}      IS there something missing? Thanks in advance PS I know I can hard code it in to my page template with               <?php if(!is_front_page()) { ?>
<?php the_title(); ?>
<?php } ?>      but I'd rather not change the template


How to make a conditional statement that checks if the page is the child of a certain page?

I know that you can use `is_page` to check the current page. How to check if the current page is the child of a certain page?


Add custom directory in URL

How can i add custom "directory" in my URL for pages and posts? So the main website url is: `http://www.example.com`, but when i go to a page I want this kind of URL: `http://www.example.com/SOMETHING/new_page` How can I put that "SOMETHING" in URL without affecting Wordpress functions?


Changing color of specific tab of top menu

I am messed up with a problem and still i am unable to find it's solution. I am trying to change color of only 1 tab in whole navigation menu. I mean if my navigation bar include 5 tabs and i want to highlight one tab with a specific background color. But i don't have any idea to do this. Can you suggest some solution to this?


Return current page type

Is there a function that simply returns the current "page type" instead of using is_page(), is_preview(), is_single(), is_archive(), etc? For example: I can find the current "post type" but I can't find it's corresponding "page type".


Looking for a simple calendar/events plugin

am looking for a simple calendar/events plugin with a list view by months and a pagination between months. Events would be simply made of a tile, description and the date of the event. Here's a quick sketch: ![enter image description here](http://i.stack.imgur.com/F9AOP.png) I've tested already plugins like: http://wordpress.org/extend/plugins/event-calendar/ \- doesnt suits my needs and gives me errors in the admin (brand new wp 3.3.1) http://wordpress.org/extend/plugins/event-calendar-scheduler/ \- too complex, and not events list http://wordpress.org/extend/plugins/events-calendar/ \- Just a widget http://wordpress.org/extend/plugins/kino-event-calendar-plugin/ \- Just a widget http://wordpress.org/extend/plugins/my-calendar/ \- list view but not by month and gives me an error when i open the page with events on first load after adding an event: `Warning: usort() expects parameter 1 to be array, string given in C:...\plugins\my-calendar\my-calendar-output.php on line 850` http://wordpress.org/extend/plugins/simple-events-calendar/ \- list view but not by month and no pagination http://wordpress.org/extend/plugins/the-events-calendar/ \- list view not by month and although great, pretty complex for waht i need http://wordpress.org/extend/plugins/wordpress-event-calendar/ \- Doesnt save any event in the admin... Am runnin glow on ideas so any help would be appreciated.


Add rewrite rule in plugin: with .htaccess in plugin folder or using WordPress functions

I need add a rewrite rule in my plugin, and distribute it with my code. All works fine if I put the rule in the .htaccess in the WordPress root folder, but I need distribute the plugin with my rule. I try to put a .htaccess inside the plugin folder and try to use the add_rewrite_rule function but doesn't works either. Here the .htaccess code that works correctly in WordPress root folder but doesn't works in my plugin folder:               <IfModule mod_rewrite.c>          RewriteEngine On     RewriteRule my-plugin/pages/tp(.*)\.php$ wp-content/plugins/my-plugin/pages/request.php?pid=$1          </IfModule>      I try the follow code in my plugin but doesn't works either:               add_filter( 'query_vars', 'add_query_vars' );     function add_query_vars( $query_vars )     {         $query_vars[] = 'pid';         return $query_vars;     }     add_action( 'init', 'add_init' );     function add_init()     {         $plugin_url = 'the-path-to-my-plugin-folder';         add_rewrite_rule('my-plugin/pages/tp(.*)\.php'                       , $plugin_url . 'pages/request.php?pid=$matches[1]','top');              global $wp_rewrite;         $wp_rewrite->flush_rewrite_rules(); // I know this should be called only one time, but I put it here just to keep simple the sample code     }      But I always get the error that the URL wasn't found. What I'm doing wrong? How can I do what I need? I searched for similar questions but none solve my problem.


W3 Total Cache "Preview mode could not be disabled"

I receive the message: > Preview mode could not be disabled. Please run chmod 777 /wp- > content/w3-total-cache-config-preview.php to make the configuration file > write-able, then try again. I have chmodded the file to 777 and the error message remains.


Export xml use/import images from theme directory

Is it possible to create demo.xml for a theme that when imported into fresh theme installation will use/import images from theme directory folder (e.g. theme/images/demo) rather than import media from previous wordpress installation? If possible, how it can be achieved?


Moving wp-content outside of web root?

Is it possible to move the entire wp-content folder outside of the Web root? I need to prevent anyone to view any asset file (images, pdfs, movies etc) with a direct url to the file... Any ideas? Or could I do this safely with htaccess?


unautomated subscription plugin

I need to send some data to my subscribed visitors periodically.   Is there any plugin that just let users subscribe (enter their email) in my site that don't send anything automatically and I be able to use it manually?   I need a plugin that collect user emails (Using a subscription form) and let me send mass mails to them manually and nothing more!. thanks


Cannot Upload Custom Header Image into Wordpress Dashboard

I'm having trouble uploading a custom image into Wordpress' dashboard. It says that it needs to be a custom 1000x288 image. When I upload it, I get the error of:               Warning: copy(/var/sites/zeldezine/wordpress/wp-content/uploads/2012/02/header.jpg) [function.copy]: failed to open stream: Permission denied in /var/sites/zeldezine/wordpress/wp-admin/includes/file.php on line 348               Warning: getimagesize(/var/sites/zeldezine/wordpress/wp-content/uploads/2012/02/header.jpg) [function.getimagesize]: failed to open stream: No such file or directory in /var/sites/zeldezine/wordpress/wp-admin/custom-header.php on line 665      When I open /includes/file.php, I get this block of code on line 348               // Set correct file permissions         $stat = stat( dirname( $new_file ));         $perms = $stat['mode'] & 0000666;         @ chmod( $new_file, $perms );      but I am not experienced enough in PHP to be able to know how to set the permissions correctly. If anyone can give me a heads up on what I need to modify to set permissions correctly, I'd appreciate it.


How to CPT with meta box, output navigation links to front end (but not ?cpt=value)

I have a custom post type with meta box. The output is paginated, so that my custom page will output one post at the time which works just fine. What I need is to be able to create a menu link on the front-end so a user can select from any of the custom post type posts. I was using next and previous links like this:               <?php previous_posts_link('« Newer') ?>     <?php next_posts_link('Older »') ?>      The problem with this approach is the user only sees links to the next and previous posts, not all of the custom post type posts. However, this system does use correct links NOT "?cpt=value" If I use a plugin to automatically generate a menu for the custom post type it uses "?cpt=value" links. I can't use a plugin since I am using a custom page template to output info, so if I use it it gives me wrong links. (http://wordpress.org/plugins/custom-post-type-auto-menu/) I could not find anything that would help me to figure the way to output correct link. How do I output correct link for all post types in that category? This is actual link to custom page with cpt(links I need):   ![enter image description here](http://i.stack.imgur.com/eIoCg.png) ![enter image description here](http://i.stack.imgur.com/JKHMs.png) But if I generate automatic link it will give me:   ![enter image description here](http://i.stack.imgur.com/1G4Ym.png) ![enter image description here](http://i.stack.imgur.com/JwoWD.png) UPDATE: I learned that I can use paginate_links function to get all cpt pages, but it displays numbers of pages not post titles, and I can't find any info if this supports titles..   src: http://codex.wordpress.org/Function_Reference/paginate_links Any help is much appreciated! Thanks


wp_query issue with post_type = page

I am using a custom query to get pages. I need them all displayed on the front page for a one page WordPress theme. For the most part, I have the theme working and things are fine. I have this problem with the code where it doesn't recognize page templates and other custom stuff like shortcodes. For the life of me, I can't figure out why. Some shortcodes work and others do not. I had to make a query that checks to see if the page has a page template asssigned and then run the template part for content-page. Here is my code for my loop                   $page_query = new WP_Query(array(         'post_status' => 'publish',         'post_type' => 'page',         'order' => 'ASC',         'orderby' => 'menu_order',         'posts_per_page' => '-1',         'paged' => (get_query_var('paged')) ? get_query_var('paged') : 1     ));                  if ( $page_query->have_posts() ) : while ( $page_query->have_posts() ) : $page_query->the_post(); ?>             <?php $template = get_post_meta( get_the_ID(), '_wp_page_template', TRUE ); ?>             <?php if( $template && $post->post_content != '' ) { ?>                         <li id="page_<?php echo str_replace(' ','_',strtolower( get_the_title())); ?>">                             <?php get_template_part( 'content', 'page' ); ?>                         </li>              <?php }                   endwhile;             endif;             ?>      I have to load all my content by a shortcode. If I try to set a custom page template to a page then when I load that page, it will be blank. The page ignores the content of the custom template. The loop does notice that a page template was assigned though. what I would like to know is if there is a better way to load all pages into the front page and make WordPress recognize all content like it does for a regular page. I have been trying for months to come up with another way to no avail. Thank you for your help.


wp_nav_menu(); Outside WordPress installation

I wanted to use WordPress menu management then show it on outside wordpress installion php file with html but I got this error               PHP Fatal error:  Call to a member function get_queried_object() on a non-object in .../blog/wp-includes/nav-menu-template.php on line 395      Here how I do it in on php file with test.php               <?php      $documentroot = $_SERVER['DOCUMENT_ROOT'];     include_once($documentroot.'/blog/wp-load.php');     ?>     <!DOCTYPE html>               <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />     <title>Test</title>

     <?php if ( has_nav_menu( 'landingpage-menu' ) ) { /* if menu location 'secondary-menu' exists then use custom menu */ ?>     <?php wp_nav_menu( array( 'theme_location' => 'landingpage-menu', 'container' => '', 'depth' => 1 ) ); ?>     <?php } ?>

                is there wrong on how I implement it? or I'm missing something?


Link to blogg-page

Im trying out wordpress and wondering of from the theme i have installed. Im not using the blog as the start page. How do i add a link to the menu that shows the blog with posts in order of date?


Dashboard Widgets - Add Admin Page With Same Functionality

I have a plugin that has its own dashboard with basically quick-views of relevant data and I wanted to know if there was an "easy" way to mimic the functionality of the admin dashboard where you can move/minimize/maximize the widgets? UPDATE: I am assuming I would have to add metaboxes similar to when you add metaboxes to a custom post type...is this the direction I should go in?


Wordpress remove Submenus

I found an answered question here Remove menus and submenus **2 Answers** for my problem but is there a way of changing the code a bit so that it removed the submenus for all Editor roles. not only for one user? and is there a way of improving this code? I am using 3.5.1 version of wordpress code that I am using:               add_action('_admin_menu', 'remove_editor_submenu', 1);     function remove_editor_submenu() {         global $current_user;         get_currentuserinfo();         if($current_user->user_login == 'username') {             remove_action('admin_menu', '_add_themes_utility_last', 101);         }     }          add_action('admin_init', 'remove_theme_submenus');     function remove_theme_submenus() {         global $submenu, $current_user;         get_currentuserinfo();         if($current_user->user_login == 'username') {             unset($submenu['themes.php'][5]);             unset($submenu['themes.php'][7]);             unset($submenu['themes.php'][15]);         }     }


How to avoid filling up an array each time I run a WP_query?

I am making a following user system and need some help for retrieving the users ids a user is following. At the moment I am using the following SQL query for retrieving the users ids a user is following:               $following_users_ids = $wpdb->get_results("SELECT follows_id FROM $table_name_users WHERE user_id = $current_user_id");      Now, here comes my main problem. To feed the WP_Query with users ids, I am filling up an array like this:               foreach ( $following_users_ids as $following_user_id ) {         $authors[] = $following_user_id->follows_id;     }      If the user is following thounsands of users, filling up the array would take a long time. My arguments for the WP_Query is as follows:               $args = array(       'author__in'     => $authors,       'posts_per_page' => 12,       'paged'          => $paged,     );      So I need a faster way to retrieve those users ids and feed the WP_Query with it.


WP_Query and using a variable for 'cat'=> in the args array = WP Bug?

For the sake of this discussion, here's a version of my query within category.php:               wp_reset_query();     $category_id = get_cat_ID(single_cat_title('', false));     $my_query = new WP_Query(array(     'posts_per_page' => SOME_DEFINED_VALUE,     'cat'  => $category_id,     'paged' => ( get_query_var('paged') ? get_query_var('paged') : 1 ),     'post_type' => array('post','post_custom_1','post_custom_2','post_custom_3')     ));     // print_r($my_query);      In short, it doesn't work. Here's what I've noticed. When I do the print_r($my_query); I can see the query_vars in the first line. They do not match my array args. For example, the posts_per_page defaults to some other value (not the CONSTANT), and the post_type list no longer includes post (which is should / must). If I remove the line with 'cat'=> or hardcode the value ('cat'=> 3) then every thing works as expected. The remaining query_vars show up in the print_r. Life is good :) I have tried the following but found no success:   * Making the var into a CONSTANT, just like posts_per_page (which doesn't cause a problem).    * Concating quote around the $category_id number - The result is the same as no quotes at all. It doesn't work.   * 'cat' => array($category_id) - I pulled an error - It didn't like   that it was an array. Anyone have any suggestions? Now here's what did "work" (read: I could use my $category_id and doing so didn't muck up the rest of the args in the WP_Query() array list).               'cat'  => '"-'$category_id'"',      That is, I could not that cat ID. Crazy, right? Unless I can resolve it properly, I'm going to have a comma separated sting of all my cat not'ed, parse out the current cat and then use that string to do the query. In other words if my cats were A, B and C, instead of doing a query for A (as one would expect to do)               'cat' => A      I'm going to query for not B, not C.               'cat' => -B,-C      Hopefully there's a less hack-y solution. I've been on this too many hours now and I'm desperate enough to use this hack and be done with it. That said, this sure feel like a bug in the core to me. Yes, I'm using 3.5.1 (or are we up to .2 or .3 now?). My point is, I'm on the latest version (and this did the same in 3.2.x). btw, I've seen this issue posted elsewhere (e.g. WP forums). The one solution suggested the args array not be an array but a string. Even if that's possible with WP_Query, how would I do the list / array for the post_types as a string? Finally, if I'm doing something wrong then the Codex help page needs an update, eh? Help. :)


Advanced Custom Fields | how to use conditional statements in repeatable group display

_**Hi there, I'm just getting started with ACF and writing php statements. Although I've been working with them for a little while I'm still building confidence._** ## My aim To display a block of code if a radio value is 'value1' and if not value1 but 'value2' then to display this block. I have the code working, but I'm stuck as to how I would do the same with a repeatable group. ## Here is what I have so far               $oriantation = get_field('oriantation');     if ( $oriantation == 'left' ) {               Run Code           }     elseif ( $oriantation == 'right' ) {               Run Code          }     else {         return false;     }      So far I think that I should be using a foreach statement but I'm getting stuck as to how to use that with the above code. I'm just beginning to write my own statements and functions at the moment so any direction would really help.


WooCommerce create new product and add to cart on form submit

I am customizing woo-commerce plugin to add product from the front end into the cart. I have written the function in functions.php, but i am getting a Fatal error. Getting this error--> > Fatal error: Call to a member function add_to_cart() on a non-object in   >  C:\wamp\www\cutting-edge_server\wordpress_theme\wp- > content\themes\cutting_age\responsive\functions.php on line 56 Any body have any idea how to resolve it? My function.php file               if (isset($_POST["addcustomcarts"]))             {            echo $_SERVER[QUERY_STRING];           // echo $_SERVER[REQUEST_URI];             echo "i am in if";             //exit();         add_filter('woocommerce_before_cart', 'customcart');              function customcart() {             echo "i am in function";              //global $woocommerce;              $my_post = array(           'post_title'    => 'My post',           'post_content'  => 'This is my post.',           'post_status'   => 'publish',           'post_author'   => 1,           'post_type'     =>'product'              );                   // Insert the post into the database          $product_ID=wp_insert_post( $my_post );               add_post_meta($product_ID, '_regular_price', 100, $unique);          add_post_meta($product_ID, '_price', 100, $unique);           add_post_meta($product_ID, '_stock_status', 'instock', $unique);                     //Getting error on this line.           $woocommerce->cart->add_to_cart( $product_ID, $quantity=1 );                              exit( wp_redirect( home_url( "cart" ) ) );         }              customcart();           }      My html file               <form name="addpro" method="post" action="">         <input type="submit" name="addcustomcarts" value="ADD TOO CART" />       </form>


Wordpress removing <p> tags?

I'd already come across a case where Wordpress added `<p>` tags. However now I'm dealing with the opposite situation. When I add [] shortcodes inside `<p>` tags WordPress automatically removes `<p>` tags.               <p>[anyshortcode]Hello World[/anyshortcode]</p>      Becomes:               Hello World      Adding dir="ltr" to `<p>` tags seems to fix the issue, maybe there is a way to add it programatically to all `<p>` tags? Any ideas on how to fix this?


difference between querying database and using the loop

I know this is a very general question, but I have been reading tuts on both wp Query, and The Loop, and it seems that you can go either way. Am I misunderstanding this? What I think I am reading is that you can bypass the loop more or less, and just query the db. If this is the case, what is better?


Adding post tags to custom post types

Standard WordPress post types have "Post Tags" which can be used to "tag" posts with similar content, makes those similar posts easily accessible just by opening that particular tag page and receiving the list of all posts. I need exactly the same thing with my custom post types:   * ability to tag the post with multiple tags   * ability to list all custom posts tagged with the same tag by opening that tag page How do I add support for adding tags to my custom post types?


How do I get category and page ID's?

I want to insert the category or page ID of the current page into my HTML so that I can use CSS to style each page based on what it is. For example, if had a category called "News" and it's ID was 5, my source code would end up having in it. Then I could use CSS to style #category-id-5 to suit my needs. How would I accomplish this?


Can I upload media to a specific folder?

By default, media uploaded through the Wordpress dashboard goes into a folder determined by the current date. For example: /wp-content/uploads/2011/09/. Once the media is uploaded I'm not seeing any options in Wordpress to change the location of my file to something else. Can I tell Wordpress to place my media in a separate folder? **Not all my media.** Just ones that I specifically select.


Condition function for is parent category?

I have a parent category with many sub-categories and I am trying to display the page differently when it is in that specific parent category. But instead of writing the code like is_category('parent', 'sub-1', 'sub-2')...etc, is there an easy way to say if it is in the parent category it is true?


Add Category Taxonomy Support to Custom Post Type

I'm writing some code that makes extensive use of custom post types- and I'm looking for a means of programatically adding a category to a defined custom post type, and then accessing its category ID. I had a poke around but I can't seem to find a robust means of achieving this - wp_create_category would be the obvious choice but of course this doesn't support custom post types.


Adding a div at the bottom of a sidebar

I can't find a way to place a div at the bottom of a wordpress sidebar, after all the widgets are displayed. Though I can acheive this by tweaking the themes I need a way to do this programmatically. Please help..


Use Post as Front Page

Is there a way to use a post as the front page? I'd like to be able to call the latest post from a given custom post type, in a certain custom taxonomy and with a specific term and use this as the front page - similar to using a page as the front page, but using a post instead (showing comments, trackback, etc. too)?


Why does Facebook not want to display my post thumbnails?

Recently when I try to share my content on Facebook, everything appears normal except I cannot get it to display a picture. I'm using WordPress SEO to handle all of the SEO and Social metadata, but it doesn't really cover images that well. When I use the Facebook Debugger, my webpages do not contain errors yet it still refuses to display images. I think the problem is happening because it is selecting the photo media using this format of link: http://media.detailsofmylife.net/uploads/2012/03/Alesso-Essential- Mix-200x125.jpg , but I am not sure why:   * Why Facebook chooses that as the default image even though I have the full size version selected as the Featured Image.   * Why Facebook has a problem with that format style of link image? Any ideas or suggestions would be much appreciated as it's doing my head in!


Is it possible to get a different header.php on language switch with qtranslate?

the problem is that on home page I have a lot of code which is added through header.php and it is not amendable through admin panel. What I want to do is to switch header files on language switch. Whenever a user press on the language icon, lets say on the English language icon the header should also switch from `<?php get_header('mylanguage') ?>` to `<?php get_header('english') ?>` or etc. Is it possible to do like this? Regards,


Static Front Page problem

My theme uses the front-page.php file to display a number of items on the front page including a slideshow and some featured items. I have also designed it so the static front page as set in the wordpress settings is displayed **as an excerpt** within this template. I then planned on having a read more button so the full page could be viewed on it's own without the slideshow etc( i presumed using page.php ) but it appears I've outsmarted myself, as that static page seems to be destined to display using front-page.php according to the WP hierarchy. Can anyone suggest anything that might help me. What i need is some way to tell that page to open in page.php if it's accessed via the read more button.


Wordpress Unknown Query

I have the following query and i can't find where is executed               SELECT count(ID) FROM wp_posts  WHERE 1=1  AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish') ORDER BY wp_posts.post_date DESC;      Does anybody know where could be executed?


WordPress Multisite. Can domain be used instead of subdomain?

i am new to multisite. It is a simple question. I know WordPress multisite can be setup for subdomains. Is it possible to use domains along with subdomains? I have searched google but have not had really good results. Perhaps I have used the wrong keywords. **so i can use a single wordpress installation for:** domain.com sub1.domain.com sub2.domain.com example.com example2.com sub1.example2com Hope you get it. Thanks in advance!


Only display custom fields that are associated with template

I am in a predicament where I have entirely too many custom fields displaying in my admin. Ideally I would like to filter through all custom fields created for my site and only display the ones created for the template I have selected. If there is anyway possible to achieve this, someone PLEASE let me know! Thanks!


Can I manage more wordpress sites with one wordpress administrator page?

I would like to find a solution, where I can administer multiple wordpress sites (50 plus) using one wordpress admin interface or other tool. I would like to manage plugins and content on these sites. Is there such tool exists?


Only get_posts of certain post formats

I'm trying to create a archive list with only my "normal" post format articles (not link, aside, quote, etc formats). How would I implement `has_post_format( 'standard' )`, or something similar, into the code below? I haven't been able to find a query for `get_posts` that only requests specific format types.               <?php             // Get the posts         $myposts = get_posts('numberposts=-1&orderby=post_date&order=DESC');          ?>          <?php foreach($myposts as $post) : ?>             <?php             // Setup the post variables         setup_postdata($post);              $year = mysql2date('Y', $post->post_date);         $month = mysql2date('n', $post->post_date);         $day = mysql2date('j', $post->post_date);         ?>
                      <a href="<?php the_permalink(); ?>"><?php the_title(); ?>                                           <?php the_time('j F Y'); ?>
          <?php endforeach; ?>      My php skills are at the beginner level at best, so any help would be much appreciated.


What's the order of loading wordpress elements?

I currently try to make a theme for wordpress and I'm confused about lots of things. I'm not sure what's the order of loading wordpress elements, where some variables are available, where they are saved, etc. So, about get_option(), in documentation says it's for retriving informations from database, but when you make some fields in theme options and user saves something he entered, that is not stored in database. So this variable is available only during loading wordpress each time? Thanks for any help