Display categories from custom post type

I have created custom post type 'Portfolio' also under this post type I have created Portfolio categories with following code functions.php - following is the code for custom post type i have defined in functions.php page                function demo_register_post_type() {                 register_post_type('Portfolio', array(                     'labels' => array(                         'name' => __('Portfolio'),                         'singular_name' => __('Portfolio'),                         'add_new' => 'Add New Portfolio',                         'edit_item' => 'Edit Portfolio',                         'new_item' => 'New Portfolio',                         'view_item' => 'View Portfolio',                         'search_items' => 'Search Portfolio',                         'not_found' => 'No Portfolio found',                         'not_found_in_trash' => 'No Portfolio found in Trash',                         'show_ui' => true,                         'show_in_menu' => true,                         'capability_type' => 'post',                         'hierarchical' => false,                         'rewrite' => true,                         'query_var' => true                     ),                     'menu_position' => 6,                     'public' => true,                     'supports' => array(                         'title','editor','author','thumbnail','excerpt','comments','page-attributes'                     ),                     'rewrite' => array( 'slug' => 'portfolio', 'with_front' => false ),                     'taxonomy' => array('category', 'post_tag')                 ));                  register_taxonomy( 'portfolio-category', 'Portfolio', array ('hierarchical' => true, 'label' => __('Portfolio Categories')));  // portfolio categories      Now I want to retrieve all the categories from this post type and display posts from the categories on page? Please let me know how could I do this? Thanks.


How can I have network sites not use year/month folders by default?

When creating a new network site, by default the site option `Uploads Use Yearmonth Folders` is on (set to `1`). I have to set it to `0` each time I create a new site. This isn't horrid, but is it possible to make this the default for newly created sites? Perhaps a hook or something I am overlooking?


Filter the_content() in the Quote Post Format to Display Quotes

I'm customizing a theme for a client and I want to leverage post formats. On the quote post format I would like               the_content();      to be wrapped in a two spans that contains quotation marks that I could style and position. Is this possible? Thanks.


Search Results not displaying for multiple word search

I've customized a theme and am having some problems with search results using multiple-word queries. Site is live at www.abetterworldbydesign.com Searching for a single word works as expected. Searching for multiple words that should have returned results shows blank results. Oddly enough, manually changing the "+" character in the URL to "&" displays the results correctly but only shows the first word in the header "Search results for:_". My code in search.php for initializing WP_Query follows exactly the code listed in the codex. Full code for search.php on pastebin. Code for searchform.php below.               <form id="searchform" name="searchform" method="get" action="<?php echo home_url(); ?>">         <div>             <input type="text" id="s" name="s" />             <input type="submit" id="searchsubmit" value="<?php esc_attr_e( 'Search', 'richwp' ); ?>" />         </div>     </form>


Pagination Not Working When Modifying Loop Based on Post Category

I have added query_posts() to my index.php file to modify the loop on the posts page:               query_posts( 'cat=-4,-7' );     get_template_part( 'loop', 'index' );      This works correctly, but when I click on "Older Posts" (link to /page/2), the latest posts show up instead of the previous ones. How can I get my pagination to show the correct posts?


Overriding functions in wordpress plugins

I notice that in some plugins you can override functions by ...   1. Creating an uploads folder   2. Creating a folder with the plugin name   3. Using the following code              if (!function_exists('function_name')) {         function function_name() {              }     }      Is this standard for all Wordpress plugins or only if they're written in a specific way?


Group WP_Query by category

OK, here's my setup: Custom post type called "issues" (for a magazine) Posts with custom meta field matching the post ID of the corresponding issue. When I'm on a single "issue" post page, I want to query all the related posts, and display them grouped by their associated category. I have the post query working, I just can't seem to get my head around the category grouping. here's my query                  <?php         global $post;              // List posts by the terms for a custom taxonomy of any post type            $current    = get_the_ID($post->ID);         $args = array(             'post_type'         => 'post',             'post_status'       => 'publish',             'posts_per_page'    => -1,             'orderby'           => 'title',             'meta_key'          => '_rkv_issue_select',             'meta_value'        => $current         );              $issue_cats = new WP_Query($args);              if( $issue_cats->have_posts() ) :         ?>
         <?php while ( $issue_cats->have_posts() ) : $issue_cats->the_post(); ?>
<?php the_title(); ?>
         <?php endwhile; // end of loop ?>         <?php else : ?>         <?php endif; // if have_posts() ?>
         <?php wp_reset_query(); ?>


After finishing building a site on localhost, how do I transfer everything to a client's server?

I have installed XAMPP to build a site on localhost. After I finish, how do I transfer everything efficiently to, say, a client's server?


Modify the_content after the more tag

I have created a custom plugin that pulls video and images out of a post and puts them into a nicely formatted set of galleries. The only problem is that the plugin doesn't allow me to put a video or image before the more tag without creating a mini gallery. Is there a name or way to adjust my plugin to make it only read the_content that comes AFTER the more tag?


Multisite custom post type's single page 404

I have two sites in my multisite setup - `domain.tld` (site A) and `domain.tld/lifestyle` (site B). This is my first multisite attempt. I've made a widget that creates a custom post type "`latest-news`" with `WP_Query` and I call the widget via `dynamic_sidebar()` within a page template `page-news.php`, which matches up with my static page News. The widget is only enabled on site A. You can see all files set up here, including my `.htaccess`:   https://gist.github.com/e97812f6d5c12d16039d The posts display correctly, but when I go to view a single post I get a 404. The URL I get is `domain.tld/blog/latest-news/news-item-1 <-- Does not work` instead of `domain.tld/latest-news/news-item-1 <-- Does work` Now I know that the first site is supposed to have `/blog/` in the URL, but this is the first instance where I've seen it on my site, all other pages don't seem to have it. Does anyone know how to:   1. remove the `/blog/` portion **without removing it from the Network admin** , or   2. get it to work with the `/blog/` portion? I've reset the permalinks many times, going between my custom `/%category%/%postname%/` and default.


How to make a H1 different then the Title?

What I want to do is... on a per page/post basis I want to be able to have the H1 say something different then the Title... This should be such a simple thing, but I've been looking around for an option and searching google for a solution for an hour now, and I can't find anything. Is there a way to do this in Wordpress without hacking the code? Or if not, what is a clean way to do this with code that will not get overwritten when I update Wordpress? p.s. im using the Dynamik/Geneisis theme.


Wp query by 2 meta field - check if they exists / have value

I am looking for the shortest most resrouce affective (not mysql query)   to count the amount of posts that have 2 meta keys <\-- if they exists i found this simple way at the codex   but it checks for values and not keys. Also it doesnt check if key exists which is basicly what i need since i dont know   upfront what the value is **The example query i found in the codex looks like this:**               $args = array(         'post_type' => 'somepostype',         'meta_query' => array(             array(                 'key' => 'fname'.$userid,                 'value' => 'WHATEVER',             ),             array(                 'key' => 'lname'.$userid,                 'value' => 'WHATEVER',             )         )     );     $query = new WP_Query( $args );     return $tempquery->found_posts;      .   So... how can i turn that "whatever" value into a non   binding value since i only need to check if it has any   value aka the keys exists...


How to make mediaelement.js work in wordpress wmv

I have the following, mediaelementjs and a wmv video file. If I create a page using html and javascript the wmv loads fine. Example;               if (filetype !== "flv") {         if (filetype == "wmv") {             player2.plugins.silverlight[0].types.push('video/x-ms-wmv');             player2.plugins.silverlight[0].types.push('audio/x-ms-wma');          }         videoplayer.innerHTML = "<video autoplay width=\"450\" height=\"250\" id=\"player2\" poster=\"../media/echo-hereweare.jpg\" controls=\"controls\" preload=\"none\"><source type=\"video/"+filetype+"\" src=\"http://localhost/wp-content/plugins/Monetizer_Pro_AV/video/"+file+"\" /></video>";     }      If I use a shortcode to create a video element this method does not work. I get no video with supported format and mime type found message. Example;               public function WMVVideoPlayer() {         return "             <script>                 window.onload = function() {                     player3.plugins.silverlight[0].types.push('video/x-ms-wmv');                     player3.plugins.silverlight[0].types.push('audio/x-ms-wma');                 }            </script>            <video autoplay width=\"450\" height=\"250\" id=\"player3\" poster=\"../media/echo-hereweare.jpg\" controls=\"controls\" preload=\"none\"><source type=\"video/wmv\" src=\"http://localhost/wp-content/plugins/Monetizer_Pro_AV/video/test.wmv\" /></video>";     }      How can I make wmv play using this method with Wordpress.


Changing Site Address (URL) causes 404

Thank you in advance for any help you might provide. I have read many other posts, and unfortunately the provided solutions did not work. The problem is this: I have Wordpress installed in a supdirectory [http://www.example.com/wordpress] and would like to change the front end url to [http://www.example.com/somethingelse] When I go to Settings > General and change the Site Address (URL) to [http://www.example.com/somethingelse] and check the front end, for [http://www.example.com/somethingelse], it returns a Wordpress custom 404 page. The permalink structure is [http://www.example.com/somethingelse/?p=123] and return a root 404 error. I have made sure that the .htaccess is correct (although when I try to update permalinks with the new Site URL it says its not writable) and that the proper permissions are set. Now, keeping [http://www.example.com/somethingelse] as the Site URL setting, if I go to the original [http://www.example.com/wordpress], the home page works, though all links show this structure [http://www.example.com/somethingelse/?p=123] I have tried adding the URL define to wp-config.php of               define('WP_HOME','http://example.com/wordpress');     define('WP_SITEURL','http://example.com/somethingelse');      I have tried adding the following to my theme's functions.php               update_option('siteurl','http://example.com/somethingelse');     update_option('home','http://example.com/wordpress');      I have even tried changing both the Site URL and the Wordpress URL (checked it manually in the db to make sure it was correct) and changing the directory name to /somethingelse which gives me the white screen of death on every page. I have tried disabling all plugins and redoing all of the above as well. I am at a total loss as to what could be causing the errors as I can go over to my other Wordpress installs on the same server and change their Site URL with out any problem. Any help would be greatly appreciated before I run out of hair ;) Thank you again!


Woocommerce - looping product images

How can I loop the product images as a list? Apparently, Woocommerce has two php files for this. One is for the featured product, and one is for the product thumbnails (`product-image.php` & `product-thumbnails.php`).   I'd like to put them on a single php file and loop the product images and make them appear in a `li` tag.


Define new user capability for custom post types?

If I create a custom post type and want to create custom capabilities for that, how do I do this? For example, I want to let my Editors to edit and create and delete posts and pages, but not the custom post type I've created? I also want to have the possibility to change the capabilities later with this plugin: http://wordpress.org/extend/plugins/user-role-editor/ (see the screens of the available capabilities: http://wordpress.org/extend/plugins/user-role- editor/screenshots/) I've done this by now this way:               global $wp_roles;          if(!isset($wp_roles)) {         $wp_roles = new WP_Roles();     }          // add capability $cap to role $role     $roles = $wp_roles->get_names();     $wp_roles->add_cap('administrator', 'organize_matches');      But then even I as administrator am not able to save the custom post type (and yeah, I mentioned 'organize_matches' in the 'capabilities' argument when registering the custom post type). Really appreciate Your help!


Updating post content on the front end

I have used the code below to add frontend editing to my posts/pages. How would I go about saving the post content when an update/save button is pressed?               $post_id = get_the_ID();          $settings = array(     'wpautop' => true,     'media_buttons' => true,     'wpautop' => true,     'tinymce' => true,     'quicktags' => true,     'textarea_rows' => 18     );          $post = get_post($post_id, 'OBJECT');     wp_editor($post->post_content, 'epicpagecontent', $settings );          <input type="submit" name="submit" id="submit" value="Update">


What's the best way to manage a lot of 301 redirects in WordPress?

Currently my site has a lot of 301 redirects we are managing in our .htaccess file (several hundreds 301 redirects); however, I am wondering would it be better and more optimal I use a plugin such as Redirection to accomplish this?


Why is a rewrite rule in wordpress prevent pagination?

I have a custom page that uses a rewrite rule. The "non-pagination" rewrite works fine:               add_rewrite_rule(          '^brand-list/([^/]*)/([^/]*)/?',          'index.php?pagename=brand-list&brand=$matches[1]&section=$matches[2]',          'top'     );      basically a url like this `/pagename=brand- list&brand=MyBrand&section=MySection` ends up like this, `/brand- list/MyBrand/Mysection` However, when using pagination the page number is never returned to wordpress so `$paged` on page 2 is still 0               add_rewrite_rule(           '^brand-list/([^/]*)/([^/]*)/page/([0-9]+)?',           'index.php?pagename=brand-list&brand=$matches[1]&section=$matches[2]&paged=$matches[3]',           'top'     );      this url, `/pagename=brand-list&brand=MyBrand&section=MySection&paged=2`, ends up like this, `/brand-list/MyBrand/Mysection/page/2` but still shows page 1. Checking the `$paged` value it outputs as 0, it should be 2. If I removed the rewrite rules and `/pagename=brand- list&brand=MyBrand&section=MySection&paged=2` is passed page 2 is shows and `$paged` value is 2. With the rewrite rule in place, if you have over the page numbers you get this:               /brand-list/MyBrand/Mysection/?paged=2      Obviously the rewrite rule is the problem but I'm not sure what part I'm missing. If I use this url:               /pagename=brand-list&brand=MyBrand&section=MySection&paged=2      with the rewrite all it results in:               /page/2/pagename=brand-list&brand=MyBrand&section=MySection      and works! but my url structure is incorrect. \----- edit ------ my current function               function rewrite_rule_brands() {             global $wp_rewrite;             add_rewrite_tag('%brand%','([^/]*)');             add_rewrite_tag('%section%','([^/]*)');             add_rewrite_rule('^brand-list/([^/]*)/([^/]*)/page/([0-9]+)?','index.php?pagename=brand-list&brand=$matches[1]&section=$matches[2]&paged=$matches[3]','top');             add_rewrite_rule('^brand-list/([^/]*)/([^/]*)/?','index.php?pagename=brand-list&brand=$matches[1]&section=$matches[2]','top');             $wp_rewrite->flush_rules();         }         add_action( 'init', 'rewrite_rule_brands' );


How do I require authorization / login to view a specific set of posts / pages?

I am working on a wordpress site for a client who wants an internal 'intranet' for his employees. The basic needs are:   1. Communicate things in-house   2. House important company documents   3. Provide quick access to resources to employees. This info is sensitive and for employees only. They would like each employee to have a user name / password and only be able to view information and documents once they are logged in. I saw these plugins, and a few like it, but they seems limited, and of course they're completely out-dated now:   * http://wordpress.org/extend/plugins/wp-require-auth/   * http://wordpress.org/extend/plugins/members-only/ I know I can password-protect individual posts / pages. Can I password protect an entire category of posts, or better yet a custom post-type? Basically, I need to group some pages / posts together under a login. The information is sensitive so it can't be available, for instance in the RSS feed. How can I do this?   * Option 1 (less desirable): have an entire wordpress build behind a login wall   * Option 2 (more desirable): have just the internal pages / posts behind the login wall Bottom line: I'm interested in option 1 if it's WAY easier, but would prefer option 2. Currently, after some research, I'm only finding out of date plugins that help with this, and can't seem to find a reliable way to pull either one off. Thanks for your help!


How to use WordPress HTTP API to download file from remote location

So this PHP code works for me:                   $ch = curl_init( TCS_CPDF_REMOTE_ZIP );         curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );         $data = curl_exec( $ch );         curl_close( $ch );         file_put_contents( TCS_CPDF_LOCAL_ZIP, $data );      but when trying to use the WordPress HTTP API:                   $the_body = wp_remote_retrieve_body( wp_remote_get( TCS_CPDF_REMOTE_ZIP ) );              file_put_contents( TCS_CPDF_LOCAL_ZIP, $the_body );      I end up getting a 0KB file, so the above WordPress version is not working. So how do you download a file from a remote location using the WordPress API?


Use the Settings API to whitelist a setting, but don't output it

I have a plugin page with several settings. Four of this settings, all in the same section, need to be displayed inline rather than one above the other. However to ensure the settings are whitelisted, I must use the `add_settings_field()` function. I can achieve most of my goal by passing a blank label and a callback to a function that outputs nothing for 3 of the options, and then add all four settings to the callback for the other. However doing so still adds a table row and thus leaves unnecessary white space for 3 of the options. I've looked at the source of the `add_settings_field()` function, and all that does is add the setting to the `$wp_settings_fields` global. These settings are then output by the `do_settings_fields()` function, which has no obvious way of not outputting a table row. Does anybody know of a way in which I can achieve all of my goal? **Here is how I am registering the settings -**               /**      * Register the settings that can be saved by this plugin      */     public function register_plugin_settings(){              add_settings_section(             'aab_header_logo_section',                                      // ID             __('What logo do you want to use?', 'djg-admin-area-branding'), // Title             false,                                                          // Callback             'djg_admin_area_branding_header'                                // Page         );              add_settings_field('header_logo_margin_top',//ID             __('Header logo margin (px)', 'djg-admin-area-branding'), // Title             array($this, '_option_header_logo_margin'),               // Callback             'djg_admin_area_branding_header',                         // Page             'aab_header_logo_section',                                // Section             array(                                                    // Args                 'label_for' => 'header_logo_margin_top'             )          );              add_settings_field(             'header_logo_margin_right',             false,             array($this, '_null'),             'djg_admin_area_branding_header',             'aab_header_logo_section'          );              add_settings_field(             'header_logo_margin_bottom',             false,             array($this, '_null'),             'djg_admin_area_branding_header',             'aab_header_logo_section'         );              add_settings_field(             'header_logo_margin_left',             false,             array($this, '_null'),             'djg_admin_area_branding_header',             'aab_header_logo_section'         );          }


What is difference between logout and switch off?

What is the difference between logout and switch off in wordpress 3.6 except below? 1.Logut - redirect to login screen of admin. 2.Switchoff - redirect to UI side.


First and last name fields not filled when using wp_insert_user

I've written a plugin to allow authentication to a WordPress install via an external API. Everything is working except the first and last names are not being set for the new WordPress user created by the plugin when a login attempt passes the external authentication. Here's the really strange part: one of the selectable display names _is_ the first and last names coming in from the external API.               $userdata = array( 'user_email' => $ext_user['email'],                                     'user_login' => $ext_user['email'],                                     'first_name' => $ext_user['firstName'],                                     'last_name' => $ext_user['lastName'],                                     'role' => $user_role                                     );     $new_user_id = wp_insert_user( $userdata );           $user = new WP_User ($new_user_id);      That's the code I'm using to create the new users. I have logged both `$ext_user['firstName']` and `$ext_user['lastName']` just before filling the `$userdata` array to ensure those values are coming through properly and they are. I can't understand how they can be in the Display Name field but the First Name and Last Name fields are blank. Can anyone help? **UPDATE:** This install runs the Cimy User Extra Fields plugin. At first, I thought this might be the culprit, but I disabled it and the issue persists. Maybe that's still the problem, but I don't know how to determine. Could this plugin replace the default first and last name fields?


Rewrite Rule Not Working

I am trying to use a rewrite rule to get 3 variables from the URL. Here is my rule:                add_action( 'init', 'pe_rewrite' );      function pe_rewrite(){          add_rewrite_rule(              'products(/([^/]+))?(/([^/]+))?(/([^/]+))?/?',              'index.php?pagename=products&top_cat=$matches[2]&sub_cat=$matches[4]&product=$matches[6]',         'top'          );      }      Everything works as expected until I add the final segment (product) to the URL. As soon as the "product" segment is added, it loads the homepage instead of the "products" page. Is there a problem with my rule?


Custom url rewriting

I am struggling to create custom rewrite rules for wordpress. This is my url structure               http://domain/cityprofile/?city=Sydney       where city profile is a page template. Now i want to make this url as               http://domain/Sydney       .htaccess               # BEGIN WordPress     <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /index.php [L]     </IfModule>          # END WordPress


Adding data to custom wordpress database table

I have a form on a page that populates the database table:

         Form Input Employees Data

             <form method="post" action="input.php">
               Product Name	               <input type="text" name="name" size="20">

               Brand	               <input type="text" name="brand" size="40">

               	               <input type="submit" name="submit" value="Sent">

      And here is input.php:               <?     //the example of inserting data with variable from HTML form     //input.php     mysql_connect("localhost","xxx","xxx");//database connection     mysql_select_db("xxxxxxx");                         $current_user= wp_get_current_user();     $id= $current_user->user_login;                //inserting data order     $order = "INSERT INTO wp_userdata                 (id, product_name, product_brand)                 VALUES                 ('$id',                             '$_POST[name]',                 '$_POST[brand]')";          //declare in the order variable     $result = mysql_query($order);  //order executes     if($result){         echo("
Input data is succeed");     } else{         echo("
Input data is fail");     }     echo $id;     ?>      I am trying to pass username to a database as "id". I am getting next error:               Fatal error: Call to undefined function wp_get_current_user() in /home/xxx/input.php on line 10      I tried to change things around but still not working..


Break down output of wp_list_categories

Im looking at how to breakdown the output from **wp_list_categories**. Currently it shows:               Drummer      But I am looking to only get the category name without the link. So would be `Drummer`. My full code to get the category:                                   <?php //Set Variable URL for ALL catefory                         $alllink = get_post_type_archive_link( 'opd-band' ); ?>                              <?php //Category Display for Custom Post type - Video                         $customPostTaxonomies = get_object_taxonomies('opd-band');                         if(count($customPostTaxonomies) > 0)                         {                             foreach($customPostTaxonomies as $tax)                             {                                 $args = array(                                     'orderby' => 'name',                                     'show_count' => 0,                                     'pad_counts' => 0,                                     'hierarchical' => 1,                                     'taxonomy' => $tax,                                     'title_li' => '',                                     'data-filter' => '',                                     'echo' => 0,                                   );                                      echo 'Categories:
';                                 echo  '
All';                                 echo str_replace( '
', '', wp_list_categories( $args ) );                                 echo '
';                                       }                         } ?>


Add Button on WP-Admin Login

I just want to add a button on wp-admin login page..How to I achieve this.![see the pic](http://i.stack.imgur.com/3WU2V.png)


Is This Code Efficient - Or is there a better way?

I have a RECIPE WP site, that is using CPTs to handle the recipe content. The client wanted an A-Z Directory listing of all recipes. I came to Wordpress Answers and found the following code that does what I wanted:               add_shortcode('recipe_list', 'recipe_query');     function recipe_query($atts, $content){     $args = array(         'post_type' => 'recipes',         'orderby' => 'title',         'order' => 'ASC',         'posts_per_page' => -1     );          $query = new WP_Query( $args );          $dl = '';     $glossary_letter = '';     $active_letters = array( );          while ( $query->have_posts() ) {     $query->the_post();     $term_letter = strtoupper( substr( get_the_title(), 0, 1 ) );     if ( $glossary_letter != $term_letter ) {         $dl .= (count( $active_letters ) ? '
' : '') . '
' . $term_letter . '
';         $glossary_letter = $term_letter;         $active_letters[] = $term_letter;     }     $dl .= '
' . get_the_title() . '
';          }     $dl .= '

';          $ul = '
';     foreach ( array( '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' ) as $letter ) {         $ul .= '
' . (in_array( $letter, $active_letters ) ? '' . $letter . '' : $letter) . '
';     }     $ul .= '
';          return '
' . $ul . '
' . $dl . '

';     }      Right now there are 1020 recipes and it seems to run slower than the other pages and since I'm a frankenstein coder (some from here and some from there) - I decided to ask the real php coders. **Is there a better, more efficient way to write the code?**


How to enable hierarchical permalinks for hierarchical taxonomies

If you have a category called "term" and a subcategory called "subterm", your can access subterm posts at /cat/subcat. But this doesn't work out of the box with custom taxonomies. They are accessible at /taxonomy/subterm, but not /taxonomy/term/subterm. They've gone over this in the Wordpress Trac (http://core.trac.wordpress.org/ticket/12659), and it kind of _looks_ like they have a solution, but as I've never used the Trac and don't fully understand its language (diffs, etc), I need someone more experienced to actually tell me how to implement this. Is there code there that I have to paste into Wordpress core files? Is this already implemented and I can add something to my theme's functions.php? If possible I'd prefer not to modify any core files. Help!


Pass a PHP variable (loop-audio.php) to jQuery function (js/script.js)

I've searched a lot for this and I seem to get different answers. In my situation, my jQuery function has to use a PHP variable from a different file. How can I accomplish this? Clear and simple answer would be greatly appreciated.


Explode Array from Repeatable Custom Field

I have an array from repeatable custom field. When I print with vardump the output is...               var_dump($affman);      this is the result ...                array(3) {         [0] => array(4) {             [0] => string(74) "Crak Affiliates|affiliate@example.com|N/A|418-977-3169|crak_affiliates"              [1] => string(0) ""              [2] => string(0) ""              [3] => string(0) ""         } [1] => array(4) {             [0] => string(74) "Crak Affiliates|affiliate@example.com|N/A|418-977-3169|crak_affiliates"              [1] => string(0) ""              [2] => string(0) ""              [3] => string(0) ""         } [2] => array(4) {             [0] => string(74) "Crak Affiliates|affiliate@example.com|N/A|418-977-3169|crak_affiliates"              [1] => string(0) ""              [2] => string(0) ""              [3] => string(0) ""         }     }       I want to explode every entry and customize the output to the list... Below is my code:               <?php     $affman = get_post_meta($post->ID, "affiliatemanager", false);      if ($affman[0]=="") { ?>          <?php } else { ?>
Finance Manager:
     <?php foreach($affman as $am) {     $temp = explode("|", "$am");       $am_name = $temp[0];       $am_email = $temp[1];       $am_aim = $temp[2];       $am_phone = $temp[3];       $am_skype = $temp[4];     ?>          Name: <?php echo $am_name ?>|Email: <?php echo $am_email ?>|AIM: <?php echo $am_aim ?>|Phone: <?php echo $am_phone ?>|Skype: <?php echo $am_skype ?>
          <?php } ?>
<?php } ?>      Above code is failed to show the output I want. Please, help me to fix it. Thank you.


How do I automate multiple category loops?

I've asked this question already on the WordPress forum, but it sank like a stone, which isn't at all unusual. I've set up a general Articles page with multiple loops, in order to display the first three articles from any category within the custom post type "Articles." These are all hard-coded into the template, like the one below, changing only the category ID number:               <?php       $args = array(       'cat' => 13,       'posts_per_page' => 3,       'post_type' => Article       );       query_posts( $args );            if( have_posts() ):?>      ..and so on. What follows is all the necessary code to produce the title, the permalink, the excerpt, etc. The loops work fine. The problem is that they're hard-coded into the template, which would require that with every new category added, I add a loop to the template file. I need to find a solution so that instead, every time a new category is created it automatically gets added as a block to the Articles page. Also, I need to have it create a link, just as though I were using wp_get_archives, so that each category block links to its own page which contains ALL of the posts within that category (with pagination, if necessary). I can't think of any function which accomplishes this. Has anyone ever come across this problem before? Or does this require some heavy custom PHP coding that WordPress doesn't support unless hacked?


WQ Query post meta date comparison

I need to perform a query on some post meta which currently stores the date time lie so `31/07/2012` I need to check to see if this post meta is greater than the current date and if true return it in the query. I can't work out a way to do this with WP_Query using the provided methods. Can anyone shed any light on this?


WordPress SEO gives 'No ending delimiter' error on new post

I've just updated WordPress SEO to Version `1.3.4.2` When posting or updating a post I get this error.               Warning: preg_match() [function.preg-match]: No ending delimiter '/' found in /home/greewoo/public_html/wp-content/plugins/wordpress-seo/admin/class-metabox.php on line 1435          Warning: Cannot modify header information - headers already sent by (output started at /home/greewoo/public_html/wp-content/plugins/wordpress-seo/admin/class-metabox.php:1435) in /home/greewoo/public_html/wp-includes/pluggable.php on line 876


URL endpoint with html

I'm using wordpress endpoints for render another template on a post page. How can i add '.html' end of the url that using endpoint? Example; Normal URL: **example.com/angry-birds** Normal URL with endpoint: **example.com/angry-birds/play** Here what i want; **example.com/angry-birds.html** and **example.com/angry-birds/play.html**


How to hide easy access to my website temporarily?

I am developing a new website and I do not want others, except for my colleagues, to access it easily. I don't want it to be password protected because my colleagues are testing it intensively. Is there any simple way to obfuscate it, so that I will not need to install WP into another folder etc.? More specifically, is there any simple way to ban access to http://www.example.com and virtually move the main page to, let's say, http://www.example.com/h6DuBo93yS? The rest of pages can remain, since their addresses are not very easy to guess.


Add Filter not working with get_posts

While tweaking the "Bryans Childpage Thumbnail Generator" plugin, I am applying filter (with pagination) to the get_posts for WP Pages (`post_type=page`), but its not filtering at all. Here is the code:               extract(shortcode_atts(array(         'order'      => 'ASC',         'orderby'    => 'title',         'id'         => '',         'number'     => -1,         'height'    => '100',         'width'     => '',         'size'       => 'thumbnail',         'style'     => '',         'include'    => '',         'pagetitle'  => false,         'selector'   => 'h2',         'selector_height' => '30px',         'selector_width' => '100%',         'selector_padding' => '',         'showimages' => true,         'text_align' => 'left',         'text_margin' => '',         'exclude'    => '',         'posts_per_page'  => '5',         'page_number'   => '1',         'filter_year' => '0'     ), $attr));          if( $id == '')     {         $id = $post->ID;     }          $id = intval($id);          if($width != null)     {         $width='width:' . $width . 'px';     }          if ($order == 'RAND')     {         $orderby = 'none';     }          if($text_margin == '')     {         $textmargin = ($height/2)-10;         $textmargin .= "px 0 0 0";          } else      {         $textmargin = $text_margin;     }          $offsettext = ($height*3);          $offset = ($page_number - 1) * $posts_per_page;          $offset = $offset < 1 ? 0 : $offset;          function filter_where( $where = '' ) {              if($filter_year > 0)             $where .= " AND post_date >= '" . $filter_year . "-01-01' AND post_date < '" . ($filter_year + 1) . "-01-01'";                  // e.g. AND post_date >= '2011-01-01' AND post_date < '2012-01-01'                  return $where;     }          add_filter( 'posts_where', 'filter_where' );          $countposts = count(get_posts(array(         'suppress_filters' => false,         'post_parent' => $id,         'post_type' => 'page',         'post_status' => 'publish',         'numberposts' => $number,         'exclude' => $exclude,         'orderby' => $orderby     )));               $childpages = & get_posts(array(         'suppress_filters' => false,         'post_parent' => $id,         'post_type' => 'page',         'post_status' => 'publish',         'numberposts' => $number,         'exclude' => $exclude,         'orderby' => $orderby,         'order' => $order,         'posts_per_page' => $posts_per_page,         'offset' => $offset     ));          remove_filter( 'posts_where', 'filter_where' );          $totalpages = $countposts / $posts_per_page;          $totalpages = intval($totalpages) + ($totalpages > intval($totalpages) ? 1 : 0);      And here is the shortcode calling this plugin:               <?php echo do_shortcode("[gallery_childpages number='-1' height='220' width='295' size='medium' style='armthumbs' include='' pagetitle='1' selector='H2' showimages='0' showimages='true' exclude='1,33,22' posts_per_page = '9' page_number='" . get_query_var('page') . "' filter_year='" . $_GET['fyear'] . "']"); ?>      The pagination is working but filter isn't..


Is there any reason that other theme elements (such as nav menus) shouldn't be within the loop?

Just wondering if there's anything particularly wrong with putting theme elements like navigation menus, or even footer content or anything else that is going to be the same on every page inside the posts loop. (`<?php while ( have_posts() ) : the_post() ?> `) Obviously for most themes, it makes sense for the posts to have their own div and to put the loop in there- But I'm just wondering if it is an actual limitation or not.


Export all posts as individual plain txt files

I wish to export all of my posts as individual plain text files. So, the format may be something like:               title.txt                    Title: title     Pub date: date     Category: cat          Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et      Is this possible? Is there a plugin or workaround to do this? Thanks.


Add child category to parent on post creation and save

I'm trying to build a tree layout for a custom taxonomy. Categories are animals.               Big Game (0)     -- Bears (2)         -- Black Bear (3)         -- Grizzly Bear (2)      The above is a glimpse of what I have. CURRENTLY, A "post" can be categorized as a child category (Black Bear, Grizzly Bear) without being part of the parent (Bears) or other ancestor (Big Game). The parentheses indicate the # of posts in that category. What I want is for a post to be added to it's parent categories when created or updated. How would I do this? Ideally I would have ended up with this automatically.               Big Game (5)     -- Bears (5)         -- Black Bear (3)         -- Grizzly Bear (2)      I figured this has been done before... however I can't seem to find the answer on my own. Thanks! **Edits for clarity** Given the above example of a custom Animal Taxonomy, what I need is for a post to be added to it's parent category by default. As geomagas pointed out, the point of hierarchical taxonomies is that the child is implicitly part of it's parent. However, what I need is for it to be explicitly a member of the parent post. Here is the ideal scenario: A user is editing ora creating a new post. He or she would write the post, and then categorize the post as "Grizzly Bear" by placing a checkbox next to the category before hitting update. After hitting update the post would have a checkbox next to Bears and Big Game, indicating it is a member of both. But wait... _Bonus clarity!_ : If a user updated a post and categorized it as a Bear, it would be added to Bear and Big Game, but not Grizzly Bear because that is a child category. More bonus clarity: I have double checked and this is not default behavior. In my situation, if I get posts by taxonomy Animals that have the term Bear, Grizzly Bear posts would not be included. I would have to go in and manually set Grizzly Bear posts to be part of Bear and Big Game queries. Hopefully that helps Thanks! PS I'm pretty close to figuring this out myself and I'll update with the answer if I get it first :)


Show wordpress locally in xammp and in iPhone via ip

My wordpress site works fine on my mac via localhost, using Xammp. I want to view the site on my iPhone. So I type in 192.168.0.2 and voila, it brings up my localhost directory. I then click on the site in question and the content is there but no styling or images. I realise that this is because the paths to all the resources is hardcoded into the wordpress database. So when I am accessing the url via 192.168.0.2/mywebsitename on my iPhone, it's looking for all the resources using a base url of localhost/mywebsitename. Localhost path doesn't exist on my iPhone, only 192.168.0.2 does. So has anyone found a solution to this little issue? How can I see a wordpress installation by ip address and by localhost access?


Hosting WordPress on Azure?

Can I host WordPress/WordPress MU installation on Microsoft's Azure cloud platform? Does anyone have any advice or experience hosting WordPress on Azure?


Wordpress: category page not for post's

Please at first let me explain my question. I use wordpress to create web sites for flash games, so I don't have certain page for post's. I add each game by `post-new.php?post_type=game` and u can see it's not the regular post for wordpress. I try to use this code from codex:               <?php     if (is_page() ) {     $category = get_post_meta($posts[0]->ID, 'category', true);     }     if ($category) {       $cat = get_cat_ID($category);       $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;       $post_per_page = 4; // -1 shows all posts       $do_not_show_stickies = 1; // 0 to show stickies       $args=array(         'category__in' => array($cat),         'orderby' => 'date',         'order' => 'DESC',         'paged' => $paged,         'posts_per_page' => $post_per_page,         'caller_get_posts' => $do_not_show_stickies       );       $temp = $wp_query;  // assign orginal query to temp variable for later use          $wp_query = null;       $wp_query = new WP_Query($args);        if( have_posts() ) :        while ($wp_query->have_posts()) : $wp_query->the_post(); ?>          <div <?php post_class() ?> id="post-<?php the_ID(); ?>">
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?>
             <?php the_time('F jS, Y') ?>
               <?php the_content('Read the rest of this entry »'); ?>

<?php the_tags('Tags: ', ', ', '
'); ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>  <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?>

         <?php endwhile; ?>

<?php next_posts_link('« Older Entries') ?>

<?php previous_posts_link('Newer Entries »') ?>

       <?php else : ?>
Not Found

Sorry, but you are looking for something that isn't here.
       <?php get_search_form(); ?>           <?php endif;            $wp_query = $temp;  //reset back to original query          }  // if ($category)     ?>      I think it really have to works for posts, but in such case I try to change post for games, try many ways, but don't sucseed yet. Could anyone tell me what I have change in this code? i think that promblem in the begining with 'have post' and 'the loop'. Thanks.


Highlight custom widgets in the admin area?

I have created some custom widgets for my client to use, but I want to make them stand out amidst the fifteen or so standard widgets in the admin area. How can I do this? _I have solved this problem myself and will place the solution here, but please feel free it add a better solution if you have one._


Limit widget to certain sidebar?

I have multiple "sidebars", but not all of them are the same size. Not all widgets fit in all sidebars (for example, I have a "footer sidebar" where the client can place custom widgets, but they are wide, and don't fit at all in the "real" sidebar). I want to give an indication when a widget is placed in a sidebar where it would not belong (change the header text color, for example). What would be the best way to do this?


Download counter for skydrive shared files in wordpress

I have attached some skydrive files in my Wordpress posts. I want to show how many times these were downloaded. Is there any plugin or theme customization or trick to do this easily and effectively? Is there any other service like skydrive (believe only google, microsoft and yahoo, nothing else) to do this job easily?


Large taxonomy (2000+ terms), causing WordPress to hang

I have a large taxonomy (and about to grow a lot larger) with several thousand terms in it. When I'm editing a post, there is now a significant hang when it goes to load the term list. Has anyone run into this before? Any suggestions for dealing with such a large list?


Storing image gallery plugin data

I'm making image gallery plugin and I'm not sure what is the best way to store data in WordPress. Plugin can contain multiple gallery instances with some options and each gallery contains images with options. Gallery can be added to site using simple shortcode, something like this: [mygallery id="gallery1"]. So should I use add_option() and store all data in one field or just create two tables for galleries and gallery items? Thanks for advice.


Looking for methods to Check if File Exist

I'm working on a custom theme framework for educational purposes. I basically have a header.php in a child theme that i want to make smarter. I'd like to only include a stylesheet if the file exist. Getting 404 errors is not cool or efficient. Are there native php or wordpress functions to check if a wordpress file exist. Basically... **I want to output** `<link rel="stylesheet" href="<?php echo get_stylesheet_directory_uri(); ?>/css/<?php echo get_stylesheet() ?>.css" type="text/css" media="screen" />` **Only If** the stylesheet with the same name as the folder containing the child theme exist. Any ideas would be awesome :-)


Map clashing with WP - suggestions on fix?

I've followed this tutorial - http://www.netzgesta.de/mapper/ to create a state map of USA which you can see here - http://www.teamworksdesign.com/clients/neurosign/contact/alabama/ I downloaded the source files and got it all working locally then uploaded all the files to the link above. It's almost working but the hover doesn't seem to work when you hover over each state. I had this working locally but cannot work out why it's not working online. One cause may be that Wordpress (that's what the site is built on) is blocking something along the way. Can anyone help? UPDATE: It's blatantly something clashing with Wordpress as it worked locally, does anyone have any idea's of how to fix it?


WP plugins for Product web catalog

I'm trying to build website using wordpress. There are tons of usable plugins, but instead of trying them all one by one id rather ask someone who can suggest me the one that would fit my needs. The website is for small company who sells car scales. I need multilanguage support(for 3languages) A plugin for displaying the products with category tree. When you click on the thumbnail it opens a picture(litebox style) with a short description and a little pdf icon as a pdf manual attachment. It isnt suppose to be a webstore, but it would be nice if under the picture there would be a link("Please tell me more") or something like that and when you click on it it opens a contact form so if people want more information, like prices, guarantee, etc they will contact the administrator. I understand that only plugins wont cover it and some php editing would be needed, but atleast I want to know with what to start. Thanks!


Custom taxonomy query showing more than 4 posts

I have a custom taxonomy query setup that shows posts from the same post type and share the same taxonomy term. The markup looks as follows:                       <?php               $terms = wp_get_post_terms( $post->ID, 'products-category' );             if($terms){               // post has course_type terms attached               $course_terms = array();               foreach ($terms as $term){                $course_terms[] = $term->slug;               }                   $original_query = $wp_query;              $wp_query = null;              $wp_query = new WP_Query( array(              'post_type' => 'regularproducts',              'tax_query' => array(               array(              'taxonomy' => 'products-category',              'field' => 'slug',              'terms' => $course_terms, //the taxonomy terms I'd like to dynamically query              'posts_per_page' => '4'                 ),               ),               'orderby' => 'title',               'order' => 'ASC'               ) );                  if ( have_posts() ): ?>     ...etc      But despite me using `'posts_per_page' => '4'` it is still showing all the posts that are related and not just 4. I can't figure out why, any suggestions would be greatly appreciated!


Delete junk text from all the post using my sql command

Because of an autoblog plugin, my site has got junk text in every post! The text format is as below .. `funny-pictures/funny-pictures-of-the-day-30-pics/attachment/funny- pictures-41-2/" rel="attachment wp-att-3846">` Almost every post has the above text with the same format but different text. Is here any SQL command with which I can delete all this junk text from all my post? More examples: `funny-pictures/funny-pictures-of-the-day-30-pics/attachment/funny- pictures-42-4/" rel="attachment wp-att-3847">` `funny-pictures/funny-pictures-of-the-day-30-pics/attachment/funny- pictures-46-3/" rel="attachment wp-att-3848">` `funny-pictures/funny-pictures-of-the-day-30-pics/attachment/funny- pictures-48-2/" rel="attachment wp-att-3849">`


Question about querying posts

I have this code on a query I'm doing               <?php query_posts('post_type=vendors'); ?>     <?php while (have_posts()):the_post(); ?>     <?php      $featured = get_field('promote_to_homepage', $post -> ID, true) ;                        ?>     <?php if($featured){ ?>
<img src="<?php the_field('vendor_logo'); ?>"/>

<?php       the_title() ?>
<?php } ?>     <?php endwhile; ?>      So what I would like to do is to show only one post, if I set the > &showposts=1 or > &posts_per_page=1 the problem is that query will be always querying the latest post if I set to show 1, but what happens if the "promote_to_page" option is set on another post it will not shown. Any ideas on how to querying all posts under that post type but only show 1 ? Thanks.


Paged homepage - requirements?

I've got the following loop in index.php file:               $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;     $post_per_page = 30;     $do_not_show_stickies = 1;          $args=array(         'post_type' => array ('portfolio'),         'order' => 'DESC',         'paged' => $paged,         'posts_per_page' => $post_per_page,         'ignore_sticky_posts' => $do_not_show_stickies     );     $wp_query = new WP_Query($args);     if( have_posts() ) :              while ($wp_query->have_posts()) : $wp_query->the_post();                  //Do some stuff...      It works perfect. It displays 30 posts but how do I access second page? I tried:   \- http://example.com/?paged=2 (server's 404 error)   \- http://example.com/page/2 (redirects to homepage and removes `/page/2` part)   \- `<?php wp_link_pages(); ?>` (returns nothing) I have default permalinks. What am I doing wrong? How do I access second page of posts?


How to crop images in a certain size only for a certain page?

To me, `add_image_size()` increases Server-space consumption, as they increases newer image size of every image that are uploaded to a site beside the three common sizes (large, medium and thumbnail) and the original one.   So, first of all, **I don't want to crop my image _physically_**. I'm creating a page for my blog with a custom `WP_Query()` with some selected posts in 3 columns. My HTML structure is as below:               <div class="my-column<?php echo $class; echo $first; echo $one; ?>">
           <img src="<?php echo catch_that_image(); ?>" alt="top-post-image-soothtruth"/>

<?php the_title(); ?>

       Where I'm loading custom classes for 3 columns dynamically. Used a custom function to retrieve the first image URL of the post (code from here). Problem is: as with a common `<img/>` tag the first images from the posts are displayed in original sizes. But for a nice design I want a cropped version of the image to display them in a custom width x height, i.e. 217px x 130px. You know I can use a width and height parameter in the `<img/>` tag like:               <img src="<?php echo catch_that_image(); ?>" alt="top-post-image" width="217" height="130"/>      But that won't work and I don't want it that way, because it makes the images re-sized in bad proportion. ### WHAT I WANT ![sooth truth - page design](http://i.stack.imgur.com/ImxWY.png)   I want the images to be cropped (not physically - as mentioned above) in 217px x 130px - so that they load faster, and looks smarter in a three column loop with the same sizes and proportions for a list of posts. Even though the images can be portrait or landscape - they will crop dynamically a portion of the image.


WP_INSERT_POST issue on Wordpress Multisite

Im having a hard time on fixing this issue of mine. I have a plugin where it creates 6 pages at default for new wordpress multisite sites. Im using the following code.               function create_pages_default() {      global $user_ID;     // Update Sample Page and turn into About page       $samplepage = array(          'ID' => '2',          'post_name' => 'about',          'post_title' => 'About',          'post_type' => 'page',          'post_author' => $user_ID,          'post_content' => '
Write something about your business. This may include but not limited to what you sell, what are your target audience or market, who you are, your objectives, background history and your location.
',          'menu_order' => '1',          'post_status' => 'publish',          'comment_status' => 'closed'       );          // Create Store Page       $storepage = array(          'post_name' => 'store',          'post_title' => 'Store',          'menu_order' => '2',          'post_type' => 'page',          'post_author' => $user_ID,          'post_content' => '[WP_online_store]',          'post_status' => 'publish',          'comment_status' => 'closed'       );          // Create Blog Page       $blogpage = array(          'post_name' => 'blog',          'post_title' => 'Blog',          'post_author' => $user_ID,          'menu_order' => '3',          'post_type' => 'page',          'post_status' => 'publish',          'comment_status' => 'closed'       );          // Create Contact Us Page       $contactus = array(          'post_name' => 'contact',          'post_title' => 'Contact Us',          'post_author' => $user_ID,          'menu_order' => '4',          'post_type' => 'page',          'post_content' => '[support-front]
Feel free to contact us using the form below about pre-sale questions, about us, our upcoming products, product/order support and anything with regards to our products and services offered.

A dedicated ticket page will be opened and the access key will be sent on your email address you have provided or your account registered email address to keep you updated of our reponses.
[/support-front]',          'post_status' => 'publish',          'comment_status' => 'closed'       );          // Create Privacy Page       $privacypage = array(          'post_name' => 'privacy',          'post_title' => 'Privacy',          'menu_order' => '5',          'post_type' => 'page',          'post_author' => $user_ID,          'post_content' => '
Edit this Privacy Policy page with regards to the policies concerning the information you get from your customers when they subscribe, comment, register or purchase anything on your blog store.
',          'post_status' => 'publish',          'comment_status' => 'closed'       );          // Create Terms Page       $termspage = array(          'post_name' => 'termsconditions',          'post_title' => 'Terms & Conditions',          'menu_order' => '6',          'post_author' => $user_ID,          'post_type' => 'page',          'post_content' => '
Edit this Terms and Conditions page for your customers. This may include but not limited to the policies concerning refunds, damaged products, deliveries, shipping, payment methods, purchasing products and so on.
',          'post_status' => 'publish',          'comment_status' => 'closed'       );                 wp_insert_post( $blogpage );            wp_insert_post( $storepage );            wp_insert_post( $contactus );            wp_insert_post( $privacypage );            wp_insert_post( $termspage );            wp_insert_post( $samplepage );     }     add_action( 'wpmu_new_blog', 'create_pages_default', 10, 6);       It works perfectly when you register a new account along with a blog. However, the problem is when a current logged-in user created a blog for his account wherein after he submitted the blog creation form, it goes into a blank white page which is a weird thing and the blog was successfully created and the pages was not. I tried to remove this function and create a sample blog and it went well without the "blank white page" so i guess the issue was on the function. How to resolve this issue?


How do i add a customer input box to my product pages

I am looking to add a customer input box on some of my product pages or when they come to the checkout, I am using a multisite install of wpress with woocommerce installed I do have jigoshop installed on a separate site which has this function but I cannot seem to find it within woocommerce. The function I need it to perform is when a customer picks the color and size of an item they require using variation dropdowns I need another dropdown or input box where the customer can add some text for personalizing the item they want. At the moment I am having to get it done via PayPal comment box when they order which is a bit lame. I am not a coder so have no clue how this works or what to implement but if some one can point me to a plugin or such I would be very grateful.


PHP header() gives headers already sent

I am working on a checkout proces in Wordpress where if customer clicks on the checkout button he gets redirected to a payment provider. **Important to know:**   * I use a `session` in this proces.   * I use PHP `header()` function to sent the customer to this location. **My problem:** Now when you click the button, there is no redirect, but an error instead. > Warning: Cannot modify header information - headers already sent by (output > started at /var/www/vhosts/website.com/httpdocs/wp- > content/themes/template/header.php:24) in > /var/www/vhosts/website.com/httpdocs/wp-content/themes/template/page- > checkout.php on line 84 Line 84 is:               header( "Location: " . $payment->getPaymentUrl() );      So it looks like I need to do the redirect earlier, but I don't know how to do it. Has anyone any idea? Hook the `init` or `send_headers` action? I have one solution at the moment which solves the problem, but I know that it is not the right one. The solution is placing `ob_start()` in the top of my header.php


Database location in Wordpress

I have created my website in WordPress and want to transfert it in my domain created with ipage. I am not able to locate the WordPress database. Can you help me? How is the format or extention of DB with WP. I have send to ipage all the files under Xampp and WordPress but they still say DB is missing. I need to know where the database is located in WP and what is the extention


Getting the "more" tag to work with plugin-list-category-post

I know the List category posts has an attribute to show only an excerpt from the post, but I can't seem to get the plugin to work for the Wordpress tag break. Does the plugin recognize the tag?


Category sticky latest

I've been trying to write a script that shows the latest (single) post (in a particular category), however, if the user has chosen to have a post be sticky then the sticky post shows. When the sticky post is removed the latest post is then shown. The trouble I've been having is trying to is using Wordpress build in methods to do:               Loop through all the 'News' categories      - if: one of the posts is sticky, echo it out      - else: echo out the latest post      Hope someone can help guide me.


Wordpress plugin for authoring technical documentation?

We'd like to use WordPress to author the technical documentation for our software product. We've used plain-old WordPress pages, arranged then hierarchically, and it works ok, but it's not great. The problems:   * The Wordpress page editor is dog slow.   * You can't drag and drop pages around to change the hierarchy   * Nothing maintains section numbering, like section 1.1, 1.2, 1.2.3.   * I haven't found a way to build an automatically-created table of contents on the right hand side.   * I'd like to have a tag to highlight and indent code. I could probably assemble a collection of plugins to do all these things, but we've already put a fair amount of time into that, and still don't have a great solution. Confluence would be a good way to go, but I'd like to keep everything in Wordpress. Any suggestions for good technical documentation plugins?


Loading scripts to the Post Edit page only

I have added a few meta boxes for the posts and pages, so I want to load a js script only on the Create/Edit post and page. How can I do that? Currently I'm using following but that loads the scripts in all pages in the admin.               function my_meta_boxes() {         add_meta_box("post_meta", "Meta", "post_meta", "post", "normal", "high");         add_meta_box("post_meta", "Meta", "post_meta", "page", "normal", "high");          }     add_action( 'add_meta_boxes', 'my_meta_boxes' );          function register_custom_scripts() {         wp_enqueue_script( 'custom_js', get_template_directory_uri() . '/inc/meta/custom.js', array( 'jquery' ));         wp_enqueue_style( 'custom_css', get_template_directory_uri() . '/inc/meta/custom.css');     }     add_action( 'admin_init', 'register_custom_scripts' );


Bug: Deleting file, then uploading same file again places file in an old month folder

This is an issue with wordpress's month based organization of media files. To re-create the issue:   1. Delete an image file from a previous month   2. Upload the same image file (same name)   3. The newly uploaded file gets placed in the SAME month folder as it was originally, rather than in the current month. This is an issue for me because the amazon s3 plugin (code.google.com/p/wordpress-s3/) which I'm using to host my images on s3, DOES place the newly uploaded file in the current month, so the file on s3 is in a different location than on the wordpress server. Does anyone have experience with this "bug"? Which is the correct behavior, that of wordpress, or the s3 plugin? thanks! * * * Some clarification: What it looks like is that the s3 plugin and wordpress _DO NOT_ work in parallel in their creation of month based uploads folders. s3 _always_ uses the current month. In other words, regardless of the publish date of the post, the upload will always get placed in the current month folder (i.e. if today's date is may 2012, I upload an image and it goes to s3bucket/uploads/2012/05/) By contrast, it seems as though wordpress places the images in the folder based on the date of the original _creation_ of the post. So if you create a post in february save as a draft, then add images in may, then publish it, in s3 your images will be in 2012/05, while in your regular server they will be in 2012/02. This is a serious problem for me for a lot of reasons that are too complex to get into here, but it is a serious issue nonetheless.


how to customize the default #adminmenu in wp-admin

i want to customize the `#adminmenu` for the wp-admin, how can i target the class via plugin? im planning to use below function, but im not sure if this is the correct way of doing so..               add_action('admin_head', 'custom_nav');     function custom_nav(){         include 'css/customNav.css';     }          //inside customNav.css       #adminmenu { //insert styles here }      the main change i want, to make it horizontal across the browser and probably customize it by changing some colors, adding some new pages/links, remove unnecessary stuffs to it and so on..


Canadian taxes on Woocommerce - how do I show both PST and GST?

I am trying to set up my taxes on Woocommerce. Here in Manitoba, I need to charge both GST and PST, and show them as separate taxes. I have seen screenshots of other woocommerce sites with multiple taxes. I input the taxes separately on the "tax rates for standard class" chart. I ensured the product was using standard class. However, it seems to only be able to charge one tax (either PST or GST, depending which comes first on the chart) when I try it out. I would really appreciate any help.


Select Category as Page Parent

I've got a custom post type called Products and when i go to select page parent i only get other pages of the same post type. Is it possible to select a category as a parent for the page? The reason i'm asking is i have a plugin that lets me automatically add child pages to a menu under the parent. If i can somehow be able to set a category as a parent to the custom post type it should automatically add it to the menu. Here's the plugin i'm using. http://wordpress.org/extend/plugins/add- descendants-as-submenu-items/


Save custom meta box data to database

I have a custom post type Events. Under Events, I have a custom meta box which selects the time and data of the event:               <?php     $meta_boxes[] = array(     'id'         => 'event_date_option',     'title'      => __('Event date'),     'pages'      => 'events',     'context'    => 'normal',     'priority'   => 'high',     'show_names' => true,     'fields'     => array(         array(             'name' => __('Event Date'),             'desc' => __('When will the event happen'),             'id'   => '_event_date',             'type' => 'text_date',         ),         array(             'name' => __('Event Time'),             'desc' => __('What time will the event start'),             'id'   => '_event_time',             'type' => 'text_time',         ),     ),     );     ?>      How can I save the date and time in a different table in my WP database when the admin clicks "Publish" or "Update"?


Open Admin bar "Visit site" in a new window

Is it possible to create a filter to make in sort that the link in the admin bar to open in a new window. I know that the right-click -> open in a new tab is a common use for us programmers but for the client who use it, it could be great to open in a new tab. ![enter image description here](http://i.stack.imgur.com/RCLHf.jpg) Hope to find a solution without changing the core file "admin-bar.php" so it won't get overwrite on any WP's updates.


Pass list of categories to JS

I'm trying to pass a list of all the categories to my MixItUp settings in my JS file to show all the items on load. But I can't seem to generate a list of the categories and reliably send them over to the JS file. Here're how I've been trying to generate the categories.               function cats()     {         $args = array(             'taxonomy' => 'portfolio_categories',             'orderby' => 'name',             'order' => 'ASC'         );         $categories = get_categories($args);               $slugs = array();         foreach($categories as $category)              $slugs[] = $category->slug;              return $slugs;              print_r($slugs);     }      And once that works I figure I would need to send it via ?               wp_localize_script('main', 'cats', array( ) );


How to customize feed?

I'm trying to customize a WordPress feed. I know that if I modify wp- includes/feed-rss2.php, the feed is modified. But I don't want to modify this file, as it might get overwritten during an upgrade. I tried copying the file to wp-content/themes/mytheme/feed-rss2.php, but the file seems to be ignored. I found this article on customizing WordPress feeds, but the article is very old and references files that are just dummy files now. Background: Here's what I'm actually trying to do, in case there is a better way to do it. Our company has a WordPress blog. The copy of the posts could have been written by anybody, but only one of the two marketing guys actually posts on the blog. I want to overwrite the author attribute in the feed so that they author always displays as "Acme, Inc." instead of showing the marketing guy's name. I've customized the blog pages to do this, but the feed still shows the user name. I tried changing both marketing guys' usernames to "Acme, Inc.", but they didn't like that because they couldn't tell them apart when they needed to edit posts.


register_activation_hook not working with symbolic links

I'm writing my first own Wordpress plugin. It's working great so far, except that now I need to create a few DB tables upon plugin activation. So I put               register_activation_hook( __FILE__, 'create_tables');      in my main plugin file, and defined the function `create_tables` (which is tested and works) in the same file. The problem is that the hook does not fire at all. I investigated, and it seems this is because:   * My main plugin file is _really_ in `/usr/share/wordpress/wp-content/plugins/myplugin/myplugin.php`, and this is exactly what `__FILE__` contains.   * However, it would seem Wordpress actually goes looking to `/var/www/wordpress/wp-content/plugins` for plugins.   * The latter is in principle fine as `/var/www/wordpress` is actually a symbolic link to `/usr/share/wordpress`. However Wordpress actually only fires the activation hook when I use the `/var/www/...` path (the symbolic link one), and not the `/usr/share/...` path (the real one) when registering the activation hook. Indeed, when I replace the above call with               register_activation_hook( '/var/www/wordpress/wp-content/plugins/myplugin/myplugin.php', 'create_tables');      ...then the activation hook gets fired fine when I activate the plugin. But this is not a good option. I do not want to harcode a path. This plugin is supposed to run elsewhere later. How to fix this properly?


NextGEN Gallery: Use the same galleries on 2 or more sites on WP network (multisite)?

I have a wordpress network with 4 sites and i use NextGEN Gallery V1.9.13. On the 2 sites (first and second on network) i use the same galleries. It is a bit waste of hosting space if I need to upload the same images on the 2 network sites. Is there a possibility to use the gallery of first net site with the second net site? I tried copy the ngg_options of wp_option(first site of network) to ngg_options of wp_2_option but it doesn't read the base of the first site


wp_dropdown_categories - remove

I need to remove the auto adding of ` ` in the `wp_dropdown_categories`, it causes a problem in the jQuery multi select dropdown plugin I'm using. Example value:               <option class="level-1" value="120">   Apples  (125)</option>


Exclude specific tag or tags from related posts?

How can i exclude the display of a specific tag or tags on the results of related posts? this is the code http://pastebin.com/Ksh7NY7g               /*-----------------------------------------------------------------------------------*/     /* Related Posts Function     /*-----------------------------------------------------------------------------------*/          function ag_get_related_post_args($id){              global $relatedcatargs, $relatedargs;              $rel_tagnames = '';         $rel_catnames = '';              if ( !($relatednumber = of_get_option('of_related_number') ) ) { $relatednumber = '2'; } else { $relatednumber = of_get_option('of_related_number'); }               // Get related post tag names         $rel_tags = get_the_tags($id);              if ($rel_tags) {             // Get list of tag names and set arguments for loop         foreach($rel_tags as $rel_tag) {               $rel_tagnames .= $rel_tag->slug . ',';             }             $relatedargs = array(               'ignore_sticky_posts' => 1,               'tag' => $rel_tagnames,               'post__not_in' => array($id),               'showposts' => $relatednumber,               'orderby' => 'rand'             );         }              // Get list of category names and set arguments for loop         $post_cats = wp_get_post_categories($id);              foreach($post_cats as $post_cat) {           $rel_catnames .= get_cat_name( $post_cat ) .',';         }              $relatedcatargs = array(           'ignore_sticky_posts' => 1,           'category__in' => $post_cats,           'post__not_in' => array($id),           'showposts' => $relatednumber,           'orderby' => 'rand'         );          }          function load_custom_scripts() {         global $wp_version;              if (version_compare($wp_version, '3.4.2', '>')) {             wp_register_script('my-jquery-ui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js', 'jquery');             } else {             wp_register_script('my-jquery-ui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.21/jquery-ui.min.js', 'jquery');         }                    wp_enqueue_script( 'my-jquery-ui' );     }          add_action('admin_init', 'load_custom_scripts');                global $relatedargs, $relatedcatargs;     // Query Posts by tag     $my_query = new WP_Query($relatedargs);          //If there are posts     if( $my_query->have_posts()) { ?>

<?php _e('Related Posts', 'framework'); ?>
              <?php while ($my_query->have_posts()) : $my_query->the_post(); ?>            <a href="<?php the_permalink();?>" class="one_col half">

<?php                    if (strlen($post->post_title) > 40) {                       echo substr(the_title($before = '', $after = '', FALSE), 0, 80) . '...';                    } else {                       the_title();                   }  ?>                                         <?php the_time(get_option('date_format')); ?> | <?php echo get_the_author(); ?>

                   <?php the_post_thumbnail('blogonecol', array('class' => 'scale-with-grid')); /* post thumbnail settings configured in functions.php */ ?>
                     <?php endwhile;  ?>

     <?php } wp_reset_query(); // end if there are posts and reset the query ?>


Maintaining two permalink structures

How can I create two different permalink structures for a Wordpress blog, determined by an addition to the post meta? On the old site, articles were available through the following structure: **/index.php/site/articles/[sanitized-title-with-dashes]-[ID]** (Note the lack of a trailing slash, the bloat before the article title, and the ID) Naturally, since we're transitioning to Wordpress, I want the new articles to have their own permalink structure: **/%postname%/** Would be it possible to write a function in the theme that, when processing the permalinks, it uses the old structure for posts I've marked as "Legacy" in the Post Edit page. Otherwise, the permalink will be the new structure. I've already tried the Custom Permalinks plugin, but it can't seem to properly reconcile the old ugly structure with the new one. This was true even when I "conceded" and tried making the new permalink structure **index.php/%postname%/**. I'll have no problems creating a new post meta to tell the system whether to apply the old permalink structure or not. The question is, where do I start with setting the permalink in the first place?


How to edit an existing WordPress theme?

I've been hired to modify/update/change an existing WordPress theme. The site is already live, and I'm wondering how to work on the theme locally first.


Inserting random posts

I'm wanting to add 2 custom post types to a slider, one is Events the other is Core Values but I am wanting to add all events and randomly insert only 2 or 3 of the 7 core values. I have this query set up which is obviously just going to insert all events and all core values. I'm a bit stuck as to how I can get the random part of it happening. And I'd prefer not to use post ID's to choose random values as post ID's may change in the future. Any ideas??                 $the_query = new WP_Query( array(     'post_type' => array( 'core-value', 'event' )) );                  while ( $the_query->have_posts() ) : $the_query->the_post();


Make a custom URL and link to custom Template

I have a set of categories in my WP site. I also have a "team" thing in my site. Now when a user makes a new post he selects a category and then chooses the team to which post belongs. I have added this team selectbox using meta boxes Now i want to have a link for each team. How can i do that??.. I though of 2 ways: (1) - Making a template and linking it to a page called team. So its url becomes : site.com/team/ And now for each team making url like site.com/team/team1 I thought that 2nd url will also be served from my template. But, instead it gave not found. (2) - Making a custom page for each team. Is there any other way???


Problem with is_page & wp_redirect

I use cookies to determine which menu I should use on my website. This is working fine, but I want to force the correct one if someone views the URL directly instead of via the URL with a query string (which gets redirected). In other words, the URL www.yourdomain.com/?region=UAE gets redirected to www.yourdomain.com/uae/ and I want to be able to show the same result when a new visitor (with no cookies) clicks on a direct link to: www.yourdomain.com/uae/ I can't use a hook for the init as I'm using the is_page() function.               add_action( 'template_redirect', 'pstv_set_uae_cookie');     function pstv_set_uae_cookie() {         // Set cookie if on UAE Home Page & redirect back         if (is_page('uae') && $_COOKIE_['region'] !== "UAE") {             $expire = time()+60*60*24*30;             setcookie("region", "UAE", $expire, '/', '.domain.com');             wp_redirect( 'http://domain.com/uae/' );              }     }      I'm getting the following error in firefox: > The page isn't redirecting properly Firefox has detected that the server is > redirecting the request for this address in a way that will never complete. > This problem can sometimes be caused by disabling or refusing to accept > cookies. I know the redirect needs to happen before anything is output, but I can't access is_page until the wp functions are initialised. Can anyone suggest a work-around? TIA


Permalink Issues by Installing WordPress in Subdirectory / Subfolder

I installed WP in subfolder `/cms` and it runs live without subfolder. When I use `/%postname%/` as permalink I get 404 error on my site. My Server supported `mod_rewrite`. # My Code _wp-config.php_               define('WP_SITEURL', 'http://www.sitename.de/cms');     define('WP_HOME', 'http://www.sitename.de');      ### root _1) .htaccess_               <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /cms/     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /cms/index.php [L]     </IfModule>      _2) index.php_               <?php     define('WP_USE_THEMES', true);     require('./cms/wp-blog-header.php');     ?>        ### /cms _1) .htaccess_               <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /index.php [L]     </IfModule>      _2) index.php_               <?php     define('WP_USE_THEMES', true);     require('./wp-blog-header.php');     ?>        Thanks for your help   Ogni


How to filter the_content() & include content from template

I am trying to filter `the_content()` on single page, but it looks like it is creating an infinite loop. I want to know how to fix this. I want to override `the_content()`. Is there any other way to override single page content from plugin?               add_filter( 'the_content', 'change_single_content' );     function change_single_content($content){         global $post;              if ( 'my-CPT' == get_post_type() && is_single() ){             ob_start();             include my_plugin_theme('single-template.php'); //include single template content             return ob_get_clean();         }              return $content;     }


encoded search terms with %20

<form class="search-form" action="<?php echo home_url( '/suche/' ); ?>" method="get">              <input type="text" name="s" class="s" value="<?php the_search_query(); ?>" />      this is in my `searchform.php` template. Any ideas why when searching for e.g. "Graphic Design" it searches for "Cool%20Car" and replaces the space with an encoded `%20`? This of course doesn't return any results because there is no text as "Cool%20Car" on my blog. Any idea how to fix that?


How to log out without confirmation 'Do you really want to log out?"?

Right now when I log out via:               <a href="<?php bloginfo('url'); ?>/wp-login.php?action=logout">Log out      it redirects me to the page where I need to confirm the log out. How to eliminate the confirmation and redirect to the homepage after logout?


"load-scripts.php" hangs and times out when plupload is requested

I have a perplexing problem with Wordpress. When pages under /admin/ loads "load-scripts.php" with "plupload" as one of the arguments, it hangs for ever. The "Add New Post" page is one such page. For example, this URL hangs for ever: http://example.com/wp-admin/load-scripts.php?c=0&load%5B%5D=jquery- core,jquery-migrate,utils,plupload,json2&ver=3.9.1 While this returns successfully immediately: http://example.com/wp-admin/load-scripts.php?c=0&load%5B%5D=jquery- core,jquery-migrate,utils,json2&ver=3.9.1 When I say "hang for ever", I mean that it hangs for several minutes and finally just returns a partial result without error. By partial result, I mean minified Javascript that just ends abruptly in the middle of an expression. I have run Wordpress versions 3.9.1 and 3.8 on Apache with libapache2-mod- php5, Nginx with php5-fpm and just using the plain php built-in development server. In all cases this problem still occurs. I have downgraded to version 3.0 and the issue disappeared. In this version, "load-scripts.php" doesn't try to fetch plupload. Since I haven't managed to find any solutions to this issue using Google I'm assuming this is an issue with my server rather than a Wordpress bug. Using `set_time_limit` has no effect, the script still hangs for ever. I'm getting no errors in any logs, nor in the console when using the php development server. For some reason, replacing this (the very bottom lines of load-scripts.php):               header('Content-Type: application/x-javascript; charset=UTF-8');     header('Expires: ' . gmdate( "D, d M Y H:i:s", time() + $expires_offset ) . ' GMT');     header("Cache-Control: public, max-age=$expires_offset");          if ( $compress && ! ini_get('zlib.output_compression') && 'ob_gzhandler' != ini_get('output_handler') && isset($_SERVER['HTTP_ACCEPT_ENCODING']) ) {          header('Vary: Accept-Encoding'); // Handle proxies          if ( false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate') && function_exists('gzdeflate') && ! $force_gzip ) {                  header('Content-Encoding: deflate');                  $out = gzdeflate( $out, 3 );          } elseif ( false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') && function_exists('gzencode') ) {                  header('Content-Encoding: gzip');                  $out = gzencode( $out, 3 );          }     }          echo $out;     exit;      With this:               header('Content-Type: application/x-javascript; charset=UTF-8');     header('Expires: ' . gmdate( "D, d M Y H:i:s", time() + $expires_offset ) . ' GMT');     header("Cache-Control: public, max-age=$expires_offset");          // if ( $compress && ! ini_get('zlib.output_compression') && 'ob_gzhandler' != ini_get('output_handler') && isset($_SERVER['HTTP_ACCEPT_ENCODING']) ) {     //      header('Vary: Accept-Encoding'); // Handle proxies     //      if ( false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate') && function_exists('gzdeflate') && ! $force_gzip ) {     //              header('Content-Encoding: deflate');     //              $out = gzdeflate( $out, 3 );     //      } elseif ( false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') && function_exists('gzencode') ) {     //              header('Content-Encoding: gzip');     //              $out = gzencode( $out, 3 );     //      }     // }          echo "SUCCESS";     exit;          echo $out;     exit;      Causes the script to return "SUCCESS" instantly. If I don't comment out the compression block, junk data is returned. Apparently the script hangs on `echo $out`. I'm guessing this bug has to do with compression, but I have no clue what to do with that information. I realize this question is hardly easy to just _answer_ , but I'm certain there is a simple solution once I figure out what's wrong. Thanks in advance for any suggestions. * * * **Edit:** I have examined the script further using CURL. I have tried requesting "load-scripts.php" with "Accept-Encoding" set to gzip, deflate and nothing. It made no difference. In all cases the script instantly returns a bunch of data then freezes in the middle of a Javascript statement. It appears to stop at a random location in the output Javascript for every request. I have enabled all error reporting and set allowed memory to 2048M, which has also made absolutely no difference. I'm starting to think there's some low- level PHP issue here that I'm not going to be able to figure out. * * * **New edit:** I have experimented further. It turns out that if I simply `var_dump($out);` and `exit;` just after `$out` is constructed, the script still hangs. This must have something to do with the size of the printed string (216459 characters.) Part of the string is sent to the browser, then the request simply hangs (in one case for as long as 6 minutes) before just dying without outputting the rest of the string. No errors are reported anywhere. * * * **Yet another edit:** I have put this in the top of the script:               header('Content-Type: application/x-javascript; charset=UTF-8');     header('Expires: ' . gmdate( "D, d M Y H:i:s", time() + $expires_offset ) . ' GMT');     header("Cache-Control: public, max-age=$expires_offset");     var_dump(str_repeat("foo", 350000));     exit;      And 1 050 000 character str is quickly and successfully sent to the browser without issue. This doesn't have anything to do with output size.


Random Characters in the end of every image url in post

I am having this strange issue, whenever a post is published the images url gets random characters in the end. i have checked teh functions.php but didn't find anything related. here is an example :   wp-content/uploads/2012/10/PhotoshopSkillz.jpg?9d7bd4


Include inside sidebar

Is it possible to include a file inside or inbetween items in a sidebar? Here are the two functions being called:               <?php get_sidebar(); ?>     <?php get_template_part('testimonial-box'); ?>      The sidebar has 3 elements inside which appear on the page when rendered. I'd like the testimonial box to appear after the first. If I switch the two functions around it'll be: TESTIMONIAL SIDEBAR ITEMS I need: SIDEBAR ITEM #1   TESTIMONIAL   SIDEBAR ITEM #2   SIDEBAR ITEM #3 At all possible?


Disable comments and pingbacks on old custom post types

This SQL code will disable pingbacks on old posts and pages:               UPDATE wp_posts SET ping_status='closed' WHERE post_status = 'publish' AND post_type = 'post';     UPDATE wp_posts SET ping_status='closed' WHERE post_status = 'publish' AND post_type = 'page';      I am looking to disable comments and pingbacks on all of my old custom post types. Also by default I noticed Wordpress allows comments on new pages. Is there a way to fix this?


can't select role

I ve got an error on admin at this page wp-admin/network/site-users.php?id=1               <select name="new_role" id="new_role_0">             Warning:  array_reverse() [function.array-reverse]: The argument should be an array in /www/site/wp-admin/includes/template.php on line 800     Warning:  Invalid argument supplied for foreach() in /www/site/wp-admin/includes/template.php on line 802     </select>      I make a manual export of my localhost sql, change my wp_ prefix manualy (find and replace) and import in my site with phpmyadmin ; some meta_key were changed in wp_capabilities to mywp_capabilities, I fixed it but my problem is not solved. How can I find my error, what can I "var_dump" ?


Single meta_query query using OR instead of AND in request's WHERE statement

I want the native WordPress search input to search metadata in addition to its standard title and content search, however setting a `meta_query` adds an `AND` clause to the request when what I need is an `OR`. My function:               function search_faqs_metadata($query) {       if(!is_admin() && $query->is_main_query()) {         if($query->is_search) {           $query->set('meta_query', array(array(             'key' => '_faqs',             'value' => $query->query_vars['s'],             'compare' => 'LIKE'           )));         }       }     }     add_action('pre_get_posts', 'search_faqs_metadata');      The problem is the query it generates:               SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts     INNER JOIN wp_postmeta ON (wp_posts.ID = wp_postmeta.post_id)     WHERE 1=1     AND (       (         (wp_posts.post_title LIKE '%foobar%') OR (wp_posts.post_content LIKE '%foobar%')       )     )     AND (wp_posts.post_password = '')     AND wp_posts.post_type IN ('post', 'page', 'attachment')     AND (wp_posts.post_status = 'publish')     AND (  //I need this to be an OR!       (wp_postmeta.meta_key = '_faqs' AND CAST(wp_postmeta.meta_value AS CHAR) LIKE '%foobar%')     )     GROUP BY wp_posts.ID     ORDER BY wp_posts.post_title LIKE '%foobar%' DESC, wp_posts.post_date DESC LIMIT 0, 10      So I don't get a match unless the post title/content **AND** the metadata match the search term. I understand there is a `relation` parameter for the `meta_query` but it only works when comparing multiple metadata values. Currently I'm running `str_replace()` on the final query to change the last `AND` into an `OR`. I chose this method is because, while hacky, it is lean on the amount of code I need to add for this adjustment to succeed:               function search_where_or_metadata($where) {       if(is_search()) {         global $wp_query;         $new_where = $where;         $new_where = str_replace('AND ( (wp_postmeta.meta_key', 'OR ( (wp_postmeta.meta_key', $where);         return $new_where;       }       return $where;     }     add_filter('posts_where', 'search_where_or_metadata');      **EDIT** Here is a better function using a more appropriate filter that changes the `AND` to `OR`:               function change_meta_key_where_from_and_to_or($sql) {       if(is_search()) {         $sql['where'] = substr($sql['where'], 1, 3) == 'AND' ? substr_replace($sql['where'], 'OR', 1, 3) : $sql['where'];       }       return $sql;     }     add_filter('get_meta_sql', 'change_meta_key_where_from_and_to_or');      Is there a better way to change that final `AND` into an `OR`?


Administrator can rate user's posts

I'm trying to figure out how something like this can get done:   Each user's post could get rated by administrator in backend (admin area) and he see the total points of each user in users list at `wp-admin/users.php` in a new column also a reset button for clearing the result.   I found this and this but they were not actually what I was looking for.   Also couldn't find any plugin for this. **UPDATE**   I've made a Meta called `post_rating` valued with 1,2,3,4,5 for rating on each post. This is my code:               $innerjoin = $wpdb->get_results("SELECT $wpdb->postmeta.meta_value, $wpdb->posts.post_author FROM $wpdb->postmeta INNER JOIN $wpdb->posts  ON $wpdb->postmeta.post_id = $wpdb->posts.ID WHERE $wpdb->posts.post_status = 'publish' AND $wpdb->postmeta.meta_key = 'post_rating'");        and here is the `var_dump($innerjoin)`:               array(3) {      [0]=> object(stdClass)#1998 (2) { ["meta_value"]=> string(1) "3" ["post_author"]=> string(1) "1" }      [1]=> object(stdClass)#1999 (2) { ["meta_value"]=> string(1) "5" ["post_author"]=> string(1) "2" }      [2]=> object(stdClass)#2000 (2) { ["meta_value"]=> string(1) "4" ["post_author"]=> string(1) "2" }      }      I need the sum of `post_rating` value where users are same (for each users).


Post Excerpt field only showing for default administrator

I am using the following code to add excerpts to certain post types within Wordpress and for some rather odd reason, the excerpt fields only appear for the default administrator account, i.e. `admin`               function connect_addexcerpt() {         add_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', 'page', 'normal', 'core');         add_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', 'clinic_location', 'normal', 'core');         add_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', 'clinic_group', 'normal', 'core');         add_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', 'career', 'normal', 'core');     }     add_action( 'admin_menu', 'connect_addexcerpt' );         ~~When creating a new user, the field is simply hidden?~~ Edit: Sorry what I meant to say, was when logging in with a new account, the field is hidden. Does anyone have any idea's what could be causing this?


Change Mail from and display name with a filter action

I'm attempting to override the from display name and email address using wp_mail function. I am using the hook to modify wp_mail_from with my custom function using add_filter('wp_mail_from','abcisupport_wp_mail_from'). If I hard code the value it'll return the address so it's wired up properly. If I use the argument, it returns the site network defaults. How can I pass in a value to the arguments (here: $email and $name) to my overriding functions?               function abcisupport_wp_mail_from($email) {       return $email; //returns our default site network email address       /* return 'michael@site.com'; // returns  michael@site.com as the from address*/     }          function abcisupport_wp_mail_from_name($name) {       return $name; //returns our default site network display name          }          function send_abc_mail_before_submit(){         add_filter('wp_mail_content_type',create_function('', 'return "text/html";'));         add_filter('wp_mail_from','abcisupport_wp_mail_from');         add_filter('wp_mail_from_name','abcisupport_wp_mail_from_name');              wp_mail($to, $subject, $mailbody, $headers);              remove_filter('wp_mail_from','abcisupport_wp_mail_from');         remove_filter('wp_mail_from_name','abcisupport_wp_mail_from_name');     }      Note: all fields within the wp_mail() function are already set; code above has been simplified for readability.