Populate custom field on publish or update

I have a custom post type called **books** , with fields genre, author, and bookname. I want to dynamically create a link called "booklink" (custom field) based on the data in the 3 above fields, and put "booklink" into the database for the post on publish or update. How do I do it? My code:               <?php         $genre = get_field('genre');     $bookname=get_field('bookname');     $author=get_field('author);     $booklink="http://mybooks/".$genre."/".$author."/".$bookname.".com";     ?>      I don't know how to get this "booklink" field created, and updated with the data, in the database for each post on publish/update. I'd like to retrieve the "booklink" directly, instead of generating it each time for the post_type books. Please guide. **Changed code to elaborate more** Using the code by **passatgt** , I tried the following :-               function update_bookstore_field( $post_id ) {         if ( $_POST['post_type'] == 'books' ) {                  $booklist = get_field('booklist');              foreach ($booklist as $post) :  setup_postdata($post);                 if (!empty($post)) {                     $bookstore=array();                     $bookstore[] = strip_tags(get_field('bookstore',$post));                  }              endforeach;              wp_reset_postdata();               update_post_meta( $post_id, 'bookstore', $bookstore[0] );         }     }     add_action( 'save_post', 'update_bookstore_field' );      Where booklist is a post type connected as a post object to books, based on the selection of the book in the booklist, the custom field bookstore in post type = books is filled with corresponding bookstore of booklist post type. e.g.               booklist        bookstore     --------        ---------     Wiz of Oz       Amazon     Wiz of Oz 1     Flipkart     Wiz of Oz 2     Barnes&Noble      So if in the select field of books post type, "Wiz of Oz 1" is selected in the booklist, then the bookstore in books should be populated with flipkart automatically on clicking publish or update... that's not happening.


How do I delete a URL on wordpress that was automatically generated by clicking on Preview in wordpress

I've been building my site on wordpress for a while now and everything seems to be working fine. The only issue I have is that for some reason, after clicking "preview" on a post, the system automatically generates a temporary URL that seems to hang around far longer than it should, and which I'm unable to delete or redirect. I've tried clearing the Cache files but it doesn't seem to help. It looks like this: /?p=209&preview=true&preview_id=209&preview_nonce=d0a4f6f9f7&post_format=standard When clicking on this link, I get a page error message saying that I don't have permission to view this page. As a result the google Adsense Crawler keeps finding this URL and reporting that it cannot check the site because it is down or behind a login. Can someone please help me delete the following link?


Different customer login form than administrator login form?

I've recently installed Woocommerce. I have realized that the administrator can access the back-end through the same login form presented to the customers. This, to me, presents a huge security risk. I thought of a couple of solutions, but I do not know the code that would help me implement them:   * How can I prevent the administrators from logging in through the customer login page? (if statement on login from the customer login form that would check the role of the user and prevent login if the user is an admin)   * How can I present a login form so that only the customers can login through? (use a default or native login form set only for customers)


Multisite questions

I've got several questions regarding WP multisite, hoping someone who's used it extensively can help:   1. Is it possible to manage several WP sites over several different domains?   2. How can plugins be managed, some I'd like to use across all the sites but others I'd only like to use on certain sites. Also what happens to each of the plugin settings, are they rolled out across the board?   3. Updating - how can this be managed per site for both the plugins and WP itself.


WP Gallery showing captions twice

I am using standard WP gallery to display images. I have added caption to every image, image title was not changed so it is same like file name. When I open one image in gallery it shows caption text in span class "TitleText". This is ok but with some images it shows the same text and it display span TitleText and span CaptionText. You can see it here: http://www.tandem.sk/galeria/automobilizmus/cerpacie-stanice/ If you click on first image caption is showing twice, however second image is working fine. The text you see is set as caption in gallery. Any ideas how to fix this?


Nested comments ignored for max per page in wordpress

I have the default setting (IIRC) of 10 comments per page, and max nesting of 5 deep. The problem (or at least, minor annoyance) is that replies to comments are not counted towards that maximum of ten per page. I can understand that you do not want to break a thread, and that should be avoided, but in my test case I have:               test10     - test10 2     - test10 3     - - test10 4     - - - test10 5     - - test10 6     - test10 7     - test10 8     - test10 9     test9     test8 (should be on a new page?)     test7     test6     test5     test4     test3     test2     test1      They all show on the same page. But in reality I want to break that after the test9 comment. I have a funny feeling it's not going to be easy. Hopefully there will be a method just within the theme framework, but I'm not afraid to modify wordpress if needs be.


My theme saves their custom post type's metadata as a serialized array, how to access the keys?

I've recently bought the WP Directory Portal theme from ThemeForest. Since the theme doesn't do frontend posting of custom post types, I've resulted to using WP User Frontend Pro. There's a problem hooking into the custom post type meta though. When I check PHPmyAdmin, I find the following field: _ait-dir-item in wp_postmeta With the content:               a:19:{s:7:”address”;s:17:”Street”;s:11:”gpsLatitude”;s:17:”12.341251949999999″;s:12:”          gpsLongitude”;s:17:”12.34779700000025″;s:18:”streetViewLatitude”;s:17:”22.46046022895586″;          s:19:”streetViewLongitude”;s:17:”22.006520910937523″;s:17:”streetViewHeading”;          s:1:”0″;s:15:”streetViewPitch”;s:1:”0″;s:14:”streetViewZoom”;s:1:”0″;s:9:”telephone”;s:0:””;          s:5:”email”;s:17:”tester@retroga.me”;s:3:”web”;s:0:””;s:11:”hoursMonday”;s:0:””;s:12:”hoursTuesday”;s:0          :””;s:14:”hoursWednesday”;s:0:””;s:13:”hoursThursday”;s:0:””;s:11:”hoursFriday”;s:0:””;s:13:”hoursSaturday          “;s:0:””;s:11:”hoursSunday”;s:0:””;s:18:”alternativeContent”;s:4:”Test”;}      I was wondering how I could access those variables, so that I can make this work with the theme's custom post type. I've tried both support forums, and the WP User Frontend author's been helping out a bit, but I could use some further insight into this. If anyone is willing to help me out with this, it'd be greatly appreciated. Thanks in advance!


Embed a Google Docs in Wordpress?

I need to embed a Google Docs / Spreadsheet in one of my Wordpress posts. Unfortunately, this: http://code.google.com/p/inline-google-docs/ does not work with my WP 3.1.3 installation. I just need something that is as easy as "pasting" the published URL for my Google Docs. Any advice? Best Regards, W


Make item checked by default for all users in "Screen Options" pane

When you are in the dashboard, the options checked and unchecked in the "Screen Options" pane seem to me to be completely random and arbitrary and cause lots of confusion when something doesn't show up that you need that "should" be there but isn't. Is there some way to influence which of these options are checked, and make that stick for all users?


Meta boxes not showing on custom post type. Blank page?

I am working on my first plugin. I've got a custom post type, with a meta box which has 4 fields which uses update_post_meta, & these work 100% fine. I have then tried to create a meta box that has repeatable fields, when the user clicks 'add new field'. I want users to be able to add as many fields as they like. My Question: Below, is my code to add new fields. This just doesn't display in the custom post type when viewed, but I don't get any errors. Please can you have a look at my code below, & advise?               <?php     // START OF CREATE MORE META BOXES AS NEEDED INCLUDING JQUERY      add_action( 'add_meta_boxes', 'dynamic_add_custom_box' );          /* Do something with the data entered */     add_action( 'save_post', 'dynamic_save_postmeta' );          /* Adds a box to the main column on the post and page edit screens */          function dynamic_add_custom_box() {         add_meta_box(                 'dynamic_sectionid', 'My Tracks', 'mp_myplugin_textdomain', 'mp_dynamic_inner_custom_box', 'post' );     }          /* Prints the box content  */          function mp_dynamic_inner_custom_box() {         global $post;         ?>
              <?php             // get the saved meta as an array              $mpformfield = get_post_meta( $post->ID, 'mpformfield', true );             $c = 0;             if ( count( $mpformfield ) > 0 ) {                 foreach ( $mpformfield as $mpfield ) {                     if ( isset( $mpfield['name'] ) ) {                         printf( '
 Field Name <input type="text" name="fieldname[%1$s][name]" value="%2$s" />

' );                     }                 }             }             ?>                           <?php 'Add form field'; ?>
 <?php     }          /* when the post is saved, saves our custom data */          function dynamic_save_postmeta( $post_id ) {         // verify if this is an auto save routine          // if it is our form has not been submitted, so we don't want to do anything          if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )             return;              // Save the data          $mpformfield = $_POST['mpformfield'];         update_post_meta( $post_id, 'mpformfield', $mpformfield );     }


Force CSS and JS loading of plugin only where needed

I saw the excellent answer (link below) but would like to learn for myself how to look for action call of a specific plugin so i can stop it using the idea of EAMan Restricting a Plugin to Only Load its CSS and JS on Selected Pages? I have used http://wordpress.org/extend/plugins/datapress/ and its js/css is only needed on one page. Same for other plugins. How do I go about finding out what function those plugins call so I can enabled it on only pages needed.


Why won't the action hook wp_head won't accept parameters?

I'm working on a plugin that adds scripting to the head using add_action('wp_head',..); I have to pass a variable to the function to get my desired result. To test this I'm simple "echoing" out the variable to be sure it's passing. I'm calling the function within a page template. The variable is echoed in the body but not the head:               function add_brand_style($newItem){         global $newItem;         echo 'item:'.$newItem;     }     add_action('wp_head','add_brand_style');      the head i get "item:' and in the body I get something like "item:dog".


How is a SOAP request handled when a user visits a page?

I am creating a plugin for my own website. I've been following this tutorial, but I see it's not handling authentication and displaying data in the way I'm needing, though it did show me how to create an admin page and put in the authentication data on the admin page: http://code.tutsplus.com/tutorials/create-a-custom-wordpress-plugin-from- scratch--net-2668 I am wanting to display incoming XML data from a SOAP request. The data displays a list of text from an external API onto the page when a visitor visits the page. The thing that I'm confused about is that the user does not need to authenticate the call to the API (IE they don't log in), but that info should be sent in the call with the authentication requirements having been populated in the admin section of the plugin. I'm not asking for someone to hold my hand through this, and I've read the help section here, so I hope I'm on topic enough. I'm hoping to find a tutorial that demonstrates a plugin making an XML call (via SOAP) when a user visits a page and then displays that data. Thank you!


Wp admin - Set default value to 999 in comments

When you are at the comments menu in wp-admin you only see 20 comments at the time, so if you want to delete alla comments you can **ONLY** mark the 20 comments you see on current page. It dosent mark comments that are on the next page. Found a solution but dont know where to look for it In WP-admin -> Screen layout there you can see that its only set to 20 comments a page. I know that i could just access the screen layout and set it to maximum (999 comments a page). Now the question is can I set that value (999) to default for every user i create ? Or just basicly for the whole network? **Follow question:** : If its possible, then whats the best way to do it ? **NOTE** : Im using latest WordPress version with Multisite network.


Strip Characters From Tag Name

I am having some difficulties trying to strip out special characters and spaces from my tags. Using the below code:

all.
                 <?php                     query_posts(array( 'post_type'=> 'work' ));                     if ( have_posts() ) : while ( have_posts() ) : the_post();                         $custom_post_tags = get_the_tags();                     if ( $custom_post_tags ) {                         foreach( $custom_post_tags as $tag ) {                             $tags_arr[] = $tag -> name;                         }                     }                     endwhile; endif;                     if( $tags_arr ) {                         $uniq_tags_arr = array_unique( $tags_arr );                      foreach( $uniq_tags_arr as $tag ) {                          // LIST ALL THE TAGS FOR DESIRED POST TYPE                          $sanitizeTag =  sanitize_title($tag);                          $tag_link = get_term_by('name', $tag, 'post_tag');                                                                        echo '
' .$tag. '.
';                          }                      }                  ?>
      On this line: `echo '<li><a class="'.$tag.'" href="javascript:void(0)">' .$tag. '.</a></li>';` I want the class="" to show the tag but if the tag has "&" or spaces etc. to strip them out. Any ideas?


Uninstall script for a plugin in Multisite

I've just realized that the traditional `uninstall.php` file along a plugin is not working in Multisite.               if ( !defined( 'WP_UNINSTALL_PLUGIN' ) )          exit();          delete_option( 'plugin_option_name' );      This doesn't delete the sub-sites options in all `wp_SITE-ID_options` tables. Is there a standard way for doing this?


Problem Locating and Changing Alt Attribute Of Link

I'm a totally amateur so please dumb it down for me. My WP them has a Social Links in the header of the theme and I want to change the Linkedin link link to a Pinterest link and change the Alt Attribute "View Our Linkedin Profile" to "Follow Us On Pinterest". PROBLEM: I can't find the text "View Our Linkedin Profile" that I want to change. If I "View Source Code" in a browser I can see the text in the Source Code but I can't find the Alt text in any CSS files and I've been looking in my C-Panel's directory's files the best I can. How do I locate the Alt Attribute, "View Our Linkedin Profile" to change the text if I can not find it in any of the CSS files? Any help would be greatly appreciated and please, please really dumb down the answer. Thank you.


Making the Add Media Link URL into a checkbox

Hopefully it's OK asking a second question pretty much directly after the first one... I'm currently having some difficulties accomplishing this: ![](http://i.stack.imgur.com/DsLsT.png) I've been able to remove the 'Attachment Post URL' button using               function medium_attachment_fields_to_edit($form_fields) {       $form_fields['url']['html'] = preg_replace("/<button type='button' class='button urlpost' title='(.)*'>(.*)<\/button>/", "", $form_fields['url']['html']);       return $form_fields;     }     add_filter('attachment_fields_to_edit', 'medium_attachment_fields_to_edit', 0, 2);      but I'm somehow unable to make the remaining buttons into a checkbox. Checked being the 'File URL', unchecked being 'None'. (or changing things into a 'Yes/No' set of radio buttons if this would be easier to accomplish) I've read about all articles about this matter of course (especially this one), but they about all seem to be about adding new settings, instead of altering existing ones.


How do I provide for multiple crops of the same image in a theme?

I've been working on a Wordpress theme (my first, actually) and the design includes a header image. However, the header is extremely wide and thus is really small when adapted to a phone layout. How would I allow for multiple crops of the same header image, so that I could have one wide crop for the desktop layout and one more squarish crop for the phone layout?


HTML in PHP problem

I have the following code but I always get an error, it's the first time I've tried to merge HTML with PHP:               <?php     if(get_field('post_image'))     {         echo '';     }     else {         echo '<img src="<?php bloginfo('template_url'); ?>/images/images/default.jpg" />';     }     ?>      Is there something wrong the blog info area? Is there an easier way to integrate these? Thanks


How to get category and archive title?

When I query the category (category.php), how to get the name of the current category, ie., the one that is being queried? And for tag and date (be it the day, the month or the year)? Thanks!!


How Do I Display A Custom Field In The Sidebar Of All My Pages?

I'm using the Types Plugin for Wordpress and created a custom field. I would like to display this custom field in the sidebar of all of my pages. The problem is that it only displays in the sidebar of the page I created the custom field on. It does NOT display in the sidebar on any of the other pages. Here's the code I placed in my generic sidebar.php file:               <?php echo(types_render_field("photo", array("alt"=>"Product image", "width"=>"300","height"=>"200","proportional"=>"true"))); ?>      Any ideas on how to get it to display in the sidebar of ALL the pages? I'm using the Twenty eleven theme with the latest version of Wordpress. Thanks!


If I change the taxonomy of a post will it get a new time stamp?

I have a category called feature that displays the latest post, but further down the line if the user wants to make an older post a featured post, it doesn't currently work. Using the time stamp would be a good hook to implement this, I'm assuming if the user was to check the feature category on an older post and update, would it get a new time stamp? Therefore I could display the most recent time stamped post?


Can't create posts with WP DB Abstraction Plugin

I have a WordPress site moved to Azure web site + Azure SQL using database abstraction plugin After that migration I'm not able to create new posts. When I click Save Draft it redirects me to the Posts page and my post isn't saved. Error is:               WordPress database error 22007 : [Microsoft][SQL Server Native Client 11.0][SQL Server]The conversion of a nvarchar data type to a datetime data type resulted in an out-of-range value.      for query INSERT INTO wp_posts (post_author,post_date,post_date_gmt,post_content,post_content_filtered,post_title,post_excerpt,post_status,post_type,comment_status,ping_status,post_password,post_name,to_ping,pinged,post_modified,post_modified_gmt,post_parent,menu_order,guid)      VALUES (540, N'2014-08-01 08:52:44', N'0000-00-00 00:00:00', N'', N'', N'Auto Draft', N'', N'auto-draft', N'post', N'closed', N'closed', N'', N'', N'', N'', N'2014-08-01 08:52:44', N'0000-00-00 00:00:00',0,0, N'')      made by wp_dashboard, do_meta_boxes, call_user_func, wp_dashboard_quick_press, get_default_post_to_edit, wp_insert_post, pdo_wpdb->query, pdo_wpdb->_post_query, pdo_wpdb->print_error      I have tried resolution of **staticdeadlock** and **JohnieBraaf** explained here, without luck: I tough that I could create new post from 'Quick Draft' section, but after few I realized that it updates an existing post. Any of you using this plugin and have noticed is working better with any specific WordPress version? Any had this same problem and found a solution? This is a part of my wp-config.php               /** Database Type. Defaults to mysql */     define('DB_TYPE', 'pdo_sqlsrv');          /** Database Charset to use in creating database tables. */     define('DB_CHARSET', 'utf8');          /** The Database Collate type. Don't change this if in doubt. */     define('DB_COLLATE', '');


Post from front-end with post types, categories and taxonomies

I am now developing a wordpress site that will be something like a directory. People will be able to submit walkthroughs, advanced reviews, as well as cheat codes for games. We were going to make a different form for each page, but now we've decided that one form with a drop down will be just fine. There doesn't seem to be a good plug in out there, that I can find, which accommodates the fact that each submission needs to be pushed through as a "pending post" but also to a certain post type. For example, the form that we'll use will be set up like this:               Game name: <post title>     Platform:  <Taxonomy>     Category:  <Category> (role playing, FPS, adventure, etc..)     This is a: () Review () Tutorial () Cheat list  <this is the post type>     Content: <post body>     Tags: <tags>     [Submit]      Upon submission, I need for the review, cheat, or tutorial to be set as a pending post, in the post type chosen from the radio boxes. I'm currently using WP User Front End, but I could probably use any post from front-end form that is suggested for easiest modification. Adding the new fields to the form is easy, making them do stuff is hard! I'd appreciate any help I can get with this, our website sort of revolves around these feature.


How to bring files from the upload directory to the media gallery?

My wordpress theme creates thumbnails of media files that I upload into my posts. These thumbnails are not accessible inside the media gallery, they exist only in the media upload directory. I want to access these thumbnail files in my media gallery. How do I import files in my upload directory into media gallery?


How to cancel redirection to admin side

My friend asked me to activate a site that someone else did it. The problem is that when I try to run it, and I go to `mysite.com` I arrive to `mysite.com/wp-login.php?redirect_to=/` Where and how can I fix it?


Title displaying multiple times

I'm facing a problem where my title is being displayed multiple times. Using the following code the page title 'News' is displayed 10 times, the same number as the number of posts I've elected to display.               <?php while ( have_posts() ) : the_post();         if( is_singular() ) { ?>
<a href="<?php the_permalink() ?>"><?php the_title(); ?>

Written By: <?php echo get_the_author() ?>•<?php the_date(); ?>
         <?php } else { ?>
<?php wp_title(); ?>
         <?php } endwhile; ?>      However, using this version of code, the latest 10 post titles are displayed instead.               <?php while ( have_posts() ) : the_post();         if( is_singular() ) { ?>
<a href="<?php the_permalink() ?>"><?php the_title(); ?>

Written By: <?php echo get_the_author() ?>•<?php the_date(); ?>
         <?php } else { ?>
<?php the_title(); ?>
         <?php } endwhile; ?>      Any help would be greatly appreciated. Thanks.


Custom Fields link to other pages, not search

I am attempting to create a website, which has a similar taxonomy system to IMDB, but instead of Movies, it is referencing Musicians. I have created a custom post type for Artists, with a few custom field called Record Label on it. I am stuck because when I create this custom field and click on the link it produces, it takes me to a search page, rather than to a page made for that Record Label. Is there anyway I can bypass the search section, and link to the Record Label page in particular? And, as bonus question, I would also like the relationship between the Movie and the Actor to show up on both pages, rather than on just one or the other. For example, if I said that an Artist was signed to a label, I would like the label page to automatically update the fact that it has signed the band. So far, I have created Custom Post Types, for both Artist and Label, but I am having trouble linking the two together. Am I going about this the wrong way? I know I am probably missing something obvious, but I cannot find an answer. Thanks for your help, Joseph.


Wordpress loop problem: Multiple loops, index.php and is_paged causing duplicate posts on next page

Hey everyone. I'm not sure if what I'm experiencing is a result of a bug (due to the recent upgrade to 3.1.2) or poor coding. Ever since i upgraded to version 3.1.2 ive been experiencing a problem with two loops on my index page. Here's what I've got for my index page               <?php         if ( ! is_paged() && is_front_page() ) {              echo '
FEATURE
';         $sticky = get_option( 'sticky_posts' );                   if ( isset( $sticky[0] ) ) {                 $args = array(                     'posts_per_page' => 3,                     'post__in'  => $sticky,                     'ignore_sticky_posts' => 1);                      $featured_query = new WP_query( $args );                 while ($featured_query->have_posts() ) :                 $featured_query->the_post();                      get_template_part( 'content', 'featured' );                      endwhile;             } // endif sticky         } // endif is_paged         ?>              <?php             $sticky = get_option( 'sticky_posts' );             echo '
LATEST ARTICLES
';             $paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;             $query_args = array(                 'posts_per_page' => 10,                 'paged' => $paged,                 'post__not_in' => $sticky                 );                  query_posts($query_args);             if (have_posts() ) :             while (have_posts() ) :             the_post();                  get_template_part( 'content', get_post_format() );         ?>                            <?php endwhile; else: ?>

                 <?php _e( 'Sorry, no posts matched your criteria.' ); ?>

              <?php endif; ?>          // Navigation comes over here      Say for example the first loop _(sticky posts)_ - which IS NOT paged, yields **3 posts** , and the second loop _(all other posts)_ - which IS paged, yields **10 posts**. The problem I'm experiencing is that when i move to the next page, the last **3 posts** from the second loop on page 1 get repeated at the the top of page 2. * * * Note: The first loop is only on page 1, and doesn't get repeated on the second page, which is what i intended. Note 2: I assume that the second loop is considering - in some odd way, the posts from the first loop as one of its own. But it still shows 10 posts on the first page + 3 posts from the first loop. * * * So in essence its: **PAGE 1:** Loop 1: 3 posts (3 unique posts) Loop 2: 10 posts (10 unique posts) **PAGE 2:** Loop 1: Doesn't execute - as intended, due to ( ! is_paged() ) Loop 2: 10 posts (7 unique, 3 duplicated from the last 3 (from the second loop) on the first page) So this is what i tried, i removed the ( ! is_paged() && is_front_page ) condition along with the entire first loop, and the problem got resolved. What am i doing wrong?


How to stop the wp_mail function?

I'm using wp_mail filter function. `add_filter('wp_mail','check_the_mail_content');` If my condition satisfied then the mail should go, otherwise I need to stop, my function is               add_filter('wp_mail','check_the_mail_content');     function check_the_mail_content($query){         if(mycondition){              //mail should go.         }         else{             //stop the mail.        }     }


add php shortcode in return function

I have this part of code:               return '';      What I want to do is to return also a php shortcode but not inside the **img** element, because my shortcode generates a **a** element so I need to return it after the img this is my shortcode:               <?php echo do_shortcode('[daisy]'); ?>      I've tried this:               return ''.do_shortcode('[daisy]');      but is not working, I receive:               Error (Parseerror): Syntax Error Unexpected Token <      How can I make this ? Thanks! Later edit: here is the entire script:               <?php      function custom_slidessc($atts, $content = null) {          $user_agent = $_SERVER["HTTP_USER_AGENT"];     if(strpos($user_agent,'iPhone') || strpos($user_agent,'iPod') || strpos($user_agent,'Android')){ $mobile = true; }else{ $mobile = false; }     $ipad = strpos($user_agent, 'iPad') ? true : false;          $class = shortcode_atts( array('text_color' => '#ffffff', 'image' => '', 'video_vimeo' => '', 'video_youtube' => '', 'video_mp4' => '', 'video_ogg' => '', 'video_webm' => '', 'video_poster' => '', 'slide_desc' => '', 'slide_horizontal' => '', 'slide_fitscreen' => '', 'slide_noresize' => ''), $atts );              /* Slide Description */         if($class['slide_desc'] != ''){              $slide_desc = $class['slide_desc'];              $slide_desc = "title=\"".$slide_desc."\"";         }              /* Slide Text/Cursor Color */         if($class['text_color'] == '#ffffff'){             $text_color = 'text_white';          }else{             $text_color = 'text_black';          }              /* ------------------------------------*/         /* -------->>> IMAGE SLIDE <<<---------*/         /* ------------------------------------*/         if($class['image'] != ''){             $image = $class['image'];             if($class['slide_horizontal'] == 'true'){ $horizontal = 'slide_horizontal '; }else{ $horizontal = ''; }             if($class['slide_horizontal'] == 'true' || $class['slide_fitscreen'] == 'true'){ $slide_fitscreen = 'slide_fitscreen'; }else{ $slide_fitscreen = ''; }             return '';              /* ------------------------------------*/         /* ----->>> HTML5 VIDEO SLIDE <<<------*/         /* ------------------------------------*/         }elseif(($class['video_mp4'] != '' or $class['video_ogg'] != '' or $class['video_webm'] != '') AND !$mobile){             $video_mp4 = $class['video_mp4'];             $video_ogg = $class['video_ogg'];             $video_webm = $class['video_webm'];             if($class['video_poster'] != ''){ $video_poster = "poster=\"".$class['video_poster']."\""; }else{ $video_poster = ""; }             return '
'.do_shortcode('[video mp4="'.$video_mp4.'" ogg="'.$video_ogg.'" webm="'.$video_webm.'" '.$video_poster.' preload="true"]').'
';              /* ------------------------------------*/         /* ------->>> YOUTUBE SLIDE <<<--------*/         /* ------------------------------------*/         }elseif($class['video_youtube'] != ''){             $video_youtube = $class['video_youtube'];             if($class['slide_noresize'] = 'true'){ $video_noresize = 'height="360" width="640"'; }else{ $video_noresize = 'height="100%" width="100%"'; }                  $strText = preg_replace( '/(http|ftp)+(s)?:(\/\/)((\w|\.)+)(\/)?(\S+)?/i', 'link', $video_youtube );             if($strText == 'link'){                 $array_link_explode = explode('v=', $video_youtube);                  $array_link_explode = explode('&', $array_link_explode[1]);                  $video_youtube =$array_link_explode[0];             }             $video_poster = $class['video_poster'];                  if($mobile){                 return '

';             }else if($ipad){                 if($video_poster){ $ipad_poster = ''; }else{ $ipad_poster = ''; }                 return '

'.$ipad_poster.'
';             }else if($video_poster != ''){                 return '

';             }else if(!$ipad){ //disable fullscreen for ipad                 return '

';             }              /* ------------------------------------*/         /* -------->>> VIMEO SLIDE <<<---------*/         /* ------------------------------------*/         }elseif($class['video_vimeo'] != ''){             $video_vimeo = $class['video_vimeo'];             if($class['slide_noresize'] = 'true'){ $video_noresize = 'height="360" width="640"'; }else{ $video_noresize = 'height="100%" width="100%"'; }                  $strText = preg_replace( '/(http|ftp)+(s)?:(\/\/)((\w|\.)+)(\/)?(\S+)?/i', 'link', $video_vimeo );             if($strText == 'link'){                  $array_link_explode = explode('.com/', $video_vimeo);                  $video_vimeo = $array_link_explode[1];              }             $video_poster = $class['video_poster'];                  if($mobile){                 return '

';             }else if($ipad){                 return '

';             }else if($video_poster != ''){                 return '

';             }else if(!$ipad){ //disable fullscreen for ipad                 return '

';             }         }else{             return false;         }     }     add_shortcode("slide", "custom_slidessc");     ?>


Using set_post_thumbnail inside save_post action gets overwritten

I've added my own function to save_post as follows:               add_action( 'save_post', 'save_recipe' );          function save_recipe( $post_id ) {         // ... set $thumb_id from custom code ...              set_post_thumbnail($post_id, $thumb_id);     }      Now if I check my DB, nothing is set for the field `_thumbnail_id` inside the `wp_postmeta` table. The Strange thing is if I use a `die()` function right after set_post_thumbnail, and check the DB my line was entered into the DB, so it is like some built in code from wordpress (or my theme) that is stripping it out after the fact. Any ideas? I assume it has something to do with the featured image code that gets added when you use `add_theme_support( 'post-thumbnails' );` in your `functions.php`. I should note I'm using Wordpress 3.4.1 as a Network, in addition to using the Thesis 1.8.5 theme which may be adding some complexity. Also I know I could be using the built in featured post section, but I'm coding this so that I can use identical functions from the front end to add new posts (with a set featured image that the user uploads). Thanks!


Pass results of custom query to loop - when writing a plugin

This is similar to this question: How to change a custom query into a standard loop? - but I want to do this while writing a plugin, not writing a theme. I need to be able to run a custom query (using regular old sql), and set the result as the post available for the loop. I am writing a plugin, so template tags, foreach loops, etc are not what I'm looking for. I just want to run my sql query, pick the correct row, and tell wordpress to use this as the post for the loop. Here's what I've tried so far:               add_filter( 'pre_get_posts' , 'customQuery' );          function customQuery() {       global $wpdb;       $sql = "some sql here";       $safequery = $wpdb->prepare($sql);            $queryResults = $wpdb->get_results($safequery);     }      That works for retrieving my expected results. The variable `$queryResults` holds the correct data. After that line, I've tried a couple of things, neither of which worked.               ...snip...     global $post;     $post = $queryResults[0]; //since it is an array, and I just need the first result      That didn't work. Or rather, if I do a `var_dump` immediately after that line, `$post` is what I expect, but it seems to be reset somewhere down the line as I get a 404 when the page actually renders. I also tried:               ...snip...     global $post;     $post = $queryResults[0];     setup_postdata($post);       Same outcome. If I check the values of variables right away, I see what I expect. With the second example I even tried, just for fun, running things like `the_title();` which works (but doesn't help me because, again, I'm trying to write a plugin, not a theme). But when I let the page run through to rendering, I get a 404. I'm sure I'm just missing something simple that'll let me pass my results to the loop from the plugin layer. Any suggestions? Thanks.


How do I preview the result of a shortcode in the TinyMCE editor?

I have created a shortcode via the Shortcode API that does something like this:               [accordion_item numero="01" primeiro="true"]Item 01[/accordion_item]     [accordion_conteudo]     Lorem ipsum dolor sit amet, consectetur adipiscing elit.     Sed quis nisi eget eros ultrices vestibulum in sit amet nunc.     Cras varius pellentesque tellus nec vulputate. Nam viverra congue diam ut vehicula.     [/accordion_conteudo]      becomes:

01

Item 01

     Lorem ipsum dolor sit amet, consectetur adipiscing elit.
     Sed quis nisi eget eros ultrices vestibulum in sit amet nunc.
     Cras varius pellentesque tellus nec vulputate. Nam viverra congue diam ut vehicula.

      I would like the user to be able to preview that result in the editor, like some other shortcodes do, like [gallery]. Any ideas?


Split the content of the_content();

I want the content before the `<!--more-->` tag in one column and the rest in another column (`single.php`) only. I don't want to use plug-ins where I would need to edit all the posts to get it as I want. I've done the following and added it in `functions.php`:               // split content at the more tag and return an array     function split_content() {         global $more;         $more = true;         $content = preg_split('/<\/span>/i', get_the_content('more'));         for($c = 0, $csize = count($content); $c < $csize; $c++) {             $content[$c] = apply_filters('the_content', $content[$c]);         }         return $content;     }      and added the following to `single.php`:               <?php     // original content display         // the_content();     // split content into array         $content = split_content();     // output first content section in column1         echo '
', array_shift($content), '
';     // output remaining content sections in column2         echo '
', implode($content), '
';?>'      The problem is that first `echo '<div id="column1">', array_shift($content), '</div>';` loads and then the bottom sidebar is loaded (Facebook comment links within). Then `echo '<div id="column2">', implode($content), '</div>';` is loaded and then the bottom sidebar is loaded again (Facebook comments link within). Does anyone have any suggestions so that the sidebar (Facebook comment links within) is only loaded once (after `column2`)?


How do I list terms of a custom taxonomy at i.e. domain.com/brands/

I have a custom post type 'products' with custom taxonomy 'brands'. My URL structure should be:   * domain.com/brands - should list the brands   * domain.com/brands/brand/ - should list products of the selected brand   * domain.com/brands/brand/product/ - should show the selected product How do I define the URL rewrite of the CPT / taxonomy for this to work, and what template file lists the terms of the brand taxonomy, instead of listing posts?


Get all taxonomy posts by id

I have this code that should return all the posts that related to the taxonomy id, but it returns the last 5 posts.               <?php      $leaderships = new WP_Query(array(         'post_type'      => 'posttype',         'posts_per_page' => 11,         'tax_query'      => array(             array(                 'taxonomy' => 'taxonomy-name',                  'field'    => 'id',                 'terms'    => 13,             ),         ),     ));     ?>      posts_per_page is not working here, Any help to get all the posts. Thanks


How do you force the wordpress dashboard to be 1 coulmn by default? I want to show the dashboard as a single column for all users.


Cosmopolitan like quiz

Is it possible to create this type of quiz in wordpress? ![](http://i49.tinypic.com/28tul5j.jpg)


Drop down+sort blog posts date added/most popular

Is it possible to have a drop down menu like youtube/demonoid that allows you to sort your index (and caterogy.php) blog posts by date/popularity/viewed)? I seen plugins for adding most popular widgets or pages, but I was hoping to be able to sort the users page they are looking at (be it the index page or a specific category). Thanks


IF.. post meta show... Conditional Tag Help...?

I have the following conditional tag, which a friend helped me with... Currently it works doing.. 1) If a featured image just show that. 2) If images attached show featured image wrapped in a link to the images attached.. Can there be a third? 3) If meta data just a text input field rw_post-vimeo just show that, its a Vimeo link..get_post_meta($post->ID, 'rw_post-vimeo',true) I made an attempt below but it breaks it, is this possible?
          <?php if (have_posts()) : while (have_posts()) : the_post(); ?>               <?php     $featured = get_post_meta($post->ID,'_thumbnail_id',true);     $attachments = get_children( 'post_type=attachment&orderby=menu_order&exclude='.$featured.'&post_mime_type=image&post_parent='.$post->ID );      ?>
                 <time datetime="<?php the_time('Y-m-d')?>"><?php the_time('F jS, Y') ?></time>                 <?php if ( !empty($attachments) ) : ?>
          <a href="<?php echo get_bloginfo('template_directory').'/gallery.php?id='.$post->ID; ?>">          <?php if (has_post_thumbnail()): the_post_thumbnail();else: $first_img = wp_get_attachment_image_src($attachments[0]->ID, 'thumbnail-size');  ?>          <img src="<?php echo $first_img[0]; ?>" width="<?php echo $first_img[1]; ?>" height="<?php echo $first_img[2]; ?>" />     <?php endif; ?>

     <a href="<?php echo get_bloginfo('template_directory').'/gallery.php?id='.$post->ID; ?>">See Rest Of Images
          <?php else: ?>
     <?php the_post_thumbnail(); ?>

               <?php else: ?>
     <?php echo do_shortcode('[iframe_loader src="http://player.vimeo.com/video/'. get_post_meta($post->ID, 'rw_post-vimeo',true) .'?title=0&byline=0&portrait=0&color=ffffff&autoplay=1" width="640" height="360" frameborder="0""]');?>

          <?php endif; ?>
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?>

     <?php the_content(); ?>

          <?php endwhile; endif; ?>
      Is it possible or no go, another way of doing it? Thank you for anyones help :)


Can I redirect the http request towards an old folder to the homepage using .htaccess file?

I am in the following situation: I had an old blog that was made using Joomla (this blog was indexed well enough by search engines). Due to some problems I deleted it and moved the site over to WordPress/ Now I have many visits (from Google) that lead to specific pages of the old site (pages that don't exist in the new version). For example I have visits to URLs as `/scorejava/index.php/corso-spring- mvc/1-test` that doesn't exist on my new site. I would know if using the .htaccess file (or other system) I can redirect the HTTP Request directed to some subfolder (that don't exist in the new version) to the homepage of my new site . For example I have the request towards the empty URL: `/scorejava/index.php/corso-spring-mvc/1-test` and I would create a regular expression that say something like: all the request toward the subfolder `/corso-spring-mvc` (and all it's content file and subfolder) have to be redirected to `www.scorejava.com` Is it possible?


How To Remove The "Click here to cancel reply" Link From The Wordpress Comment Form

I am trying to remove the "Click here to cancel reply" link from the Wordpress comment form on my posts. In the document there is an argument you can supply to the comment form function to remove the link, but it doesn't appear to be working. The documentation link: http://codex.wordpress.org/Function_Reference/comment_form I have tried different values for the cancel_reply_link value including double quotes, double quotes with a space between them, a zero and a value of false; all of which were to no avail. Surely I am overlooking something here as removing that link is pretty common in Wordpress installations. Here is the current function call with parameters that I am using at present:               <?php comment_form(          array(         'comment_notes_before' => FALSE,         'comment_notes_after'  => FALSE,         'cancel_reply_link'    => FALSE     )      ); ?> Your help is gratefully appreciated.


changing body background color for custom post type in admin backend

i have a custom post type called 'auctions', and i'd like to be able to visually differentiate auctions from posts and pages **in the backend** by assigning a different background color to the auction post type. this could be easily achieved if i had a way to assign a body class to admin pages pertaining to this specific post type, except i'm not sure as to how i'd go about that :). any help would be greatly appreciated. thanks!


How to add editor-style.css styling to wp_editor on front end for comments

How can I apply my own css (to match `editor-style.css`) to `wp_editor` being used on the front end for comments? Currently I'm using code from here to enable the visual editor for comments. My actual code in functions.php:               add_filter( 'comment_form_defaults', 'custom_comment_form_defaults' );     function custom_comment_form_defaults( $args ) {         if ( is_user_logged_in() ) {             $mce_plugins = 'inlinepopups, wordpress, wplink, wpdialogs';         } else {             $mce_plugins = 'fullscreen, wordpress';         }         add_filter( 'wp_default_editor', create_function('', 'return "tinymce";') );         ob_start();         wp_editor( '', 'comment', array(             'media_buttons' => false,             'teeny' => true,             'textarea_rows' => '7',             'tinymce' => array( 'plugins' => $mce_plugins ),             'editor_css' => '<style> p { font-family: Arial } </style>'         ) );         $args['comment_field'] = ob_get_clean();         return $args;     }      As you can see in the code I'm passing a css style into `wp_editor` with the `editor_css` param, however it's getting rendered outside the `iframe` so it's having no affect. You can see that style declaration and iframe in the source here.


Control Panel options for Users?

Are there options to change the format of the control panel/dashboard for **the users** with WordPress? I believe I've seen options for admins, but not users. I'm looking for something much more user friendly than the default CP. Personally I'm a fan of the dashboard for AirBNB.com but perhaps others have better examples? Thanks. --Eric


Why Do I get "wp_remote-get: could not handle for fopen()"?

I'm trying to get an image from Google but... wp_remote_get returns me:               Could not open handle for fopen() to      https://ajax.googleapis.com/ajax/services/search/images?     v=1.0&q=whatever.whatever&key=MYKEYWHICHIDONTPOST&userip=127.0.0"      I don't know why:   * when I enter the url directly I do get results.    * all other wp_remote_gets in the same class work ok so yes php.ini allow=ok this is the code i run:               $referer_url = get_bloginfo('url');     $referer = $parsed_url[host];                        $google_images_url = self::GOOGLE_IMAGES_URL . "&q=" .  $url_to_look_for . "&key=" . $key . "&userip="  . $_SERVER['REMOTE_ADDR'];     $response = wp_remote_get($google_images_url, array( 'headers' => array( 'Referer' => $referer)));      hmmm


Search custom post type with multiple queries

I am looking for way to search custom post type with multiple queries. I need to run single query from user search and if that isnt resulting with single post result to use another query. If first query returns some result (at least one post) second query won't be run. I found `posts_request` filter but it's only to override main query. Is there any simple way to achive this type of search? Do I need to extend WP_Query for that? EDIT: Search is triggered from search form. Thanks in advance.


Sortable admin columns, when data isn't coming from post_meta

I have a custom post type that uses a custom taxonomy. I'm imposing a limit of a single term to each post (using a custom meta box drop down on the edit post screen for the CPT). The term for the taxonomy is assigned using the standard wp_set_object_terms() function. How can I make the taxonomy column sortable (using WP 3.1rc3)? This post by Scribu got me almost there. However, since I'm not using a numeric value stored in a meta key, the {name}_column_orderby function will not work for me. How can I create sortable columns within the manage-edit screens, when the information that I'm listing does not come from the post_meta table?


Add link to attachment for old posts

All images from posts have no link set! How I can add to all posts link to attachment ? There is a filter I can inject on functions.php.


Pages displays correctly but returning a 404 error in http header.

I decided to delete a custom post type and change them to pages instead. The pages display properly but anything in the directory that the custom post type used is returning a 404 even though the pages display normally. Here is an example Every page in the /accidents/ subdirectory is returning a 404 even though the page is displaying the proper content. I deleted all of the posts with that posttype out of the database but I think I must be missing something. Any ideas?


Replacing Scripts in Admin Load_Scripts

I'm currently creating a plugin that requires me to overwrite one of the Wordpress admin panel javascript files. I have recreated the file with the changes, I need to know how to replace the existing file that gets loaded in load_scripts.php (the script needs to be added in the same order). I was hoping something like this would do the job: wp_register_script('admin-widgets', WP_PLUGIN_URL. '/oak-automated- sidebars/oak-widgets.js'); wp_enqueue_script('admin-widgets'); But it doesn't seem to work, the original script is still loaded. Any suggestions?


Categories in admin interface: can they be collapsible?

I have many hierarchical categories, some of which have the same names. Can I add collapsible categories functionality in the category selection widget in the admin interface? I refer to the categories selection widget next to the posts edit screen in the admin interface. From my front end (Mozilla, IE, Chrome) this widget is NOT collapsible, but offers a huge linear listing of categories, which is difficult to navigate. If that widget had little crosses to collapse branches, it would be easier to navigate large branches easier.


Archieve page, Advertisement Every 3 Posts

Currently this code http://pastebin.com/As0exwZy is displaying 10 posts because I set it in the Reading settings. Now what I want is to display a advertisement(widgetize) every 3 posts... how can I do that?


Wordpress Ajax Posting from App

I am working on an App for a University radio station that allows users to listen to the station and read stories from there wordpress site. I can do this functionality easy enough using RSS feeds. An additional piece of functionality required is for users to be able to post comments/feedback live to the DJ. Is there anyway of doing this? My thought was using an AJAX comment plugin and designing the app to fake the AJAX call to post the comment, posting the comment to a different page depending on which DJ is on air at the moment. Any thoughts? Anyone had experience with this kind of thing?


Wordpress category filters as subcategories

I want to develop a course database available in certain countries. Name of country will be set as top most category name. Then it will be sub-categorized alphabetically, subject, degree level and some other parameters. The question is, when showing archive of specific country (top most category) how can I set filters so user may get filtered result (alphabetically, degree level etc) of only same country.


Some images not being returned with wp_get_attachment_image

For some reason this code works on my local copy of a wordpress site but the live site is not working.               // WP_Query arguments         $args = array (             'post_type'               => 'post',             'pagination'             => false,             'posts_per_page'     => '99',             'category_name' => 'wedding'         );              // The Query         $query = new WP_Query( $args );              // The Loop         if ( $query->have_posts() ) {             while ( $query->have_posts() ) {                 $query->the_post();                      $thumb_ID = get_post_thumbnail_id( $post->ID );                 $blogimages = get_post_meta( get_the_ID(), 'blogimages', true );                  if ( $images = get_children(array(                         'post_parent' => $post->ID,                         'post_type' => 'attachment',                         'post_mime_type' => 'image',                         'exclude' => [                             $thumb_ID,                             isset( $blogimages[0]['blog-image-inside'] ) ? $blogimages[0]['blog-image-inside'] : 0,                             isset( $blogimages[0]['blog-image-front'] ) ? $blogimages[0]['blog-image-front'] : 0,                             isset( $blogimages[0]['blog-image-main'] ) ? $blogimages[0]['blog-image-main'] : 0                         ],                     ))) :                      foreach( $images as $image ) :                          echo '
';                         echo 'ID).'" rel="nivo" data-lightbox-gallery="wedding">';                         echo wp_get_attachment_image($image->ID, array(360,999));                         echo '';                         echo '
';                     endforeach;         else: // No images             //This post has no attached images         endif;             }         }         // Restore original Post Data         wp_reset_postdata();      I have one post under the wedding category, with 5 images attached and none of the images are being displayed, is there any reason why that code may not be working? Yet it works perfectly on my local version? In checking my php versions my remote server is running 5.4.26 and my local was on 5.5.10, when I changed local to the same as the remote version it stops working, so it seems to be something with that code on 5.4.26? After messing with the code again I have come up with this bit of code here...                $args = array(             'category_name' => 'wedding',             'pagination' => false,             'posts_per_page' => -1          );          $the_query = new WP_Query( $args );              // The Loop         if ( $the_query->have_posts() ) {             while ( $the_query->have_posts() ) {                 $the_query->the_post();                 $blogimages = get_post_meta( get_the_ID(), 'blogimages', true );                  $attachments = get_posts(array(                     'post_type' => 'attachment',                     'posts_per_page' => -1,                     'post_parent' => $post->ID,                     'exclude' => [                         get_post_thumbnail_id(),                         isset( $blogimages[0]['blog-image-inside'] ) ? $blogimages[0]['blog-image-inside'] : 0,                         isset( $blogimages[0]['blog-image-front'] ) ? $blogimages[0]['blog-image-front'] : 0,                         isset( $blogimages[0]['blog-image-main'] ) ? $blogimages[0]['blog-image-main'] : 0                     ]                 ));                      if($attachments){                     foreach($attachments as $attachment){                         echo '
';                         echo 'ID).'" rel="nivo" data-lightbox-gallery="wedding">';                         echo wp_get_attachment_image($attachment->ID, array(360,999),true);                         echo '';                         echo '
';                     }                 }             }         } else {             echo 'No images found for this category';         }         /* Restore original Post Data */         wp_reset_postdata();      But I am now noticing that if I remove or add images to posts they are not being reflected, but if I delete the post entirely, even after I've already removed images from it, they finally get removed from the gallery page. Also if I add a new post with images under the specified category, the images are not being added to the gallery. Why is this happening, is there some sort of caching thing going on?


How to Change 404 page title

i have try many methods after searching on internet but unable to ramove Nothing Found from my 404 page title how to do it please help me even i have us this in my 404 page header ` if( is_404() ) echo '404 message goes here | '; else wp_title( '|', true, 'right' ); ` i also ramove php title function and five their my own header but still not changing why ?


How to refine WP-Query with further criteria

I have a WP-Query which I pass post IDs to via               'post__in' => explode(',', $my_ids)      I then want the ability to refine this list by a custom field value (if present). I have tried including the custom field test in the args for WP-Query but I get my ID list **PLUS** the custom field post IDs (instead of my IDs filtered by the custom field value). I also tried adding a query_post after the WP-Query as a filter but that didnt work at all. How can I filter the query further?


Plugin privelages for "editors"

I have a few plugins installed in wp that appear in the submenu of the dashboard. I want users with the "editor" role to only have access to specified plugins.


Multiple options not staying selected after saving

**Problems:** The save works, but is only storing one of the options in the database after save. Options not showing as selected after save. The select fields:               <select id="exclude_page_from_cookies" name="exclude_page_from_cookies[]" multiple="multiple">             <?php                  $pages = get_pages();             foreach ( $pages as $page ) {                 $title = get_the_title($page);                 $id    = $page->id;                 ?>                      <option id="<?php echo $id; ?>" value="<?php echo $title ?>" <?php selected( $title ); ?> >                     <?php echo $title;?>                 </option>             <?php             }             ?>         </select>      The save function:               if ( isset( $_POST['exclude_page_from_cookies'] ) ) {         foreach( $_POST['exclude_page_from_cookies'] as $exclude_page ) {              echo $exclude_page;              update_option( 'exclude_page_from_cookies', $exclude_page ) ;         }     }      I understand I have already posted this in regular stack exchange, but since this is a WP thing I figured I'd move it here :)


Why not working /%postname%/ with ajax serverinterval?

I use ajax server interval for load new entries, and if I use this method the function return 404 in 30 second.   If I use default link strukture,work fine.   The mod_rewrite is enabled on my server... The ajax part:               <script>      (function($) {       $(document).ready(function() {         var refreshId = setInterval(function()         {           $('#content').fadeOut("fast").load('new.php').fadeIn("fast");         }, 30000);       });     })(jQuery);          </script>      The PHP:               <?php require_once("wp-blog-header.php"); ?>       <div id="content" <?php cyberchimps_filter_content_class(); ?>>                  <?php do_action( 'cyberchimps_before_content'); ?>                  <?php if ( have_posts() ) : ?>                      <?php while ( have_posts() ) : the_post(); ?>                          <?php get_template_part( 'content',       get_post_format() ); ?>                      <?php endwhile; ?>                  <?php elseif ( current_user_can( 'edit_posts' ) ) : ?>                      <?php get_template_part( 'no-results', 'index' ); ?>                  <?php endif; ?>                  <?php do_action( 'cyberchimps_after_content'); ?>              </div>      If I not use the ajax,this function work fine. My htaccess file content:               # BEGIN WordPress     <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /test/     RewriteRule ^index.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . test/index.php [L]     </IfModule>          # END WordPress      My test site: My test site (Don't worry the other problem like,the page not load or text bugs thats not important.   This erorr(links erorr) also have on my live site,if I enable the pretty permalinks,but now i disabled)   I dont why not working:D Please help me...


why is this content-template not showing any of my blog-entries?

i'm using the blogolife-theme on wordpress 3.6.1 my template looks like this:               <?php     /*     Template Name: Template One     */     ?>          <?php     /**      * A custom template file.      * @package WPLOOK      * @subpackage BlogoLife      * @since BlogoLife 1.0      */     get_header();      $hasSidebar = "";     $sidebar =    get_post_meta($post->ID,'wpl_enable_sidebar',true);     get_template_part('content', 'page' ) ;     //get_template_part('inc', 'indexloop' ) ;     if($sidebar=="false" ) {     echo '

';     } else {          get_sidebar(one);          }     get_footer(); ?>      the content-page.php looks like this:               <?php     /**      * The default template for displaying content      *      * @package wplook      * @subpackage BlogoLife      * @since BlogoLife 1.0      */     ?>

             <?php wplook_doctitle(); ?>             <?php if ( have_posts() ) : ?>             <?php /* Start the Loop */ ?>                 <?php while ( have_posts() ) : the_post(); ?>     <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'wplook' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?>

             <?php the_content(); ?>             <?php wp_link_pages( array( 'before' => '

' . __( 'Pages:', 'wplook' ) . '', 'after' => '
' ) ); ?>

             <?php if ( the_category ( '', ', ' ) ) { ?>
                     <?php _e('Category:', 'wplook'); ?>                     <?php the_category(', ') ?>

                 <?php } ?>                 <?php if ( get_the_tag_list( '', ', ' ) ) { ?>
                      <?php _e('Tag:', 'wplook'); ?>                     <?php echo get_the_tag_list('',', ',''); ?>

                 <?php } ?>

<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'wplook' ), the_title_attribute( 'echo=0' ) ); ?>" rel="nofollow"><?php wplook_get_date_time();?>
                 <?php if ( comments_open() ) : ?>
<?php comments_popup_link(__('No comments', 'wplook'), __('1 comment', 'wplook'), __('% comments', 'wplook'), 'comments-link', __('Comments off', 'wplook')); ?>
                 <?php endif; ?>
<?php wplook_get_author();?>
                 <?php edit_post_link( __( 'Edit', 'wplook' ), '
', '
' ); ?>

                       <?php comments_template( '', true ); ?>                 <?php endwhile; ?>             <?php endif; ?>

      but nothing is happening. my index.php used               get_template('inc' 'indexloop' ) ;      which showed all entries, but when i use this function on my custom template, also nothing appeares. btw. this is my not modified index.php, the modified works the same, only has some edits:               <?php     /**      * The main template file.      *      * @package WPLOOK      * @subpackage BlogoLife      * @since BlogoLife 1.0     */     get_header();     get_template_part('inc', 'indexloop' ) ;     get_sidebar();     get_footer(); ?>


what is __return_false in filters

I was thinking of removing/hiding admin-bar from my wordpress (3.1.1) installation. I visited following link: http://codex.wordpress.org/Plugin_API/Filter_Reference/show_admin_bar I was surprised to see only a single line to remove/hide admin-bar               add_filter( 'show_admin_bar', '__return_false' );      My question is what is **__return_false** means? why __ and _?


Sidebar does not display on blog page, but fine with static pages

Please help as I am loosing my mind with this issue. I built my first really simple wordpress theme. http://www.designstest.co.uk/ For NEWS (blog) page I created a new template page-blog.php (based in index.php that is used by all other pages). The only difference - it has sidebar. It works fine if I apply same template to static page, but it does not display sidebar on NEWS(blog) page. If you see CMR page - it has same template applied as NEWS. I have tried instead of get sidebar just place some simple text and it acts the same - displays text in static pages but not blog. I really don't understand what is going on.


WP Simple Fields - Single repeatable field inside repeatable field group

I have a field group "teaser". Now my teasers have different types like:   * linked headline + image   * unlinked headline + image   * indidivual html The group itself is repeatable because you can add multiple teasers. Up to now I just had the different fields for all types and you would only fill the fields you needed (e.g.: There is a field "HTML" which is only considered if you chose the type "indidvidual html"). Now I have a new type of teasers where multiple images shall be shown in a row, like in a diashow. My problem is, that therefore you should be able to choose multiple images of any number inside the repeatable field group "teaser". But it seems only field groups can be repeatable and not a single field inside. Also maybe my approach is completely wrong... maybe there is another way how to solve this. I found the alternative plugin "Advanced Custom Fields", which might be able to do this, but unfortunately I cannot change the plugin for this project - it's already launched and I would rather extend the simple fields plugin, than updating the templates, redoing and refilling all fields. So do I really have to extend the simple fields plugin to accomplish this? Also there seems to be no option to make conditional fields for the cms only, like choosing an option (e.g. teaser type) and differ the shown fields in that way - but I am just curious if someone implemented something like that and could share his knowledge.


How to create single page site in WordPress

I have total 5 pages on my website, I want to display all pages as single page. It is possible? Example: http://yaremchuk.ru


How to use my style.css file outside of wordpress subdomain?

I am building a wordpress theme from scratch on a subdomain and I want to use the same CSS files across my entire site. My problem is linking my wordpress PHP files (which are on the subdomain) to my CSS files (which are on the main domain). I have tried going into theme.php and changing the ['/style.css'] to an absolute reference such as 'http://diginomics.com/css/style.css' but it doesn't work.               function get_stylesheet_uri() {         $stylesheet_dir_uri = get_stylesheet_directory_uri();         $stylesheet_uri = $stylesheet_dir_uri . '/style.css';      I am assuming my subdomain doesn't have permissions to access my root folder or something is simply wrong with the syntax. I would like to link my wordpress theme to all my CSS files and frameworks and use theme site wide and on all my subdomains. Also, what would the solution be to link my Javascript files site-wide as well?


Retrieve Menu name for nav_menu_item

Given a `nav_menu_item` object, how would I determine the name of the Menu it is associated with? I have a couple menus defined in my theme, as well as, a `nav_menu_css_class` filter. Inside the filter, I only want to add classes to one of the menus. If I can dynamically pull the menu name using the `$item` variable I can make sure I'm only acting on a specific menu.


A real way to override BuddyPress files in a WordPress plugin

Is there a working (must be) way to override BuddyPress template files in via a WordPress plugin. I know it can be done using a theme, but is it possible to do it with a plugin? I'm really eager to create something from it, but can't find how to do that :/


Using 2 URL's for Wordpress

I have a Problem, that my internal company blog should be visible via 2 URL's. One internal and one external. Now I would need to rewrite URL's before content is delivered to the browser. All URL's are in the database and I can't seem to find a place to start rewriting things. Any clue wich hooks might be useful and what can be done to implement this?


how to store arrays into a database

I'm trying the store multiple rows into a database. The number of fields will change. Below is the way that I use to store just one row.                 <?php            if(isset($_POST['save'])){           $wpdb->insert('wp_table_name',               array(                   'field_a' => $_POST['field_a'],                   'field_b' => $_POST['field_b'],                   'field_c' => $_POST['field_c'],                   'field_d' => $_POST['field_d']                                ),               array(                   '%s',                   '%s',                   '%s',                   '%s'                   )               );       }       ?>            <form>           <input type="text" name="field_a[]"/>           <input type="text" name="field_b[]"/>           <input type="text" name="field_c[]"/>           <input type="text" name="field_d[]"/>                <input type="text" name="field_a[]"/>           <input type="text" name="field_b[]"/>           <input type="text" name="field_c[]"/>           <input type="text" name="field_d[]"/>                <input type="text" name="field_a[]"/>           <input type="text" name="field_b[]"/>           <input type="text" name="field_c[]"/>           <input type="text" name="field_d[]"/>                <button type="submit" name="save">Save</button>       </form>


How to upload/update theme from local - bitbucket - shared hosting?

I am having tough time to figure out the best most appropriate way to maintain and update my custom theme for wordpress. I have setup local server (wamp) with wordrpess where I mainly develop my theme and push everything to bitbucket. At this point I usually just upload my theme from my local machine to ftp server theme folder - and voilà! However, this seems like an old approach. I see people talk more and more about dynamic update - push theme directly to host (from lets say bitbucket). I tried to search for best approach and a "how-to" tutorial however I failed. My hosting is shared and does have ssh access. How to use all of this - no idea. Maybe someone could direct me to a tutorial?


WP_QUERY Get posts by category and similar name (Like)

I have a small problem with wp_query. I want to get the posts filtered by category and with similar project name (like query), so im trying this code:               $args=array(     'post_type' => 'post',     'post_status' => 'publish',     'category_name' => 'projects',     'name__like' => 'Proj');          $my_query = null;     $my_query = new WP_Query($args);     if( $my_query->have_posts() ) {     while ($my_query->have_posts()) : $my_query->the_post();         echo '
'.get_the_title().'
';     endwhile;     }     wp_reset_query();      Actually it displays the projects filtered by category, but the name__like is not working. How can i fix it?? Thank you.


insert a taxonomy for a custom post type

I have been created a custom post type and create a taxonomy for it, below is the code which i used to create those:               //create custom post type of jobs     add_action( 'init', 'create_jobs' );     function create_jobs() {         register_post_type( 'jobs',             array(             'labels' => array(                 'name' => 'jobs',                 'singular_name' => 'Jobs',                 'add_new' => 'Add New',                 'add_new_item' => 'Add New Jobs',                 'edit' => 'Edit',                 'edit_item' => 'Edit Jobs',                 'new_item' => 'New Jobs',                 'view' => 'View',                 'view_item' => 'View Jobs',                 'search_items' => 'Search Jobs',                 'not_found' => 'No Jobs found',                 'not_found_in_trash' => 'No Jobs found in Trash',                 'parent' => 'Parent Jobs'             ),                  'public' => true,             'menu_position' => 15,             'supports' => array( 'title', 'editor', 'comments', 'thumbnail' ),             'taxonomies' => array( '' ),             'menu_icon' => 'dashicons-visibility',             'has_archive' => true             )         );     }          //create a taxonomy for jobs     add_action( 'init', 'create_jobstax', 0 );     function create_jobstax() {         register_taxonomy(         'jobs_taxonomy_genre',         'jobs',         array(             'labels' => array(                 'name' => 'Create Jobs Genre',                 'add_new_item' => 'Add New jobs genre',                 'new_item_name' => "New jobs genre"             ),                      'show_ui' => true,                 'show_tagcloud' => false,                 'hierarchical' => true                       )         );       }      now what i want is to insert a default taxonomy for that custom post type only, example: i want to insert "latest" and "active" as a default taxonomy for the jobs custom post type, how to achieve that? currently looking for a approach around but seems found nothing to meet my needs. Any ideas, recommendations and suggestions, would love to hear. Very thank you in advance.


Website showing random code like texts in a post after pasting from MS Word

My website is showing this type of content in a blog. When I click the title of same content, the content is fine there. It shows this type of content in one of the many listed contents. What can be the possible reason?               Normal     0          false     false     false          EN-AU     X-NONE     X-NONE                    DefSemiHidden="false" DefQFormat="false" DefPriority="99"     LatentStyleCount="371">               UnhideWhenUsed="true" QFormat="true" Name="heading 2"/>     UnhideWhenUsed="true" QFormat="true" Name="heading 3"/>     UnhideWhenUsed="true" QFormat="true" Name="heading 4"/>     UnhideWhenUsed="true" QFormat="true" Name="heading 5"/>     UnhideWhenUsed="true" QFormat="true" Name="heading 6"/>     UnhideWhenUsed="true" QFormat="true" Name="heading 7"/>     UnhideWhenUsed="true" QFormat="true" Name="heading 8"/>     UnhideWhenUsed=”true” QFormat=”true” Name=”heading…


Where to add the_post_thumbnail( )

I am trying to add the featured image of a post into my category archive pages. My theme already supports post-thumbnail (used for the sliding top menu of the sliding doors theme). from what I gathered I need to modify "the loop" and add `the_post_thumbnail( 'thumbnail' );` somewhere in it. Questions is where? I tried different places and no matter what I do, nothing happens. I tried putting it in the _category.php_ files, same thing. Once I get it to pop up somewhere I should be able to arrange formatting but right now, no matter what I do it's got no effect on the page. edit: I was able to make the thumbnail appear. My problem was that I didn't put it in the right place. Now, formatting is clearly not as easy as I thought: if I put it right after the while (have_posts() .....) it'll show, but it puts it above the post title, details, etc. if I try to put within the existing code, no matter how I do it, the thumbnail won't show. below is what the unmodified code loops like. I'd like to split this in 2, having the thumbnail on the left and the rest on the right.               <?php if ( in_category( _x('gallery', 'gallery category slug', 'slidingdoor') ) ) : ?>         <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'slidingdoor' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?>

                 <?php slidingdoor_posted_on(); ?>


Are term IDs unique even between multiple custom taxonomies

I can't find the answer for this question on either Wordpress or here, nor via Google searches, so I'm throwing this out to the community. If you have two taxonomies, and you add 1 term to each taxonomy, will the first term added in taxonomy_1 have a term ID of 1 and the second term added to taxonomy_2 have a term ID of 2?


Hide post completely and still reach it via cURL

I've been struggling with this for several hours. I want to have a post hidden from every listing, including the posts edit screen, and having it not reachable by browsing to it. I successfully did this with the **pre_get_posts** action hook, but I need to be able to make the post reachable again only when I'm running a specific function, where I use cURL to request the post and do some validations, then I want to hide it again as soon as I'm done with it. The problem I'm having, is that cURL gets a **Not Found** response when my **pre_get_posts** hook is active. I have tried using a *remove_action( 'pre_get_posts', 'my_function' )* statement, but it seems it's not taking it and I can't get to the post. I thought of having the post just be a private post, or password protected, but I really prefer to have this post hidden completely. I also tried the **posts_where** filter, same thing, it works but I can't make cURL get the post correctly. Those are the only two hooks I have found that do what I want, but for some reason I cannot remove them. Can anyone please share some ideas on how to make this work? Or, what am I missing? Thanks! Edit: Ok, here's the code I have for the **pre_get_posts** hook:               function hide_post( $query ) {         $query->query_vars['post__not_in'] = array( $hidden_post_id ) );     }      And this is the code I use to show/hide the post:               remove_action( 'pre_get_posts', 'hide_post' );     $post_permalink = get_permalink( $hidden_post_id );          $ch = curl_init();     curl_setopt( $ch, CURLOPT_URL, $post_permalink );     curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );     curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0 );     curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 0 );          $buffer = curl_exec( $ch );     curl_close( $ch );          remove_action( 'pre_get_posts', 'hide_post' );      Worth noting that the part that's not working as I would expect is the remove_action() part, where I should be able to get to my hidden post and after that I will hide it again.


Custom Search Page to a different table in the same db

I am new to wordpress and php. I want to create a search page. The inputs are: State, GoverningOrg, ProgramType, Orderby. Then press the submit button. So basically what I did was create a new page and then chose the default template. I want to add the inputs pluse the submit button. And then it would return the query below. Please advise Cheers! Sherwin


How to paginate get_categories?

I have been working on this code for about a week now. I have tried many things. My recent attempts today resulted in infinite loops that just made the browser keep posting the posts. This is what I get without limiting the posts. ![bad result](http://i.stack.imgur.com/02GTZ.png) This is what I have now and want setting number => 3 in my `get_category` args. ![desired result](http://i.stack.imgur.com/9aP7d.png) This chunk of code below is what needs to be paginated. The allcats variable is passed to the foreach loop and returns the posts needed. The args in the foreach loop gets passed to the query which would handle getting the posts that are listed under the categories of Dinner Menu, Lunch, Pasta. It's the foreach loop that I can't figure out how to re-write into a working query that I can paginate.                //setting the paged variable trying to get pagination      $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;           //the allcats variable gets the child categories of Dinner menu, Lunch, Pasta that are assigned to the parent category of Menu      $allcats = get_categories(array('child_of' => get_query_var('cat'), 'number' =>    3,'order'=> 'asc', 'paged' => $paged));       foreach ($allcats as $cat) :              $args = array(           'category__in' => array($cat->term_id),           'paged' => $paged       );      Now, in the above code, I had hoped that setting the paged variable would work. I experimented by putting in 'paged' => $paged into the args but this does not work. Now I figured that it won't work because the number => 3 that is set above in the $allcats variable is telling WordPress to only return 3 categories. Problem is that I plan on having many more than 3 categories. I only want to display 3 categories on each page. The wine list that you see in the photo above needs to be on page 2. My issue is that I cannot figure out how to get the posts to show on a regular WordPress query so that the paged variable can do it's job. The only way I can get the posts the way I need them is by using the get_categories method with the foreach loop to get the child category. I am using a plugin to get the images that are attached to the child category. Here is the rest of my code:                 query_posts($args);       if (have_posts()) :       echo '
';              //this bit of code gets the images attached to the category using the plugin         $terms = apply_filters( 'taxonomy-images-get-terms', '' );         if ( ! empty( $terms ) ) {         foreach( (array) $terms as $term ) {                 if($term->term_id == $cat->term_id) {                   echo wp_get_attachment_image( $term->image_id, 'menu' );                 }         }         }           //Display the category title of Dinner Menu, Lunch, Pasta      echo '
'.$cat->name.'
';      echo '
';           //Get all the post titles that are posted to the categories of Dinner Menu, Lunch, Pasta        while (have_posts()) : the_post(); ?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?>
           <?php       endwhile;        echo '

';             ?>            <?php else :        echo 'No post published in:'.$cat->name;                       endif;        wp_reset_query();       endforeach;        ?>
<?php next_posts_link( __( '← Older posts', 'paradiso' ) ); ?>

<?php previous_posts_link( __( 'Newer posts →', 'paradiso' ) ); ?>


WordPress Redirect on Name Change

I changed the domain name in my WordPress options menu because I was changing the domain name of my site. Now, however, the page never loads. What can cause this and/or how can I revert it back to the previous domain?


Filter posts by meta query?

I made custom post type and used a meta query … For this link:               wp-admin/edit.php?s&post_status=all&post_type=itinerary&action=-1&m=0&ipt_country=0&ipt_city=0&paged=1&mode=list&action2      … I want this this meta query to apply:               'meta_query' => array(                 array(                     'key' => 'ipt_country',                     'value' => $qv['ipt_country']                 ),                 array(                     'key' => 'ipt_city',                     'value' => $qv['ipt_city']                 )                            ),      How can I do that?


Order posts by how many categories it is assigned to in total

I'm already doing some custom ordering based on various stored custom fields but this latest one has me stumped. I know I can get the count for how many categories a post is assigned to, but this only helps me re-arrange them as I display the posts - no good for pagination. Ideally something like this would be awesome:               else if($orderItems == 'relevance'){         $wp_query->set('order','DESC');         $wp_query->set('orderby','category_count');     }      Thanks for your time


How to avoid website url appending problem in wp site?

On localhost when I opens my site (Ex: **http://example.com** ) and when I select any navigation menu then the url of my selected navigation menu appends the previous url. some what like this ( **http://example.com#http://localhost/example.com/?page_id=2** ) but I just want ( **example.com/?page_id=2** ). I damn sure the problem should be in index.php but I am unable to solve it. Anyone can help me to resolve it? Can anyone answer it?


WPDB query - decrypting DB data

I am trying to grab data from the DB using WPDB but I am stuck on how to decrypt the data e.g. The data is stored as: a:2:{i:0;s:2:"92";i:1;s:2:"71";} I want the 92 & 71 as that's my post IDs, how to I get that part from the DB using WPDB? My code so far is:               $crosssells = $wpdb->get_results(      "SELECT *        FROM $wpdb->postmeta       WHERE _crosssell_ids != ''       "     );      The table is only created when data is in putted in the post so I need to check if the table exists and then grab the post id's


How to get main menu only with wp_nav_menu

I have created one menu and have some sub-menu but I don't want to display any sub-menu from my template. My Menu code:               <?php wp_nav_menu( array('menu' => 'header-uk', 'menu_id' => 'nav', 'menu_class' => 'sitemap', 'fallback_cb' => false) ); ?>      My Menu Screenshot: ![enter image description here](http://i.stack.imgur.com/9JDFG.png) I want to display only this menu in my template:               Awards     Sagres Town     Getting Here     Sister Hotels     Other     Work for Martinhal     Disclaimer     Site Map


Get tags for post_type

I have several custom post types that all share the same tags. On the archive for each custom post type I want to display a list of tags used, and the number of posts associated with each. `get_tags()` by default pulls all its information from the entire site content. I can't find any filters for the `get_tags()` function, and I don't want to perform and intensive queries/functions to manually count and restrict.


Remove parent page from url

I would like to remove the parent page name from the permalink. At the moment, I have site.com/parent-page/child-page.php and I would like to have something like that site.com/child-page.php


Should I enable FastCGI on WordPress?

I am looking at my server settings and these are as follows: >   * WebDav : active > >   * FastCGI : inactive > >   * SSL support : active > >   * Perl as Apache module : CGI-Programm > >   * PHP module : CGI-Programm > >   * Memory usage : 131072 kB > >   * Process timeout : 60 seconds > >   * Maximum simultaneous processes : 1024 > > Using WP-Supercache (mod-rewrite mode) and have around 6,000 posts. Should I enable FastCGI on my server? Any other settings you recommend changing?


Plugin frontend with themes

I'm developing a calendar plugin and i need to show my content like a page, how i integrate my plugin file with themes? I created a index.php file in my plugin directory and load the get_header() get_footer() but i dont know if it right.


How to avoid foreach error WebDevStudio's WDS_Taxonomy_Radio taxonomy metabox class?

What is the correct way to use WebDevStudio's WDS_Taxonomy_Radio taxonomy metabox class? I have included the code in my functions.php file but I'm getting an error that reads: *Invalid argument supplied for foreach() WDS_Taxonomy_Radio.class.php on line 45* so I must be doing something wrong. The instructions on GitHub say to: > Initialize the class (update the taxonomy slug with your own) using the code `$custom_tax_mb = new WDS_Taxonomy_Radio( 'custom-tax-slug' );`. Of course I updated the slug to my taxonomy's. The script otherwise works. Any help is appreciated! Links   1. https://github.com/WebDevStudios/WDS_Taxonomy_Radio   2. http://webdevstudios.com/2013/07/08/replace-wordpress-default-taxonomy-metabox-with-a-radio-select-metabox/


Conditional Check in The Loop's Parameters

I have several loops each of them built to display a certain category in different style, based on user's input (they're within shortcodes). Now I want to "merge" these (or just 1 of them) loops with the loop to display recent posts, regardless of the category. Currently this is my code (to display post from a certain category):               $args = array(       'category_name' => $category,        'showposts' => $numposts,        'order' => $order     );          $query = new WP_Query( $args );          while ($query->have_posts()) : $query->the_post();     // loop's usual stuff      As I said, they are inside shortcodes, so, $category, $numposts (number of posts) and $order are user's input (shortcode's atts) Anyway, to display the recent posts, all I have to do is take away the category part. However, when I did that from the shortcode's "side" (by not filling the shortcode and not displaying it), the loop is broken. I suppose it is because I have declared "category" within the query parameters. I've tried:               $args = array(        if (!empty($category)) {         'category_name' => $category,       }       'showposts' => $numposts,        'order' => $order     );      but of course, it is throwing an error :P. Well, I guess at least it is better explaining what I am trying to achieve. My question: Is there anyway around this or should I build a new shortcode / loop, specific to just display the recent posts? Thanks in advance. EDIT: Longer code:               function boxed_category($atts, $content) {         extract(shortcode_atts(array(           "category" => '',           "numposts" => '-1',           "order" => 'ASC'         ), $atts));              $output = '';              $args = array(           'category_name' => $category,            'showposts' => $numposts,            'order' => $order         );              $query = new WP_Query( $args );              while ($query->have_posts()) : $query->the_post();      well, not many difference - function name because it is originally made to display a certain category (inside "boxed" - CSS) - I want to turned this shortcode to have a "Recent Posts" option. I'm going to need more atts, but first, need to figure out how to "get rid" of $category from the query should a user chose "Recent Posts" option.


Download an image from a webpage to the default uploads folder

I am writing a custom theme/site in which I need to download images programatically from certain webpages to the upload folder and then insert them as part of the post. So, I was able to find the image url's programatically, and then I need to save them to the upload folder under w-content, however that folder has specific WordPress folder structure inside it for the saved images. Now my question is, is there a WordPress API or function or method that will allow me to download images from the web and save them to the uploads folder? And if so, what is it. Otherwise, what should I do to save those images? So far, I am doing this               $filetype = wp_check_filetype(basename($image_file_name), null );          $upload_dir = wp_upload_dir();          $attachment = array(         'guid' => $upload_dir['url'] . '/' . basename( $image_file_name ),          'post_mime_type' => $filetype['type'],         'post_title' => preg_replace('/\.[^.]+$/', '', basename($image_file_name)),         'post_content' => '',         'post_status' => 'inherit'     );          $attachment_id = wp_insert_attachment( $attachment, $image_file_name, $post_id );          $attachment_data = wp_generate_attachment_metadata( $attachment_id, $image_file_name );          wp_update_attachment_metadata( $attachment_id,  $attachment_data );     set_post_thumbnail( $post_id, $attachment_id );      But the above code is giving me the following error               imagejpeg(http://wscdn.bbc.co.uk/worldservice/assets/images/2013/07/21/130721173402_egypts_new_foreign_minister_fahmy_304x171_reuters-150x150.jpg): failed to open stream: HTTP wrapper does not support writeable connections in C:\dev\wordpress\pterodactylus\wp-includes\class-wp-image-editor.php on line 334      And after further investigation, it looks like the error is cause by               $attachment_data = wp_generate_attachment_metadata( $attachment_id, $image_file_name );      And after even further investigation, the documentation for `wp_insert_attachment()` states that _`The file MUST be on the uploads directory`_ in regards to the `$image_file_name` So, how do I download an image and save it to my post correctly? Thanks a lot.


Easiest Way to Authenticate WP Users Using an External DB?

I have been looking for the best/easiest way to share users on a WP blog (in a subfolder) with the MAIN site's user database so that people do not have to register/log in on the WP blog when already registered/logged in on the main site. It seems like this should be a fairly "common" thing, that a blog is a PART of a larger website, rather than a stand-alone website, but apparently not. I have found plenty of info on sharing users between 2+ WP installations, but the main site in my case is NOT another WP site. I had looked at a plugin called "external DB authentication" but it apparently does not work with the more recent versions of WP. In a nutshell, I just want users on my main site to be shared with my WP blog and be able to post without having to register or login again. Any tips/suggestions will be very much appreciated!


Disable visual editor on one specific page

I would like to remove the visual editor from one specific page because if I edit this one page in Visual mode, it breaks the code. I want to make sure the client doesn't have this option on the particular page. However, I don't want to remove the html editor. This line of code removes the visual editor and the html editor: remove_post_type_support('page', 'editor'); a closer look at remove_post_type_support: http://codex.wordpress.org/Function_Reference/remove_post_type_support But I want to only disable the visual editor. Initial testing, in functions.php for this theme, I have:               function remove_editor_init() {           if ( is_admin() ) {         if (is_page(2548)) {                    remove_post_type_support('page', 'editor');         }      }     }     add_action('init', 'remove_editor_init');      However, the conditional statements is_admin() and is_page() don't seem to working together. Any suggestions?


Archive show thumbnail

I want to show thumbnails next to my posts in archive page, however it only shows thumbnails if the posts has a featured image. So I want to show thumbnail for the image attached to the post, but I don't know how to. At the moment I am using the following code to show thumbnails if set as featured.               <?php if ( has_post_thumbnail()) : ?>        <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >        <?php the_post_thumbnail(thumbnail, array('class' => 'alignleft')); ?>        </a>     <?php endif; ?>      Any suggestions are appreciated


Widget which displays thumbnails, but links to urls?

I'm working on a wordpress site and need to have a widget on the sidebar which has thumbnails, but links to URLs specified per thumbnail rather than the images. It seems simple, but I can't find any plugin to do it in a way a non- developer can from the admin panel. Currently the NextGEN gallery plugin is being used. Is there any way to configure that, or any similar plugin, in that manner? How hard would it be to build a plugin from scratch to achieve this, and do you think that's necessary?


WYSIWYG editor in WP 3.2 plugin

I've created my own WP 3.2 plugin. Now I want to put the WYSIWYG editor in it. I've tried the following code:               <?php the_editor(null, 'body', null, false); ?>      Then it's displayed. I don't know why, but the CSS doesn't look as it should look. Am I missing something? Should I include any CSS file?! ![weird tinymce](http://i.stack.imgur.com/o9JIG.png) Please look at the HTML/Visual buttons and the size of the content area.


Excerpt formatting for Google News Feed

We're currently bringing in a Google RSS News Feed using FeedWordPress and it works great. This issue is that Google uses a defined table structure in their RSS. The excerpt function has no problem stripping all the tags but it leaves the excerpt cluttered with 3 unwanted snippets of text; Image Caption, Article Title and News Source. Here is an example; _msnbc.com1000-year-old hoard of gold coins dug up at Crusades sitemsnbc.comA 1000-year-old hoard of gold coins has been unearthed at a famous Crusader battleground where Christian and Muslim forces once fought for control of the Holy Land, Israeli arch…_ The offending snippets use the "a" and "b" tags. You can view it live at this link; http://www.orrvweb.com/?cat=123 Our site uses the Third-Style theme which is a variant of Twenty-Eleven. We've looked for suitable plugins and tried many of the excellent code samples available of this site thanks to Boutros, Alchymyth and others but we can't get the code to function. The smoothest thing we've found is the Advanced Excerpt plugin. It works flawlessly with our site but lacks the exact functionality. If we could modify it to strip out the tags and text it would be an ideal solution. Any input or ideas would be greatly appreciated.


An issue with register_sidebar and the admin interface

Okay, I'm sure there is an simple explanation for this problem... it's just that I can't see it right now. Here is my code adding widget sidebars:               add_action('widgets_init', 'starter_register_sidebars');          function starter_register_sidebars() {          register_sidebar(array(         'id' => 'sidebar',         'name' => __('Sidebar'),         'description' => 'The first (primary) sidebar.',         'before_widget' => '
',         'after_widget' => '
',         'before_title' => '
',         'after_title' => '
',         ));          register_sidebar(array(         'name' => __('Main Sidebar'),         'id' => 'sidebar-1',         'before_widget' => '',         'after_widget' => "",         'before_title' => '
',         'after_title' => '
',         ));          }      So when I go the admin widget area it tells me: 'Drag widgets from here to a sidebar on the right to activate them' But there is not sidebar on the right created by the above code... I've looked at a couple of other themes at what they do, and it's not obvious what they are doing differently from me