Contact Form loaded with Ajax

I'm loading Contact Form plugin with an Ajax request. It is correctly loaded, but when trying to submit the form, I get a blank page with a 0 as unique response. I'm guessing it has something to do with the Event Handler, but don't know how to solve it. Any idea? This is my ajax code in `functions.php` (here I'm omitting the contact-page template call in Ajax callback, because it works):               function theme_name_scripts() {         wp_enqueue_script( 'mi-script-ajax',get_bloginfo('stylesheet_directory') . '/js/ajax-search.js', array( 'jquery' ) );         wp_localize_script( 'mi-script-ajax', 'MyAjax', array( 'url' => admin_url( 'admin-ajax.php' ) ) );     }          function ajax_callback() {       //Submenu     echo '
';     if( $sPostType !== '' ) {         if( $sPostType == -1 ) {             $allCategories = get_categories();             foreach( $allCategories as $cat ) {                 echo '
cat_ID ) . '">' . $cat->name . '
';              }         } else {                  global $wpdb;             // set the target relationship here             $post_type = $sPostType;             $taxonomy = 'category';                  $terms_ids = $wpdb->get_col( $wpdb->prepare( "                 SELECT                     tt.term_id                 FROM                     {$wpdb->term_relationships} tr,                     {$wpdb->term_taxonomy} tt,                     {$wpdb->posts} p                 WHERE 1=1                     AND tr.object_id = p.id                     AND p.post_type = '%s'                     AND p.post_status = 'publish'                     AND tr.term_taxonomy_id = tt.term_taxonomy_id                     AND tt.taxonomy ='%s'                 ", $post_type, $taxonomy ) );                  $terms = get_terms( $taxonomy, array(                 'include' => $terms_ids,                 'orderby' => 'name',                 'order' => 'ASC'             ) );                        //$aTypeCategories = get_categories( array( 'post_type' => $type, 'number' => '10'  ) );              foreach( $terms as $cat ) {                 echo '
term_id ) . '">' . $cat->name . '
';               }         }     } else {         echo '
Sin categorías
';      }     echo '
';     }          add_action( 'wp_enqueue_scripts', 'theme_name_scripts' );     add_action('wp_ajax_ajax', 'ajax_callback');     add_action('wp_ajax_nopriv_ajax', 'ajax_callback');      This is the full `ajax_callback` function:               function ajax_callback() {         $pageId = 0;         $newSlug = '';         $reviewSlug = '';         $sPostType = '';         $sTemplatePart = '';              //Links         if( isset(  $_POST['href'] ) ) {             $pageId = preg_match( '/^http:\/\/.+\/\?page_id=\d+$/', $_POST['href'] ) ? substr( strrchr( $_POST['href'], '=' ), 1 ) : 'no-page' ;             if( $pageId === 'no-page' && preg_match( '/^http:\/\/.+\/\?(news|reviews|entrevistas|radio_shows)=.+$/', $_POST['href'] ) ) {                 $newSlug = substr( strrchr( $_POST['href'], '=' ), 1 );             }             //$pageName = get_page_template_slug( intval( $pageId ) );             if( $pageId !== 'no-page' ) {                 if( $pageId === '8' ) {                     $sPostType = -1;                     $sTemplatePart = 'home-ajax';                 } elseif( $pageId === '22' ) {                      $sPostType = 'reviews';                     $sTemplatePart = 'reviews-rvw-ajax';                 } elseif( $pageId === '6' ) {                     $sPostType = 'news';                     $sTemplatePart = 'noticias-news-ajax';                 } elseif( $pageId === '109' ) {                     $sPostType = 'entrevistas';                     $sTemplatePart = 'entrevistas-ajax';                 } elseif( $pageId === '112' ) {                     $sPostType = 'radio-shows';                     $sTemplatePart = 'radio-shows-ajax';                 } elseif( $pageId === '412' ) {                     $sTemplatePart = 'podcasts-ajax';                 } elseif( $pageId === '415' ) {                     $sTemplatePart = 'contacto-ajax';                 }                  } elseif( $newSlug !== '' ) {                 if( preg_match( '/^http:\/\/.+\/\?news=.+$/', $_POST['href'] ) ) {                      $post_type = 'news';                 } elseif( preg_match( '/^http:\/\/.+\/\?reviews=.+$/', $_POST['href'] ) ) {                      $post_type = 'reviews';                 } elseif( preg_match( '/^http:\/\/.+\/\?entrevistas=.+$/', $_POST['href'] ) ) {                      $post_type = 'entrevistas';                 } elseif( preg_match( '/^http:\/\/.+\/\?radio_shows=.+$/', $_POST['href'] ) ) {                      $post_type = 'radio_shows';                 } elseif( preg_match( '/^http:\/\/.+\/\?podcasts=.+$/', $_POST['href'] ) ) {                      $post_type = 'podcasts';                 } else {                     //die();                 }                 $sTemplatePart = 'single-ajax';                 //get_template_part( 'single-ajax' );             }              //Siguiente y Anterior         } elseif( isset( $_POST['cadenaAll'] ) && ( isset( $_POST['cadenaPrev'] ) || isset( $_POST['cadenaNext'] ) ) ) {             if( isset(  $_POST['pageName'] ) ) {                 if( $_POST['pageName'] === 'reviews' ) {                     $sPostType = 'reviews';                     $sTemplatePart = 'next_reviews-rvw-ajax';                 }                 elseif( $_POST['pageName'] === 'news' ) {                     $sPostType = 'news';                     $sTemplatePart = 'next_noticias-news-ajax';                 }                 elseif( $_POST['pageName'] === 'entrevistas' ) {                     $sPostType = 'entrevistas';                     $sTemplatePart = 'next_entrevistas-ajax';                 }                 elseif( $_POST['pageName'] === 'radio_shows' ) {                     $sPostType = 'radio-shows';                     $sTemplatePart = 'radio-shows-ajax';                 }                 elseif( $_POST['pageName'] === 'radio_shows' ) {                     $sPostType = 'podcasts';                     $sTemplatePart = 'podcasts-ajax';                 }             }         }                   //Submenu         echo '
';         if( $sPostType !== '' ) {             if( $sPostType == -1 ) {                 $allCategories = get_categories();                 foreach( $allCategories as $cat ) {                     echo '
cat_ID ) . '">' . $cat->name . '
';                  }             } else {                      global $wpdb;                 // set the target relationship here                 $post_type = $sPostType;                 $taxonomy = 'category';                      $terms_ids = $wpdb->get_col( $wpdb->prepare( "                     SELECT                         tt.term_id                     FROM                         {$wpdb->term_relationships} tr,                         {$wpdb->term_taxonomy} tt,                         {$wpdb->posts} p                     WHERE 1=1                         AND tr.object_id = p.id                         AND p.post_type = '%s'                         AND p.post_status = 'publish'                         AND tr.term_taxonomy_id = tt.term_taxonomy_id                         AND tt.taxonomy ='%s'                     ", $post_type, $taxonomy ) );                      $terms = get_terms( $taxonomy, array(                     'include' => $terms_ids,                     'orderby' => 'name',                     'order' => 'ASC'                 ) );                            foreach( $terms as $cat ) {                     echo '
term_id ) . '">' . $cat->name . '
';                   }             }         } else {             echo '
Sin categorías
';          }         echo '
';         if( $sTemplatePart ) get_template_part($sTemplatePart);     }      And this is the Ajax code:               jQuery(document).ready(function($) {                   var linksPages = $('.menu-menu-container a');              linksPages.on('click',function(e){                     e.preventDefault();                     jQuery.post(MyAjax.url, {action : 'ajax' ,href : $(this).attr('href') }, function(response) {                     $('#content').addClass('cortinaOut');                     setTimeout(function() {                         $('#content').html(response).fadeIn();                         $('#content').removeClass('cortinaOut');                     }, 500);                 });         });              var linksPost = $('a:not(".rpswNamePrev_2, .rpswNameNext_2, .no-ajax")')         linksPost.live('click',function(e){                     e.preventDefault();                     jQuery.post(MyAjax.url, {action : 'ajax' ,href : $(this).attr('href') }, function(response) {                     $('#content').addClass('cortinaOut');                     setTimeout(function() {                         $('#content').html(response).fadeIn();                         $('#content').removeClass('cortinaOut');                     }, 500);                 });         });                   var cadenaNext='';         var cadenaPrev='';         $('#ajax-form-next, .ajax-form-num').live('submit',function(e){                     e.preventDefault();                     jQuery.post(MyAjax.url, {action : 'ajax' ,cadenaNext : $(this).find('.nextPosts').val(), cadenaAll : $(this).find('.allPosts').val(), pageName : $(this).find('.pageName').val(), numPage : $(this).find('.numPage').val() }, function(response) {                     $('#content').addClass('cortinaOut');                     setTimeout(function() {                         $('#content').html(response).fadeIn();                         $('#content').removeClass('cortinaOut');                     }, 500);                 });         });              $('#ajax-form-prev').live('submit',function(e){                     e.preventDefault();                     jQuery.post(MyAjax.url, {action : 'ajax' ,cadenaNext : $(this).find('.prevPosts').val(), cadenaAll : $(this).find('.allPosts').val(), pageName : $(this).find('.pageName').val(), numPage : $(this).find('.numPage').val() }, function(response) {                     $('#content').addClass('cortinaOut');                     setTimeout(function() {                         $('#content').html(response).fadeIn();                         $('#content').removeClass('cortinaOut');                     }, 500);                 });         });               });


Remove hyperlink on gallery shortcode

I use a gallery shortcode in my index.php (theme directory) to display 3 boxes of images. The images are fetched from my Media.               <div class="well well-clear" style="padding-bottom: 0; margin-bottom: 0;">     <?php echo do_shortcode('[gallery ids="165,166,167"]'); ?>     </div>      By default these images have a hyperlink that when I click on it, a page will open and show the bigger version of this image. I don't want this to happen. Is there any option that I need to modify so that it will not hyperlink? I'm new to WordPress, please don't be rough on me.


Copying theme from Localhost to Live does not copy all theme settings with it?

This has happened on a number of occasions now where I move my site from Localhost to Live environment and the theme settings such as the logo, and other settings are not copied with it, so I am almost have to rebuild the site twice sometimes. Responsive is one example where this is happening as well as numerous other themes I move from Localhost to Live environment. Is there something I am missing when move the DB over? Perhaps another settings file? Many thanks


Changing permalink structure breaks link to .php file which generates files dynamically

I'm creating a (calendar) plugin where one feature is the ability to download an event as a .ics-file. To do that I have a file called ics.php in which I generate an .ics-file based on the id of the event, passed by a querystring. So far everything works.               header('Content-type: text/calendar; charset=utf-8');     header('Content-Disposition: inline; filename=event.ics');     // output...      However, after changing permalink structure from the default to month and name, everytime the file is generated the browser can't find it. (net::ERR_FILE_NOT_FOUND in Chrome, and "File not found" in Firefox). I can access ics.php but when I add the id of the event to be parsed (ics.php?e=5) I get the above mentioned error. I want the users to be able to use any kind of permalink structure with the plugin, so I need a solution to this. Maybe worth mentioning is that the events are stored as custom post types.


Select objects from get_posts()

How can I select the first/last object from the list returned by get_posts()? How can I select the preceding/following object relative to an arbitrary object in the object list returned by get_posts? How can I extract a sublist from the list returned by get_posts()?


how to search through plugin in wordpress cimy-user-extra-fields?

I have a plugin clalled - Cimy User Extra Fields. I need to search the content through this plugin. This plugin is in WordPress, and all the content are stored in the database also, like industry, keyword, experience, location. I need to search all the content through the database MySQL. Is it possible to search. What is the code to write in this plugin. Is there any other plugin is there.


Dynamic Chart using EXCEL data

I want to create a dynamic chart in WordPress blog. How can I import excel data to WordPress and make a chart?


after wp_insert_post need to get the post id

I have a function in function.php and it does wp_insert_post. how can I get the post id which just posted? when I do wp_insert_posts, it saves a PR value (unique and it saves in post- meta table). Do I need to do "select"? like select post_id from wp-post where oid=".$oid...... etc like this? I have tried to get   $post_id = wp_insert_post($new_post); $post_id = get_post($post_id) But these are not working. I am not also very good at wp join. how can I do?


Limit search results to exact match

I have a problem showing results in Wordpress with `WP_Query`. Problem is simple but as far I'm not programer I wound it difficult. So, I have custom field with values like `1-1-1-1` and `2-1-1-1-1` for example. And when I search for example `1-1-1-1` it gives me also second result and thats what I dont want to. I only want exact match to show in my search results. Can anybody help me out? code:                   <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;             global $wp_query;                  $query = new WP_Query( 'meta_key=wpcf-resitevtags' );             $query = $wp_query->query;             if (!is_array($query)) parse_str($query, $query);              $custom_query = new WP_Query(array_merge($query, array('posts_per_page' => $gantry->get('search-count'), 'meta_key' => 'wpcf-resitevtags', 'posts_per_page' => 22,  'paged' => $paged)));              ?>                  <?php if($custom_query->have_posts()) : ?>                  <?php if($gantry->get('search-page-title')) :                   ?>             <?php endif; ?>                  <?php while ($custom_query->have_posts()) : $custom_query->the_post(); ?>                  <?php                  //$title    = strip_tags(get_the_title());             $content    = strip_tags(strip_shortcodes(get_the_content(false)));             $excerpt    = strip_tags(strip_shortcodes(get_the_excerpt()));             $keys       = explode(" ",$s);             //$title    = preg_replace('/('.implode('|', $keys) .')/iu', '\0', $title);             //$content  = preg_replace('/('.implode('|', $keys) .')/iu', '\0', $content);             //$excerpt  = preg_replace('/('.implode('|', $keys) .')/iu', '\0', $excerpt);                  ?>


About WordPress site security

If I install WordPress on my server, does it mean that Akismet is installed automatically?   If so - do I still need to create e-mail verification and captcha tools for improving site security (as I see WP does not have this features in itself).   What is recommended for captcha test- simple php captcha or some graphical ajax invention (by drawing or moving objects etc)? My site will be rather plain, but will have user's comments on each page.


PHP Memory Limit Question

I just moved to a dedicated server and I was wondering whether i need to do anything explicitly inside wordpress config files to increase the performance of the site, like setting an upper memory limit.. is this really needed? many thanks, Andy


WordPress: Interact with Database Query Data and Login

I'm relatively new to Wordpress thats why I'm asking this question. I need something to start in order not to waste a lot of time. I want to connect a mobile device with the wordpress database. The user creates an account on the WordPress site with his browser. Afterwards the device logs in with username and password and queries new data. Is something like that already available? As a plugin or as a manual? thanks Tata


How to set up suhosin.ini for unlimited menus

On my custom menus page, I'm getting a limit (e.g. the users cannot add more menu items). I have done some research and have found that my suhosin settings may not be allowing wordpress enough memory. What is the best way to fix the config so that my menus won't be limited?


Wordpress Subdomain MultiSite on localhost XAMPP on :8080 with IIS taking port 80

I currently have Windows 7 , 64 bit on which I am running an IIS on localhost:80 and I installed XAMPP on localhost:8080. I have 15 individual wordpress sites but now i need a subdomain multisite wordpress. I created wp.dev:8080 in the hosts file for multisite, and correctly amended the apache virtual file. All worked until I added the `define('WP_ALLOW_MULTISITE', true);` to the config file. When I clicked on the new Network menu option in wordpress, I got an error: > ERROR: You cannot install a network of sites with your server address. You > cannot use port numbers such as :8080. Now here is the problem. localhost is mapped to 127.0.0.1 on port 80 for IIS. And Apache is taking all of localhost:8080. can I somehow split the localhost:80 traffic by assigning wp.dev to be the only :80 to go to Apache and the remainder to continue going to IIS. How would I define that since in Apache I already have *:8080 defined? Please help, my files are below: > Hosts file on c/windows/system32/drivers/etc/hosts this is root of iis if i > dont specify port (:80) and if i specify port (:8080) go to xampp 127.0.0.1 > localhost these below are the :8080 individual wordpress on xampp 127.0.0.1 > sb.localhost tw.localhost ups.localhost vet.localhost box.localhost > ea.localhost multisite below 127.0.0.1 wp.dev **This is my Apache config file in D:\xampp\apache\conf\extra\httpd- vhosts.conf** > NameVirtualHost *:8080 > > DocumentRoot "D:/xampp/htdocs" ServerName localhost **This is a working wordpress normal blog** > DocumentRoot "D:/xampp/htdocs/ki/abce/wordpress" ServerName abce.localhost > Options Indexes FollowSymLinks ExecCGI Includes Order allow,deny Allow from > all **This below is how network subdomain blog that would work if not for 8080 problem** > DocumentRoot "D:/xampp/htdocs/alllive/wordpress" ServerAlias *.wp.dev > ServerName wp.dev Options Indexes FollowSymLinks ExecCGI Includes Order > allow,deny Allow from all Thank you in Advance!


How i can get the URL?

How i can get the base URL in the wordpress? `get_bloginfo('url')` returns me the current URL. I just want the base URL e.g `http://localhost/wpsite/` not any **?page_id=123** with it


How to let a user choose an authors and save it to the database?

I have a multi-author Wordpress site which reads different rss feeds and posts them to my page. I was wondering if it is possible to make a code that would provide an opportunity to registered user choice of which authors/sources to follow. There is already a few plugins that allow users to subscribe or 'follow' an author with email notifications (Example). But what I'm looking for is how to allow a user to select which feeds they want to read and this plugin would show only those feeds on my website. I have little knowledge of php but none from Wordpress really. Where should I start developing it? It needs to remember each user's follows so it has to be saved database for what i know. * * *               function select_authors_fields( $user ) {     $authors = get_users();     $user_tags = get_the_author_meta( 'select_authors', $user->ID );     ?>

             My interests:	                      <?php         if ( count( $authors ) ) {             foreach ($authors as $author) {                  if (user_can($author->ID, 'publish_posts')) { ?>
<label for="select_authors_<?php echo esc_attr( $author->ID); ?>">                 <input                     id="select_authors_<?php echo esc_attr( $author->ID); ?>"                     name="select_authors[<?php echo esc_attr( get_the_author_meta('display_name', $author->ID) ); ?>]"                     type="checkbox"                     value="<?php echo esc_attr( get_the_author_meta('ID', $author->ID) ); ?>"                     <?php if ( in_array( get_the_author_meta('ID', $author->ID), $user_tags ) ) echo ' checked="checked"'; ?> />                 <?php echo esc_html(get_the_author_meta('display_name', $author->ID)); ?>
<?php                  }              }         } ?>

     <?php         }      add_action( 'show_user_profile', 'select_authors_fields' ); add_action( 'edit_user_profile', 'select_authors_fields' );               // store authors     function select_authors_fields_save( $user_id ) {         if ( !current_user_can( 'edit_user', $user_id ) )             return false;         update_user_meta( $user_id, 'select_authors', $_POST['select_authors'] );     }     add_action( 'personal_options_update', 'select_authors_fields_save' );     add_action( 'edit_user_profile_update', 'select_authors_fields_save' );      This ones prints authors in user preferences with checkboxes. Now i need to make post_query depending selections. Any clues?


resizing image upload for all

I'm having problems with file upload, upload any image that I resized. however already deactivated every plugin, pro vopltei default theme, and still occurs redimenxionamento, tme some other option to disable automatic thumbnailing, something in the database \-- I do nothing that solves the problem, I can change the theme and the error continues, the media settings to put the maximum 1024x1024 be some more when I uploade image is resized it to 370 height, did resinstalação files from wordpress not put resolved


How to have custom tinyMCE buttons break onto next line when too long

There is probably a really simple solution that I am missing here but I have added multiple custom buttons to the tinyMCE editor in Wordpress and my problem is the row of buttons is too long (they're all on the same row - their own row) so since I am hooking into mce_buttons_3 and I have a lot of buttons, is there anyway of breaking this up so that if the row is too long to where it breaks the default WP layout that I could have the additional buttons on another row? Below is a sample of what I am working with:               add_action('init', 'add_button');       function add_button() {          if ( current_user_can('edit_posts') &&  current_user_can('edit_pages') )          {            add_filter('mce_external_plugins', 'add_plugin');            add_filter('mce_buttons_3', 'register_button');          }       }           function register_button($buttons) {          array_push($buttons, "quote", "one-fourth", "one-fourth-last", "one-third", "one-third-last", "one-half", "one-half-last", "two-third", "two-third-last", "three-fourth", "three-fourth-last", "custom-list-1", "custom-list-2", "custom-list-3", "custom-list-4", "message-box-info", "message-box-success", "message-box-warning", "message-box-erroneous", "message-box-simple", "message-box-custom", "recent-posts", "custom-frame-left", "custom-frame-center", "custom-frame-right", "custom-table", "accordion", "accordion-toggle", "tabs", "tabs-content", "toggle-content", "dropcap", "pull-quote", "clear", "divider", "divider-top", "custom-button", "round-button", "small-button", "button", "read-more" );          return $buttons;       }


Using Bootstrap in themes

Twitter has just came out with a new web framework called Bootstrap. What's the right way to use it within a theme? **Update** : The stylesheet inclusion is simple indeed. I want to know which caveats or compatibility issues I should expect.


Getting /feed/ behind post urls in Google Webmaster Tools; crawler errors?

Currently I have a wordpress site submitted in Google Webmaster Tools. But at the Crawler Errors page, I see a lot of : site.nl/post/feed. Does anyone know how these get there and how to get rid of em?


How to restore my wordpress site on your server?

Yesterday my wordpress site "http://planetofcoders.com", Hacked by someone Bangladeshi hacker. After that I did delete all site and database data. I have my site and database backup as on 09-Nov-2012. I did restore all site data and database backup on server. But after restoring all data my site doesn't work properly. I want to know that what is the process to restore my site data and database backup on your server? How to prevent my site from hackers? When i enable debug in wordpress in that case it gives me this error i.e.               Notice: register_uninstall_hook was called incorrectly. Only a static class method or function can be used in an uninstall hook. Please see Debugging in WordPress for more information. (This message was added in version 3.1.) in /home/planetof/public_html/wp-includes/functions.php on line 2758          Notice: Constant HMBKP_REQUIRED_WP_VERSION already defined in /home/planetof/public_html/wp-content/plugins/wp-database-optimizer-tools/wp-database-optimizer-tools.php on line 37          Warning: Cannot modify header information - headers already sent by (output started at /home/planetof/public_html/wp-includes/functions.php:2758) in /home/planetof/public_html/wp-includes/pluggable.php on line 881


Storing an XML Response (Transient)?

Haven't worked much with XML so I'm hitting a bit of a wall:               function getapi()      {         $api_response = wp_remote_get( "http://example.com/getXML" );         $data         = wp_remote_retrieve_body( $api_response );         $output       = new SimpleXMLElement ($data );              return $output;     }      ## Get or set the Transient               function transient()     {          $transient = get_transient( 'transient_value' );              if ( ! $transient ) {             $transient = getapi();             set_transient( 'transient_value', $transient, 180 );         }              return $transient;     }      I can easily show the data, but **calling it up from a stored transient** results in this error being shown:               Node no longer exists in C:\xampplite\htdocs\...      Not sure what the extra step is that I need to perform in order to store the data correctly. Many thanks! Noel


Filter have_posts()/ the_post()

What is the best way to filter the posts being displayed? For example in my functions.php file I want to have something like               add_filter( $tag, 'filter_posts');          function filter_posts(){             if(is_home()){             //return custom post query that will be used in loop        }     }


Featured Image missing in Wordpress 3.2 Admin

I've just upgraded from 3.1.2 to 3.2, and now "featured image" is no longer listed at the bottom right of a post in admin. Has this feature of WP been removed? Can it be added back, or turned back on? My old posts still have their old featured image, but it cannot be added to new ones.


Viewing category won't show up Custom post type posts

I'm having a strange problem: I've build a category page and want to load up all related posts of a custom post type but won't give any results. I'm using the following code:                 query_posts( array( 'post_type' => 'blog', 'showposts' => 3, 'cat' => 9 ) );      When deleting the 'cat' it shows all posts of the custom post type. Is anyone familiar with this problem?


Stylesheet switching and caching

I'm implementing a site that allows users to switch stylesheets (to show a high contrast version for people with vision impairments). The switcher essentially just changes the `<link>`ref to whichever stylesheet is appropriate. However, I've just realised that this will lead to problems when I switch on caching (either using WP Supercache or W3 Total Cache) - as only one version of the page will be cached and thus displayed to the user. Any thoughts on possible solutions?


Wordpress 4.0 Media Gallery (Same Image) Bug - Does anyone know how to fix this?

So, we've been working on this site for a long time and have finally started finishing up. As a last cleanup we updated all our plugins and Wordpress to 4.0 and expected awesomeness. However, for some reason the site feels slower, takes up around 30-40% cpu on our server and this(see image) happened to the media gallery: ![this screenshot](http://i.imgur.com/oEAIhhI.jpg) Has anyone encountered this before or have any suggestions of how I might go about fixing this? Front-end everything looks fine, no errors or images missing. Backend won't let us upload images or browse images we've already uploaded..


Is it possible to make wp insert last comment onto another page

If we set wp to break comments into pages after X nr of comments and we have X+1 comments , wp only shows that last comment instead of showing X and move the comment from bottom onto the next page. Any help would be appreciated since it is a big deal for what I am trying to use it.


Group pages by custom field values

I plan to have each individual product as a page, with custom fields for : Brand, size, feature 1 and feature 2. My question: Will it be possible to build a summary page template say for Brand, based on the custom field?   I would like to be able to display a thumbnail for each brand, showing the count of products [ie pages] for each brand. When you click on the thumbnail I would like a second page listing each product with a link to the actual product page. Is this a valid approach or is there a better way?


How to change links in the 3 main categories, on widget category, to a javascript function call

I'd like to know.. How could I change my 3 main categories links, so they call a javascript function? I'm using Snapshot Theme from WooThemes. Here's the current state of the website: http://www.mpn.p.ht/wp_br2/ The categories I'd like to change the links to a javascript function call, are: **_Masculino_** , **_Feminino_** and **_Infantil_**. They are at a container with class `widget`. EDIT: I´ve changed the jquery. I've tried to use jquery in `index.php`:               $(document).ready(function() {              $(".widget ul li > a").not("ul li ul li>a").attr("href", "javascript:hideMenu();showSubMenu('m-submenu');");     $(".widget ul li+li > a").not("ul li+li ul li>a").attr("href", "javascript:hideMenu();showSubMenu('f-submenu');");     $(".widget ul li+li+li > a").not("ul li+li+li ul li>a").attr("href", "javascript:hideMenu();showSubMenu('i-submenu');");          });      But, it seems that some sub-categories are calling the javascript function. In other words, my .not() it´s not working in some cases. What could I do? Thanks.


htaccess rewrite conflict with wordpress rules and ssl

this one has me buggered- I have the below htaccess rule to redirect ssl to non-ssl pages. this works fine, except I'd like to exclude certain wordpress requests from this rule- for example, https://mysite.com/info/. I've tried the following:               #rewrite all ssl pages to non-ssl for everything that doesn't have /info/ in the request uri      RewriteCond %{HTTPS} on     RewriteCond %{REQUEST_URI} !^/info/     RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,QSA,L]          #wordpress     RewriteBase /     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /index.php [L]      the result is that https://mysite.com/info/ redirects to http://mysite.com/ instead. If I disable the wordpress rewrite rules, the preceding rules work fine. Can anyone suggest the proper way to target pretty urls in a rewrite condition?


Add child pages automatically to nav menu

I have built a custom menu in Wordpress that contains links to posts and pages. I am adding it to my header using this line of code:               <?php           wp_nav_menu(         array(             'theme_location' => 'primary',              'depth'          => 0,              'menu_class'     => 'nav-menu',         )      );          ?>      My problem is, if I add a child page to the top level ones on the menu, they don't automatically appear as sublinks on the nav. I know I can create them manually each time by rebuilding the menu, but I would like to be able to just add a child page in the pages section and have it show up in the nav without having to go to the menu and build it there also, if that makes sense? I've tried using `depth => 0`, but that didn't work. Is there a way to have child pages show up without having to build it into the custom menu?


Saving Custom Field Data before Publish

When creating a page or a post WordPress lets the content (title, body, featured image) be saved when using Ctrl + S. The Custom Fields do not save in the same way (in this case I'm using Advanced Custom Fields as well, but it happens without this plugin). Does anyone have a solution for saving this data in the same way? In this case Publishing isn't an option. **UPDATE** : If I click the "Save draft" button the Custom Fields save. The ctrl + S save only seems to be in scope when in the content area. Is there an easy way to change this to be a global post ctrl S? The "Save Draft" button thankfully removes the urgency, but that would be nice!


Help with WP gallery function, wrap gallery in div

I have a function in my functions.php file I need to change slightly and am having trouble doing it correctly. This function changes the gallery markup for Wordpress, making it more html5 friendly. It works fine as is, except that I'd like to wrap the entire gallery in a div, for example `<div id="sort">`. (I want to wrap the gallery, not the entire post.) I'm having trouble figuring out how to add that to this function:               //Gallery Code Filter     add_filter( 'post_gallery', 'my_post_gallery', 10, 2 );     function my_post_gallery( $output, $attr) {         global $post, $wp_locale;         static $instance = 0;         $instance++;         // We're trusting author input, so let's at least make sure it looks like a valid orderby statement         if ( isset( $attr['orderby'] ) ) {             $attr['orderby'] = sanitize_sql_orderby( $attr['orderby'] );             if ( !$attr['orderby'] )                 unset( $attr['orderby'] );         }         extract(shortcode_atts(array(             'order'      => 'ASC',             'orderby'    => 'menu_order ID',             'id'         => $post->ID,             'itemtag'    => 'figure',             'icontag'    => 'dt',             'captiontag' => 'figcaption',             'columns'    => 3,             'size'       => 'thumbnail',             'attachment' => 'large',             'include'    => '',             'exclude'    => ''         ), $attr));         $id = intval($id);         if ( 'RAND' == $order )             $orderby = 'none';         if ( !empty($include) ) {             $include = preg_replace( '/[^0-9,]+/', '', $include );             $_attachments = get_posts( array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );             $attachments = array();             foreach ( $_attachments as $key => $val ) {                 $attachments[$val->ID] = $_attachments[$key];             }         } elseif ( !empty($exclude) ) {             $exclude = preg_replace( '/[^0-9,]+/', '', $exclude );             $attachments = get_children( array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );         } else {             $attachments = get_children( array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );         }         if ( empty($attachments) )             return '';         if ( is_feed() ) {             $output = "\n";             foreach ( $attachments as $att_id => $attachment )                 $output .= wp_get_attachment_link($att_id, $size, true) . "\n";             return $output;         }         $itemtag = tag_escape($itemtag);         $captiontag = tag_escape($captiontag);         $columns = intval($columns);         $itemwidth = $columns > 0 ? floor(100/$columns) : 100;         $float = is_rtl() ? 'right' : 'left';         $selector = "gallery-{$instance}";         $output = apply_filters('gallery_style', "");         $i = 0;         foreach ( $attachments as $id => $attachment ) {             $link = isset($attr['link']) && 'file' == $attr['link'] ? wp_get_attachment_link($id, $size, false, false) : wp_get_attachment_link($id, $size, true, false);             $output .= "<{$itemtag} class='item'>";             $output .= "                                 $link                 ";             if ( $captiontag && trim($attachment->post_excerpt) ) {                 $output .= "                     <{$captiontag}>                     " . wptexturize($attachment->post_excerpt) . "                     </{$captiontag}>";             }             $output .= "</{$itemtag}>";             if ( $columns > 0 && ++$i % $columns == 0 )                 $output .= '';         }         $output .= "                 <br>\n";         return $output;     }


How can I change this footer.php code to call a random image on reload?

This comes from the `footer.php` file of a wordpress theme I would like to modify. I want one of five images to load on refresh instead of `1.jpg` every time.               <script type="text/javascript">          <?php          if((is_archive()) || (is_author()) || (is_category()) || (is_home()) || (is_single()) || (is_tag()) || ($posttype == 'post')  ) {             $name = "news-and-information";     }else{             $name = $wp_query->post->post_name;     }          ?>          $(document).ready(function(){                  var imgPath = '/wp-content/themes/nexus/img/page-headers/<?php echo $name; ?>/1.jpg';                  $('.subheader-wrapper').css('background-image', ('url("'+imgPath+'")'));          });     </script>


Changing theme = change home page for mobile visitors?

I'm trying to create mobile-friendly version for a wp site. I'm using the "any mobile theme switcher" to switch to an alternative (mobile) theme which works well. I have also created some alternative key pages (home, contact & news) which are heavily edited (shorter) versions of the desktop theme content and added these to a mobile-only menu. Again - this is working well. The problem I'm trying to solve is how to avoid someone using a mobile device landing on the desktop version of the home page? I can't see a way of setting a different home / front page within my mobile theme files so.. Can mobile devices be re-directed to my alternative "mobile homepage" instead? And If at all possible, retain the option to view the full desktop version if desired. I see the codex describes useful bits of code, but I need help to make them all work together. In human terms, I think what I need is something that does this - If is home page, And if is mobile, Redirect to http://mysite.com/mobile- homepage Many Thanks


Bookmark anchor link to load another page first before completing?

**Question: is there a way for a link to an anchor bookmark to arrive at its destination by loading another page first?** I'm developing a vertical-scrolling style website where the home page displays the contents of 3 other pages within sections or divs. Each section has a bookmark and a "back to top" link, and my main navigation menu uses custom bookmark anchor links. I'm also using thejQuery smooth scrolling plugin which works very well. The problem I'd like to solve is that if you are not on the home page, but another page (such as the blog page) and you hit a bookmark link then the smooth scrolling effect can't work. It simply jumps straight there. Would it be possible for the bookmark links to load the homepage first, and then continue to the required bookmark so the scrolling will still work??


WP_query exclude posts of a format

I'm using the code below to try to exclude the format "post-format-quote", but it is excluding all posts, including ones of the standard format (no format).                           $myposts = new WP_Query(array(                     'tax_query' => array(                         'taxonomy' => 'post_format',                         'field' => 'slug',                         'terms' => array('post-format-quote'),                         'operator' => 'NOT IN'                     ),                     'posts_per_page' => 3                     )                 );


How does WordPress choose archive type template?

I can't find a comprehensive list of criteria for how WordPress determines which archive type template it chooses. From what I understand it uses URL forms for this purpose, like:               example.com/category/some-category -> category.php (i guess tags work similarly)     example.com/2012 -> date.php      But what about author.php and taxonomy.php? What triggers the template hierarchy to use those routes? My ignorance is about how WP selects certain templates for I which I don't know how to trigger. I think I understand category templates with higher specificity, and archive.php I understand as a catch-all before going to index.php, but I have no idea when WP will select for example author.php and why. For example, suppose I have two posts by the same author. How do I make WP use the author.php template to show me the posts by that author? I suppose the notes around each box in the template hierarchy chart is supposed to give some clue about this, but I don't understand when and where those pieces of code should be used. I did look at the hierarchy chart, but there are things about it I don't understand, which is part of the reason I'm posing this question. For example, I can not read from the chart that if I have a URL on the form example.com/2012 it will use the date.php template. It makes sense, but I can't see that the URL should be on any form, especially this one. In general I have a hard time understanding how WordPress selects which template(route) to take. I may have misunderstood, but I expect WordPress to determine which template to use before it starts interpreting its contents. At that point it can display anything you want depending on its contents and using the is_sometype() functions. What I don't understand is how it reaches that point. Have I got this reasoning wrong? I'd be very grateful if someone could address this point. edit: Some follow-up questions after Chip's answer: Do I understand it correctly that WP parses permalinks using rewrite rules to build the query, or else the query is already in "native" format, i.e. a URL followed by ? and a concatenation of query variables? Can a combination of both occur? What is the definition of "current context" with regard to queries? Could you give an example? What do the blue .keywords signify that are below each box in Chip's diagram?


Force post slug to be auto generated from title on save

I'm running a property site where many properties are sold in apartment blocks. Because of this what the content editors do is create a post/property with all the details and then use a duplicate post plugin to create the others. Each time they duplicate a post/property they change the title to reflect the property number and maybe change a few bits of meta data E.G price. What they forget to do is wipe out the slug and let a new one be generated from the title. Here is an example slug from the first property entered: `merle-court-plot-50-182-carlton-vale-nw6-5hh` but then when they duplicate the slugs become:               merle-court-plot-50-182-carlton-vale-nw6-5hh-2     merle-court-plot-50-182-carlton-vale-nw6-5hh-2-2     merle-court-plot-50-182-carlton-vale-nw6-5hh-2-2-2     merle-court-plot-50-182-carlton-vale-nw6-5hh-2-2-2-2     etc      But when they change the titles the slugs would be better like:               merle-court-plot-51-182-carlton-vale-nw6-5hh     merle-court-plot-52-182-carlton-vale-nw6-5hh     merle-court-plot-53-182-carlton-vale-nw6-5hh     merle-court-plot-54-182-carlton-vale-nw6-5hh     etc      So my question: > How do I force the slug to be re-generated on post save, after they have > updated the property title? The slug for this CPT should always be auto generated, there is never a need to manually set it.


How to fix unchanged URLs in Database after running serialized search and replace script?

I just did my first migration from a dev site to a prod site, using the InterconnectIt serialized search and replace script. The migration worked, but here is where I’m struggling: The site was unusually slow and some clients could not view the slider and images, so we looked through the theme settings and found many URLS still with the dev site address. We had used the back button on the InterconnectIt script and run it several times at the time of migration, and I ran it again several times since then, even changing the GUID columns, but that still didn’t change all of them. Here are some examples of the old URL left in the options table: 1: http:\/\/www.example.com\/client\/wp-content 2: newsletter@example.com And from the SlimStats plugin table: 3: www.example.com (with the "http://" in front) Our criteria was: Search: http://www.example.tk/client Replace: http://www.client.org I don't feel competent to use other criteria than that, as I'm not sure of the consequences. Do I need to search with other variations of the URL in various instances (e.g., without the "http://", without the "www") in order to catch them all? I've researched and can't find a solution. Search and Replace Regex plugin only seems to change posts and author stuff, not the other tables. Other plugins don't seem to be serialized. I'm hesitant to do it myself in a text editor (as the WPTuts+ migration tutorial showed), as I'm not sure where all the serialized data is. Have you any clue why some URLs were left unchanged, or if there is something I might be doing wrong? Any help is certainly appreciated. Thank you.


Where the Nickname is being used in WordPress

I see most of the place is using the " **Display name** ", so why I need to set a Nickname? Where it is being used?


wordpress plugin for database field search

Is there any wordpress plugin to search for people's names in the database? If i have a column 'name' , i need to provide search functionality over it, give all the matching results for that column. Sentence completion would be even better. I am no PHP programmer. Any help is greatly appreciated. Thanks


how to interconnect custom post types?

I'd like to make a site about choirs, composers, conductors and singers. And so far I decided that I need to make a custom post type for "piece" -- any piece can be associated with choir[s], composer, conductor and singer[s]. I could do this with taxonomies (tags), assigned to every "piece". But I need to be able to write about conductors, too. So, I need to create another post type? So, now I have "piece", "conductor", "composer" post types. And I can use Posts 2 Posts plugin to interconnect them. But in some cases conductor may act as a soloist -- and it seems that I could create "person" type, but anyway I can not say that "piece"<\--(conductor)-->"person" and "piece"<\--(soloist)-->"the_same_person" with posts2posts. Actually I think that I need these post types (should I use tags for some?): piece, conductor, composer, soloist, collection (CD or live performance) and I need for some of them to have custom fields (creation year, publication year etc) -- hope this can be done too by other means. I guess I could add custom fields to piece and put "conductor_id" here. Do I overcomplicate things? How this could be done? Thanks! **UPDATE** : Thanks, scribu; I was wrong: it looks like posts2posts is what I need.


What difference does it make if I enable support for video post format?

I am sorry if this is stupid. I can't seem to figure out what special things it does. If I embed a youtube video(embed/iframe) it works for both standard and video format. Surely, I am missing something...


WP 3.9 TinyMCE no longer loads on category description editor

I've used this script below inside functions.php since WP 3.5 It converts the standard category description editor to a rich text editor. Unfortunately, after upgrading sites to WP 3.9, the description editor is back to a standard text area. Any ideas what I need to change for 3.9?               add_action('load-categories.php', 'cb_admin_init');     add_action('load-edit-tags.php', 'cb_admin_init');          function cb_admin_init()     {         if ( user_can_richedit() && isset($_GET['action']) && 'edit' === $_GET['action'] && ( !empty($_GET['cat_ID']) || ( !empty($_GET['taxonomy']) && !empty($_GET['tag_ID']) ) ) ){             add_filter( 'tiny_mce_before_init', 'cb_mceinit');             add_action('admin_footer', 'wp_tiny_mce');             add_action('admin_head', 'cb_head');         }     }          function cb_mceinit($init)     {         $init['mode'] = 'exact';         $init['editor_selector'] = 'description';         $init['elements'] = 'category_description,description';         $init['plugins'] = 'safari,inlinepopups,spellchecker,paste,fullscreen';         $init['theme_advanced_buttons1'] .= ',image';         $init['theme_advanced_buttons2'] .= ',code';         $init['onpageload'] = '';         $init['save_callback'] = '';         return $init;     }          function cb_head()     {     wp_enqueue_style('editor-buttons');         ?>     <style type="text/css">#category_description_tbl,#description_tbl{border:1px solid #dfdfdf;}.wp_themeSkin .mceStatusbar{border-color:#dddddd;}</style><?php     }               add_action('init', 'cb_editor_init');


Detecting errors generated by $wpdb->get_results()

How do I detect errors when using $wpdb->get_results()? For example:               $result = $wpdb->get_results("SELECT * FROM this is not a valid query");      The preceding code doesn't generate any exceptions or errors; it simply sets $result to an empty array. How do we reliably detect errors generated by get_results()?


Custom Connect to Facebook, problem logging in/logging out

I am working on a custom function for login in my users via facebook. I started by reading this nice tutorial on how to login in via facebook: http://digitalzoomstudio.net/2013/02/09/tutorial-how-to-login-via-facebook-in- your-wordpress-blog/ The function will log in the user to wordpress if an account with his/her facebook email already exists in the wordpress blog. If it doesnt exist, it will automatically create an account for the user. Everything works as expected. However, I have an issue when login in and login out. There is a "Login with Facebook" button. This button will change to Logout (this logout button is supposed to logout the user from facebook) if the user logged in. ## One issue (LOGIN IN):   * The first time the user clicks the "Login with facebook" button, the user is logged into the wordpress blog; however, Facebook API wont recognize the user thus making the facebook login button output a LOGIN button instead of a LOGOUT button.   * The second time, the user clicks the LOGIN button, Facebook API DOES recognize the user and the button changes to LOGOUT. So, why is it that the first time the user is not being recognized by facebook but the second time is? ## The other issue is this (LOGIN OUT):   * Once the user logs in the first time it hits the facebook LOGIN button, and wants to logout from my wordpress blog through a custom made logout button (this button is supposed to logout the user from the blog only and not from facebook), it works perfectly!   * However, if the user has logged in by clicking the facebook LOGIN button a second time, the custom made logout button has to be clicked twice in order to logout the user successfully. I know how to solve this partially. I could just check if the user is logged in the blog and remove the LOGIN button; however, I want to know why I am getting this strange behavior from facebook and how it is conflicting my blog. ## UPDATE For the second issue (when user logs out) I found the solution. I just had to destroy facebook session `$facebook->destroySession();` ## UPDATE 2: SOLVED! The tutorial from the link I provided was destroying the facebook session after login in and when creating a new account for some reason. I just had to remove `$facebook->destroySession();` from both parts and now everything is working as intended.


Retrieve data from post meta meta_key having '_product_fq_image' while having author_id and post type is PRODUCT

How can we retrieve data from postmeta having '_product_fq_image' while having author_id and post type is PRODUCT I have tried this               $lt_content_design= get_user_meta( $user_id, 'lt_content_design', true );      but how can we use JOIN here for listing only particular user data having posttype is product


array of objects to do_action, callback gets singular object?

So I was passing an array of objects through an action today, no biggy, and things were working fine. Until I was iterating over one of the arguments to a callback and started getting errors. The only difference was that the passed array to the `do_action` call only had a single object in it. Confused by this, I simply didn't call the action unless the array had a count of over 1 (the action is caching something FYI). Looking into the function definition I found this on line 411 of wp- includes/plugin.php               if ( is_array($arg) && 1 == count($arg) && isset($arg[0]) && is_object($arg[0]) ) // array(&$this)      which is what was causing my array of a single object to become just an object. To me this is really weird, if I pass an array to an action then I expect an array on other side. I'm using WordPress 3.7.1 and am wondering if anyone knows _why_ do_action has this behavior? A ticket or a link to something in the wordpress repository would work as an answer for me. EDIT: Request for code and actions: I create an action within my code like so:               add_action('hs_cache_merchants', array('HoneyCache', 'cacheMerchants'), 10, 1);      It is called like so within a method that retrieves data from the database, where `$merchants` is an array of objects.:               do_action('hs_cache_merchants', $merchants);      And then my callback registered with the add_Action:               public static function cacheMerchants($merchants){         if(!is_array($merchants)){ /* WordPress will convert an array of a single object to just the object. */             $merchants = array($merchants);         }              set_transient(HoneyMerchant::CACHE_CURRENT_MERCHANTS_KEY, $merchants, HoneyMerchant::CACHE_CURRENT_TIME);     }      If I modify my prototype to be               public static function cacheMerchants(Array $merchants){      then I will get the error:                PHP Catchable fatal error:  Argument 1 passed to HoneyCache::cacheMerchants() must be an array, object given      I used print_r in the function that calls `do_action` and noted an array with a single object in it, this only happens if the array has 1 item in it, since that's part of what that `if` in the core checks.


LaTeX for WordPress strips codes in loop

Installed LaTeX for WordPress and added post: > Some text $$\alpha+\beta\geq\gamma$$ other text. I see that equation in post page, but it stripped in loop. How can I see equation in loop too?


Pagination custom query

I am trying to make a custom page template that shows the most viewed posts. I can return posts but I am having trouble figuring out how to paginate it. Here is what I have:               $args = array('orderby' => 'meta_value_num', 'meta_key' => 'post_views_count', 'posts_per_page' => 36 );                 $loop = new WP_Query( $args );                 while ( $loop->have_posts() ) : $loop->the_post();      I tried:               $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;                  $args = array('paged' => $paged, 'orderby' => 'meta_value_num', 'meta_key' => 'post_views_count', 'posts_per_page' => 36 );                 $loop = new WP_Query( $args );                 while ( $loop->have_posts() ) : $loop->the_post();      but my pagination still doesn't show up. I am wondering if it has to do with my pagination function or the way I am setting up my query. I just call my pagination function below the query, it all looks like this:               <?php                 $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;                  $args = array('paged' => $paged, 'orderby' => 'meta_value_num', 'meta_key' => 'post_views_count', 'posts_per_page' => 36 );                 $loop = new WP_Query( $args );                 while ( $loop->have_posts() ) : $loop->the_post();?>                     <?php get_template_part( 'content', get_post_format() ); ?>                 <?php endwhile; ?>             <?php wp_reset_postdata(); ?>          <?php pagination(); ?>      This is my pagination function:               if ( ! function_exists( 'pagination' ) ) :         function pagination() {             global $wp_query;                  $big = 999999999; // need an unlikely integer                  echo paginate_links( array(                 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),                 'format' => '?paged=%#%',                 'current' => max( 1, get_query_var('paged') ),                 'total' => $wp_query->max_num_pages,                 'mid_size' => 1,                 'prev_text'    => __('«'),                 'next_text'    => __('»'),                 'type'         => 'list'             ) );         }     endif;      Any help would be greatly appreciated.


Change WP-LOGIN and WP-SIGNUP for any request

I want to rename `wp-login.php` and `wp-signup.php` for any request I tried this               RewriteRule ^login$ /wp-login.php [L]     RewriteRule ^signup$ /wp-signup.php [L]      but when someone insert a wrong password his redirected from `/login/` to `/wp-login.php` and in the Second page of registration in Multisite is redirect from `/signup/` to `/wp-signup.php`


Auto Nofollow attribute in custom field links. How?

I have a wordpress network. All the contents in my network are user generated. All posts links are now dofollow. I want to change it to nofollow. My site uses plugin for custom fields. I removed the default description area. So i cannot use the_content function. I use custom fields for all. I tried many auto nofollow plugins. But its not working in my custom fields. Can anyone help me? Is there any function code available? I just want               My Link      to               My Link      Thanks


Use Custom Post Type as Custom Field

I want to create a custom post type for store that having all store names and it is working. Now I want to fetch the all stores in a select box in every new post of WordPress, then selected store name will used as custom field for that post. I want to save this store name as meta value for this post in `wp_postmeta` table. Every custom post having the post_type='store' so how I write a function to fetch all post by store type.


How can I display sticky posts at first in wp_query?

I'm looking for a long time, but I could not find a solution. I'm not a coder. Please help me. Here is my wp_query code;               $my_query = new WP_Query('category_name=animals&showposts=10');     while ($my_query->have_posts()) :          $my_query->the_post();         $do_not_duplicate = $post->ID; ?>
<a href="<?php the_permalink()?>"><?php the_title(); ?>
<?php      endwhile; ?>


Post archive pages bringing me to a 404 page

When I try to use `next_posts_link()` and `previous_posts_link()` in my `archive` posts page I got a `404 error` page. I'm using this permalink setting `/%category%/%postname%` and working well for all pages like `site.com/contacts` or posts like `site.com/category/this-is-a- post-tile`. The only problem is in archive posts, for test I've set the number of posts per archive by 1 per page and trying with three articles to change the pages. The paginator is simple this:               <?php get_header(); ?>
         <?php if (have_posts ()) : while (have_posts ()) : the_post(); ?>             <article class="left-icon article" id="post-<?php the_ID(); ?>">                 <a class="permalink" href="<?php echo get_permalink();?>">
<?php the_title(); ?>

<?php echo __('di:').' '.get_the_author();?> / <time datetime="<?php echo get_the_date('Y-m-d H:i:s');?>"><?php echo get_the_date();?></time>

<?php the_excerpt(); ?>

                 <a class="button" href="<?php echo get_permalink();?>"><?php echo __('Continue to article'); ?>

         <?php endwhile; endif; ?>                      <?php             // PAGINATOR             next_posts_link();             previous_posts_link();             ?>
              <?php         // some menu here         ?>          <?php get_footer(); ?>      I'va always had mistakes with permalinks and pages, probably I miss some base concept of `WordPress` about it. How can I do to make it work and let WordPress paginate `blog` pages correctly?


Add specifications table for products page

I have a WordPress issue that has been keeping me busy for a few days. I'm currently building a website for a client. This website will show products and each product page also has a table with specifications of the product. The specifications will be shown in a table like this: ![http://preview.navinpoeran.com/images/tabel.jpg](http://i.stack.imgur.com/Smkj4.jpg) What would be the best way to implement this in the template, so the client can add data for each product from the back-end? Each product gets its own page of course. For example: iPhone 4S   iPhone 5   etc. (no it's not an Apple-related website, just an example)


how to disable user confirmation from administration?

I have a multi-site network, on one of the sites the access is restricted to registered users, and only an administrator can create users. I was asked to get rid of the confirmation email sent to new users, and I know you can select an option to add the user without sendind the email. The problem is, that option is only available to super administrators (me) and not regular administrators. Is there a way to add the new users without sending a confirmation email? I can get rid of the email, but I also need to remove the activation link, I need the users to be automatically added. I've looking for hooks but I can't find anything helpful, any ideas?. P.S. Every user is added from the _Add new user_ menu in the backend.


How can I add rel="nofollow" attributes on RSS widgets?

By default WordPress does not appear to have the option to add `rel="nofollow"` attributes on the RSS widgets.               <li>         <a class="rsswidget" href="http://news.google.com/news/url...">             The 60-Something Entrepreneur         </a>     </li>      How can I make it so my RSS feed links have the `rel="nofollow"` attribute?


Sort query_posts for Parent Pages to menue order or the count?

thanks to a member here i display my Parent Pages in a 2 column grid with title and excerpt. But for some reason i can't figure out how to sort all 5 Pages by the menu order for example or the order number i assigned. i display them by using query_posts( 'post_type=page&post_parent=0' ); so that the child Pages won't displayed. but i can't figure out how to order them.. Any ideas??? thanks in advance! Dan


Somehow adding to "Insert Into URL" posts are contradicting each other

I added a second upload image ( doc_thumb_box ). They both work perfectly independent of each other. But when the second one is added, the first one (doc_uri_box ) no longer pastes the value of the URL into the box. Instead **both** boxes, if there is any content in them, become _blank_. Is there something obvious that is contradicting the other?               public static function doc_thumb_box() {     global $post;          $thumb = get_post_meta( $post->ID, 'upload_image', true );          function my_admin_scripts() {     wp_enqueue_script('media-upload');     wp_enqueue_script('thickbox');     wp_enqueue_script('my-upload');     }          function my_admin_styles() {     wp_enqueue_style('thickbox');     }          if (isset($_GET['page']) && $_GET['page'] == 'my_plugin_page') {     add_action('admin_print_scripts', 'my_admin_scripts');     add_action('admin_print_styles', 'my_admin_styles');     }          echo 'Enter a URL or upload an image for the thumb.';     echo '
';     echo '
';     echo '';     echo '<input id="upload_image" type="text" size="36" name="upload_image" value=" ' . $thumb . '" />';     echo '<input id="upload_image_button" type="button" value="Upload Thumb" />';               echo "\r\n";          }          public static function doc_uri_box() {         global $post;              $uri = get_post_meta( $post->ID, 'wpa_upload_doc', true );         echo "";        echo '
Please provide the abosulte url of the file (including the http://):
';         echo '<input type="text" id="wpa_upload_doc" name="wpa_upload_doc" value="' . $uri . '" size="25" style="width:85%" />';         echo '<input class="button" id="upload_doc_button" type="button" value="Upload Publication" alt="Upload Publication" />';         echo "\r\n";     }      **UPDATE** For the `doc_uri_box()` method, I have found that the `window.send_to_editor` code block is never executed! Strange indeed..


Custom Shortcode that includes filtering by tag

Within a custom shortcode, how do I filter the posts that come back from get_posts() such that only posts with Tag = "xyz" are returned? Here is what I have in my shortcode currently:               $args = array(         'post_type'         => $type,         'category_name'     => $category,         $type . '_category' => $custom_category,         'numberposts'       => $numb,         'orderby'           => $order_by,         'order'             => $order,         'suppress_filters'  => $suppress_filters     );          $posts = get_posts($args);      Is there something that I should be adding to the $args? Or is there some function I should be calling before/after the get_posts() call?


dynamic enquiry form

I'm thinking to use **Contact Form 7** to create a simple enquiry form like : name, phone, email. This enquiry form will be displayed on every portfolio page. What I want to do is to retrieve also from the user the page title from where he submitted the enquiry, because I will have more than 50 posts and I don't want to create 50 different forms for each post. Any suggestions on how to achieve this ? Thank you!


Declaring a var, placing it in a query and using the output of the query?

So i'm wondering if it's possible to declare a `variable` that you'd place in a `query` to then use it in a `update_post_meta` function? This is how I tried to do it. First off I made a connection to another db where the info comes from to than query out the results(Tested in SQL works) like so:                global $newdb;       $newdb = new wpdb('....', '....', '....', '....');       $newdb->show_errors();       $column1  = "member_name";       $column2  = "memberID";       $meta_key = "field_12312ewrwe12312";       $result   = $newdb->get_results("SELECT ".$column1.",".$column2."  FROM members");         $columnq  = $newdb->get_results("SELECT ".$column1." FROM members");       $columnq2 = $newdb->get_results("SELECT ".$column2." FROM members");      Most notably `$columnq` and `$columnq2`. I than used the query strings to fetch the data in a `update_post_meta` function/button and thought this should've worked since blankly putting `$column1` and `$column2` after clicking submit only adds the actual `value` it contains so say I get a new post called `member_name` each time I submit. The code:               <form action="" method="post">         <input type="submit" value="Test" id="submit" name="submit">         <?php              if(isset($_POST['submit'])){             $postargs = array(                 'post_title'   => $columnq,                 'post_status'  => 'draft',                 'post_type'    => 'bedrijf'             );                  $thisid = wp_insert_post ( $postargs, true);                  if ( is_wp_error($thisid) ) {                 return get_error_codes();             } else {                   update_post_meta( $thisid, $meta_key, $columnq2);             }         }            var_dump($columnq);            var_dump($columnq2);         ?>           </form>      P.S. Yes `var_dump` shows the correct information. EDIT: Added the `var_dump`. The information output by the `var_dump` is far to many, instead I will post a piece of both. Columnq:               array(460) { [0]=> object(stdClass)#1026 (1) { ["member_name"]=> string(18) "Some information" }      Columnq2:               array(460) { [0]=> object(stdClass)#1486 (1) { ["memberID"]=> string(1) "0" }       EDIT2: I also placed the `var_dump` into the button itself(Under `update_post_meta`) and it output the exact same and correct information. Yet in the back code it adds only one post which is empty with also `(no title)` as name.


Remove [gallery] shortcode altogether

I used remove_shortcode('gallery'); ...the gallery is gone, but the shortcode is visible in the text. How do I remove sitewide? I've searched for sql queries, but no solution fixes my specific problem. ![gallery shortcode still visible](http://i.stack.imgur.com/3GWzB.png)


How do I show errors after validation with a custom form frontend?

I'm struggling to understand how I should achieve a decent error-handler at frontend (serverside). The code is written in functions.php in a specific theme (if that matters). Down below a custom post type named pupil is created upon submit.               $pupil = new Pupil();     add_shortcode('wppb-register', array($pupil, 'frontEndRegistration'));          //Check if visitor is trying to save a new pupil     $pupil->checkFrontEndRegistration();      In the pupil-class I show (return) this content (form):               //Show public register-form     public function frontEndRegistration($atts, $content="", $errors = null) {             $class_errors = array();              if (is_array($errors) && !empty($errors)) {                  foreach($errors as $key=>$err) {                 if ($err === true) {                     $class_errors[$key] = ' error';                 }             }                    }         $content .= '         <form id="adduser" name="adduser" method="post" action="">' .                 '

'.$this->getRelatedCoursesPupil(null, array('args' => array('fetchContent' => 'returncontent')))         .  '

             Förnamn*	             <input name="first_name" id="first_name" value="" class="regular-text' . $class_errors['first_name'] . '" type="text">

             Efternamn*	             <input name="last_name" id="last_name" value="" class="regular-text' . $class_errors['last_name'] . '" type="text">

             Ålder*	             <input name="age" id="age" value="" class="regular-text" type="text">

             E-post	             <input name="email" id="email" value="" class="regular-text" type="text">

             Telefon hem*	             <input name="homephone" id="homephone" value="" class="regular-text" type="text">

             Mobiltelefon*	             <input name="cellphone" id="cellphone" value="" class="regular-text" type="text">

             Adress	             <input name="adress" id="adress" value="" class="regular-text" type="text">

             Postnr	             <input name="postnr" id="postnr" value="" class="regular-text" type="text">

             Ort	             <input name="ort" id="ort" value="" class="regular-text" type="text">

             Övrigt	             <textarea name="description" id="description" class="description"></textarea>

         <input type="hidden" name="action" value="newpupil-frontend" />         ' . wp_nonce_field( 'newpupil-frontend', 'newpupil-frontend') .               '

         <input type="submit" value="OK" name="addusersub" id="addusersub" />         </form>         ';              return $content;     }      Here I'm doing the actual checking before saving it to database.               //Save pupil     public function checkFrontEndRegistration() {                  if( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) &&  $_POST['action'] == "newpupil-frontend") {                      //Required fields                 $errors = array();                 if (!isset($_POST['first_name']) || strlen($_POST['first_name']) == 0) {                     $errors['first_name'] = true;                 }                 if (!isset($_POST['last_name']) || strlen($_POST['last_name']) == 0) {                     $errors['last_name'] = true;                 }                 if (!isset($_POST['age']) || strlen($_POST['age'] == 0)) {                     $errors['age'] = true;                 }                          if (!isset($_POST['homephone']) || strlen($_POST['homephone']) == 0) {                     $errors['homephone'] = true;                 }                  if (!isset($_POST['cellphone']) || strlen($_POST['cellphone']) == 0) {                      $errors['cellphone'] = true;                 }                                 //Add new pupil-cpt into post-table when there are no errors                 if (empty($errors)) {                     //Remove hook temporarily                     remove_action( 'save_post' , 'postsubmitted');                          $pupil = array(                         'post_title'    => 'unregistered',                         'post_status'   => 'private',           // Choose: publish, preview, future, draft, etc.                         'post_type' => 'pupil',                         'post_author' => 5500                                        );                     //save the new post and return its ID                     $post_id = wp_insert_post($pupil);                           //Save everything relevant for this new pupil                     saveform_db($post_id, $_POST, true);        //True says that it's frontend-saving                          //Rehook temporarily removed hook                     add_action( 'save_post' , 'postsubmitted');                 }                 else {                     throw new Exception('Pupils must be entered');                     //$this->frontEndRegistration('', '', $errors);                 }                  }              }      It works fine, but I can't figure out how to show the errors when user hasn't typed in required fields. Instead of `throw new Exception(Pupils must be entered);` I want to show the same `frontendRegistrationform()` but with the errors that are set when there are no value in the required fields. I guess I oould use sessions, but is there any better way?


How to make WordPress use protocol indepentent upload files?

I am using `FORCE_SSL_ADMIN` in `wp-config.php` so everytime I upload a new image and inserted into the post, it is using SSL version e.g.               <img src="https://www.example.com/wp-content/uploads/2013/01/test.png" ..      My blog is using HTTP in the public side, so how to make the upload path as rotocol independent, e.g.               <img src="//www.example.com/wp-content/uploads/2013/01/test.png" ..


Adminstering Large Number of Wordpress Sites

I have inherited a situation where our team supports over 100+ separate WordPress installs for various clients. I am looking to make the whole process a bit more efficient. For all of those in a similar situation of managing a large number of Wordpress installs: Are there any tools or techniques that are helpful? The thought of migrating all of these to 3.0.2 by logging in or writing a script from scratch both sound particularly unappealing.


Forcing all posts associated with a custom post type to be private

Does anyone know of a way to add code to the functions.php file which will automatically force all posts belonging to a custom post type to be "private" and/or "password protected" with a default password set? I am specifically referring to creating a new post or editing an existing post thus ensuring a post belonging to a specific custom post type never changes...


register_post_type for Pages?

Been reading this site and Wordpress Codex and I see there is a function to enable custom type of pages in Wordpress. How can I do the same to enable for Pages ? Or at least get the options for the posts to appear for placing the posts under Pages ?


i want multiple blog, themes and database

i am running http://article-stack.com. I want to create a separate blog say help.article-stack.com. Again, it should have 2 portion. One for discussion and another for information. I am planning to install wordpress in 2 more direcotries. Both will have separate database. Tell me is you have some better solution It will be helpful if you can suggest me some free theme for discussion. I am aware with twitter like theme p2. But it is not suitable for me. I want stackexchange type of site. So if someone helps others they must get their credit. It helps to motivate them and others. Thanks in advance


Stuck on maintenance mode

I put my site in maintenance mode using this hook in `functions.php`,               function activate_maintenance_mode() {         //If the current user is NOT an 'Administrator' or NOT 'Super Admin' then display Maintenance Page.         if ( !(current_user_can( 'administrator' ) ||  current_user_can( 'super admin' ))) {             //Kill WordPress execution and display HTML maintenance message.              wp_die('
Sitio en mantenimiento

Nuestro sitio esta actualemente en mantenimiento.
Ya volvemos!
', 'mantenimiento');         }     }     //Hooks the 'activate_maintenance_mode' function on to the 'get_header' action.     add_action('get_header', 'activate_maintenance_mode');      and now I can't return back to normal mode. **EDIT:** The problem had to be with W3 Total Cache plugin.


Seamless integration between WordPress and BBpress

I have a WordPress site at domain.com and a BBPress install at domain.com/subfolder the wp site has a menu item that goes to the forums, and I'd like the header to be the same between the two, so that they can navigate back to the main site. how can I do that? thanks


Check if there is an post to be published in future

I need to check if there is an post to be published in future. I want to use WP functions, no directly access to database via mysql_query. Has anyone some sample of code?


Managing Images for a WordPress Blog: Picasa or Flickr?

_( **Moderator's note:** The original title was "Is it good to use picasa web album for images in wordpress blog?")_ Is it good to use Picasa web album for post's images in WordPress blog? What are pros and cons? Which one (Flickr or Picasa) is more suitable for blog post's images?


List Posts by Category for a Non-Zero, Non-NULL Custom Field Value?

_( **Moderators note:** The original title was: "Need help identifying and looping through categories where posts have custom field set")_ I need to loop through my categories however I need to limit the categories to those categories that include posts where the custom field of `price != 0` or `null`. What is the best way to handle this? Currently I've got this...
               <?php          $categories=get_categories();     foreach($categories as $category) {       $myColumnCount = 1;     ?>
<a href="<?php bloginfo('url'); ?>/category/<?php     echo($category->slug); ?>"><?php echo($category->name); ?>
          <?php     query_posts('cat='.$category->cat_ID.                 '&posts_per_page=-1&orderby=title&order=ASC');     ?>     <?php if (have_posts()) : while (have_posts()) : the_post(); ?>                    <div id="" class="span-1 <?php if ($myColumnCount==6) { echo "last"; } ?> thumb20" >         <a class="thumb" href="<?php the_permalink(); ?>" rel="bookmark" title="Link      to <?php the_title(); ?>" ><?php echo the_post_thumbnail( 'thumbnail' ); ?>
               <?php if ($myColumnCount == 6) {         $myColumnCount=0;     } ?>          <?php $myColumnCount = $myColumnCount+1; ?>          <?php     endwhile;     endif;     echo '
';     ?>     <?php } ?>          <?php $wp_query = $temp_query; ?>


File Storage Plugin (For Individual Users)?

I have a client who has a Wordpress blog and he'd like to give a small number of clients their own user accounts in which, ideally, they'll be able to access a specific set of files. These files would only be visible to users to whom the files are assigned by the site administrator (for lack of a better word), not all users. In other words, if Bob and Susan both had Wordpress accounts on this site, the site admin would be able to upload a file and assign it to Bob and that Susan would not be able to see. Bob and Susan wouldn't need to add files, just have access to files provided by the site admin. I've Google'd around a bit for a plugin that will allow this, but I'm not finding anything. Does such a plugin exist?


Include files in child theme functions file

Typically in my theme function file I'll require other files to keep things neat.               require_once("foo.php");      Now working in a child theme I'd like to do that same. I'm adding custom admin options and it seems impossible to include code. I've echoed out the path to make sure I'm calling the right file and it is calling the proper location but nothing inside that file seems to run. The code runs fine if placed inside the child theme functions file.


Proper syntax to add boolean in array()

Conditional php question... I have an array and need to add an OR boolean to check for an additional category 4. Don't know the syntax to use for adding more category id's. I've tried array('cat' => -9, -4, but that only recognizes first id.               query_posts(              array_merge(                 $wp_query->query,                 array('cat' => -9,                       'ignore_sticky_posts' => 1,                       'post__not_in'  => $sticky,                       'posts_per_page' => get_option('posts_per_page'))


How to obtain a group of post meta and assign each meta to other variables?

I saved a group of data in post meta, now I need to get the meta and use them as other items. My code not working, please help me correct it, thanks!               $boxes = Array( 'height', 'width' );          foreach ( $boxes as $data ){     $project = get_post_meta($post->ID, $data, true);     }          $item_a = $project->height;     $item_b = $project->width;


Plugin: connect to external database without showing password

I am creating a WP plugin, which shows information from an external database. The plugin will be distributed, the external database is on my own server. I know the following code will connect to my database:               $newdb = new wpdb($DB_USER, $DB_PASSWORD, $DB_NAME, $DB_HOST);     $newdb->show_errors();      But I do not want to show my password to everyone who downloads the plugin. I searched on Google and many forums, but I could not find a way to do this safely. I hope someone can push me in the right direction.


Execute certain function on GET request

I am currently designing a plugin which will export some data in admin panel, only when a GET parameter `export=data` is passed. In normal PHP it will do something like:               <?php      if(isset($_GET['export']) && ($_GET['export']=='data')){      abc(); //Execute this function on GET request     }          function abc(){      //function data     }     ?>      Now I want the same thing to happen in my plugin in admin area, assuming the slug of my plugin is '_my-plugin'. So basically I would like to call the function when this URL is visited: `http://myblogaddress.com/wp- admin/admin.php?page=_my-plugin&export=data` Thanks in advance


Add rewrite endpoint to author page + pagination

I want to add a new endpoint to the author page, so that the URL looks like this: > http://example.com/writer/username/articles So far, I have:   * Changed the author base   * Added a rewrite rule   * Setup the query_vars   * Added the endpoint   * Used template_redirect to use my template Result: 404 Page Not Found (even after flushing the rewrite rules). I can't figure out where the problem is. Also I'd like to add pagination to the endpoint. Below is my code: Changed the author base:               function foo_change_author_base() {         global $wp_rewrite;         $wp_rewrite->author_base = 'writer';     }     add_filter( 'init', 'foo_change_author_base', 0 );      Added a rewrite rule:               function foo_rewrite_rule()     {         add_rewrite_rule( 'writer/([^/]+)/articles(/(.*))?/?$', 'index.php?author_name=$matches[1]&articles=$matches[3]', 'top' );     }     add_action( 'init', 'foo_rewrite_rule' );      Setup query_vars:               function foo_add_vars($vars) {         $vars[] = 'articles';            return $vars;     }     add_filter('query_vars', 'foo_add_vars');      Added the endpoint:               function foo_add_endpoint() {         global $wp_rewrite;         add_rewrite_endpoint( 'articles', EP_AUTHORS | EP_PAGES );     }     add_action( 'init', 'foo_add_endpoint');      And added my template:               function foo_rewrite_template()     {         global $wp_query;              if ( array_key_exists( 'articles', $wp_query->query_vars ) ) {             include (get_template_directory_uri() . '/articles.php');             exit;         }     }     add_action( 'template_redirect', 'foo_rewrite_template' );


Dynamically add CSS to the visual editor

I created an options page for my theme, where I can manually edit the CSS.   Lets say I change the CSS in the options page for the `<H1>` tag, so it will now change it on the front-end.   What I want to also do is have it change in the visual editor. I have added the function               add_editor_style(style.php);      and in the `style.php` I have it saying in the top               <?php     header('Content-type: text/css');     ?>      so it recognizes the file. But now I can't get the options dynamically... How should I achieve this? EDIT this is in the functions.               add_filter( 'mce_css', 'cnote_visual_css' );     function cnote_visual_css() {         return get_bloginfo('template_directory') . '/cnotethegr8/global-style.php';     }      this is the global stylesheet               <?php     header('Content-type: text/css');     global $shortname;     ?>          h1 { <?php echo(get_option($shortname.'_style_h1')); ?> }      when i echo $shortname nothing shows...


How to fake a Wordpress login?

As many of you know WPEngine don't support PHP SESSIONS unless the user is logged in. In that case WPEngine start taking consideration of PHP SESSIONS and the software based on hybridauth like Wordpress Social Login or Wordpress Social Invitations will work ok. So my question is : There is a way to fake a Wordpress login?


Using pre_get_posts to filter one loop in a multiloop archive

I have a custom-post-type archive (archive-rg_blog.php) with two loops in it. One of the loops I'd like to filter with the below code. It's just a basic loop for all posts, and I just need to set it to return all posts instead of the custom posts it'd return by default. The other loop needs to pull the title and content from a specific custom post. The below seems to be filtering the second loop too, and so that it returns nothing at all.               function blog_filter($query) {       if ( !is_admin() && $query->is_main_query() ) {         if ($query->is_post_type_archive('rg_blog')) {           $query->set('post_type', 'post');         }       }     }     add_action('pre_get_posts','blog_filter');      And this is the loop that returns nothing:               <?php // blog title and description query     $post_id = 4606;     $queried_post = get_post($post_id);     $title = $queried_post->post_title;?>
<?php echo $title;?>
      Edit: Just to clarify, this is what I'm trying to do.               ///loop 1, queries a specific post     ///loop 2, a normal loop filtered with pre_get_posts, which should return all posts.     ///loop 3, also queries a specific post      So I need to add the filter before loop 2, and remove it again before loop 3. I've tried to add the filter into the archive template in the appropriate place, but loop 2 then fails to return all posts. Edit #2: Here's the whole loop in action. It's the SECOND loop that needs to be filtered.               <?php get_header(); ?>          <?php // blog title and description query     $post_id = 4606;     $queried_post = get_post($post_id);     $title = $queried_post->post_title;?>
<?php echo $title;?>
               <?php function blog_filter($query) {       if ( !is_admin() && $query->is_main_query()) {         if ($query->is_post_type_archive('rg_blog')) {           $query->set('post_type', 'post');         }       }     }     add_action('pre_get_posts','blog_filter');?>     <?php $post = $posts[0]; $c=0;?>     <?php if (have_posts()) : ?><?php while (have_posts()) : the_post(); ?>          <?php $c++;     if( !$paged && $c == 1) :?>               <?php else :?>                               <?php endif;?>     <?php endwhile; endif; ?>          <?php remove_action('pre_get_posts','blog_filter');?>                         <?php // blog title and description query     $post_id = 4606;     $queried_post = get_post($post_id);     $title = $queried_post->post_title;?>
<?php echo $title;?>
                     <?php echo $queried_post->post_content;?>     <?php get_footer() ?>


WP 3.5 media uploader API set selected item

I know how to use the new media uploader in WP 3.5 and integrate it with plugins and themes but I have a problem, say the user selected the image and the frame closed I want when he open it again the image user selected before being selected in the gallery or highlighted. the codex doesn't have any api doc about it               $button.on('click', function(e){         // prevent default behavior         e.preventDefault();         if ( typeof file_frame != 'undefined' ) {             file_frame.close();         }              // create and open new file frame         file_frame = wp.media({             //Title of media manager frame             title: 'Select an Image',             library: {                 type: 'image'             },             button: {                 //Button text                 text: 'Use Image'             },             //Do not allow multiple files, if you want multiple, set true             multiple: false,         });              //callback for selected image         file_frame.on('select', function() {             var selected = [];             if ( is_multiple ) {                 // multiple images selected                 var selection = file_frame.state().get('selection');                 selection.map(function(file) {                     selected.push(file.toJSON());                 });             } else {                 // single image                 selected.push(file_frame.state().get('selection').first().toJSON());             }                  // loop through selected images             for (var i in selected) {                 console.log(selected[i]);             }              });              // open file frame         file_frame.open();     });      can anyone help


How to get all post_parents of a post?

Unfortunately, $post->post_parent is a single variable and not an array. I want to get all post_parents of a post (especially of an attachment, which is often linked to multiple posts!).


What is theme-compat?

I have noticed that `wp-includes/theme-compat` directory.   So, what is it?   Is it a theme?


How to change tag based on metabox value within $wp_query

I have a custom post type called "issue" and a contents page for each issue. I tag all of my articles with each issue by the issue number, so for instance, all articles with Issue 15 are tagged `'issue-15'`. I have a custom post template for contents and I use the following code to call up all issue posts within the same issue number.               $wp_query = new WP_Query( array(          'post_type' => 'issue',         'tag' => 'issue-14',         'posts_per_page' => 50     ) );      Where it says `'issue-14'`, I need that to change based on a custom metabox field called `'issue-number'` which only contains the number of the issue. So if the metabox field is "`12`" I need the tag to be "`issue-12`".


How to display posts by current user in a drop down

I am trying to write a shortcode that works in conjunction with Contact Form 7 to display the current user that is logged in posts. I have been able to get it to work with regular posts using this code here:               wpcf7_add_shortcode('postdropdown', 'createbox', true);         function createbox(){         global $post;         $args = array('numberposts' => 0);         $myposts = get_posts( $args );         $output = "<select name='cursus' id='cursus' onchange='document.getElementById(\"cursus\").value=this.value;'><option></option>";         foreach ( $myposts as $post ) : setup_postdata($post);             $title = get_the_title();             $output .= "<option value='$title'> $title </option>";                  endforeach;         $output .= "</select>";         return $output;     }      However i am not sure how to go about adapting it for to display only the posts that the currently logged in user posted. Any help and direction on this would be welcome. Thank you :)


Problem with wordpress pagination

First of all thank you everyone for all the knowledge base i got reading trough stackexchange. For the first time i couldn't find an answer to my problem. The matter is that with this custom query (which has the purpose to search trough the posts with multiple taxonomy fields):               global $wp_query;     $tax_query = array();     $parametri = array(                             'ih_tipo_struttura' =>  array('tipo_struttura','IN'),                             'ih_localita'       =>  array('localita', 'IN'),                             'ih_stelle'         =>  array('stelle', 'IN'),                             'ih_categorie'      =>  array('categorie', 'AND'),                             'ih_servizi'        =>  array('servizi', 'AND')                         );     // Faccio il post dei parametri e li inserisco nella query     foreach ($parametri as $post => $taxonomy) {         if ( isset($_GET[$post]) && !empty($_GET[$post]) ){              $tax_query[] = array(                         'taxonomy'  => $taxonomy[0],                         'field'     => 'slug',                         'terms'     => $_GET[$post],                         'operator'  => $taxonomy[1]                         );          }     }     // Parametri base della query     $args = array(          'post_type' => 'post',         'tax_query' => $tax_query     );     // Parametri paginazione     if ( $pagination ) {         $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;         $args['posts_per_page'] = 2;         $args['paged'] = $paged;     } else {         $args[] = array( 'posts_per_page' => 20);   // Se imposto la paginazione a false ritorno i primo 20 risultati     }     // Eseguo la query     $wp_query = new WP_Query( $args );     return $wp_query;      everything works fine until i try to do some pagination. When i pass trough the url some $_GET parameters like:               http://mywebsite/ricerca/?ih_localita%5B%5D=riccione&ih_localita%5B%5D=rimini&ricerca_hotel=true      or               http://mywebsite/ricerca/page/2/?ih_localita=riccione&ih_localita%5B%5D=rimini&ricerca_hotel=true      there's no problem but if try:               http://mywebsite/ricerca/page/2/?ih_localita%5B0%5D=riccione&ih_localita%5B1%5D=rimini&ricerca_hotel=true      wordpress cut off all the search parameters returning the url just like:               http://mywebsite/ricerca/page/2/?ricerca_hotel=true      I'm getting crazy with this so i would really appreciate any help. Thx


Breadcrumb NavXT plugin - exclude 'home' page

Does anyone know how to exclude the breadcrumb from appearing on the 'home' page only using this plugin? I have currently got it set up in the header template and so it is appearing on every page.


Comment Count for each Comment Author

In WordPress 3.4.1: I am trying to add the Comment Author's total number of comments beside their info. (name + date/time) in the comment's list. Here is the SQL that I am using:               $count = $wpdb->get_var('SELECT COUNT(comment_ID) FROM '. $wpdb->comments. ' WHERE comment_author_email = "' . get_comment_author_email() .'" ' AND comment_approved = '1' AND comment_type = '');      Basically The Author's email will be checked and the total number of comments will be displayed. But also I want only approved comments to be counted and also I don't want pingbacks/trackbacks to be counted. The above code is returning a syntax error and probably is wrong in terms of logic. Any help is appreciated. thanks.


Including two taxonomies in a permalink structure

I am trying to get my head around the permalink structures on Wordpress sites, and I'm a bit stuck with what I'm trying to achieve: My current permalink structure: **/%category%/%postname%/** I have a custom-post type called 'city', and I want to create a structure like below: **mydomain.com/asia/china/beijing** So just to explain this structure: **asia** \- This is a term under a taxonomy called **'continent'** **china** \- This is a term under another taxonomy called **'country'** **beijing** \- This is the actual custom-post type post with title **'Beijing'** So I basically have two taxonomies (continent and country) linking to my **'city'** post type. So the way I see it, I need a structure like this: **mydomain.com/(taxonomy-continent)/(taxonomy-country)/(custom-post)** But I cannot seem to figure out how to achieve this with the permalink structure. Any help would be greatly appreciated! Thanks