Include post title in readmore link?

Trying to include the post title in my excerpt readmore links. I've read the codex on this, but my theme files are much more complicated so I could use a bit of expert help... Extract from functions.php: ** Edited to show more code.........               function theme_get_content($args = array()) {          $more_tag = theme_get_array_value($args, 'more_tag', __('Continue Bob →', THEME_NS));     theme_ob_start();     the_content($more_tag);     $content = theme_ob_get_clean();     return $content . wp_link_pages(array(                 'before' => '
' . __('Pages', THEME_NS) . ': ',                 'after' => '
',                 'link_before' => '',                 'link_after' => '',                 'echo' => 0             ));      }               function theme_get_excerpt($args = array()) {     global $post;     $more_tag = theme_get_array_value($args, 'more_tag', __('My Words...→', THEME_NS));     $auto = theme_get_array_value($args, 'auto', theme_get_option('theme_metadata_excerpt_auto'));     $all_words = theme_get_array_value($args, 'all_words', theme_get_option('theme_metadata_excerpt_words'));     $min_remainder = theme_get_array_value($args, 'min_remainder', theme_get_option('theme_metadata_excerpt_min_remainder'));     $allowed_tags = theme_get_array_value($args, 'allowed_tags',         (theme_get_option('theme_metadata_excerpt_use_tag_filter')             ? explode(',',str_replace(' ', '', theme_get_option('theme_metadata_excerpt_allowed_tags')))             : null));     $perma_link = get_permalink($post->ID);     $more_token = '%%theme_more%%';     $show_more_tag = false;     $tag_disbalance = false;     if (post_password_required($post)) {         return get_the_excerpt();     }     if ($auto && has_excerpt($post->ID)) {         $excerpt = get_the_excerpt();              $show_more_tag = theme_strlen($post->post_content) > 0;     } else {         $excerpt = get_the_content($more_token);         // hack for badly written plugins         theme_ob_start();         echo apply_filters('the_content', $excerpt);         $excerpt = theme_ob_get_clean();         global $multipage;         if ($multipage && theme_strpos($excerpt, $more_token) === false) {             $show_more_tag = true;         }         if (theme_is_empty_html($excerpt))             return $excerpt;         if ($allowed_tags !== null) {             $allowed_tags = '<' . implode('><', $allowed_tags) . '>';             $excerpt = strip_tags($excerpt, $allowed_tags);         }         if (theme_strpos($excerpt, $more_token) !== false) {             $excerpt = str_replace($more_token, $more_tag, $excerpt);         } elseif ($auto && is_numeric($all_words)) {             $token = "%theme_tag_token%";             $content_parts = explode($token, str_replace(array('<', '>'), array($token . '<', '>' . $token), $excerpt));             $content = array();             $word_count = 0;             foreach ($content_parts as $part) {                 if (theme_strpos($part, '<') !== false || theme_strpos($part, '>') !== false) {                     $content[] = array('type' => 'tag', 'content' => $part);                 } else {                     $all_chunks = preg_split('/([\s])/u', $part, -1, PREG_SPLIT_DELIM_CAPTURE);                     foreach ($all_chunks as $chunk) {                         if ('' != trim($chunk)) {                             $content[] = array('type' => 'word', 'content' => $chunk);                             $word_count += 1;                         } elseif ($chunk != '') {                             $content[] = array('type' => 'space', 'content' => $chunk);                         }                     }                 }             }                  if (($all_words < $word_count) && ($all_words + $min_remainder) <= $word_count) {                 $show_more_tag = true;                 $tag_disbalance = true;                 $current_count = 0;                 $excerpt = '';                 foreach ($content as $node) {                     if ($node['type'] == 'word') {                         $current_count++;                     }                     $excerpt .= $node['content'];                     if ($current_count == $all_words) {                         break;                     }                 }                 $excerpt .= '…'; // ...             }         }     }               if ($show_more_tag) {         $excerpt = $excerpt . ' ' . $more_tag . ' ';      }               if ($tag_disbalance) {         $excerpt = force_balance_tags($excerpt);     }     return $excerpt;      } Any ideas how to include the post title within the readmore permalink??? Thanks


Why get_page_template() doesn't show taxonomy template file name?

I made a custom taxonomy called - `work-category` and a template file for it called - `taxonomy-work-category.php`. That part work just fine. For a purpose I did put `get_page_template()` in that `taxonomy-work- category.php` file to get the current template file name. But it does print out as `page.php` (with full path ofcourse). I was expecting it to print out `taxonomy-work-category.php`. Even when I'm certain it is printing out from a custom taxonomy template file - Why doesn't `get_page_template()` function doesn't returns the taxonomy template file name?


Post Title Not showing up

Hi i'm using this code to call post from a certain category               <?php     $queryObject = new  Wp_Query( array(             'posts_per_page' => 3,             'post_type' => array('post'),             'category_name' => 'photos-bet-awards-2013-2',                 'orderby' => 'date',             ));     // The Loop!     if ($queryObject->have_posts()) {     ?>     <?php     while ($queryObject->have_posts()){         $queryObject->the_post();         ?>          <a href="<?php the_permalink(); ?>" title="<?php printf(__( 'Read %s', 'wpbx' ), wp_specialchars(get_the_title(), 1)) ?>">                         <?php the_post_thumbnail('betphumbs'); ?>                                                <?php       $args = array(     'post_type' => 'attachment',     'numberposts' => -1,     'offset' => 0,     'orderby' => 'menu_order',     'order' => 'asc',     'post_status' => null,     'post_parent' => $post->ID,     );     $attachments = get_posts($args);     if ($attachments) {     foreach ($attachments as $attachment) {         if(wp_attachment_is_image( $attachment->ID )) {         echo 'ID) . '"><?php the_title(); ?>    ';         break;      }     }     }          ?>                    <?php     $attachments = get_children(array('post_parent'=>$post->ID));     $nbImg = count($attachments);     echo ''.$nbImg.' photos.';     ?>
 <?php the_time('m/d/y \a\t g:ia') ?>          <?php     }     ?>     <?php wp_reset_postdata();     }     ?>      Now the problem that I am having is the for some reason `<?php the_title(); ?>` isn't grabbing the post title **how can i fix this?**


Featured image size in ADMIN panel?

I want to be entirely clear about this, what I'd like to do is change the size of the featured image thumbnail on the ADMIN panel, not on the front end. I'm building a WP-admin theme, and I need to make the featured image larger on the back end. It seems, featured images in the edit-post screen always spit out at 266x148px, ideally I'd like them to be actual size. I've searched around and can't find any hooks or functions that'd let me do this, but if anyone knows how, it's the people on here.


Unable to add "code" button to TinyMCE toolbar

This is driving me crazy. Using code from the WP codex, I can add SOME buttons to the TinyMCE bar, but NOT others. For example this code:               function my_mce_buttons_2($buttons) {            /**          * Add in a core button that's disabled by default          */         $buttons[] = 'sup';         $buttons[] = 'code';              $buttons[] = 'hr';         $buttons[] = 'fullscreen';              return $buttons;     }     add_filter('mce_buttons_2', 'my_mce_buttons_2');      WILL add the hr and fullscreen buttons to the editor, but WILL NOT add the code nor superscript button to the editor. What gives?! Any ideas? I am using WP 3.9.1


Change default tab of media manager

Is there a way to change the default media manager tab? I have managed to remove everything that I didn't want to show in media manager, using the instructions from the first post here Add a menu item to Wordpress 3.5 Media Manager. I also have created a custom tab. The problem is that when I click the Add Media button in posts, it sends me to the Media Library by default, which I have disabled. ![http://i.stack.imgur.com/e3oLk.png](http://i.stack.imgur.com/e3oLk.png) Is it possible to set the default screen from Media Library (which I have disabled) to the Insert from URL? So every time i click the Add Media I will get this screen: ![http://i.imgur.com/fWNb47h.png](http://i.imgur.com/fWNb47h.png) (the one from Insert from URL). My coding skills are nearly zero... and the closest solution to my problem I believe it's this Changing the media library default tab, but it doesn't work...


How to prevent posts from being published too close to each other?

I manage a blog which consists of about 25 writers. Sometimes a few of them are in the process of writing a new post at once, and they end up publishing them too close to each other. Is there a way to prevent this from happening? Something to say "Another post just went live within the last 5 minutes. You'll need to wait 55 mins to publish yours."


Style reply form different than comment form

Is there a way to display (css and html) in a different way the "reply" form and the main "comment" form?


Using add_action before add_filter on a plugin?

I'm writing a plugin and having a problem. I have `add_action('publish_post', 'sender');` and I want this function to run first before the add_filter function, although it won't. Is there a way to do this? I've tried moving the add_filter below add_action but that doesn't work. Also pasting the add_filter one into the add_action function doesn't work. Thanks for the help. Edit:   For example, if this would work it would be great.                 if (add_action('publish_post', 'sender'))       {           add_filter('wp_insert_post_data','changePost','99',2);       }      But it doesn't and somehow still runs the add_filter function first.


How can I duplicate "Add Custom Field" with just JavaScript?

I frequently need to add several Name-Value pairs to the Custom Fields of a post. At present I add these one by one, by entering the Name and Value and clicking Add Custom Field. I'd like to speed this up by entering several pairs into a single box (textarea, prompt, whatever), and have some JavaScript parse them and add them as though I had entered them manually. (Why JavaScript? Because I don't have access to edit any PHP or install any new plugins. I'm doing this browser-side, with Greasemonkey.) As far as I'm aware, the Add Custom Field button submits the Name-Value pair with AJAX, but I'm not familiar enough with jQuery or WordPress to find the exact code that does this so that I can copy it. Any pointers would be much appreciated. Thanks!


How can i do a search for tags in a certain category?

I'm trying to search for a certain category with a tag, how can I do this via url? For example: www.example.com/?cat=1&tag=tag1 how can i achieve this using parameters in the url?


Alternative to mysql_real_escape_string

I have a WordPress plugin that at one point I need to see if a certain title exists in the database. For 2 years, this code worked fine:               $myposttitle= $wpdb->get_results(      "select post_title from $wpdb->posts       where post_title like '%".  mysql_real_escape_string($myTitle) . "%'"     );      However, with php 5.5. and WP 3.9.1, this causes an error because the function `mysql_real_escape_string` is deprecated. Any ideas on what other function will properly escape the contents of `$myTitle` now that I can't use `mysql_real_escape_string` anymore? Thanks


Import RSS as posts with redirect?

I'm looking for a way to import RSS items from an **external blog** as posts _with a redirect_ on them. The purpose is to have another blog's posts show up in my front page excerpts but actually deliver the user to the source blog upon clicking. Does anyone know of a simple way to accomplish this?


Are there functions for file paths, instead of just urls

Is there any equivalent to functions like `plugins_url()` and `content_url()` that give you either the relative paths or the file path. For instance, instead of > http://localhost:8888/wordpress-3.2/wp-content I want: > /Users/username/Sites/wordpress-3.2/wp-content I know that I can build this path using the `ABSPATH` constant, but I'm specifically interested in learning if there are built in functions to handle this. In the meantime, I'll probably just write a function to swap the url for the abspath. EDIT: Here's the simple function that I wrote to handle this:               function get_file_path($url)     {         return str_replace(site_url(), ABSPATH, $url);     }      Seems to do the trick, but I'd much rather use built in functions if available.


Permalink issue only with numbers

I use wp-e-commerce plugin and when I write a url like "mysite.com/event/testevent" very thing is ok and wordpress shows the correct page. In case that the event is a number like "mysite.com/event/123456" wordpress shows me the products page. I follow this post but my issue continues to exist.


Displaying an ACF list of users

I've created a custom field using ACF to display the editors of a page (this may be a comma separated list of a few) including a link to their archive, but all I'm getting is a plain text 'Array'. Could someone help me get this right? For some reason I'm not finding the right info through the documentation.               if(get_field('editor')) { echo ', edited by ' . get_field('editor') . '';}     $values = get_field('editor'); if($values) { foreach($values as $value) {     echo ' ' . $value . ','; } }


Changing the ID of an option - not working (SMOF) [Solved]

Recently I decided to use the SMOF Options Framework in my WordPress theme, instead of my own options page. I think that switching it is easy, but I'm having a problem that I can't understand. First I create a new section in the array:               $of_options[] = array("name" => "Main options",     "type" => "heading");      Then I add a predefined option with a select box:               $of_options[] = array("name" => "Normal Select",             "desc" => "Normal Select Box.",             "id" => "example_select",             "std" => "three",             "type" => "select",             "options" => $of_options_select         );      At the moment, it works perfect. The problem appears when I change the ID **"example_select"** to a new name, for example **"ft_content_layout"** or any other name... The option disappears from the options page. Why is that? **Update:** Fixed! It needs a "Reset" (reseting options) every ID change.


How to auto-translate custom user roles?

I developed a small plugin that adds (or to be more precise: first deletes then adds again) some custom user roles. Each of these roles is set up in a way like this:               function wpdev_141551_add_role_someone() {              $role = 'someone';              remove_role( $role );              $capabilities = array(             'read'          => TRUE,             'publish_posts' => TRUE,             'edit_posts'    => TRUE,             'delete_posts'  => FALSE,             // ...         );              add_role( $role, 'Someone', $capabilities );     }      Now the problem is, these custom user roles don't get translated at all. The translations of the default user roles (Author, Contributor etc.) are included in WordPress's default text domain. So how/where should I step in and translate these custom role names? If I add the role with a gettext call for its name `__( 'Someone', 'plugin- text-domain' )` then the string that gets written to the database will be translated according to the current language. What I would like to have, however, is a solution that lets me switch languages as I want and have the roles be displayed accordingly-- **without** having to de- and then reactivate the plugin (i.e., delete and add the role, again). * * * I will post my current solution to this, but I'm still **very interested in any other** (possibly more efficient) **approach**.


Personal page for every user (not just authors)

I've got a page displaying all WP users using get_users() and get_userdata(). I need an individual user page automatically (with its own slug) generated for each new user added. I'm a bit clueless about how to achieve that. Any suggestions?


Return comments_link() instead of echoing it

Is there a way to return the comments link instead of echoing it? I've been searching the Codex for a little while now, without being able to find a function that just returns the link and doesn't echo it. Thanks.


How to create single static page extending another URL

I have existing URL **game/ninja-cat-and-zombie-dinosaurs/** which is created by rewrite: **game/([^/]+)(/[0-9]+)?/?$** It leads to a custom post type (defined by theme Swatch). Now I'd like to have a URL **game/ninja-cat-and-zombie-dinosaurs/fullscreen** which will lead to totally different page - how should I do that?   1. Create game/ninja-cat-and-zombie-dinosaurs/ directories on server and put fullscreen.php file there? Ugly and hacky   2. I learned about special function, example use: `add_rewrite_rule('^game/([^/]+)(/[0-9]+)/fullscreen$','index.php?page_id=55','top');` In this case should I create wp page and pass here its id? Problem is that I don't want to have that page visible in other places and for that probably I would need to install plugins that would hide it etc.   3. If not through custom rewrite, perhaps easier is use GET parameter game/ninja-cat-and-zombie-dinosaurs?fullscreen and inside page check whether there is fullscreen parameter, and if so, present different page? I just need it for single page (static custom .html file, so don't even need/can to make it through WP probably), no need for having it be scalable.


Are Custom Taxonomy Templates Possible?

I am trying to have some information specific to a taxonomy term appear above that taxonomy's archive list. Example: Taxonomy is 'Sports', with football, soccer, and baseball being terms within the 'Sports' taxonomy. I would like to have a small description of each sport display above that term's archive page. In researching this possibility, I have read the Category Templates page, found a plugin that appears to do what I want, but only with regard to Categories and not custom taxonomies. I would do it with Categories, but I have multiple taxonomies now and cannot use the simple categories solution any longer :( Am I being dense, or are custom taxonomy templates not possible?


Bulk Image Upload And Rerrange Functionality

I am looking for a solution, it can be pre-existing plugin or code I put into my functions.php file that will allow me to batch upload images to a post, and then have the ability to rearrange the positioning of them. I know Wordpress by default allows you to batch upload images, so I am presuming the solution will use that functionality. But to my knowledge it doesn't let you adjust the order of which they are attached to the post. The reason I need to be able to have the option of rearranging bulk-uploaded images, is because on the front-end, images are shown sort of like a mosaic where multiple images make up one larger image in the form of grid. **The scenario** :   * A user creates a new post.   * A user then clicks on a button which shows the media uploader and allows them to upload a whole bunch of images at once.   * The images are processed and then associated with the post.   * The user is then able to rearrange the order of the attached post images which will then be displayed in that particular order on the homepage in a WP post loop. Thank you in advance for your assistance.


How make a php script run only with wp-cron

I have a php script that executes a function and creates an xml file with results. I want this script runs only once daily and i'm using wordpress cron to do this. Problem is this script always runs on all pages load and this is bad because it takes more than 30 sec to complete. How can i stop it always runs and make it works only with wp-cron ? I read about cronjob but my host hasn't this feature. This is the code i use at top of my php file :                add_action( 'my_cron_hook', 'myfunction' );          if( !wp_next_scheduled( 'my_cron_hook' ) ) {      wp_schedule_event( time(), 'daily', 'my_cron_hook' );     }          register_deactivation_hook( __FILE__, 'my_deactivate' );          function my_deactivate() {      $timestamp = wp_next_scheduled( 'my_cron_hook' );      wp_unschedule_event($timestamp, 'my_cron_hook' );     }      I want script runs daily and always in background , it should not affect user navigation. Thanks. Edit. This is all code script :                add_action( 'cO_cron_hook', 'remoteHeader' );           if( !wp_next_scheduled( 'cO_cron_hook' ) ) {      wp_schedule_event( time() + 24 * 60 * 60, 'daily', 'cO_cron_hook' );      }           register_deactivation_hook( __FILE__, 'bl_deactivate' );          function bl_deactivate() {     $timestamp = wp_next_scheduled( 'cO_cron_hook' );     wp_unschedule_event($timestamp, 'cO_cron_hook' );     }          set_time_limit(300);          function remoteHeader($url){     $online = 'online';     $offline = 'offline';     $agent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0)";     $ch = curl_init();     curl_setopt ($ch, CURLOPT_URL,$url );     curl_setopt($ch, CURLOPT_USERAGENT, $agent);     curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);     curl_setopt ($ch,CURLOPT_VERBOSE,false);     curl_setopt($ch, CURLOPT_TIMEOUT, 10);     curl_setopt($ch, CURLOPT_NOBODY, 1);     curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, FALSE);     curl_setopt($ch,CURLOPT_SSLVERSION,3);     curl_setopt($ch,CURLOPT_SSL_VERIFYHOST, FALSE);     curl_exec($ch);     $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);     curl_close($ch);     if($httpcode >= 200 && $httpcode < 400) return $online;     else return $httpcode;     }          /* create a dom document with encoding utf8 */     $domtree = new DOMDocument('1.0', 'UTF-8');          /* create the root element of the xml tree */     $xmlRoot = $domtree->createElement("xml");     /* append it to the document created */     $xmlRoot = $domtree->appendChild($xmlRoot);          $currentSite = $domtree->createElement("site");     $currentSite = $xmlRoot->appendChild($currentSite);          /* you should enclose the following two lines in a cicle */     $site = remoteHeader("http://google.com/");     $currentTrack->appendChild($domtree->createElement('google',$site));          $site2 = remoteHeader("http://wordpress.com/");     $currentTrack->appendChild($domtree->createElement('wordpress',$site2));          ...          header("Content-Type: text/plain");     /* get the xml printed */     echo $domtree->save('mytest.xml')


Data sanitization for user registration and user login

What kinds of data sanitization I have to do if I make a front end login and registration system for wordpress users?   1. For login function `wp_signon()` should I escape the data for possible sql injection or wordpress will automatically do it for me?   2. For registration I have found two function so far `wp_insert_user()` and `wp_create_user()` and for updating user `wp_update_user()` For the registration function I think `wp_create_user()` will do the job for me. Again how much sanitization should i do? Do i need to do the password hashing? Also i have found some filters on the function reference page of the `wp_create_user()`. Those are `pre_user_user_pass`, `pre_user_user_login`, `pre_user_user_nicename` etc. Do, I need to use those filter before insert a new user?


How can I find the source of slow queries in Wordpress?

I have a WordPress site with more than 8000 posts and everytime I add a new one the site becomes unresponsive. I checked the MySQL slow queries log and found out that it is performing a select that returns most of the rows in the posts table and is taking a lot of time to execute. This is an example:               Query_time: 149.702704       Lock_time: 0.000078       Rows_sent: 4699       Rows_examined: 9398       Rows_affected: 0       Rows_read: 4699     use 488726_wp;          SELECT `ID`, `post_author`, `post_date`, `post_date_gmt`, `post_status`, `post_name`, `post_modified`, `post_modified_gmt`, `post_parent`, `post_type`         FROM `wp_posts`              WHERE ( (post_status = 'publish' AND (post_type = 'post' OR post_type = ''))                   OR  (post_status = 'publish' AND post_type = 'page') )               AND post_password=''              ORDER BY post_modified DESC;      How can I find the source of these queries?


Check if current user has post in post type and is author role

I want to check to see if the current user has already submitted a post in our custom post type and if they have, and they have the author role then add inline style to the header to hide some things.. Here is what Im trying but it isn't working and I can't seem to figure out why?               function chelsea_user_has_posts($user_id) {       $result = new WP_Query(array(         'author'=>$user_id,         'post_type'=>'ait-dir-item',         'post_status'=>'publish',         'posts_per_page'=>1,       ));       return (count($result->posts)!=0);     }          function cross_check_user_items() {       $user = wp_get_current_user();       $chelseaRole = get_the_author_meta('user_level');       if ($user->ID)         if (chelsea_user_has_posts($user->ID) && $chelseaRole == 1) {           echo '<style type="text/css">                    #adminmenuwrap ul#adminmenu li#menu-posts-ait-dir-item.wp-has-submenu ul.wp-submenu li:nth-child(2), body.post-type-ait-dir-item div.wrap h2 a.add-new-h2, #woocommerce-product-data.postbox div.inside div.panel-wrap ul.product_data_tabs li:nth-child(8) {display:none !important;}                  </style>';       } else {         //show them the goods       }     }     add_action('admin_head', 'cross_check_user_items');      All of this of course is in my functions.php file Thanks for looking :-)


Media/attachment urls don't redirect with fake URL structure

I'm having an issue with media/attachment files and I'm not quite sure how WordPress is returning the URL that it does. I've noticed that I can add anything as a subdirectory structure before a media slug and WordPress will return a 200 header and somehow direct to the correct media. For example:               http://mysite.dev/asdfasdfadsfasdf/media-slug      When the correct URL should be:               http://mysite.dev/media-slug      The incorrect URL returns a 200 HTTP header and the attachment template loads fine even with the correct file. I thought this was happening as a result of something in the canonical.php file but after quite a bit of testing and even deleting everything in that file (in a test environment), WordPress is still doing this. If I do this for regular posts WordPress returns a 301 and redirects to the actual post URL, which is what I would have expected. Anyone know what is different about media? This is happening on a site where a lot is going on but I also tried it on super basic WP install in a test environment. Permalink structure is set to:               /%postname%/      Is this permalink setting part of the problem?


Custom menu: Link names

I would like to build a wordpress theme with a custom menu (no dropdowns, nothing fancy). I am trying to get `wp_nav_menu` do what I want, but I can't quite see how to achieve the following. I would like to give the menu items different names, i.e. if I have a page called `Classes`, I would like the link in the menu to be called `clAssEs` (which I will style to be rendered in a different font). Should I use custom fields for this? P.S.: Looking at the html output, the classes of my menu list items are `page_item` and `page-item-21`. Does this mean I am doing something wrong? This looks more like it is generated by `wp_page_menu`. I am calling `wp_nav_menu` with               <?php wp_nav_menu(array(       'theme_location' => 'main-menu',       'menu_class' => 'menu',       'container_id' => 'none',       'fallback_cb' => 'wp_page_menu'     )); ?>


$wpdb query a post type within a specific taxonomy term while ordering posts by custom meta value?

I have a custom post type 'event', a custom meta field 'event_date' and a custom taxonomy 'locations'. I want to query $wpdb to retrieve posts in this way   1. posts must be of the 'event' post type   2. 'events' must be associated with a certain $location term within the 'locations' taxonomy   3. results have to be ordered by the 'event_date' custom meta value (which is actually a date in yymmdd format), compared with today's present date I'm trying with the following query parameters (I can get the $location value - either ID or slug - correctly and pass to this query):               SELECT  $wpdb->posts.*      LEFT JOIN $wpdb->postmeta ON($wpdb->posts.ID = $wpdb->postmeta.post_id)     LEFT JOIN $wpdb->term_relationships ON($wpdb->posts.ID = $wpdb->term_relationships.object_id)     LEFT JOIN $wpdb->term_taxonomy ON($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)     LEFT JOIN $wpdb->terms ON($wpdb->term_taxonomy.term_id = $wpdb->terms.term_id)     FROM    $wpdb->posts, $wpdb->postmeta     WHERE   $wpdb->posts.ID = $wpdb->postmeta.post_id      AND     $wpdb->terms.term_id = $location     AND     $wpdb->term_taxonomy.taxonomy = 'locations'     AND     $wpdb->posts.ID = $wpdb->postmeta.post_id      AND     $wpdb->posts.post_type = 'event'     AND     $wpdb->posts.post_status = 'publish'      AND     $wpdb->postmeta.meta_key = 'event_date'     AND     $wpdb->postmeta.meta_value > NOW()     ORDER   BY $wpdb->postmeta.meta_value ASC     LIMIT   $numberofposts      the query is not working; if I remove the JOIN part and the taxonomy part, it will work, ordering all the results by comparing 'event_date' meta with NOW() date. I guess I'm doing it wrong with the taxonomy part... As advised, I tried to do a WP_Query rather than a $wpdb query:               $args = array(                    'post_type' => 'event',                    'tax_query' => array(                                          array(                                                 'taxonomy' => 'locations',                                                 'field' => 'id',                                                 'terms' => $location // location term id                                                )                                         ),                    'meta_key' => 'event_date',  // this meta field stores event date in yymmdd format                    'meta_value' => $today,  // this would be today's date in yymmdd format                    'meta_compare' => '>=',                    'posts_per_page' => $numberofposts, // this variable stores the number of posts I want to get                    'orderby'=> 'meta_value_num'                 );      However, in this latter case, the query will return ALL the posts under the specificed post_type, regardless of any other specification within $args including the sorting order I've tried using meta_query instead of meta_key but result doesn't change


Replace all of post's image URLs with upload directory URLs

On a WordPress website for a client, he's going to be posting articles with quite a lot of images in. When the post is saved/published, we need to be able to download/save these images to the server, and then instead of showing the original URLs, show the URLs of the image as in the uploads directory. I've chosen to do this by writing a function in `functions.php` and then adding it as a filter. Here is the code I've written so far:               function getpostimgs() {       global $post;        $postContent = $post->post_content;            preg_match_all( '/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $postContent, $matches );       // match all images in post, add to array and then       // get first array (the one with the image URLs in)       $imgURLs = $matches[1];            $upload_dir = wp_upload_dir(); // Set upload folder            foreach ( $imgURLs as $imgURL ) {         $image_data = file_get_contents( $imgURL ); // Get image data         $filename = basename( $imgURL ); // Create image file name         // check upload file exists and the permissions on it are correct         if( wp_mkdir_p( $upload_dir['path'] ) ) {           $file = $upload_dir['path'] . '/' . $filename . "-" . $post->ID . ".jpg";         } else {           $file = $upload_dir['basedir'] . '/' . $filename . "-" . $post->ID . ".jpg";         }         // save file to server, with the filename of the image and then the post ID.         file_put_contents( $file, $image_data ); // save the file to the server         // find the occurence of each URL (within the post content)         // that was in the array and replace them with the file link                 preg_replace( "*" . $imgURL . "*", $file, $post->post_content );       }     }          add_action('content_save_pre', 'getpostimgs');      I've written some comments so hopefully the lines are explained enough for you to understand what's going on. The problem is, when it's saved (using `content_save_pre`, so that it's filtered before being saved to the database), it simply wipes all the content. The files are being saved and I know the value of `$matches[1]` is correct (i.e the right image links are there), as I've checked it with `var_dump()`. So there's something wrong with the `preg_replace`. Even if take out all the file stuff and just leave the `preg_replace` with a simple replacement string (e.g "Hello world"), it still doesn't work (still just wipes all the post content). Does anyone know why? Thanks for helping out, hopefully I've been clear enough, happy to provide any more info or make it clearer :)


Is it possible to import all files from a uploads DIR into WP media, retaining paths to the files

So i have a uploads DIR from a WP install. I want to migrate that to my new site, retaining all the old paths - so if something is in 2011/08 that path is kept and the file registered in the media section of WP admin


Remote database -> massive response time increase?

I have nginx web server running newest WordPress and DB server running MySQL 5.6 There is around 90-100ms latency(round-trip delay) between those 2 servers. The problem is that It takes about 5000 ms to get response from my web-server if I access DB remotely.(The connection is encrypted by SSL) In comparison it takes about 200 ms if I access MySQL locally(web-server & MySQL installed on one single machine). 1. Why is that ? Is it because WP has multiple MySQL queries per page and waits for each and every one to complete ? Therefore it adds up : 100+100+100+100..=5000ms ? 2. Can WP be modified to request from MySQL asynchronously, in order to reduce waiting time for request to be successful? Thank you. :)


Help adding image upload functionality to widget

I am working on a small WordPress widget and I am trying to set it up where the user can upload an image. So far, the necessary scripts are loading but when I click the "Media Library Image" button the image uploader doesn't pop up. Here is my javascript file:               jQuery(document).ready(function($) {          var formfield = null;          $('#upload_image_button').click(function() {         $('html').addClass('Image');         formfield = $('#wp-ss-image').attr('name');         tb_show('', 'media-upload.php?type=image&TB_iframe=true');         return false;     });               // user inserts file into post. only run custom if user started process using the above process     // window.send_to_editor(html) is how wp would normally handle the received data          window.original_send_to_editor = window.send_to_editor;     window.send_to_editor = function(html){         var fileurl;              if (formfield != null) {             fileurl = $('img',html).attr('src');                  $('#wp-ss-image').val(fileurl);                  tb_remove();                  $('html').removeClass('Image');             formfield = null;         } else {             window.original_send_to_editor(html);         }     };          });      Here is are my functions to call the scripts:               add_action('admin_print_scripts-widgets.php', 'wp_ss_image_admin_scripts');          function wp_ss_image_admin_scripts() {         wp_enqueue_script( 'wp-ss-image-upload', plugins_url( '/WP-Simple-Social/wp-simple-social-image.js' ), array( 'jquery','media-upload','thickbox' ) );     }          add_action('admin_print_styles-widgets.php', 'wp_ss_admin_styles');          function wp_ss_admin_styles() {         wp_enqueue_style( 'thickbox' );     }      And here is the html to display the input box and image upload button:               <p>Upload Photo: <input id="wp-ss-image" class="widefat" type="text" size="75" name="<?php echo $this->get_field_name( 'image' ); ?>" value="<?php echo esc_url( $image ); ?>" />             <input id="upload_image_button" type="button" value="Media Library Image" class="button-secondary" />      Since all of the necessary files/scripts are loading, could this be a jQuery problem? If there is any other additional info that would help out please let me know. Thanks for the help.


Wordpress Front-End Theme Editor

I would like to change my option panel to the front-end. So user can see whats happening with the site. Changes must be real-time. Searched allover but cant find a way to solve this.


How can I detect hierarchal relationships beyond children (grandchild, great-grandchild, etc)?

Often times, a custom theme for Wordpress will require a dynamic content that reflects a relationship to a top level page of a site. Is there a Conditional Tag that will check if the current page is a grand- child (or separated by further generations) by ID?


echo current taxonomy id for this loop?

I have this query to get posts and show like this:               Custom taxonomy 1     <div ID1>      |-- post 1      |-- post 2     </div>        Custom taxonomy 2     <div ID2>      |-- post 3      |-- post 4     </div>      Now I need to get the current taxonomy ID for each section and insert to < div **ID** >. How to request & echo the ID in this code?               <?php            $taxid = get_the_terms( $post->ID , get_cat_slug() );         if($taxid) {             foreach( $taxid as $xid ) {                 echo $xid->term_id;             }         }       // for a given post type, return all         $post_type = get_post_type();         $tax = get_cat_slug();              $tax_terms = get_terms(             $tax, array(                 'hide_empty' => 1,                 'orderby' => 'name',                 'order' => 'ASC',             ));              if ($tax_terms) {             foreach ($tax_terms as $tax_term) {                 $args = array(                     'post_type' => $post_type,                     "$tax" => $tax_term->slug,                     'post_status' => 'publish',                     'caller_get_posts' => 1,                     ); // END $args                      $my_query = null;                 $my_query = new WP_Query($args);                      if ($my_query->have_posts()) { ?>                          <div id="ID"> <!-- I need ID insert here -->                          <?php while ($my_query->have_posts()) : $my_query->the_post(); ?>                       <!-- I need ID insert in HTML here -->                     <?php endwhile; ?>                     </div>                      <?php } // END if have_posts loop                 wp_reset_query();             } // END foreach $tax_terms         } // END if $tax_terms              ?>      Thank you very much


Suggestions: Customizable header image and style colors that are different for each page

I'm working on a project where each page should have a custom header image and custom style colors (borders, etc). So that I don't have to be the one creating a brand new style everytime a page is created, I'd like a way in the admin area for someone else to edit the image and colors. My first thought is to use the custom fields, and they can put in the image URL and HEX codes. But that may be over the head of the people who will be creating the pages. I'm just looking for some direction on how to accomplish this. Thanks!


How to solve this problem with my subdomain?

I have my site hosted at http://blog.rgksugan.in. I have set a subdomain in it for my blog. But after landing on my blog whatever other links I click i get the link as http://rgksugan.in/blog/wordpress/stack-overflow/. I want it to be http://blog.rgksugan.in/stack-overflow What should I do...?


wp_get_nav_menu_items() returns an empty array under tags archive

I have three nav menus and for some reason under tags archive wp_get_nav_menu_items('MenuName') returns an empty array. Frontpage, posts, pages are OK, but when you go into tags archive, no items are returned. Here is my code in functions.php:               function vp_get_nav_items() {              $items = array();              $items['foo'] = wp_get_nav_menu_items('foo');              $items['bar'] = wp_get_nav_menu_items('bar');              $items['xoo'] = wp_get_nav_menu_items('xoo');              return $items;          }


How to display sql query that ran in query?

I have come across a function before that displayed the exact SQL code that was used in a loop for example, but can't remember. Can anybody tell me that function? Cheers


Forcing oembeds to top of post

What's the best way to force oembed (or shortcodes too) to the top of a post? I'd like to feature youtube embeds before the actual article content, regardless of where the link was inserted. Any ideas?


WordPress Post - On Post - 404 Page Not Found

I was helping a friend with a website. Every thing seem to work fine. I set up some demo content manually. But today some thing wired happened. When we try to do a post it returns to a 404 not found page. The only thing we recorded doing are deleting posts and trying to add new posts. Scenario: Post a Post   1. Login   2. Write a post   3. 'Publish' -> `404` page @ route -> `wp-admin/post.php` Scenario: Upload media   1. Login   2. Media -> new   3. Drag/drop image   4. HTTP Error (in red) I tried:   1. Disabling plugins   2. Changing the theme   3. Adding the following to .htaccess > # BEGIN 404 Fix > > SecFilterEngine Off SecFilterScanPOST Off > > # END 404 Fix But it didn't fix. Just noticed, the same problem persists with another blog hosted in the same account. May be a host issue? Updates: Old fashion upload : wp-admin/media-new.php (OK) Old fashion upload (POST) : wp-admin/media-new.php => 404 Page publish: wp-admin/post.php (GET => OK, POST => not ok - 404) I think it is filtering out any attempt to post. But the odd thing is, any post gets saved ( as draft ).


wp_enqueue_scripts hook is not being called

I added the following code to my `functions.php`:               if(!function_exists('bi_frontend_scripts')) {         function bi_frontend_scripts() {             wp_enqueue_script('jquery');             // I originally wanted to do:             wp_enqueue_script('jQuery.bxSlider', get_bloginfo('template_url').'/scripts/jquery.bxslider/jquery.bxslider.min.js', array('jquery'));         }     }     add_action('wp_enqueue_scripts', 'bi_frontend_scripts');      But apparently neither of the scripts is being enqueued. I didn't get what my problem was, so I added this script to find out if the hook is called:               function aal_handler() {         static $list = array();         // exclude certain actions:         $exclude = array('gettext', 'gettext_with_context');              $action = current_filter();              if(!in_array($action, $exclude)) {             $list[] = $action;         }         // shutdown is the last action         if ('shutdown' == $action) {             print '<pre>' . implode( "\n", $list ) . '</pre>';         }     }     add_action('all', 'aal_handler', 99999, 99);      And in the list `wp_enqueue_scripts` does not appear. So why the hook is not called?!


prevent sub categories to show up

i created filterable portfolio using this tutorial _http://wp.tutsplus.com/tutorials/creating-a-filterable-portfolio-with- wordpress-and-jquery/_ everything working well , but it grab the sub tags and its post also not only the main tags . how i can stop this issue ?                       <?php                  $terms = get_terms("tagportifolio");                  $count = count($terms);                  echo '
';                     echo '
All
';                  if ( $count > 0 ){                              foreach ( $terms as $term ) {                                  $termname = strtolower($term->name);                             $termname = str_replace(' ', '-', $termname);                             echo '
'.$term->name.'
';                         }                  }                  echo "
";             ?>             <?php                  $loop = new WP_Query(array('post_type' => 'project', 'posts_per_page' => -1));                 $count =0;             ?>

                      <?php if ( $loop ) :                           while ( $loop->have_posts() ) : $loop->the_post(); ?>                              <?php                         $terms = get_the_terms( $post->ID, 'tagportifolio' );                              if ( $terms && ! is_wp_error( $terms ) ) :                              $links = array();                                  foreach ( $terms as $term )                              {                                 $links[] = $term->name;                             }                             $links = str_replace(' ', '-', $links);                              $tax = join( " ", $links );                              else :                               $tax = '';                           endif;                         ?>                              <?php $infos = get_post_custom_values('_url'); ?>                              <li class="portfolio-item <?php echo strtolower($tax); ?> all">
<a href="<?php the_permalink() ?>"><?php the_post_thumbnail( array(215, 215) ); ?>

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

<a href="<?php the_permalink() ?>"><?php echo get_the_excerpt(); ?>

<a href="<?php the_permalink() ?>">More Details →

                          <?php endwhile; else: ?>
Sorry, no portfolio entries for while.
                      <?php endif; ?>


pull all posts' meta key values from current category only

I am having trouble figuring out how to pull the meta key values for just one category. I can pull all the meta key values (for meta_key "city") in all categories no problem like this:                $querystr = "SELECT $wpdb->posts.*,$wpdb->postmeta.*          FROM $wpdb->posts, $wpdb->postmeta         WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id AND meta_key = 'city'";      but cannot figure out a way to limit it to a single category. Every time I try to modify the query above with various left and inner and right joins, I get back nothing useful. Any ideas? Ideally it would filter by the category page we are on, but If I need to create individual category pages, I can deal with that...


How to choose the parent category that shows when using multiple custom categories

When a post is in two or most custom categories, how can I specify the parent category name that I want to show up? An example is the custom post type "tour". It is in the following categories:   * Alaska sailing   * Alaska   * Best selling tours I want only "Alaska" category name to display and not others.


Including CSS and JS on Admin Screen of Custom Theme Options

I am creating a custom theme with a theme options page. I would like to style the options page and do not want to include inline styles. Is there any way to include an external stylesheet from say               TEMPLATEPATH . '/css/admin.css'      I have also found this chunk of code and it seems to work - link               function admin_register_head() {      $siteurl = get_option('siteurl');      $url = $siteurl . '/wp-content/plugins/' . basename(dirname(__FILE__)) . '/yourstyle.css';      echo "<link rel='stylesheet' type='text/css' href='$url' />\n";     }     add_action('admin_head', 'admin_register_head');      What is the best way?


Using Default WordPress Custom Header Image Crop Feature in a Post Type / MetaBox

I am not sure how many of you have experimented with the new custom header image functionality of wordpress 3.0 but its actually very cool (enabled by adding the function to your functions.php file). One of the key things which I find to be extremely useful is that it allows you to upload an image and on step 2 it actually places the image on the admin page and shows you a crop box based upon the header image width/height which was defined in your functions.php file. You now have the ability to move the box around or proportionally increase/decrease the size of the area you want to use. The problem that I am having here is that I would like to utilize this functionality with my own custom post type. More specifically, I am just looking for the ability to include the upload functionality, defining the width/height and the select/cropping functionality once the image was uploaded. My thoughts are that if someone can show this can be done then I can create all the other functionality I am looking for by adding this to a custom post type and associating custom metaboxes. Can anyone provide a solution here?


Importing media medium setting image gallery / image attachments

I have recently imported an image gallery to a clean WP install as I am deploying the site to a live domain. I have imported the posts but the images use the medium size for attachements. I would like to get these all to revert to the settings I had set up in the development install.      Does anyone have a idea on how to change the size on already imported image attachements? Thanks in advance, J


Theme looks ugly - FOUC - stylesheets loaded in footer

My theme looks good and it works so far, but in the first seconds of loading the whole layout looks buggy: http://andreapuiatti.de/screenshots/cssstylebug.png I think is because the css has been loaded with a delay but even positioning the wp_enqueue_style on the top of my functions.php doesn't make any difference Any Idea on how to fix that? Follows part of the functions.php               // Load Stylesheets     function addMyStyles() {              wp_register_style('reset', get_template_directory_uri().'/reset.css');         wp_register_style('style', get_template_directory_uri().'/style.css', array('reset') );              wp_enqueue_style('style');          }     add_action('wp_head', 'addMyStyles');          // Load Scripts     if ( !function_exists( 'core_mods' ) ) {         function core_mods() {             if ( !is_admin() ) {                 wp_deregister_script( 'jquery' );                 wp_register_script( 'jquery', ( "//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ), false);                 wp_enqueue_script( 'jquery' );             }         }         add_action( 'wp_enqueue_scripts', 'core_mods' );     }          function addMyScripts() {         /*wp_register_script( 'modernizr', get_template_directory_uri().'/_/js/modernizr.js', null, false );         wp_enqueue_script( 'modernizr' );*/              wp_register_script( 'jwplayer', get_template_directory_uri().'/_/js/jwplayer.js', null, false );         wp_enqueue_script( 'jwplayer' );              wp_register_script( 'bootstrap', get_template_directory_uri().'/_/js/bootstrap.js', array('jquery'), false );         wp_enqueue_script( 'bootstrap' );              wp_register_script( 'spk_slide', get_template_directory_uri().'/_/js/slides.js', array('jquery'), false );         wp_enqueue_script( 'spk_slide' );     }     //add_action('wp_enqueue_scripts', 'addMyScripts');          // Add slider to front page     function my_enqueue_stuff() {       if ( is_front_page() ) {         addMyScripts();         }     }     add_action( 'wp_enqueue_scripts', 'my_enqueue_stuff' );      SOLVED: after research I found out that that effect name is FOUC (flash of unstyled content). I just had to increase the priority of the function which is adding the stylesheets to get them added to the head section: add_action( 'wp_enqueue_scripts', 'core_mods','2' ).


wp get attachment image always gives me thumbnail

I have an image which should be output on the page. The space is limited (width-max = 209px). Now I have to provide the image in a scaled size, if the user doesn't do it. This is my code:               $src = wp_get_attachment_image_src($logo, 'full');     $width = $src[1];     $height = $src[2];     $new_width = 200;     $factor = $width/$new_width;     $new_height = round($height/$factor);     echo wp_get_attachment_image($logo, array($new_width, $new_height))      But the image used is the thumbnail image (150x150) and the width and height in the html code is 92!               <img width="92" height="92" title="my title" alt="Logo" class="attachment-200x92" src="http://www.test.com/wp-content/uploads/2012/07/logo-150x150.jpg">      In the docu it is stated that I should use `add image size` but the height can be different for each picture. Also what happens with already uploaded pictures? How can I fix this? **Solution:** `add_image_size( 'squeeze', 200, 1000, false );` and Regenerate Thumbnails did the job for me.


How to do 302 redirects "in" WordPress using Redirection plugin?

I am planning to use the **Redirection** plugin to do redirects. The plugin's description states that it also enables 302 redirects, but I can't see how. There's no option as such (see screenshot below). ![Redirections plugin screenshot](http://i.stack.imgur.com/DiV3C.png) Am I looking in the wrong place? Does anyone know how to do 302 redirects using Redirections plugin?


problems with jquery external rss feed integration

Iam using an external file (feed_home.php) wich is loaded with AJAX onclick.                       $(document).ready(function(){         $.ajaxSetup({cache:false});         $("#new a").click(function(){                  var post_id = $(this).attr("rel")             $(".featureline").html("loading...");             $(".featureline").load(jQuery(this).attr("href"))             return false;         });     });      > feed_home.php has the following code to load the amazon rss feed:                   <?php     include_once(ABSPATH . WPINC . '/rss.php');     $feed = 'http://www.amazon.de/rss/new-releases/videogames/';     $rss = fetch_feed($feed); ?><?php      if (!is_wp_error( $rss ) ) :         $maxitems = $rss->get_item_quantity(3);         $rss_items = $rss->get_items(0, $maxitems);         if ($rss_items):             echo "
\n";             foreach ( $rss_items as $item ) :                 echo '
';                 echo 'get_permalink() . '">' . $item->get_title() . "\n";                 echo '
' . $item->get_description() . "
\n";             endforeach;             echo "
\n";         endif;     endif;     ?>      The problem is, that I'm always getting this error:               include(stream.php) [function.include]:      failed to open stream: No such file or directory in      /is/htdocs/...mywebsite/feed_home.php on line 2      Without the Ajax, the Amazon Rss Feed appears. Any idea? Thank you! AD * * * Well, I think, I am getting slowly what this means: But I have no clue how to handle this. the "feed_home.php" has to have something like a minimal Wordpress surrounding, right? Has it something to do with               // Stop most of WordPress from being loaded if we just want the basics.     if ( SHORTINIT )         return false;      But how can I get it work? Thank you! AD


Getting the different post statuses + count like in edit.php, in a custom submenu page

I'm trying to create a submenu page for reordering posts/pages. Right now I'm trying to include the list that display the different post statuses, for example: `All (5) | Published (4) | Draft (1)` I was digging around in edit.php and found that it pulls the list like this: `$wp_list_table->views();` Which lead me to class-wp-list-table.php where I found this:               function views() {         $screen = get_current_screen();              $views = $this->get_views();         $views = apply_filters( 'views_' . $screen->id, $views );              if ( empty( $views ) )             return;              echo "
\n";         foreach ( $views as $class => $view ) {             $views[ $class ] = "\t
$view";         }         echo implode( " |
\n", $views ) . "
\n";         echo "
";     }      So, since it checks the current screen, would it be possible in someway to set my custom submenu item to "pose" as edit.php although it's not? Or if there's some easier way to do this. Thanks alot in advance


get backend to front end

im trying to mashup this german have gotten it to work with tinymce im trying ti mash it up with this get posting from to the front end would be glad if someone has done similar things or guide me in some direction


hide/protect original full-size images

I was hoping it would be possible to save original images to a separate directory to the resized images so that they could be safely hidden but this seems to be too difficult. So I am now asking if there are any ways of protecting original full-size images from public but still allow them to view the re-sized images. I'm not talking about hiding/protecting images on screen, moreover ways of giving original images _unguessable_ url's or some such scheme to stop them from possibly being downloaded. ie. `uploads/my_image-200x200.jpg` (given this url) `uploads/my_image.jpg` (this url can be easily worked out)


Why links are not linked if edited comment?

I am using the plugin `front end editor` to edit posts.. This works very well in posts, where all links are perfectly visible if I have edited a post. For some reason, if I edit a comment and there are links in the post, I can't see the links and can't click on them because it's not linked. I must refresh the page to see the comment linking to where they were linking... Is there a solution without having to refresh the page? Why is this happening at all?


CRM and newsletter integration?

I already use WordPress to create an online catalog and web presence. Now, a little box tells people to enter their email, and they will receive an email when a new product is added to the site (which is useful). Now, having entered the emails manually or asking people to enter it, I would like to have a little CRM for managing those mails, getting the names, phones, emails, addresses, and references (why they are in the database) - all in WordPress. So when new content is added, or when I would like to send all those people info (mass mailing), I can use the same system as for managing my site. What solutions have you tried and used for this?


How to extract data from a post meta serialized array?

I found an XML to WP decoder script that stores the data as an array in a custom meta field. What is the best way to extract the information? For example how could I display the "Manufactured in" field as "CANADA"? `[_ttn_i_details] => Array ( [0] => a:5:{s:9:"engine_id";a:1:{i:0;s:9:"300000225";}s:15:"transmission_id";a:1:{i:0;s:6:"257691";}s:5:"plant";a:1:{i:0;s:23:"Oshawa, Ontario, Canada";}s:15:"Manufactured in";a:1:{i:0;s:6:"CANADA";}s:22:"Production Seq. Number";a:1:{i:0;s:6:"151411";}} )` The example code above was produced via `print_r(get_post_custom($post->ID));`. I really appreciate any insight, no matter how small. :)


Trigger "unsaved changes" dialog for custom post meta changes

I'm using a custom post type with custom meta fields, but autosave and the "unsaved changes" dialog don't seem to be triggered for these custom meta fields. Autosave isn't as important to me as the unsaved changes dialog - is there a way to trigger it?               function add_meta_boxes() {         add_meta_box('places_location', __('Location'), array(&$this, 'location_box'), 'place', 'normal', 'high');     }          function location_box($post) {         wp_nonce_field(plugin_basename(__FILE__), 'places_location_nonce');              $lat = get_post_meta($post->ID, 'places_lat', true);         $lng = get_post_meta($post->ID, 'places_lng', true);              ?>         <p>             <label>                 Latitude:                 <input name="places_lat" value="<?php echo esc_attr($lat); ?>" />             </label>             <label>                 Longitude:                 <input name="places_lng" value="<?php echo esc_attr($lng); ?>" />             </label>         </p>         <?php     }          function save_place($id) {         // skip unverified location nonces         if(!wp_verify_nonce($_POST['places_location_nonce'], plugin_basename(__FILE__))) return;              // skip autosave calls         // commenting this out still doesn't trigger saving these fields on autosave         //if(defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return;              // update our custom post meta         update_post_meta($id, 'places_lat', (float)$_POST['places_lat']);         update_post_meta($id, 'places_lng', (float)$_POST['places_lng']);     }


Removing the first 8-10 letters from a post?

I have a widget that shows all the post names. All the post names are "Chapter ## - Title" I would like the php in the widget to remove the "Chapter 1 -" or "Chapter 12 -" for example so that just the part after the Chapter is left....


How to add "alt" attribute for image during upload at WP front-end?

At WP Front-end I create a upload form for users. That form has three input fields (title, tags and upload). So I want to add " **Title - Tag - file_name** " as `alt` attribute for images during the file upload. How can I do with my code below?               if ($gui == 'upload') {         if (!function_exists('wp_generate_attachment_metadata')){             require_once(ABSPATH . "wp-admin" . '/includes/image.php');             require_once(ABSPATH . "wp-admin" . '/includes/file.php');             require_once(ABSPATH . "wp-admin" . '/includes/media.php');         }         if ($_FILES) {            foreach ($_FILES as $file => $array) {                if ($_FILES[$file]['error'] !== UPLOAD_ERR_OK) {                   return "Upload Err: " . $_FILES[$file]['error'];                }                $attach_id = media_handle_upload( $file, $newPost );            }                                }        if ($attach_id > 0){            //and if you want to set that image as Post  then use:            update_post_meta($newPost,'Uploaded_Image_ID',$attach_id);        }     }


How to set options on a sub blog in a multisite environment?

How would I set options for a specific multisite blog? Do I switch blogs, call `add_option`, and then switch back? Also, can I set options for a site if it hasn't been activated yet? Code:               switch_to_blog($blog_id);     update_option($id, $value);     switch_to_blog($blog_id);


Show post count in wordpress instead of page count in wordpress pagination

Iam using wordpress numbered pagination function, it works good I have around 800 posts on homepage, every page i show 8 posts. So when the user clicks on pagination i want to show 1-8 of 800. 1st post out of 8 total 800 then user clicks 2nd page - i want to show 9-16 of 800 how to implement i researched a lot.


Width 100%: Aspect ratio of image

If I add an image to a post, WordPress hardcodes `width` and `height` attributes to the `img` tag. I added `max-width:100%` to my CSS, but of course, if my browser window gets smaller, the resized image gets stretched in height. What can I do about it? Is there a way to: **A** : Solve it with CSS (I would prefer that)?   **B** : Forbid WP to hardcode width and height?   or   **C** : Is there a common way of dealing with image widths, I'm not aware of?


2 loops in archive.php (one for each category)

I have a custom post type set up for a news blog on a site I'm building, the custom post type being `blog` consisting of 2 categories, `blog-image-post` ID=`3` and `blog-text-post` ID=`4`. I want to loop each category separately as each one is displayed and styled slightly differently in the archive. I currently have this:
               <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

          <?php endwhile; endif; ?>             <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

                     <?php the_title(); ?> etc etc

          <?php endwhile; endif; ?>
      The first loop would be for `blog-image-post` ID=`3` and the second loop for `blog-test-post` ID=`4`, I'm not sure if this is at all possible? Can't figure it out, any suggestions would be greatly appreciated!


Custom Excerpts Per Page

I'm trying to set up a specific page to use a specific number of characters in an excerpt. I tried using this code, but it broke the site:               function wpse61271_custom_excerpt_length( $length )      {         if (             is_front_page()            XOR is_home()         )            return 50;              // return default length         return $length;     }     add_filter( 'excerpt_length', 'wpse61271_custom_excerpt_length', 999 );      Is there an alternate bit of code that could work better? EDIT: Here's the full loop, in case that helps:               <?php while ( have_posts() ) : the_post(); ?>                             <a href="<?php the_permalink(); ?>">
<?php the_title(); ?>

<?php the_post_video(); ?>

                                 <?php                                     function wpse61271_custom_excerpt_length( $length )                                      {                                         if (                                             is_front_page()                                            XOR is_home()                                         )                                            return 50;                                              // return default length                                         return $length;                                     }                                     add_filter( 'excerpt_length', 'wpse61271_custom_excerpt_length', 999 );                                 ?>
<a class="button" href="<?php the_permalink(); ?>">Read More

                         <?php endwhile; ?>                         <?php if(function_exists('wp_paginate')) {                             wp_paginate();                         } ?>


WP_Query loop doen't work with my custom taxonomy

My loop don't display my all relevant posts, It's should display the all posts which started w/specific letter (if it " " then it's should display the all posts sorted by popularity) what's wrong w/it?                $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;      if ($first_letter!=' ') { $args = array (             'posts_per_page' => $posts_per_page,             'taxonomy' => $term->taxonomy,             'term' => $term->name,             'post_type' => $post_type,             'orderby' => 'title',             'order' => 'ASC',             'paged' => $paged); }         else {$args = array (             'posts_per_page' => $posts_per_page,             'taxonomy' => $term->taxonomy,             'term' => $term->name,             'post_type' => $post_type,             'meta_key' => 'post_views_count',             'orderby' => 'meta_value_num',             'showposts' => 160,             'order' => 'DESC',             'paged' => $paged); }           $the_query = new WP_Query( $args );           $mam_global_where = ''; // Turn off filter      if ( $the_query->have_posts() ) {         $in_this_row = 0;         while ( $the_query->have_posts() ) {             $the_query->the_post();             if ($first_letter!=' '&&$first_letter!='') { $first_letter = strtoupper(substr(apply_filters('the_title',$post->post_title),0,1));}             if ($first_letter != $curr_letter) {                 if (++$post_count > 1) { end_prev_letter(); }                 start_new_letter($first_letter);                 $curr_letter = $first_letter;                 }             if (++$in_this_row > $posts_per_row) {                 end_prev_row();                 start_new_row();                 ++$in_this_row; // Account for this first post                 } ?>         <a href="<?php the_permalink(); ?>" rel=.....
          <?php }      end_prev_letter();


count the number of views of a post excluding own views

I am using WP Post Views plugin to display the post number of views. To do so, I use:               <?php if(function_exists('the_views')) { the_views(); } ?>      This plugin gives 3 choises in its setting :   * Count Views From Everyone   * Count Views From Guests only   * Count Views From registered users only My website is a private community of authors. I have created some badges that are awarded automatically if some conditions are met. For example, I award a badge to an author when its post attain a certain number of views by the other members of the community. (I use `add_action( 'update_post_meta', 'award_badge'` on the meta field updated by `the_views();` ) **The problem** is: The plugin I am using can increment the number of a post views if the author himself see it. It will be good if the number of views increase only when other authors see the post. I hope my explanation is clear enough. I thank you for your time. **Questions:** Is there a plugin that provides this feature of excluding its own post visits from views count? Is there a piece of code that can be a starting point for me to create a post count views plugin? You usual help is appreciated. **Edit after S_Ha_Dum comment:** The link to the code source is :http://plugins.trac.wordpress.org/browser/wp- postviews/trunk/wp-postviews.php


Should WordPress Add Options to Enhance Security or Leave it to plugin developers?

Based on the passion engendered with the responses to this question. It appears that the answer is a resounding "Nothing!" or "leave it to plugin developers to handle, WP is already secure enough"... So I guess I'm way off base with the question? It appears to have stirred a hornet's nest and that was not the intent. Never the less, here's the real world outcome... I just got an email from one of my customers who had 12 of his sites hacked because an attacker cracked his password. His comments opened my eyes a bit to the possibilities for some very easy options that could be added to the WordPress core in order to help make WP sites less prone to these kinds of attacks. The simplest thing a user can do is to change the default username. I would guess that over 90% of live WP sites have an "admin" user profile that may or may not be used, but that obviously has full rights and permissions. An attacker's job is already half done! But WP core could be enhanced with some very simple security options too. How hard would it be to add...   * Failed login attempts lockout (user defined setting)   * Regulate the time between failed login attempts (user defined setting in seconds)   * IP range restriction (set a list of IPs from which logins are accepted) These are just a few things off the top of my head. I'm sure you guys have some better options too. And the point of my question is not what "users" should do to enhance security, that's a whole other question. I'm asking what steps WP could take to provide some OPTIONS, nothing mandatory, but things that plugin developers are currently having to fill gaps where stuff should be part of every default WP installation (IMHO). Are any of these kinds of enhancements planned for near term WP releases?


Drop down menus css in custom menus

I have created some pages and some pages have children.When i go to the wp admin menu,i create new menu and drag all the pages,including ones with children pages.I notice that the menus are all displayed without the cool drop downs i had hoped to see. Does it mean that menus created in the wp admin cannot have drop down menus?.


Is it possible to load an admin page inside a thickbox?

I'm currently trying to load a custom made admin page inside a thickbox. It's for creating new users with loads of extra custom data and none of the stuff I don't care about. Administrators can navigate to this page manually and outside of a thickbox and the user gets created fine. But displaying it inside a thickbox is proving to be very difficult. The reason I need it displayed inside a thickbox is because it will automatically assign the new user to a custom post type I've made called 'office' when the new user is created via this thickbox. I think it needs to make a remote request, however the request times out even when I increase the timeout argument to 30 seconds. At first I thought it was due to the fact I was submitting a remote request to get an admin page without authentication, so I tried getting the site homepage on the frontend and still got the same timeout error. For those of you that prefer to read/edit my code elsewhere, you may do so via this link - http://www.writeurl.com/text/65akmve9a5ofi7vbr4k0/8qma3hz8r0g9lgae5usp/ci2ipat23le7u66zl9c, otherwise I have included the same code below.               # link to call action to load addNewUser thickbox     printf(         '%s',         get_admin_url(             get_current_blog_id(),             "admin-ajax.php?action=addNewUser&width=640&height=400"         ),         __('Add New User')     );          # action when link is clicked     function getAddUserAdminPage() {         $newUserPage = wp_remote_get(             add_query_arg(                 array(                     'page' => 'newUser',                     'postID' => get_the_ID()                 ),                 get_admin_url(                     get_current_blog_id(),                     'users.php'                 )             )         );         echo is_wp_error($newUserPage) ? $newUserPage->get_error_message() : wp_remote_retrieve_body($newUserPage);         die();     }     add_action('wp_ajax_addNewUser','getAddUserAdminPage');


Complex menu structure with 6 custom post type hierarchy

We chosen to use Wordpress to this client but we have not work with a menu structure like this one on Wordpress.      **Those content types i what we have created as custom post type. Is listed below:**   * Magazine   * Magazine article   * Blog   * Blog article   * Content article   * Form   * Navigation    **The first level in the menu is static:**   * Magazine   * Info   * Search    **Levels on Magazine:**   * Magazine (Magazine post type)     * Link to another Magazine (Magazine post type)       * Link to articles the Magazine contents (Any article post type)     * Link to Magazine archive (Navigation post type)       * Link to Magazine (Magazine post type)         * Link to articles the Magazine contents (Any article post type)    **Levels on Search i think it gives itself.**    **Level on Info:**   * Info (Navigation post type)     * Take a education (Navigation post type)       * PHD (Navigation post type)         * Study Form (Content article post type)       * Change of address (Form post type)     * News (Navigation post type)        * Jobs (Blog post type)         * Post (Blog article post type)     * Contact (Content post type)     * Student ID (Form post type)    This is a small amount of the Info levels to show you have i should work. And the client must be able to add a new level like a new navigation to the Info. And the client must be able to sort the menu exclude level 1.    We use a Wordpress plugin with name post 2 post to connect post types between each other. And a article can be link to more than once from different post types.    **With the post 2 post i create how the post type can be linked together and is listed below:**   * Pages can be connected to Navigation   * Blogs can be connected to Blog articles, Navigation   * Blog article can be connected to Blogs   * Form can be connected to Navigation   * Magazine can be connected to Magazine articles, Navigation   * Magazine article can be connected to Magazines   * Navigation can be connected to Magazine, Blog, Content article, Navigation, Form, Pages   * Content articles can be connected to Navigation    The problem is we don’t know how we should solve the menu at best possible way for the client and us. We have tried alot of plugins and custom code, And use alot of hours to talk about how we can solve this. But right now we are stuck with the menu and breadcrumb.    Right now the url is on root level like http://aaa.local/hire-a-graduate/ on every custom post type.    Has anybody experienced this or maybe give some advice for to make things work. Thanks in advance :)


Multisite non www domain gives registration error but should redirect to www.domain.com

I'm running wordpress multisite, and when I connect to my domain at domain.com I get the error "Greetings Site Administrator! You are currently allowing “none” registrations. To change or disable registration go to your Options page." Should I create a 301 redirect from non www to www.domain.com or is there a way to configure multisite to handle this redirect? Thanks


Wordpress Media Uploader custom Javascript not working

I encountered a strange problem with my JavaScript (jQuery) when trying to modify the behavior of my Media Uploader in Wordpress 3.5 ![Image filter selector](http://i.stack.imgur.com/3tX3L.png) This was my JQuery:               $('.attachment-filters').change(function(){         if($(this).val() === 'uploaded'){             alert("Uploaded images selected");         } else {             alert("Other option selected");         }     });      And this was the part of the media uploader i wanted to react to:               <select class="attachment-filters">         <option value="all" selected="selected">All media items</option>         <option value="uploaded">Uploaded to this page</option>         <option value="image">Images</option>         <option value="audio">Audio</option>         <option value="video">Video</option>     </select>      To my big frustration this worked perfectly in a JS fidle, however it failed miserably in my wordpress admin screen...


if file_exists not working with wp_enqueue_style

Inside a function I'm doing something like this:               $optional_css_exists = get_template_directory_uri() . "/css/optional.css";       if ( file_exists($optional_css_exists) ) {           wp_enqueue_style('options', get_template_directory_uri() . '/css/optional.css', 'style');       }      But for some reason it's not being enqueued. When I echo out $optional_css_exists, I get the correct path of the file. If I remove the if statement, the file is enqueued. Why isn't the file being enqueued when it exists and the path is correct?


How can I filter by taxonomy on a custom post type's page?

Right now I am outputting the related categories to the current displayed post type as shown below. I am using `wp_list_categories` to list out the categories and it works just fine. The only issue is that this is being displayed on archive.php and not a single post, so the Taxonomies that are being listed link to their main taxonomy archive. I would like to link to the taxonomy archive for the current post type (`$type`) as well as include the query to display that specific taxonomy. Similar to linking to `http://example.com?post_type=foo&custom_tax=bar`               <? $type = get_post_type(); ?>                     <?php                           $customPostTaxonomies = get_object_taxonomies($type);                          if(count($customPostTaxonomies) > 0)                     {                     echo '
Browse By:
';                          foreach($customPostTaxonomies as $tax)                          {                              $args = array(                                   'orderby' => 'name',                                   'show_count' => 0,                                   'pad_counts' => 0,                                   'hierarchical' => 1,                                   'taxonomy' => $tax,                                   'title_li' => ''                                 );                              $woah = get_taxonomy($tax);                             echo '
';                             //var_dump($tax);                             //var_dump($woah);                             //print_r($woah);                             echo '
'.$woah->labels->name.'
';                             echo wp_list_categories( $args );                             echo '
';                          }                     }                          ?>`


"Automatically add new top-level pages" Default

I'm looking for a way to set the default "Automatically add new top-level pages" to be checked when creating a new menu. I haven't been able to find anything on this - any help you could give me? Thanks!


I dont know how/why this happened. I was working on my site over the weekend and it was fine. When I came into the office this morning, I went to the site and got this:               Fatal error: Allowed memory size of 146800640 bytes exhausted (tried to allocate 57 bytes) in public_html/wp-includes/rewrite.php on line 1561      I searched and found some articles that offered solutions, but none of them worked for me. What I noticed that the file that is effected is usually different in each case. Mine happen to be the "rewrite.php" file. That might help. Other than that Im stumped. I know the customer complaints are coming. Hopefully I get it fixed soon. What would be causing this, so I know not to repeat it ( _if_ I did cause this). Can anyone help with this? **UPDATE** I defined the memory limit in the wp-config.php to 64M and the line reference in the error is now 836 instead of 1561. This is the code for line 836:               if ( is_array( $uris ) ) {                 foreach ( $uris as $uri => $pagename ) {                     $this->add_rewrite_tag('%pagename%', "($uri)", 'pagename=');                     $rewrite_rules = array_merge($rewrite_rules, $this->generate_rewrite_rules($page_structure, EP_PAGES));                 }             }      **UPDATE** I fixed the problem. The problem was somehow related to the permalink settings. Im using the CouponPress theme for wordpress. After increasing the memory limits, as suggested in most of the solutions (php.ini, wp-config.php, etc), I simply changed the permalinks to default and then back to my custom permalink. Everything seems to be back to normal. Why did this happen? I have no idea. All of sudden the error came up Monday morning and everyone was crazy (angry). I _WOULD_ like to know what caused this, so I can prevent it in the future if I can. Thanks to everyone who helped me out with actual solutions.


update user information

this is my code               /* Update user information. */         if ( !empty( $_POST['url'] ) ){             update_user_meta( $current_user->id, 'user_url', esc_url( $_POST['url'] ) );             else{             delete_user_meta( $current_user->id, 'user_url');             }         if ( !empty( $_POST['twit'] ) ){             update_user_meta( $current_user->id, 'twitter', esc_attr( $_POST['twit'] ) );             else{             delete_user_meta( $current_user->id, 'twitter');             }         if ( !empty( $_POST['face'] ) ){             update_user_meta( $current_user->id, 'facebook', esc_attr( $_POST['face'] ) );             else{             delete_user_meta( $current_user->id, 'facebook');             }         if ( !empty( $_POST['gplus'] ) ){             update_user_meta( $current_user->id, 'googleplus', esc_url( $_POST['gplus'] ) );             else{             delete_user_meta( $current_user->id, 'googleplus');             }         if ( !empty( $_POST['email'] ) )             update_user_meta( $current_user->id, 'user_email', esc_attr( $_POST['email'] ) );         if ( !empty( $_POST['first-name'] ) ){              update_user_meta( $current_user->id, 'first_name', esc_attr( $_POST['first-name'] ) );              else{             delete_user_meta( $current_user->id, 'first_name');             }         if ( !empty( $_POST['last-name'] ) ){             update_user_meta($current_user->id, 'last_name', esc_attr( $_POST['last-name'] ) );             else{             delete_user_meta( $current_user->id, 'last_name');             }         if ( !empty( $_POST['display_name'] ) )             update_user_meta($current_user->id, 'display_name', esc_attr( $_POST['display_name'] ) );         if ( !empty( $_POST['description'] ) ){             update_user_meta( $current_user->id, 'description', esc_attr( $_POST['description'] ) );             else{             delete_user_meta( $current_user->id, 'description');             }      but it gives me server error. it doesnt work. what is wrong with my code? thanks.


Wordpress multisite,one theme,and different languages?

I'm not sure is this possible,for example I have english,french and italian blog,they all use same theme,I just want when visitor is on french site for example to display date,(some strings like search,next page,...) on French,can I do it with theme localization an how,how to setup wordpress multisite to use this theme localization?


No feedback when installing plugins or updating

I've had this problem for a while now; I hoped that it would go away when I moved to my new host but it hasn't. Whenever I try to install or update a plugin or theme, or even update Wordpress, the page will simply say `downloading install package ...` but that is the only line that ever appears. If I leave it for a sufficient time the operation will complete successfully but Wordpress will only ever display the first step. I'm running the latest version of Wordpress and everything is up to date. Does any one know why this is happening and how to resolve it? Thanks in advance


Post type specific upload folder in 3.5

In 3.4 I used the following function to change image upload folder by post type. Different upload directory based on post type in a theme Now it doesn't work anymore in 3.5. Do you have any idea how to replace this function in 3.5 version? thanks


Author List page: Exclude based on last post date

I have a Author page that I built using this code and it works fine. However, I have several writers that range from frequent to one-time writers. I would like to seperate out writers that have not posted an article for say 6 months. It would be nice then to output those writers in a different section like "Past Writers" or something after the other list of writers. NOTE: I know little to nothing about coding so specific code help is needed! **Here is the code I am using now**               <?php     // Arguments to pass to get_users     // ************* $args = array( 'orderby' => 'post_count', 'order' => 'DSC', 'who' => 'authors' );     // Query for the users     $authors = get_users('orderby=post_count&order=DSC&role=contributor'); ?>
Writers
     <?php     // Loop through all the users, printing all of their posts as we go     foreach ( $authors as $author ) { ?>                 <a name="<?php echo $author->user_nicename; ?>">                 <div class="author-posts-wrapper" id="author-<?php echo $author->ID; ?>-posts-wrapper">                     <div class="author-avatar" id="author-<?php echo $author->ID; ?>-avatar">                         <?php echo get_avatar( $author->ID, 96 ); ?>
                     <div class="author-posts" id="author-<?php echo $author->ID; ?>-posts">
<a href="<?php echo get_author_posts_url( $author->ID ); ?>"><?php echo $author->display_name; ?>
         <?php         // Set up a Loop, querying for all of the current user's posts         $args = array( 'author' => $author->ID, 'posts_per_page' => 1 );         $posts = query_posts($args);         // Now that we have the posts, simulate a Loop here         if ( have_posts() ) : ?>                     <ul class="author-post-list" id="author-<?php echo $author->ID; ?>-post-list">             <?php while ( have_posts() ) : the_post(); // Print whatever we want for each post - for now the title ?>
<?php the_author_meta("description"); ?>

<?php the_author_posts(); ?> articles written. Most recent: <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?>

                 <?php if(get_the_author_meta('user_url')): ?>
             <?php endwhile; ?>
         <?php else: ?>
This author has not yet published any posts
         <?php endif; ?>

     <?php } // End looping over all users ?>


Integrating Magento and Wordpress Users

I've found posts on letting Wordpress manage Magento users and vise versa, but what I'm looking to do is not to have one manage users over the other. I'd like users to have the option to sign up through the shop or through the Wordpress main site, but enable Wordpress to use the Magento users and vise versa. Should I install both: http://www.magentocommerce.com/magento- connect/wordpress-integration.html http://wordpress.org/extend/plugins/magento-wordpress-integration/


get_pagination not working on a custom post type query (using WP_Query)

So I have a page on my site for press releases, and the press releases are a custom post type. I'm using a custom template called `page-press.php` for the Press page, and I want to display a loop of the recent posts for this post type in it. All is well there. However, when I set the `posts_per_page` argument to a value that should trigger pagination, I'm not getting the pagination. I think it must have to do with where I'm calling for the pagination in relationship to the loop, perhaps, or the order of my if else logic, but I've been looking at this for so long I think I'm probably just missing the obvious by now. Here's teh codez:
     <?php if ( have_posts() ) : ?>              <?php /* Start the Loop */ ?>         <?php while ( have_posts() ) : the_post(); ?>              <?php the_content(); ?>              <?php endwhile; ?>                       <?php $a2_press_query = new WP_Query( array ( 'post_type' => 'a2_press', 'posts_per_page' => 2)); ?>         <?php while ( $a2_press_query->have_posts() ) : $a2_press_query->the_post(); ?>         <article class="post <?php the_ID();?>" id="post-<?php the_ID();?>">
<a href="<?php the_permalink(); ?>"><?php the_title(); ?>

<?php the_time('M') ?> <?php the_time('d') ?> <?php the_time('Y') ?>

                 <?php the_excerpt(); ?>
<a href="<?php the_permalink(); ?>" title="Read the whole post" rel="nofollow" class="button small muted read-more">Read more →

         <?php endwhile;         // Reset Post Data         wp_reset_postdata(); ?>

             <?php get_pagination(); ?>

              <?php else : ?>

<?php _e( 'Apologies, but no results were found. Perhaps searching will help find a related post.', 'appendto-2012' ); ?>
             <?php get_search_form(); ?>
          <?php endif; // end have_posts() check ?>
      Why isn't the pagination being generated from this? Note: everything else is working properly - it is displaying my posts from this category on the page.


Getting values of a custom taxonomy dropdown

I have a custom taxonomy dropdown (`custom_authors`) which is displayed in the comments form when logged in to select a different author than the logged in one.               add_action( 'comment_form_logged_in_after', 'taxonomy_dropdown' );     add_action( 'comment_form_after_fields', 'taxonomy_dropdown' );     function taxonomy_dropdown() {         wp_dropdown_categories( array(             'name'       => 'alt_comment_user',             'taxonomy'   => 'custom_authors',             'hide_empty' => false          ));        }      The following function should save the selected value (`name` and `id`) but I don’t manage to get it to work.               add_filter('preprocess_comment', 'save_user_settings' );     function save_user_settings($input) {              if(current_user_can('moderate_comments') && isset($_POST['alt_comment_user'])){                      $user = get_user_by('id', (int)$_POST['alt_comment_user']);                  $my_fields = array(                 'comment_author'       => $user->name,                 'user_ID'              => $user->ID,             );                  // escape for db input             foreach($my_fields as &$field)                 $field = $GLOBALS['wpdb']->escape($field);                 $input = $my_fields + $input;            }           return $input;     }      The output I get the name "Anonymous" as comment author. Can somebody help how I get the correct value from the taxonomy dropdown? I think I have to change especially this line `get_user_by('id', (int)$_POST['alt_comment_user']);` to get_term_by but I don’t know how …


Adding numbers inside a span tag in nav menu

I am working on a wordpress navigation menu and trying to simlpy (of course, dynamically) add number inside a span tag for each menu li item. So I created a "top menu" using the wordpress custom menu function then I used a simple jquery function to add a "span" tag inside each tag like so:               $("#top .menu ul li a").prepend("");      This generated the following HTML:

Menu Item

Menu Item

Menu Item

Menu Item

      Thats exactly what I want as step #1 Now, what I am trying to get is a simple jquery function which will dynamically add a following number inside each divs maybe using a variable or something. The out put needs to be:

1Menu Item

2Menu Item

3Menu Item

4Menu Item

      etc.. etc.. should be a very simple jquery function. just can't find it. any suggestions? Thanks a lot!


Programmatically edit the text of a widget

I have text widgets that contain text. I'd like to programmatically edit that text. Is there a way to do that?


How to have a custom display for both woocommerce archive and product-category pages?

# So far Hi there, I understand my question is very closely related to a common question about 'woocommerce'. I have been using a variety of woo hooks, filters and creating copies of original woo template files in my child theme in a folder called woocommerce/. This is working and I'm able to make the edits that integrate woocommerce into my theme. # What I'm trying to do _Woocommerce uses archive-product.php to display product categories. It also uses this template to display the products of the category._ **I'd like to style the products page very differently to the category page and create another archive template that displays the products of a category** I'm thinking that using a new products-product.php template page or would be my best option. I'm very interested in learning more and more about the plug- in, therefore I'm trying to stay away from quick CSS fixes and learn to use the template files and hooks. **Advice or points in the right direction would be greatly appreciated.**


Adding custom post types to the default loop, yet only posts that has terms from the core taxonomies

I know ways to add Custom Post Types to the default loop or feeds and ways to add custom post types to the default categories and tags, all involving 'pre_get_posts' filters. I was trying to do something related, yet more awkward: Adding Custom Post Types to the default post loop, but _only_ post that do have any term from the default categories or tags assigned to them. Sort of if I'm seeing an archive of a category that includes all posts from the core "post" post type, plus a few other post from other post types. Edit: I have resolved it in part (I wasn't getting results due to a dull typo):                   add_filter( 'pre_get_posts', 'my_get_posts_test_dos' );              function my_get_posts_test_dos( $query ) {         // Not sure if one needs too many conditionals, but still. Previously, the script was working without the opening and closing braces inside the if statement, but it was buggy just for that.             if ( $query->is_post_type_archive('post') && $query->is_main_query()  && !$query->is_feed() && !is_admin()) {        //  I'm naming manually some categories to include in the query. Althought for the   particular purpose is fine, I would need a simple way to just name *all* categories.             $cat_a = get_cat_ID('category-one');             $cat_b = get_cat_ID('category-two');             $query->set( 'category__in', array($cat_a, $cat_b) );             $query->set( 'post_type', array('post', 'video') );             return;             }         }


why doesnt my formatting work in my wisiwig editor?

I am trying to format my post with extra blank lines. But for some reason they dont get reflected when i save it? But the underline etc work fine Any idea how to sort this problem


Add a Jquery Datepicker to custom field in post edit

I would like to add a custom field that is set by a jquery datepicker ui in the post edit panel. Im new to wordpress, so Im not sure how to go about adding something like this. I haven't had much luck with plugins, so I would like to know how one would go about adding something like this manually. I am familiar with PHP.


Missed scheduled WordPress

I am currently in version 3.1 of WordPress and I have a problem with planning my post. In fact, whenever I plan a post, it is written: "Scheduled missed. Could you help me please. Thank you in advance Francis NIKOU