How to update records using $wpdb?

I am migrating non-wp database to Wordpress (for the first time in my life, and hopefully the last). As both new and old websites are multilingual, one of the tasks for me is to connect the articles with its translations. I am using WPML plugin for multi language support on Wordpress. This plugin creates a table, `wp_icl_translations` with the following structure:               element_id | trid       | language_code           | source_language_code     ---------------------------------------------------------------------------     (post id)  | (group id) | (of the translated post)| (of the original post)      `trid` is the id of the original post id and all translations of one original post have the same value for the `trid`. If the post is original, `trid` is the same as `element_id` which is the post id, and `source_language_code` is `NULL`. Couple of notes on the posts I have:   * Not all posts are translated to all the languages (I have 8 languages)   * There are posts that have only original entries in any language In the old database posts had `item_id` which was the same for all the translations of one article. When I migrated them, I added this `item_id` as `meta_value` for each posts. I did the same for the language code, so I was able to create a custom table where I would have a connection between post ids of the wordpress database and item_ids and language codes of old database. This custom table, `id_item_lid`, has the following structure:               id                           | item_id                     | lid     ---------------------------------------------------------------------------     post id assigned by wordress | old item_id                 | language code                                  | (translations share this id)|      So in short I need to update `trid` column of `wp_icl_translations` with the post ids of posts that share the same `item_id` in `id_item_lid` table. Here is the function I came up with:               function rkm_translation_update() {     global $wpdb;     $trans_row = $wpdb->get_row("SELECT * FROM id_item_lid", OBJECT, 0);     $id = $trans_row->id;     $item = $trans_row->item_id;     $lid = $trans_row->lid;          $trans_array = $wpdb->get_results("SELECT * FROM id_item_lid");     foreach ($trans_array as $trans) {         $id_new = $trans->id;         $item_new = $trans->item_id;         $lid_new = $trans->lid;         if ($item === $item_new) {             $wpdb->update('wp_icl_translations', array('trid' => $id, 'source_language_code' => $lid), array('element_id' => $id_new));         } else {             $id = $trans->id;             $item = $trans->item_id;             $lid = $trans->lid;         }     }     }          add_action( 'init', 'rkm_translation_update');      Idea behind it is to take the records of the first row, and compare it to the next. But, nothing happens. I am doing this kind of database manipulation for the first time, so I don't know where should I start with the debugging. Any help and direction is highly appreciated. If you need more info please do not hesitate to ask. Thanks!


Presetting the link of video attached to a Standard Post Format in a custom field

I am trying to create a function that presets the URL (of an attached video in a Standard Post Format) to a custom field when the post is created using a front-end form. (P.S.: All data inputted in the form correctly displays in the post editor) Thanks in advance. Here is my code below:               add_action( 'save_post', 'get_video_file' );     function get_video_file( $post_id ) {         if('post' != get_post_type())         return;         if ( $attachments = get_attached_media( 'video', $post->ID );         foreach ($attachments as $attachment) {             $meta_value = wp_get_attachment_url( $attachment->ID );             update_post_meta( $post_id, 'tm_video_file', $meta_value );         }             // To prevent an infinite loop             remove_action( 'save_post', 'get_video_file' );             wp_update_post($post);             add_action( 'save_post', 'get_video_file' );     }


Converting dreamweaver to WordPress

I created a WordPress site than needs a much needed facelift and I want to work with a designer who uses dreamweaver. We looked at tweaking my existing WordPress site but it would require coding expertise that neither of us have (for example we want each page to have a different header image and we don't want a top navigation menu on the home page). Is the best course of action for him to create the site entirely in dreamweaver and then hire someone else to convert it or export it back into WordPress? I would like to be able to update it myself once the conversion is complete. Thanks, Wendy


How to limit user to login only once per session

How can I use code to limit users from sharing there ids and password and login muliple times? what i want to do is not allow the user to login multiple times at the same time.


How to add a filter to get_the_author_meta?

I need to filter calls to get_the_author_meta() but I haven't been able to do it. I'm using a plugin which uses this function: get_the_author_meta('display_name', $p->uid)` I need to be able to filter this funcion and get the uid parameter. But I don't know how to do it. I've been trying to add a simple filter to the get_the_author_meta() function but I haven't been able to do it. This is what I'm trying now:               function get_the_author_meta_filter( $field = '', $user_id = false ) {         return "Johnn";     }     add_filter( 'get_the_author_meta', 'get_the_author_meta_filter' );      How can this be done?


remove <p> tags from the_content

I've got a post format of Image, and I am running into an issue where the image is being wrapped by a `<p>` tag. I want to get rid of that tag (specifically on the `single.php` version) of those post types. How can I get inside the formatting in a theme and remove the `<p>` tags, or create any format that I want for the output of this type of post, without affecting posts of a different post format?


how to exclude posts on current page from recent posts sidebar widget

I am using Wordpress 3.6. I would like to exclude posts on any given current page from appearing in the recent posts sidebar widget. I haven't been able to find a custom widget that has that option. I hope someone can help.


Create Child Taxonomies Automatically

Actually is not child taxonomies to auto create them without something triggering something, I'm looking for a solution for when a taxonomy is published some other taxonomies of my choice will be published under it making them child. Example I have artist like Eminem, Beyonce, Adelle etc... I want the artist to be the parent taxonomy and want things like Videos, Lyrics, and Album to be the child taxonomies.... So when i create a new taxonomy Like......               Beyonce (Parent Taxonomy) ------> Will be created manually             ---> Videos (Child Taxonomy)  Auto publish under Beyonce immediately the Beyonce is publish so this becomes Beyonce's child             ---> Lyrics (Child Taxonomy)     Auto publish under Beyonce immediately the Beyonce is publish so this becomes Beyonce's child             ---> Album (Child Taxonomy)   Auto publish under Beyonce immediately the Beyonce is publish so this becomes Beyonce's child      And it should do the same for any artist i publish, Charles i hope its clear now.... Thanks


export individual posts to text files or a single csv file

I'd like to export my blog posts to plain text files so I can version control and update them using emacs org-mode via the org2blog package. However, I'm unfamiliar with SQL and the wordpress database structure. I'm hoping to get ideas for a SQL script to export my posts where each post is stored to a file named "YYYY-MM-DD_Title-of-post.org" and where the files will look like:               #+POSTID: 1071     #+DATE: [2011-09-21 Wed 18:00]     #+OPTIONS: toc:nil num:nil todo:nil pri:nil tags:nil ^:nil TeX:nil      #+CATEGORY: cat1, cat2, cat3     #+TAGS: tag1, tag2, tag3     #+DESCRIPTION:      #+TITLE: Hello World     ### URL: http://...          BODY OF POST      The parts to be filled in is the DATE field, CATEGORY, TAGS, TITLE, URL, and BODY OF POST. I think it might be asking too much to have someone do all my work for me. So, alternatively, I'd be content with a SQL script that outputs those fields in a delimited file, say delimited by "|||" so I can write a script elsewhere to get what I want. Thanks for your help. Much appreciated!


Redirection Plugin: Redirect all URLs with a regular expression

I understand little about regular expressions, but I need to figure one out to use with the Redirection plugin which supports redirects with regular expressions. http://urbangiraffe.com/plugins/redirection/ What I need to do is redirect all urls in /oldsite/ to the domain root. That means any page in /oldsite/ like /oldsite/this-is-my-page.html, /oldsite/this- is-my-page-too.html, etc., needs to go to root via a regular expression. I can't get a 301 redirect rule to work in .htaccess for some reason; there may be a restriction at the host, so I need to use this plugin. It needs to be a regular expression in the format that the plugin understands. Some examples are in the docs for the plugin at that link above. The first field for a new redirection in the plugin takes the regular expression; the second field is the target URL. This doesn't work:               Source: /oldsite/*     Target: http://mydomain.com      Nor does this:               Source: ^oldsite/(.*)     Target: http://mydomain.com


How to include line-breaks in the_excerpt?

how can I include a line-break inside the_excerpt. I’ve modified the length and the more-button via my functions.php. I’m using teaser for every blog- entry and sometimes it looks a bit ugly, that there no line-breaks included.


Wrong category being displayed in URL

I'm a newbie to wordpress so please bear with me. I have two categories I'm using, basketball and baseball. I've only recently added the baseball category and if I add a new post with category baseball, in the URL, the post displays /basketball/post-name regardless of what I do. I've changed the permalinks settings and played with some plugins as well, and I've checked to make sure my SEO plugin isn't messing with these things. Thanks for any help.


wordpress threaded comments - customize nested ul / how child ul is displayd

I just wasted 1 day trying to make wp threaded comments works... and I think I'm finally done!!!! except that it doesn't work properly - well it doesn't work the way I want ! :) Child comments get displayed inside the comment li - I don't like this behavior, I'd prefer wp to display it right below the parent comment li.               So by default wp handles it like this:
     comments parent here here

child comment reply :P

          Anyways, I want it displayed like this:

      Is this possible without modifying core wp files? Did wp developers leave options that enable customization of how child/nested comments are displayed? I'm including screen shot for better visual. http://i.stack.imgur.com/8PiJu.png


trying to add a author value in wp page links?

function wp_link_pages_titled($args = '',$name,$author) {         $defaults = array(             'before' => '
' . __('Pages:'),              'after' => '
',             'link_before' => '',              'link_after' => '',             'echo' => 1         );              $r = wp_parse_args( $args, $defaults );         extract( $r, EXTR_SKIP );              global $page, $numpages, $multipage, $more, $pagenow, $pages;              $output = '';         if ( $multipage ) {             $output .= $before;             for ( $i = 1; $i < ($numpages+1); $i = $i + 1 ) {                 $part_content = $pages[$i-1];                 $has_part_title = strpos( $part_content, '' );                     $title = trim( str_replace( '' );                     $title2 = trim( str_replace( '      the original code which works for these tags                         function wp_link_pages_titled($args = '',$name) {         $defaults = array(             'before' => '
' . __('Pages:'),              'after' => '
',             'link_before' => '',              'link_after' => '',             'echo' => 1         );              $r = wp_parse_args( $args, $defaults );         extract( $r, EXTR_SKIP );              global $page, $numpages, $multipage, $more, $pagenow, $pages;              $output = '';         if ( $multipage ) {             $output .= $before;             for ( $i = 1; $i < ($numpages+1); $i = $i + 1 ) {                 $part_content = $pages[$i-1];                 $has_part_title = strpos( $part_content, '' );                     $title = trim( str_replace( '` tag?


Call a Simple JQuery from within Flash

This is hopefully really simple for someone but I'm a newbie and trying to learn how to connect to JQuery's on my site from an embedded Flash swf. I'm attempting to do a simple example first to test the connection between Flash and JQuery... I've embedded an swf onto my page. When I click my button in Flash I'd like it to connect to a JQuery function that produces a popup alert saying "hello world!" Here's my JQuery function (I need to name the function):               function helloWorld() {            alert('Hello World');      }      I have an eventlistener (which I tested and works) on my button within Flash which tries to call the following:               function AddToBasket(event:MouseEvent):void{     var alert:URLRequest = new URLRequest("javascript:helloWorld();");     navigateToURL(alert);     }      When I 'inspect element' in Chrome I can see the JQuery is there, but when I click my button no popup alert appears. I'm misunderstanding something pretty basic, any help would be appreciated!!! My Flash SWF is added to my Wordpress page using Kimili Flash Embed, which I've added to my WP page like this:               [kml_flashembed movie="http://www.example.co.uk/upload/ImageUploader.swf" allowscriptaccess="samedomain" height="500" width="728" /]      The following AS3 does produce the popup, but the whole point of the exercise is calling a JQuery outside of Flash:               function AddToBasket(event:MouseEvent):void{     var alert:URLRequest = new URLRequest("javascript:alert('Hello World!')"); //"javascript:helloWorld();"     navigateToURL(alert, "_self");     }      Thanks guys Dean


How to check if I'm on the last page of posts?

I want to display some text on the last page that isn't displayed on the other pages. For example, on category pages: url.com/category/categoryname/page/6 or last page of all posts listed on the homepage: url.com/page/9 How do I check if I'm on the last page? Thanks in advance.


WordPress MultiSite Won't Work on Google AppEngine

I'm receiving this error when trying to access network dashboard on app engine:               Warning: require(C:\Users\Jon\Documents\GitHub\kapx-wordpress\wp-admin\network): failed to open stream: Permission denied in C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\php\setup.php on line 106      I've added these handlers to no avail. Anybody else have any luck?               - url: /wp-admin/network/(.+)       script: wordpress/wp-admin/network/\1       secure: always          - url: /wp-admin/network/       script: wordpress/wp-admin/network/index.php       secure: always


How can I move/redirect single blog posts from one blog to another?

I see lots of answers about moving entire blogs, but here's my scenario: I have a few blogs with a lot of content. I'm no longer publishing new content on these sites. I'm now publishing on another (new) site. I don't want to migrate all of the content from the previous sites, but I'd like to move a few "greatest hits" posts. What's the best way to migrate a few single posts from one site to another? I'm thinking that for SEO purposes, it would make sense to have a redirect in place so that the posts currently receiving search traffic will pass that traffic onto the new site.


All my files are on my blog! I need sync solution

I uploaded all my files on my blog (self hosted). Now all my files (documents, photos, etc...) are somewhere in wp-content/upoads folder... Is there a way of having all my files in their folders (documents in docs folder, photos in photos, etc) but still have them available trough wordpress... Thanks


Automatically set posts to NoIndex depending on category?

I'd like all new posts with a specific category to automatically have NoIndex applied. There are various plugins - e.g. Wordpress SEO - which make it easier to manually select posts for NoIndex. But I can't find a way of automating the process.


DB connection error after copying a WordPress Multisite instance to a second location

Here's my setup. I have a Multisite instance running at http://example.com, and I want to do development and staging. Moving an existing Multisite instance of WP onto localhost is a nightmare, so I'm going to do dev on a staging location instead. I set up http://staging.example.com to point to the /public_html/staging/ directory of the hosting account, and copied all of the WP files from my root into the /staging/ directory. I also copied the database files (SQL dump, imported the tables into a new database), and changed the wp-config.php file to point to the new database. After running SQL to change the database records, I also change this one line in the wp-config.php file:               /** Turning on WordPress MU, new in 3.0 */     define( 'MULTISITE', true );     define( 'SUBDOMAIN_INSTALL', false );     $base = '/';     define( 'DOMAIN_CURRENT_SITE', 'example.com' ); // <- I change this line     define( 'PATH_CURRENT_SITE', '/' );     define( 'SITE_ID_CURRENT_SITE', 1 );     define( 'BLOG_ID_CURRENT_SITE', 1 );      Changed to:               define( 'DOMAIN_CURRENT_SITE', 'staging.example.com' ); // <- now changed      When I load up http://staging.example.com, I get... `Error establishing database connection`! I've checked and triple checked the username and password, made sure that the user has all privileges on the new staging database, and I've left the DBHOST as 'localhost' (although changing it to staging.example.com didn't help, either). Why would the database connection fail? Anyone? (Thanks for your help in advance.) _**NB:** http://example.com is working fine running on very similar db connection settings, just with a different database, so it's not an issue with the database server being down._


Is it possible to use Wordpress as an online portfolio for text content? What kind of theme would I look for?

I'm trying to build an online portfolio for a quantity of text content I've produced. I don't have to skills to design it myself or the money to pay someone, so I thought using a CMS with a free theme might be a possible way to solve my problem. Is it possible to use WP as a portfolio rather than a blog? (i.e. not have content appear date-stamped any in reverse chronological order?) If so, what kind of theme or other add-on would I look for? I'm looking for someone really simple, but sleek and polished looking. I could just put a bunch of *.txt files on an ftp server, but I'm looking for something that looks just a little better and more professional, while still being free. Thanks!


orderby in custom WP Query does not work

I have this query:                 $new = new WP_Query(array('post_type'=>'support','order'=>'DESC', 'meta_key'=>'post_views_count', 'orderby'=> 'meta_value_num', 'posts_per_page'=>'20'));      the result set is pulling the correct number of posts, from the custom post type `support` but the posts are not ordered by the meta_value. I cannot fathom why this is as the codex shows this is the correct way to order by a custom meta value?


Does Extending Multiple Nav_Menu_Walkers Allow Nested Menus?

Essentially I'm trying to add multiple sub nav menus and I'm pretty close but I just can't seem to find the right tack to solve my problem ... I'm using a variation of a Stu Nichols CSS Menu ... Code explains better ;-) The relationship required to build this menu would have the top level elements as list-items, child-containers as divs and children and siblings {nth child} as uls ... So the structure would be the following ...
parent
child-container

item
              ...

item
              ...

item
              ...

      My current line of thought is to add an additional nav_menu_walker to build the sub-menu lists ... However, I'm not sure if I can pass multiple walker's as args to wp_nav_menu ... IE ... ASSERT                   $menu_params = array (          'theme_location'  => 'primary',     'menu'            => 'Main Menu',      'container'       => 'div',      'container_class' => 'nav',      'container_id'    => FALSE,     'menu_class'      => FALSE,      'menu_id'         => FALSE,     'echo'            => TRUE,     'fallback_cb'     => 'wp_page_menu',     'before'          => FALSE,     'after'           => FALSE,     'link_before'     => FALSE,     'link_after'      => FALSE,     'items_wrap'      => "\n\t" . '
%3$s
' . "\n",     'depth'           => 0,     'walker'          => new Top_Nav_Menu_Walker()              );          echo "\t\t
\n\t\t\t";          wp_nav_menu( $menu_params );          echo "\t\t
\n";          }      To obtain the parent -> child-container relationship I've simply added div and ul to the start_lvl function ... Here's where I'm having issues determining how I can create multiple siblings ...               function start_lvl( &$output, $depth = 0, $args = array()) {              $indent = str_repeat("\t", $depth);              $output .=  "\n$indent
\n";         $output .=  "\n$indent
\n";     }        In order to add classes to the top level anchor elements I have a custom walker. In the start_el function I've injected classes for the anchor items based on the parent class.               function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {         global $wp_query;         $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';              $class_names = $value = '';              $classes = empty( $item->classes ) ? array() : (array) $item->classes;         $classes[] = 'menu-item-' . $item->ID;              $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args ) );         $class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';              $id = apply_filters( 'nav_menu_item_id', 'menu-item-'. $item->ID, $item, $args );         $id = $id ? ' id="' . esc_attr( $id ) . '"' : '';              /* inject some anchor classes */              if(  $this->$depth == 0) {             if ( in_array( 'two', $item->classes ) || in_array( 'three', $item->classes )) {                 $item->class = 'oneCol fly';             }             if ( in_array( 'four', $item->classes )) {                 $item->class = 'twoCol fly';             }         };              $output .= $indent . '
';            $output .= in_array( 'sub_nav_h4', $item->classes ) ? "\n" . $indent . "
\n" : '';              $attributes  = ! empty( $item->attr_title ) ? ' title="'  . esc_attr( $item->attr_title ) .'"' : '';         $attributes .= ! empty( $item->target )     ? ' target="' . esc_attr( $item->target     ) .'"' : '';         $attributes .= ! empty( $item->xfn )        ? ' rel="'    . esc_attr( $item->xfn        ) .'"' : '';         $attributes .= ! empty( $item->url )        ? ' href="'   . esc_attr( $item->url        ) .'"' : '';              /*  This 'should' always be true as WP doesn't support anchor classes    */              $attributes .= ! empty( $item->class    )       ?   ' class="'  . esc_attr( $item->class            ) . '"' : '';              $item_output = $args->before;         $item_output .= '';         $item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;         $item_output .= '';         $item_output .= $args->after;              $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );     }      Here's the navigation structure I'm trying to achieve ...

One

Two

Egestas Sed

Consequat Leo

Lacinia & Blandit

Interdum

Pellentesque Velit

Lacinia & Blandit

Interdum

Donec non Fringilla

Fusce Ullamcorper

Facilisis

Tristique

Donec

Sapien

Purus

Congue

Mattis

Integer nec Diam

Morbi Eget Pharetra

Nulla & Orci

Eget Sapien Sodales

Aenean

Velit Ligula

Maecenas

Three

Egestas Sed

Consequat Leo

Pellentesque Velit

Lacinia & Blandit

Interdum

Donec non Fringilla

Fusce Ullamcorper

Facilisis

Tristique

Donec

Sapien

Purus

Congue

Mattis

Integer nec Diam

Morbi Eget Pharetra

Nulla & Orci

Eget Sapien Sodales

Aenean

Velit Ligula

Maecenas

Four

Ut vel Cursus

Maecenas imperdiet

Congue Metus

Vitae Luctus

Purus Pellentesque

Pellentesque Sed

Felis Nunc

Morbi Placerat Luctus

Ut & Eleifend

Feugiat Euismod

Tempus Condi

Five

Six

Seven


Media gallery - inserting full size images without link

I want to use built-in WP media gallery. I'm trying to simply add images in one - horizontal line. I want images with original size and without any link. I'm trying to add/edit some code into wp-admin/includes/media.php but I can't get it ;/ I know I have to use size="full" and columns="0" but how to add this with shortcode as default? And I have no idea how to get rid of links under images? Am I looking in good file? If no - point me to right direction please ;)


Backbone is breaking the media uploader

Greets, when using backbone in a plugin of mine the media uploader on the post edit page stops working properly. The uplaod button doesn't work anymore and the drag and drop functionality doesnt work. I managed to narrow it down to backbone being the culprit which I include like so:               wp_register_script(          'superchart-wizard',          plugins_url('/scripts/js/wizard.min.js', dirname(__FILE__)),          array(             ...             'backbone',             ...         )     );     wp_enqueue_script('superchart-wizard');      You can easily see the problem for yourself by installing the SuperCharts plugin here. Any help would be much appreciated!


Can I force WordPress to use <i> instead of <em>?

For example,               Did you know that hot was used to mean "sexually attractive" as long ago as 1450? (Though it seems that in earlier use, it more commonly meant "sexually attracted".)      The second use of `<em>` in the above is correct: I want to _emphasise_ the suffix _-ed_. However, the first use is incorrect. I want to use italic type to indicate the "use/mention distinction". This is the proper preserve of the `<i>` tag. But WordPress autoconverts `<i>` to `<em>`. Is there any way to get around this?


Duplicate posts showing up in loop using infinite scroll

I'm experiencing an odd issue using Infinite Scroll for the `WP_Query` loop on my homepage. Half the time when the second page fires, I'm getting a few duplicate posts showing up in the second set. I can't find a pattern for why this is happening so I'm looking for a better way to tell the infinite scroll script which posts to get. Here's what we're looking at.                  <?php          global $wp_query;          $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;          $args = array(             'meta_key' => 'hotness',             'orderby' => 'meta_value_num',             'order' => 'DESC',             'cat' => -1,             'posts_per_page' => 40,             'post_type' => array( 'post','fod_videos','fod_music','fod_articles', 'fod_albums'  ),             'paged' => $paged          );         $wp_query = new WP_Query( $args );         while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>          <?php get_template_part( 'loop', 'contents' ); ?>         <?php endwhile; ?>     <?php if ( $wp_query->max_num_pages > 1 ) : ?>      <div class="infinitescroll">        <?php next_posts_link( __( 'Load more posts' ) ); ?>      </div>     <script type="text/javascript">     var href = 'first';     $(document).ready(function() {         $('#boxes').infinitescroll({             loading: {               finished: undefined,               finishedMsg: '',               img: '',               msgText: '',               speed: 'fast',               start: undefined             },             navSelector: '.infinitescroll',             nextSelector: '.infinitescroll a',             itemSelector: '#boxes .box',             debug: false         }, function(arrayOfNewElems) {            var $newElems = $( arrayOfNewElems ).css({opacity: 0});            $newElems.imagesLoaded(function(){             $newElems.animate({opacity: 1});             $('#boxes').masonry('appended', $newElems, true);             if(href != $('.infinitescroll a').attr('href')) {                 href = $('.infinitescroll a').attr('href');             }           });         });     });     </script>     <?php endif; ?>      Any ideas what the culprit is here or a better way to do this? UPDATE: Looking at the source and clicking on the link to page 2 shows the duplicates in it really isn't anything to do with the script as it my `pagination` is off for some reason. It seems like removing                       'meta_key' => 'hotness',             'orderby' => 'meta_value_num',             'order' => 'DESC',      it paginates correctly("seems"). So I'm thinking maybe sorting by the meta key isn't being recognized by pagination? The problem seems to be when the pages break at posts that have the 'hotness' value of 0. Not sure why.


What's the simplest way to backup my WordPress database?

I have WordPress installed on my server for my blog. I back up all the files from the server on a schedule. But this is just the files--not the database. Ideally, I'd like to automatically save a database dump on the server periodically so that it gets backed up along with all the files. What's the simplest way to do this?


Database connection close

Is there any method to close connection similar to `mysql_close()` for `$wpdb` in WordPress? Is it not necessary to close connection for global `$wpdb`?


Wrong post_type argument passed to the query when using a custom post type

I'm trying to obtain a structure like this               1) Posts -> /%category%/articles/%postname%/     2) CPT   -> /%category%/CPT/%postname%/      But although I am able to see the right URL in the address bar, the page return a "404 error". Digging this down I noticed that the query that WP sends is not correct               SELECT   wp_posts.* FROM wp_posts  WHERE 1=1  AND wp_posts.post_name = 'win' AND wp_posts.post_type = 'post'  ORDER BY wp_posts.post_date DESC      The post_type argument should be - in my case - qualifications as this is the name of the CPT. Does anybody know how to fix this? Is there any relationship with the add_permstruct function? Thanks Andrea


Add unique ID number to end of permalink

I'm building a membership based website that will use custom post types to store data. I came across a problem which is if two users happen to create a post using the same exact name, WordPress would add -2, to one of the users posts. I'd like to keep permalinks on and have a unique ID added to the end of the permalink so that the URL's appear as example.com/postname-XXX, where XXX is a unique ID. I thought about using the post ID, but if a user is submitting from a form which is creating the custom post types am I able to insert the post ID before the post or permalink are set and if so how? If this isn't possible what is another method to add a unique ID to the permalink from the form? Thanks


Loop not showing first post

I've set up the following loop on a page, but it is missing out the first post. Does anyone know why this might be?
       <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
           <a href="<?php esc_url( the_permalink() ); ?>">             <?php the_post_thumbnail('thumbnail'); ?>

<?php the_title(); ?>

View project

         <?php endwhile; ?>
       <?php bones_page_navi(); ?>       <?php endif; ?>


Add content depending on page loaded

I would like to add some code depending on which page the users are.                 <?php      $arr = array(2506, 2516,2512,2513,2509,2515,2510,2508,2514,2511,2507);     if (in_array(the_ID(),$arr)){         if ($_SESSION['logged'] != 'true'){             echo '<script>document.location.href="./connexion";</script>'; //Not logged so good bye !         }     }      ?>      I know my that it's not quite accurate but can you check it out ? Any clue on how to make this ?


Is this a wordpress bug? get_comment_link auto shoots when user visits his dashboard

If user is **editor** , this function auto-shoots when user visits his dashboard! How is this possible? This function should only work when user successfully posts comment, so what is happening? could be wordpress bug?               function redirect_after_comment($location)     {          //This should run only when comment is confirmed. But for user level Editor, this function auto shoots!          }     add_filter('get_comment_link','redirect_after_comment');        1. User role is EDITOR   2. user logins, goes to dashboard.   3. Anything inside this function runs. For example return...


template_redirect not being called when using ajax

Usually I hook all my custom plugins code with the `template_redirect` hook but one of the issue I encountered is it does not work for the ajax call. So if I want to target both standard calls and ajax call what hook should I use? Is `wp_loaded` a good choice?


two menus show different menu based on what menuitem is selected on menu1

Iv got two menus:   menu1 with three menuitems.   menu2 which is based on which menuitem I selected in menu1 Like this: **menu1** menu2 menu3   **Home** Tax Company Aboutus menu1 **menu2** menu3   **Home** Posts News et menu1 menu2 **menu3**   **Home** Test1 Test2 et How can I make this?   Thanks


Use same Wordpress Users on a different site

I have WP installed on my main domain, `mywebsite.com`. I have a subdomain, `sub.mywebsite.com`, on which I want to utilize the same users from `mywebsite.com`. I have a multisite set up but I don't have a WP installation on my subdomain. I know I can get the user data from the WP database, but I want to get the logged-in user. For example, if user `x` is logged in to `mywebsite.com`, I want to be able to get that username on `sub.mywebsite.com`. However, if the user is not logged on, I want to prompt a log on. I tried using cookies with JavaScript, but I can't access the `wp_logged_in` cookie from the subdomain; I can only access it on the main domain. So, how can I access the logged in username (for the user browsing the website)?


wp_schedule_single_event function not working

I am testing the wp_schedule_single_event function and it is currently not working on my upgraded version of wordpress. It looks like the event is being scheduled but the code in my hook is never executed. Any help with this matter would be greatly appreciated Here is example code I put in my themes function.php:               var_dump(get_option('test_action_option'));     if(isset($_GET['begintest'])){         update_option('test_action_option', 'Scheduled: ' . $_GET['begintest']);         wp_clear_scheduled_hook( 'event_test_action'); // clear anything else in the system         wp_schedule_single_event( time() + 10, 'event_test_action');     }          add_action('event_test_action', 'event_test_action');     function event_test_action(){         update_option('test_action_option', 'Ran');     }


How can I manually combine all my javascript files to speed up my website?

I purchased a theme that uses 30 separate internal javascript files and 6 external (google maps) javascript files. Some of them are part of wordpress core, of course. What's the correct approach to de register these scripts; recombined them to reduce page requests; and speed up the site? For the external sites can I just combine those files and load them as one locally from my server? If you'd like to take a look, please check out http://findafarmersmarket.org. Please be patient it takes about 15 to 20 seconds to load because of the google maps integration. Ultimately I'm trying to speed up the site and page tool sites tell me this is one of my biggest issues.


Change the template when the user is not logged in using page_template filter (it does not work)

I want to print other template when the user is not logged in. I use this code:               function restrict_access_to_unlogged_users($template) {         global $post, $pagename;         $new_template = get_stylesheet_directory() . '/need-login.php';         return $new_template;     }     add_filter( 'page_template', 'restrict_access_to_unlogged_users', 20 );      I have got a template file called "need-login.php" in my child theme folder, however, my webpage prints a big blank in the screen. What Am I doing bad? Regards.


3.5 media.editor: what is the event listener for choosing an image?

What is the event listener for selecting an image in the media.editor javascript. I am attempting to add a multiple image selector to a custom plugin, and I need to show the user what images they have selected, before actually hitting the 'Select' button or the 'Insert' button. I have the media.editor configured like this:               file_frame = wp.media.frames.file_frame = wp.media({         title: $(this).data('uploader_title'),         button: {             text: $(this).data('uploader_button_text')         },         multiple: true,         library:{type:'image'}     });      Setting multiple to true doesn't seem to do anything different than setting it to false. In other words before the user goes to insert the images, what is the event callback that will listen to whether or not an image is checked for selection? The 'select' event is not it. Is there an API for the media.editor script?


WP Multisite with Domain Mapping : Preventing User Access to Dashboard

I have a theme being used by a sub-folder multisite and a domain-mapped multi site. E.g. mywpsite.com/site1 mywpsite.com/site2 www.site2.com (leads to the above) I have this snippet of code in my functions.php file               function my_wp_admin_ban(){     if( !current_user_can('activate_plugins') ){     wp_redirect( get_bloginfo('url') );     exit;     }     }          add_action('admin_init','my_wp_admin_ban');      This successfully prevents members of site1 from access the admin (wp-admin) dashboard area. This code does not, however, seem to work for site2. Instead, those users are shown a "You do not have sufficient permissions to access this page." error message. Tried everything I can think of including different ways of doing the same thing I.e. How to redirect non admins to homepage if trying to view mysite.com/wp-admin/? and How do I remove dashboard access from specific user roles? What can I do to ensure all users (non admin) of the multisite are redirected away from the dashboard area?


Wordpress loop is not working

Can anyone tell me why this wordpress blog is looping the header and banner over and over? It seems like instead of just looping the post it is looping the whole page. This code is inside of my content.php file. Any help would be greatly appreciated. Here is a link to my blog: http://testing.printlabelandmail.com/blog/               <?php     /**     * The default template for displaying content.     */     get_header(); ?>

<a href="<?php echo esc_url( home_url( '/' ) ); ?   >">        PRINTLABELANDMAIL.COM
         <button type="button" class="navbar-toggle" data-toggle="collapse" data-    target=".navbar-ex1-collapse">                    </button>

          <?php          $defaults = array(     'theme_location'  => '',     'menu'            => 'main-nav',     'container_id'    => 'nav',     'container_class' => 'navbar navbar-default navbar-shrink',     'container'       => 'div',     'container_class' => 'collapse navbar-collapse navbar-ex1-collapse',     'container_id'    => '',     'menu_class'      => 'menu',     'menu_id'         => '',     'echo'            => true,     'fallback_cb'     => 'wp_page_menu',     'before'          => '',     'after'           => '',     'link_before'     => '',     'link_after'      => '',     'items_wrap'      => '
%3$s
',     'depth'           => 0,     'walker'          => ''     );          wp_nav_menu( $defaults );          ?>

          <?php if (function_exists('dynamic_sidebar') && dynamic_sidebar('blog-banner')) :     else : ?>

Widgetized Area

This panel is active and ready for you to add some widgets via the WP  Admin

          <?php endif; ?>

                          <article <?php post_class('box  box--md  blog--post  push--bottom-sml'); ?>>          <?php the_post_thumbnail('thumbnail', array('class' => 'img-responsive push--bottom')); ?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?>

<?php _e('posted by'); ?> <?php  the_author(); ?>

<?php the_category(',') ?>

          <?php the_content('

Read More

'); ?>          <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?>           <?php edit_post_link('Edit', ' | ', ''); ?>

<

1

2

>

<?php previous_post_link('<< %link') ?>

<?php next_post_link(' %link >>') ?>

     <?php get_sidebar(); ?>


SQL query to check whether a meta key is set or not for a post in post_meta table

Condition: some post have meta_key 'status'. Please help me in with this condition: sql query for those post who don't have meta_key 'status'


Ability to set character limit in BuddyPress?

I would like to limit characters in BuddyPress posts to certain limit . Ex: Set it to the limit of 150 ... just like twitter's 140. Googled about it and found nothing. Does any one have Idea on this? Thanks


Widget on home page displays wrong time compared to same widget on inside pages

I am trying to use the timely events calendar and I have the upcoming events widget on my home page widget area. The time that displays is not the time I have selected. When I put the same widget to a different widget area that displays on the inside pages, the time is correct. Is there some kind of time setting that a widget area needs to register? Or an issue with the page template? thanks this is the code on the page template:

<?php _e("This is a widgeted area which is called Homepage Bottom 3.", 'genesis'); ?>

                 <?php endif; ?>
      code in functions.php:               genesis_register_sidebar(array( 'name'=>'Homepage Bottom 3', 'description' => 'This is a widgeted area which is called Homepage Bottom 3.', 'before_title'=>'
',     'after_title'=>'
'      ));      I am using the All in one event calendar by timely


Rotating background images with admin options

I recently saw an admin panel that had options to set background images for a page. The option was found on from clicking pages and then a "main page". Under the description was a form that allowed you to upload up to 5 different images. You could reorder them etc. This in turn uses those images to rotate through background images on the "main page" I was wondering how you would replicate this? I'm a huge wp noob when it comes to editing admin stuff. If it's a just bunch of PHP hooks and stuff no problem, but I have a feeling it's more than that. I realize one solution is to create a post and then attach a bunch of images to that post, but the client saw this panel and wants something just like it. Where they can change the images from the page configuration (which makes sense). As for the delivery end (the css and javascript) that's no problem, I'm just wondering about this piece right here. here's the setup: ![enter image description here](http://i.stack.imgur.com/TqafF.png) Any help would be phenomenal. Thank you Example of the result http://www.honolulufurniturecompany.com


How to order posts tag by tag?

I want to order my posts by tags with only one WP_Query() In my WP_Query I would like to display 2 posts with tags `portrait` 2 posts with tags `paysage` 2 posts with tags `portrait` 2 posts with tags `paysage` 2 posts with tags `portrait` 2 posts with tags `paysage` Etc... And I need to order these posts by recents. What is the query to do that ? Thanks PS : Sorry I cannot use code because I'm with my iPhone.


How to retrieve attachments from child pages of a specific Page?

How would I retrieve attachments from all **subpages** of a specific Page ID? Example: SPECIFIC PAGE   * Child (with attachments)    * Child (with attachments)    * Child (with attachments)  I'm currently using this code to retrieve all attachments site-wide, however I would like to limit this to only pull images from all children of a specific Page.               <?php     $args = array( 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => null );      $attachments = get_posts( $args );     if ($attachments) {         foreach ( $attachments as $post ) {             setup_postdata($post);             the_title();             the_attachment_link($post->ID, false);             the_excerpt();         }     }     ?>      Almost there using this code below:               <?php          $mypages = get_pages('child_of=19');     foreach ( $mypages as $mypage  ) {     $attachments = get_children(array('post_parent' => $mypage->ID, 'numberposts' => 1, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'rand'));               if ($attachments) {              foreach ( $attachments as $post ) {                  setup_postdata($post);             the_title();             the_attachment_link($post->ID, false);             the_excerpt();         }     }     }     ?>      However, there are two remaining issues:   1. Limiting the amount of **total photos** pulled. Using 'numberposts' only limits the amount of images pulled from each post   2. Randomization. Orderby => rand only randomizes the images within each post. I would like to randomly shuffle the order for everything.


Nested Queries using meta_query

I'm trying to build a query that lists posts of a custom type with specific custom field values. Then I need to list children of each of those posts within the post, and those children also need to be filtered by specific custom field values. Here's my current code, which isn't working. Any help would be greatly appreciated. Thank you!               <?php         $args = array(             'post_type' => 'clients-placements',             'posts_per_page' => -1,             'post_status' => 'publish',             'order' => 'ASC',             'meta_query' => array(                 array(                     'key' => 'type',                     'value' => 'Client'                 ),                 array(                     'key' => 'featured',                     'value' => 'yes'                      )             )                                );         $the_query = new WP_Query( $args );          ?>              <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>                  <?php get_template_part( 'content', 'clients' );?>
         <?php             $args = array(                 'post_type' => 'clients-placements',                 'posts_per_page' => -1,                 'post_status' => 'publish',                 'order' => 'ASC',                 'post_parent' => $post->ID,                 'meta_query' => array(                     array(                         'key' => 'type',                         'value' => 'Placement',                     ),                     array(                         'key' => 'featured',                         'value' => 'yes',                          )                 )                );             $the_query = new WP_Query( $args );                   // The Loop             while ( $the_query->have_posts() ) : $the_query->the_post();                 echo '
';                 the_title();                 the_content();                 echo '
';             endwhile;                   ?>
            <?php endwhile; ?>


Make 'Howdy, [name]' function as log out button

I have been customising the `admin bar` in version 3.3 to only have certain custom links with the following added to `functions.php`:               function mytheme_admin_bar_render() {     global $wp_admin_bar;          $wp_admin_bar->remove_menu('site-name');     $wp_admin_bar->remove_menu('new-content');     $wp_admin_bar->remove_menu('updates');     $wp_admin_bar->remove_menu('comments');     $wp_admin_bar->remove_menu('edit-profile');               $wp_admin_bar->add_menu( array(         'id' => 'reports',  'title' => __( 'Reports'),  'href' => __('xyz.html'),     ));     }     add_action( 'wp_before_admin_bar_render', 'mytheme_admin_bar_render' );      I'd now like to have the far right link that says Howdy, ..., function as a Logout button. Does anyone have any suggestions on how achieve this?


Specify ABSPATH in jQuery url

I'm building a custom jQuery form and I need to specify the siteurl in the url that loads /wp-admin/admin-ajax.php. I place this code in the template that has the form:               <script type="text/javascript">     jQuery('#newFeedbackForm').submit(ajaxSubmit);      function ajaxSubmit(){         var newFeedbackForm = jQuery(this).serialize();         jQuery.ajax({             type:"POST",             url: <?php get_bloginfo('siteurl'); ?> . "/wp-admin/admin-ajax.php",             data: newFeedbackForm,             success:function(data){                 jQuery("#feedback").html(data);             }         });         return false;     }     </script>      When I submit the form I get a **404 error** with all the form inputs in the URL. I'm thinking ajax isn't being called right to handle the form and apply the function of the hidden value:               <input type="hidden" name="action" value="addComment"/>      Working backwards, here is the addComment function:               function addComment(){     global $wpdb;          $topic = $_POST['topic'];     $name = $_POST['name'];     $email = $_POST['email'];     $no_results_comment = $_POST['no_results_comment'];          // EXTRA     $date = time(); // UNIX TIMESTAMP          if($wpdb->insert('wp_no_results_feedback',array(         'topic' => $topic,                                                               'name' => $name,         'email' => $email,         'no_results_comment' => $no_results_comment,         'date' => $date         ))===FALSE){             echo "Error";                    }else{             echo "Thanks for your feedback. We will get back to you shortly.";         }         die();     }     add_action('wp_ajax_addComment','addComment');     add_action('wp_ajax_nopriv_addComment','addComment');


List random posts on single page in the current category

I would like to show 8 random posts on single page from same category.               <?php         global $post;         $categories = get_the_category();         foreach ($categories as $category) :         $args = array( 'numberposts' => 8, 'orderby' => 'rand', 'category' => $category->term_id);         var_dump($category->term_id);         $rand_posts = get_posts( $args );         foreach( $rand_posts as $post ) :         ?>
<?php the_post_thumbnail(); ?><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?>
         <?php endforeach; ?>         <?php endforeach; ?>      ..but if the post has 2 or more categories it lists 16/24/32 posts. I hope anyone can help to me. Thanks!


order event posts by multiple custom fields

My event date data is in 3 separate custom fields and I need to sort by entire date, including day, month, year. Right now it's sorting by month only. How can I change it to sort by not just month but full date? Here's my code:               $arguments = array(         'post_type' => 'post_events',         'post_status' => 'publish',         'paged' => $paged,         'meta_query' => array(             array(                 'meta_key' => 'eventsmonth',                 'orderby' => 'meta_value'             ),             array(                 'meta_key' => 'eventsday',                 'orderby' => 'meta_value'             ),             array(                 'meta_key' => 'eventsyear',                 'orderby' => 'meta_value'              )       ),         'meta_key'   =>  'eventsmonth',  // sorting by month         'orderby'    =>  'meta_value_num', // numeric value         'order'      =>  'ASC'      );


Modify taxonomy-$taxonomy-$term.php to include posts from all blogs in multisite

How should I modify the `taxonomy-$taxonomy-$term.php` template to include posts from all sites in the network? I've been looking into the `query_posts` method from the Custom Queries Codex article, and also into the `pre_get_posts` method, and while it is clear how to modify the query to include other parameters from WP_Query, it isn't clear how to include posts from all sites. I'm thinking something like this:               global $wp_query;          $all_blogs_ids = array();     $all_sites = wp_get_sites();     foreach ( $all_sites as $site ) {         $all_blogs_ids[] = intval($site['blog_id']);     }     $posts = array();     foreach ( $all_blogs_ids as $blog_id ) {         switch_to_blog($blog_id);         $query = new WP_Query(array($taxonomy => $term));              foreach ($query->posts as $post) {             $posts[] = $post;         }         restore_current_blog();     }          global $post;     foreach ( $posts as $post ) {         setup_postdata($post);              // Actual template functions and html here.     }      What's the best way to achieve this? ### Update Doing the following has allowed me not to worry about `setup_postdata`:               <?php     $GLOBALS['wp_query']->posts = array();     $GLOBALS['wp_query']->post_count = 0;          $posts = array();     $sites = wp_get_sites();          foreach ($sites as $site) {         switch_to_blog($site['blog_id']);                   // Get posts         $q_posts = get_posts(array(             'position' => 'event_highlights',             'posts_per_page' => -1         ));              foreach ($q_posts as $post) {             $posts[] = $post;         }              restore_current_blog();     }          $GLOBALS['wp_query']->posts = $posts;     $GLOBALS['wp_query']->post = $post;     $GLOBALS['wp_query']->post_count = count($posts);          // Rest of the template here      The only problem with this is tags like `the_permalink` and thumbnails, which don't fetch correctly.


How to tell if a script is being executed from a plugin, a theme or a child theme in WordPress?

I have a framework for WordPress that can be embedded into either a **plugin** , a **theme** or a **child theme**. In order to return proper URLs, the script needs to determine from where it is being executed. I believe I could do something like matching `__FILE__` against:   * `get_template_directory_uri()` (theme),    * `get_stylesheet_directory_uri()` (theme or child theme), or    * `plugin_dir_url( __FILE__ )` (plugin) Is there a better, more reliable approach than using `strpos()` to compare the above? How would I go about it?


How to send form data from WordPress (Meta Box) to an OData service?

I have created a form within a Meta Box on the 'Add New Page' screen. I want the data from this form to be sent to an OData service on a central server. I can see that OData is supported on PHP (http://odataphp.codeplex.com/) but it requires the **OData for PHP SDK** to be installed on the server. Because the server could be Windows/UNIX/LINUX/other I don't know if I can create a generic installation file to make it transparent for the user to install my plugin. What would be the best method of doing this?


Why this plugin is not working?

I am testing jQuery in my wordpress plugin. Two files 1. main_plugin.php 2. js_plugin.js (Both in the same directory HelloWorld).   CODE:   PHP FILE:               <?php     /*     Plugin Name: jQuery Test Plugin     Plugin URI: http://www.rabwahnetwork.net     Description: This plugin is a test     Author: Rana Faiz Ahmed     Author URI: http://www.rabwahnetwork.net     */          function load_my_script()     {         wp_enqueue_script( 'script-name', WP_PLUGIN_URL . 'HelloWorld/js_plugin.js', array("jquery"), false, true );     }          add_action( 'wp_enqueue_scripts', 'load_my_script' );      JS file:               jQuery('.entry-header').click(function(e) {         e.preventDefault();         jQuery(this).remove();     });


WordPress Loop: List All Posts by a Category & Subcategory

I want to display all post under a category and all subcategories under the parent categories. But couldn't find proper suggestion over forum or failed to understand the solution. It's possible to perform this tasks by manually adding add ID into query but for me, I need all to be autopopulated. Need suggestion.


get_posts() doesn't consider user permissions

I want to show a list of links to posts for the logged in user on my wp. So I started to do so:               $posts_array = get_posts( array( 'post_type' => 'download', 'post_status' => 'publish' ) );     //$posts_array = apply_filters( 'downloads_shortcode', $posts_array );     foreach($posts_array as $post) {         setup_postdata($post);         $title = "ID ) . ">" . $post->post_title . "";         echo $title;     }      But it seems like the function doesn't care about the user capabilities. I use a plugin called "Groups" to require a capability for viewing a post. Everywhere on the page the posts are hidden, if a capability is missing. I'm confused because wp uses get_posts() itself. How to achieve this? //through Ravs hint I was able to do this approach: I extended the plugin Groups:               add_filter( 'get_posts', array( __CLASS__, "get_posts" ), 1 );     /**      * Filter posts by access capability.      *      * @param array $posts      */     public static function get_posts( $posts ) {         $result = array();         $user_id = get_current_user_id();         foreach ( $posts as $post ) {             if ( self::user_can_read_post( $post->ID, $user_id ) ) {                 $result[] = $post;             }         }         return $result;     }      and applied the filter as I already experimented:               $posts_array = apply_filters( 'get_posts', $posts_array );      Thank you.


How to override shortcodes.php core file?

I would like to override/update to core shortcodes.php file. Build an array and send data differently to other functions, but my question is how to do that without editing the core file? Is there a best practice way overriding core files and/or functions?


Renaming wordpress login and get new password button

I am currently building custom wordpress admin login theme.Now I have an idea but not sure it is possible.I want to rename "Get New Password" to something "Get New". Is it also possible to rename "Log In " to "Go"?


(resolved) Uploading images from a custom page using blueimp uploader?

I'm working with a frontend upload form that uses blueimp jQuery-File-Uploader to do all the heavy lifting ... but, after attempting to add the necessary WordPress functionality to blueimp I started running into some errors that I am unable to figure out. **Update / My code** HTML (the frontend form):               <form id="fileupload" action="" method="POST" enctype="multipart/form-data">                           Add files...                          <input type="file" name="files[]" multiple />

     </form>      JS (I'm using the same js that is used in the Basic Plus demo file) Just changing the url variable to the location of the UploadHandler.php file PHP (relative parts of my upload script ... I'm using the default UploadHandler script and trying to customize it for WordPress)               // Required WordPress files and hooks     require_once( $_SERVER['DOCUMENT_ROOT'] . "/wp-load.php" );     require_once( $_SERVER['DOCUMENT_ROOT'] . "/wp-admin/includes/media.php" );     require_once( $_SERVER['DOCUMENT_ROOT'] . "/wp-admin/includes/file.php" );     require_once( $_SERVER['DOCUMENT_ROOT'] . "/wp-admin/includes/image.php" );          $upload_dir = wp_upload_dir();          global $current_user;     get_currentuserinfo();     $logged_in_user = $current_user->ID;          // Some default blueimp code          // First few lines of the __construct function     global $upload_dir;     $this->options = array(         'script_url' => $this->get_full_url(),         'upload_dir' => $upload_dir['path'] . '/',         'upload_url' => $upload_dir['url'] . '/',          // A lot more default script code          // The handle_file_upload function with WordPress customizations     protected function handle_file_upload($uploaded_file, $name, $size, $type, $error,         $index = null, $content_range = null) {         global $logged_in_user;         $file = new stdClass();         $file->name = $this->get_file_name($uploaded_file, $name, $size, $type, $error,         $index, $content_range);         $file->size = $this->fix_integer_overflow(intval($size));         $file->type = $type;         if ($this->validate($uploaded_file, $file, $error, $index)) {             $this->handle_form_data($file, $index);             $upload_dir = $this->get_upload_path();             if (!is_dir($upload_dir)) {                 mkdir($upload_dir, $this->options['mkdir_mode'], true);             }             $file_path = $this->get_upload_path($file->name);             $append_file = $content_range && is_file($file_path) &&                 $file->size > $this->get_file_size($file_path);                  if ($uploaded_file && is_uploaded_file($uploaded_file)) {                 // multipart/formdata uploads (POST method uploads)                 if ($append_file) {                     file_put_contents(                         $file_path,                         fopen($uploaded_file, 'r'),                         FILE_APPEND                     );                 } else {                     move_uploaded_file($uploaded_file, $file_path);                 }             } else {                 // Non-multipart uploads (PUT method support)                 file_put_contents(                     $file_path,                     fopen('php://input', 'r'),                     $append_file ? FILE_APPEND : 0                 );             }             $file_size = $this->get_file_size($file_path, $append_file);             if ($file_size === $file->size) {                 $file->url = $this->get_download_url($file->name);                 if ($this->is_valid_image_file($file_path)) {                     $this->handle_image_file($file_path, $file);                 }             } else {                 $file->size = $file_size;                 if (!$content_range && $this->options['discard_aborted_uploads']) {                     unlink($file_path);                     $file->error = $this->get_error_message('abort');                 }             }             $this->set_additional_file_properties($file);         }              $attachment = array(             'post_mime_type'    => $file->type,             'post_title'        => preg_replace( '/\.[^.]+$/', '', basename( $file_path )),             'post_content'      => '',             'post_author'       => $logged_in_user,             'post_status'       => 'inherit',             'post_type'         => 'attachment',             'guid'              => $this->options['upload_url'] . $name         );              $attachment_id = wp_insert_attachment( $attachment, $file_path );              // Generate the attachment data         $attachment_data = wp_generate_attachment_metadata( $attachment_id, $file_path );              // Update the attachment metadata         wp_update_attachment_metadata( $attachment_id, $attachment_data );              return $file;     }      **Updated Issue:** At first this seems to work ... but, when you check the `wp_posts database table` nothing has been added. Also, when looking in the `media library` it only shows the uploaded image (none of the other images, which are in the database) and the following errors appear in the `error_log`:               PHP Warning: strpos() expects parameter 1 to be string, object given in /Applications/MAMP/htdocs/wordpress/wp-includes/post.php on line 188     PHP Warning: preg_match() expects parameter 2 to be string, object given in /Applications/MAMP/htdocs/wordpress/wp-includes/post.php on line 188     PHP Catchable fatal error: Object of class stdClass could not be converted to string in /Applications/MAMP/htdocs/wordpress/wp-includes/post.php on line 189      I understand the fact that the variable that I'm calling is an object, not a string, but I'm unsure what to put in it's place. Any help is appreciated have tried everything I can think of. Really need to get this up and running ASAP! Thanks


Wordpress Jquery UI Spinner

I am trying to use jquery-ui spinner in my plugin. I had googled it, but not found any referrence that can help me out. It is also not written in the docs http://codex.wordpress.org/Function_Reference/wp_enqueue_script. Nor also only the word `spinner`. Is the current version of wordpress (3.8.1) include jquery ui spinner in its library? If so, how to use it on a plugin? Best Regards :)


Get value from post meta array, and add it as a category

I have a form that performs an AJAX hook that does several things, one of them is that it takes some form fields, adds them to an array, and adds that array as meta to the post that is created from the form. In the AJAX function, it looks like this:               // get form data array (we already have $post_id set)     $data_cf = $_POST['form_data'];     // update post meta (post is the newly created fundraiser from above)     update_post_meta( $post_id, '_cf_data', $data_cf );           // set some stuff from form data array     $data_cf_country = $data_cf['country'];     $data_cf_city    = $data_cf['city'];     $data_cf_state   = $data_cf['state'];      then I need to add each of the above to their respective categories/taxonomies for the post. Ex: the values could be United States, Chicago, Illinois, which would be added to Country, City, State. I have the taxonomies registered already for the post. I just can't seem to find out how to add the post to them at this step. Tips? Thanks!


Site running slow on new server?

I recently uploaded a website to a new 123-reg server on a single WP installation (www.moseleycoachsales.co.uk). I had developed the site on my own hosted multisite environment (http://test.digitalgroupmedia.com/moseley/). I had a nightmare uploading the website as the standard wordpress xml export/import facility that had always worked for me kept crashing crashing. In the end I managed to get the website live using this method (http://matteth.wordpress.com/2012/01/12/exporting-a-site-from-multisite-to- single-installation/) The live website is now very sluggish and nowhere near the speed it was on my test environment. I don't know if this is down to the new server, or if something has occurred in the website move (perhaps database related) that has created the issue? I'm not great with MySQl so don't really have the skill to diagnose this issue (if it even is the issue) and would really appreciate some help.


Does WP Have a Function To Generate .htaccess RewriteCond?

I know that I can edit .htaccess manually and add a RewriteCond statement inside, but I need to build a plugin that does this the proper way by using WP rewrites which then get pushed into .htaccess with flush_rewrite_rules(). I need RewriteCond in this case. Does WP have some obscure function that lets me push a RewriteCond statement into the .htaccess?


Link to page in category

I want to link to an archive page in WordPress, so like:               <a href="<?php page( 2 ); ?>">link      so if a for example a category page is shown, this link needs to go to the second page for that category.


Current theme broken - after server and domain migration

I'm migrating a Wordpress install and trying to get down the correct process for doing so. I've tried using the method I thought would work, but it didn't. My files and database are in place, but when I visit the wp-admin the theme manager tells me this - The active theme is broken. Reverting to the default theme. Unfortunately if you then re-activate it, it work's but loses all it's widgets etc. I've been using a search and replace function to change all the instances and options using the old domain with this script - http://interconnectit.com/124/search-and-replace-for-wordpress-databases/ Which is pretty cool. I'm just replacing               http://domain1.com      with               http://domain2.com      although even running this before I access the site doesn't seem to stop the problem of the broken theme and thus losing all the widgets. Anyone know how I can migrate this site without having the ass-ache of losing all the widgets (of which there are way to many to do manually).


Search CPT Title AND Meta

I currently have a CPT I would like to search, the catch is I also need to be able to search the meta data for the CPT. I have the following code that currently searches the meta value needed but I can't seem to get it to search the title AND the meta data. Help would be greatly appreciated!               <?php     /**      * @package WordPress      * @subpackage themename      */          get_header();      $search = get_search_query(); ?>

<?php printf( __( 'Search Results for: %s', 'themename' ), '' . get_search_query() . '' ); ?>
                             <?php                                 // LOOP ARGUMENTS                                 $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;                                 $args = array( 'post_type' => 'team_members', 'posts_per_page' => -1, 'paged' => $paged, 'orderby' => 'title', 'order' => 'ASC', 'meta_query' => array(                                         array(                                             'key' => 'memberFirstName',                                             'value' => $search,                                             'compare' => 'LIKE'                                             ),                                         )); // -1 Shows ALL Posts                                 $loop = new WP_Query( $args );                                 while ( $loop->have_posts() ) : $loop->the_post();                                      // CUSTOM CONTENT                                 $memberFirstName = get_post_meta($post->ID,"memberFirstName",true);                                 $memberPosition = get_post_meta($post->ID,"memberPosition",true);                                 $memberPhone = get_post_meta($post->ID,"memberPhone",true);                                 $memberEmail = get_post_meta($post->ID,"memberEmail",true);                                 $thumb = wp_get_attachment_image_src(get_post_thumbnail_id(), 'thumbnail_name');                                 $imgURL = (isset($thumb[0]) ? $thumb[0] : get_template_directory_uri() . "/images/member_placeholder.jpg");                                      $postID = get_the_ID();                                 $terms = get_the_terms( $postID, 'service-type' );                                 foreach($terms as $term) {                                     if($term->parent == 14 ) {                                         $memberDivision = $term->name;                                     }                                     if($term->parent == 8 ) {                                         $memberDivision = $term->name;                                     }                                     if($term->parent == 3 ) {                                         $memberCity = $term->name;                                     }                                 }                             ?>
                                     <img src="<?php echo get_template_directory_uri(); ?>/thumb.php?src=<?php echo urlencode($imgURL); ?>&h=79&w=79&zc=2">
                                              <?php echo $memberFirstName; ?> <?php the_title(); ?>, <?php echo $memberPosition; ?>
                                         <?php echo $memberDivision; ?>, <?php echo $memberCity; ?>
                                             <?php echo $memberPhone; ?>                                             <a href="mailto:<?php echo $memberEmail; ?>">Email

                                            <?php /* END WHILE AND RESET QUERY */ endwhile; wp_reset_query(); ?>
                             <?php $total_pages = $loop->max_num_pages;                                      if ($total_pages > 1){                                          $current_page = max(1, get_query_var('paged'));                                          echo paginate_links(array(                                     'base' => get_pagenum_link(1) . '%_%',                                     'format' => '/page/%#%',                                     'current' => $current_page,                                     'total' => $total_pages,                                 ));                             }   ?>

                     <?php if ( dynamic_sidebar('team-sidebar') ) : else : ?><?php endif; ?>

               <?php get_footer(); ?>


How are terms connected with posts in database?

In a multi-site environment, I have a special need to get post terms (on a custom taxonomy) without the expensive operation of "switching blogs". I thought I might write my own query to get terms for a given post on a given blog. I'm looking through the three tables:               wp_3_terms     wp_3_term_relationships     wp_3_term_taxonomy      Yet I cannot see where there is a connection to post_id in any of these. So the question: How do terms link with a given post in the database? If I can know that, I can do the rest.


Set Transient expiration

I have a page that displays a random post every day. In order to change post every 24 hours I use `set_transient('totd_trans_post_id', $totd[0]->ID, (60*60*24));` What I'm wondering is this:   * Does the countdown (60*60*24) start as soon as I have inserted and saved the code?   * If yes: What happens if I let the code run for 23 hours, and then decide to "update" the code. Will the countdown restart?   * If no one visits the site for 48 hours, will the expiration still take place? Or does someone have to visit after 24 hours to "run" it?


Make 2 different WooCommerce checkout pages?

I'm wondering whether it's possible to make 2 different checkout pages for 2 different products? If a buyer chooses the product #1, he/she will be redirected to the checkout page #1. If he/she chooses the product #2, he/she will be redirected to the checkout page #2. These 2 checkout pages have some same fields and some different fields. Some same fields are optional on the checkout page #1 but are mandatory on the checkout page #2. Any help is appreciated. :)


'jQuery is not defined Error' appearing in load-scripts.php

I'm writing this question having already found a solution, in order to see whether other people have encountered this problem. I was having a problem on the back end of a site I am building in wordpress in which all the jquery scripts that I tried to load using the native wordpress handles (i.e. jquery-ui-core, jquery-ui-sortable, etc) were not loading. If I checked the state of those script handles using the wp_script_is() function, it showed that they were registered, enqueued, but not printed. At the same time my load-scripts.php file was registering an error: "jQuery not defined'. It turns out that this problem has something to do with a new feature added in Wordpress 3.5 that attempts to concatenate all javascript requests into a single call. This feature, however, was causing conflicts for some reason with some plugins. That at least is what Kevin Leary has reported here. The solution that Leary describes is to disable this feature by adding the following line to the wp-config.php file (after the line defining the ABSPATH):               define('CONCATENATE_SCRIPTS', false);      Does anyone understand why this bug is occurring? And is this a bug in the new version of Wordpress?


Proper way to hook wp_get_attachment_url

I am trying to hook `wp_get_attachment_url()` with my custom implementation. I am trying to get my post images and any other static data from the Amazon S3 and I was wondering if I can configure the URL with my Amazon bucket URL. This is what I was trying to do               add_filter('wp_get_attachment_url', 'custom_get_attachment_url', 1, 1);          function clrs_get_attachment_url($post_id = 0) {     // change URL for Amazon bucket     }      but this is not working as expected as I am getting `$post_id` as `0`. How to do it in a proper way?


Verify Registration email on local host windows 7 xampp

I am very new to word press development. I have set up xampp and successfully installed wordpress on my localhost with my admin account. I need to create a registration for the users to register in my website. I have used various plugins for registration. One of my plugins says a registration was successful and a confirmation mail will be sent. How can I check or activate to send mail confirmation to check whether it works fine.


Advice on how to build multiple cross-tagged content types

From those who are more experienced with WP, I could use some advice on how to best set up a local history site to do the following:   * There will be a list of _articles_ on different historical topics. Each will be tagged with the _people_ who appear in the article, the _organizations_ discussed, and maybe other metadata like _events_ or _places._   * Each _person_ should have his/her own page that shows all the _articles_ the person is mentioned is, all the _organizations_ the person is a member of, and maybe also all the _events_ they attended or _places_ they lived/frequented.   * Each _organization_ should list all the _people_ who were its members, and maybe also all the _events_ it threw and _places_ it met. And so on... I think you get the point... basically I have 3-5 sets of content that need to be tagged to each other in flexible ways. I'm not sure how best to accomplish this.   * Out of the box tags and categories don't link to each other (plus it's painful to create custom tag and category pages), though they seem like they ought to be the more natural fit.    * Then I thought I could create a custom post format for each of the non-article content types (people, orgs, events, places) and then using the plugin Advanced Custom Fields 4.3.8 I could shoe-horn all the tags in there, but that seems pretty hideous, and it's not clear it would even work since it seems to want everything to be 1:1. I know this isn't the best fit for StackOverflow, but I feel like this use- case isn't so unique that there isn't a clear architectural recommendation or even an existing plugin. Thanks so much!


Difference between the 4 Built in RSS Feeds?

Can somebody give me an explanation on the differences between the 4 different built in RSS Feeds and why / when I should choose one over the other? Why does WordPress incorporate 4 different ones instead of focusing on 1 universal one? The feeds include: 1) RDF/RSS 1.0 feed 2) RSS 0.92 feed 3) RSS 2.0 feed 4) Atom feed WordPress RSS Feeds Codex


How can I implement a simple post editor?

I want a simple post editor for WordPress, it should be something like tumblr editor or the stackoverflow editor. My questions:   1. Is there any plugin I can use? (I just can't find it)   2. If no plugin, how can I implement it? Is there any example? (I saw one site has such editor using WordPress, but they have reworked their site now)


How to get clean code for a gallery?

I want clean code for a gallery, like:

      Currently my code is coming out like this:


Store SNS share value via function.php

I am trying to store SNS share value + comment count on my postmeta, DB. I put code below to accomplish this task,               function get_sns_share($post_ID=0) {          $url1=get_permalink($post->ID);         $src = json_decode(file_get_contents('http://graph.facebook.com/' . $url1));         $share_count = $src->shares; // facebook commnet + comment like + share + like         $my_var = get_comments_number( $post_id ); // comment count         $social_score = $share_count + $my_var + $tweet; // social score sum             if ($social_score > 999) $social_socre = 999;              return $social_score;          update_post_meta($post_id, '_social_score', $social_score);     }      The problem is this code certainly do works every field other than update_post_meta. It seems it does not add add post meta field to my database, thus I cannot get any value from there. Your help would be much appreciated.


Where can I find documentation on what characters are allowed in user names and why?

I would love to be able to use spaces in usernames, but this does not seem possible. Is there a writeup in the codex or somewhere that explains what characters are allowed and why it was restricted to that set or is it just alphas only and suck it up? If I want users to use something other than a username with no spaces, is my only real option a plugin that allows users to login with their email addresses instead, but still requires an alpha only username at account creation? Oh, and I am on a WPMU/network site.


Show message in media-new.php

I'm wondering if there's a way to show a specific message when user uploads a file using the `wp-admin/media-new.php` script. So far I have this:               function my_uploads_notice(){         global $pagenow;         if ( $pagenow == 'media-new.php' ) {              echo '

MY NOTICE

';         }     }     add_action('admin_notices', 'my_uploads_notice');


Where is the Leave a Comment link set

I have a self hosted WordPress blog and use the Isabella Theme from BluChic. The initial installation of this was set up via an auto installer that the host provider offered. I moved the blog from one domain to another and in the process took the initial install and moved all the files. I had to do some changes in the db export to update the url to get everything working. Everything works fine apart from the submit link for the Leave a Comment button. Does anyone know where this link is stored? I have all the files downloaded locally and have access to the database but so far I have no luck finding where this link is set. The problem is the link is there but it points to the old domain address, even though all of the other links updated. This is the only link giving me hassle. It appears when you press post on the comment edit box that is popped up after clicking Leave a Reply Any help on its location would be much appreciated!


Is it possible to make specific posts editable by all authors?

I have a Q&A site in which people can ask experts different questions. Some questions are addressed to a specific expert so I insert the post under their authorship. However, there is also a General option which should allow all the experts to answer the question. Is there a way to open specific posts to all users which has a role of author?


Wordpress excerpt for specific posts in category

Is there any way to create "more" link for excerpt only for posts in a specific category? For example only posts in "news" category should have a more link. If there's no option for that, maybe posts in specified WP Query? I am using this code for creating "more" link for excerpts but it works for _all_ posts:               function excerpt_read_more_link( $output ) {        global $post;        return $output . 'ID ) . '">more';     }     add_filter( 'the_excerpt', 'excerpt_read_more_link' );      toscho thak You for reply. I will check Your solution, but I remeber that I used this code:               if (in_category('news')) {      function excerpt_read_more_link( $output ) {        global $post;        return $output . 'ID ) . '">more';          add_filter( 'the_excerpt', 'excerpt_read_more_link' );     }      and this didn't work :-/


How do I sort a custom post type admin column using two meta keys?

I have created a custom post type along with custom columns. One of my columns displays a date range such as "12/05/2012 - 11:00 am to 12/15/2012 - 1:00 pm". This is a concatenated string using a combination of four fields: `startDate`, `startTime`, `endDate`, `endTime`. So far I have been able to make this column sortable based upon the `startDate` meta_key, but I would like to extend this such that it's sorted by the `startDate` and then by the `startTime`. ### Currently   * 12/23/2012 - 7:00 pm   * 12/05/2012 - 11:00 am   * 12/05/2012 - 2:00 pm   * 11/30/2012 - 1:00 pm ### Need   * 12/23/2012 - 7:00 pm   * 12/05/2012 - 2:00 pm   * 12/05/2012 - 11:00 am   * 11/30/2012 - 1:00 pm This is my progress from what I've gathered over the internet so far, but it does not sort by time:               add_filter( 'request', 'event_column_orderby' );          function event_column_orderby ( $vars ) {              if ( !isset( $vars['orderby'] ) || isset( $vars['orderby'] ) && 'datetime' == $vars['orderby'] ) {             $vars = array_merge( $vars, array(                 'orderby'       => 'meta_value',                 'order'         => 'ASC',                 'meta_query'    => array(                     array(                         'key'   => 'rqp-event-startDate'                     ),                     array(                         'key'   => 'rqp-event-startTime'                     )                 )             ));         }              return $vars;     }


Post Comments with Ajax in Wordpress

I use this code to post comments with ajax on my WP blog. It works fine but I display the comment form on my homepage so the plugin only works for the first post (first comment form). I want it to work for all the forms. Here is my code:               if (typeof jQuery != 'undefined') {       jQuery('document').ready(function($){         var commentform=$('#commentform');         commentform.prepend('

');              var statusdiv=$('#comment-status');              commentform.submit(function(){           var formdata=commentform.serialize();           statusdiv.html('
Processing...
');                var formurl=commentform.attr('action');                $.ajax({             type: 'post',             url: formurl,             data: formdata,             error: function(XMLHttpRequest, textStatus, errorThrown){               statusdiv.html('
You might have left one of the fields blank, or be posting too quickly
');             },             success: function(data, textStatus){               if(data=="success")                 statusdiv.html('
Thanks for your comment. We appreciate your response.
');               else                 statusdiv.html('
Please wait a while before posting your next comment
');                 commentform.find('textarea[name=comment]').val('');             }           });                return false;          });       });     }


Display posts where date field matches current month?

I have a loop which displays all the posts of the "events" post type on my site. Each of these posts has a custom date field "event_date", which I sort the display of the loop by. I would like to simplify my post management by only display posts which match the current month; that is, as of today (Dec.30) all the December posts display but on January 1, all the January posts display. Note this is not post date, it's the value of the field (when the event takes place). I want to keep the month's worth of posts up ll month even when their date passes -- so always the complete month. Most of the posts I found here with search are dealing with the post date, whereas I need to use the value of this custom field instead. Thanks. My current query:               $args = array( 'post_type' => 'hh_event', 'posts_per_page' => -1,'orderby' => 'meta_value', 'meta_key' => 'event_date', 'order' => 'ASC'  );                 $the_query = new WP_Query( $args );      To add to this, the field is a custom field made with the Advanced Custom Fields plugin, and the date is save by this as yymmdd.


How to add a class when there's no sidebar?

I would like to add a class to a page template's body if the sidebar is not defined. How can I do that?


Can't create tables with my plugin

Here is the code:               <?php          /*       Plugin Name: MyPluggin       Plugin URI: http://localhost/       Description:        Version: 0.0.2       Author: localhost       Author URI: http://localhost/       License: GPL2      */               function crear_tablas() {              global $wpdb;                   require_once(ABSPATH . 'wp-admin/includes/upgrade.php');                   $table_name_1 = $wpdb->prefix . "usuarios";         $consulta_1 = "create table $table_name_1(                     count bigint unsigned not null  primary key auto_increment,                     ID bigint not null references wp_users(ID),                     puntosDisponibles bigint unsigned default 1000                 );";              dbDelta($consulta_1);                   $table_name_2 = $wpdb->prefix . "deportes";         $consulta_2 = "create table $table_name_2(                     ID int unsigned not null  primary key auto_increment,                     nombre tinytext                 );";              dbDelta($consulta_2);              $table_name_3 = $wpdb->prefix . "ligas";         $consulta_3 = "create table $table_name_3(         ID int unsigned not null  primary key auto_increment,         nombre tinytext     );";                  dbDelta($consulta_3);                   $table_name_4 = $wpdb->prefix . "equipos";         $consulta_4 = "create table $table_name_4(         ID int unsigned not null  primary key auto_increment,         nombre tinytext,         apodo  tinytext,         deporte int unsigned not null references deportes(id),         liga    int unsigned not null references ligas(id)          );";                  dbDelta($consulta_4);                  $table_name_5 = $wpdb->prefix . "eventos";         $consulta_5 = "create table $table_name_5(         count bigint unsigned not null  primary key auto_increment,         ID  bigint unsigned not null references wp_posts(ID),         localID int unsigned not null references equipos(ID),             visitanteID int unsigned not null references equipos(ID),         goleslocal  int unsigned,         golesVisitante  int unsigned,         fecha DATE not null,         hora  TIME not null,              status  int unsigned default 0          );";                  dbDelta($consulta_5);              $table_name_6 = $wpdb->prefix . "apuestas";         $consulta_6 = "create table $table_name_6(         count bigint unsigned not null  primary key auto_increment,         eventoID bigint unsigned not null references   wp_posts(ID),         puntosJugados   bigint unsigned not null,         userID  bigint unsigned not null references wp_users(ID),          fecha DATE not null,         hora  TIME not null,              resultado int unsigned not null,         porcentaje float(4,2),         estado int unsigned not null default 0     );";                  dbDelta($consulta_6);          }                                   function instalar_sistema_apuestas () {         crear_tablas();         //crearCategorias();         //crearPaginaPerfil();           }          register_activation_hook(__FILE__,'instalar_sistema_apuestas');                                        ?>         No tables were created:               mysql> show tables;     +------------------------+     | Tables_in_wordpress |     +------------------------+     | wp_commentmeta         |     | wp_comments            |     | wp_links               |     | wp_options             |     | wp_postmeta            |     | wp_posts               |     | wp_term_relationships  |     | wp_term_taxonomy       |     | wp_terms               |     | wp_usermeta            |     | wp_users               |     +------------------------+     11 rows in set (0.00 sec)


Upload more than one media files with a post

I am not sure if this has been asked to community before. I 'd like to have more than one upload custom fields with WP post. Could anyone please suggest if there is any plugin available for it OR if I can achieve it by using WordPress native feature. Thanks,


Is it possible to find out what theme a specific web site is using?

I just want to know is there a way to find out (by inspecting links or etc.) to find out what theme a specific web site is using? P.s. I do not own the sites that I want to check. Regards,


How long does a deprecated function live in core?

I'm curious to find out the process/philosophy behind removing deprecated functions from core. The Codex says this: > These functions below have been deprecated. That means they have been > replaced by new functions or are no longer supported, and may be removed > from future versions. Since 'may be removed' is a bit ominous and somewhat unclear, I have the following questions.   1. What is the criteria for deletion of a deprecated function? (i.e. version gap, time-frame, security risk, etc...)   2. Is the deletion of a function communicated to the public officially?  For example: `get_postdata()` has been deprecated since 1.5.1 and doesn't have an official Codex page. Is there a reason this is still around other than to support older versions of WordPress?


Subpages return 404 error

I set permanent link as http://site.com/%postname%/. I'm talking about this type of pages: http://codex.wordpress.org/Pages_Screen. All first level pages work fine. But subpages don't. For the first level page I get url like this: http://site.com/page/. For the second level page - http://site.com/page/subpage/. If I use permanent link http://site.com/?p=123 or http://site.com/2012/02/29/sample-post/, subpage works fine then. How does make it work with http://site.com/%postname%/ mask? Added:               # BEGIN WordPress     <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /index.php [L]     </IfModule>          # END WordPress      **Update:** **I found the reason. It is a post_type field in the wp_posts. But I cannot find out where this field is saved?**


WordPress Dashboards: slowness and timeouts

On a single server, we have a number of single-site WordPress installations (which have been around for many years and have worked fine 'til now) and one newer multi-site installation that has been working fine for a few months. They are all connected to separate databases on a separate MySQL server in the same data center. In the last week or so, the dashboards on ALL of these installations will intermittently load extremely slowly or timeout altogether (depending on the browser -- Chrome seems to give up sooner than Firefox), to the point of being unusable. When one of the dashboards is showing the problem, all of the other dashboards on the same server do the same. When one is working, all are working. This will happen at any point during the login or dashboard-using process. The actual reader-facing blog pages work fine at these times, and the other non-WordPress pages on the server all work fine. A WordPress installation on a separate server but connected to the same MySQL server also works fine during these times. It's only the dashboards on this one server. I've tried disabling nearly all of our plugins (the ones not needed to keep the blogs minimally functional, like Akismet and Google Analyticator). I've tried upping the PHP memory limit. No luck with any of this. Our host has been trying to help me but is also at a loss. Any ideas would be greatly appreciated!


Renaming child-theme folder fixed wp-admin blank

Weird thing happened. I have a WP instance, and I wanted to have a local copy. I copied all the files, created the DB from a dump, and everything seemed to be working fine. However, when going to `wp-admin`, BLANK SCREEN. I renamed the child-theme from `alterna-child` to `alterna-child2` and then I could login. I deactivated the alterna-child theme, and then activate it back, but if I logout, I can't access the admin either. I am confused, because in the live site this is not happening. Any thoughts? EDIT: I have tried removing all the files from the theme, and I can see that the file that creates the conflicts is functions.php, which contains the following:               include(WP_CONTENT_DIR . '/graduates_functions.php');      And yes, I have `graduates_functions.php`