Shortcode callback for add_action('wp_footer')

I am trying to build a Google Maps shortcode using the gMap plugin from Github, not a plain iframe. For which I have to echo a custom inline script for EACH shortcode, right before the closing body tag, after jQuery and all other scripts have been loaded. The following shortcode works, but it only adds the inline script once, not for every shortcode. When I add three [map] shortcodes, it should add the inline script for each og the shortcodes, three inline scripts, to the footer. But it only adds one script. Which is the one from the last shortcode.               class map_class     {         protected static $var = '';              public static function map_callback($atts)          {                  extract(shortcode_atts(array(                     'address'               => 'Main Street, New York City, United States',                     'zoom'                      => '14'                 ), $atts));                      $id= rand();                      $script  = '';                 $script .= '';                  self::$var = $script;                  add_action( 'wp_footer', array ( __CLASS__, 'footer' ), 20 );                          return '

';                    }              public static function footer()          {           echo self::$var;         }          }     add_shortcode( 'map', array ( 'map_class', 'map_callback' ) );      $script is holding all three inline scripts, but when I try to call $script in add_action like this:               add_action( 'wp_footer', array ( __CLASS__, $script ), 20 );      .. I get the following error: "First argument is expected to be a valid callback" I appreciate any help here.


How to change the quantity of feeds in custom post type?

I created a custom post type "podcast" and all podcasts are inside it. when I visit `http://example.com/?feed=podcast`, it only shows latest 10 podcasts. How do I change it to 99? I googled and found the code below:               function feedFilter($query) {     if (is_feed()) {         $query->set('posts_per_page','30');     }     return $query;}     add_filter('pre_get_posts', 'feedFilter');      It doesn't work. How to customize the feed items quantity in a custom post type?


How to register and enqueue JavaScript files without breaking plugin dependencies?

In theme development, what is the best way to register and enqueue JavaScript files to avoid problems with plugins? I want to create a theme which uses scripts like jQuery, Masonry and so on. I downloaded the scripts and added them via the reqister and enqueue function to **avoid problems with Wordpress Updates**.               function my_scripts() {       // Register scripts       wp_register_script( 'my_masonry', get_template_directory_uri() . '/js/masonry.pkgd.min.js', array(), '1.0.0', true );        // Add scripts before closing body tag.       wp_enqueue_script( 'my_masonry', true );     }          add_action( 'wp_enqueue_scripts', 'my_scripts' );      **The other way** would be to use the built-in Wordpress scripts to may avoid problems with plug-ins.               function my_scripts() {       // Add scripts before closing body tag.       wp_enqueue_script( 'masonry', true );     }          add_action( 'wp_enqueue_scripts', 'my_scripts' );      What is the better approach?


Should I escape wordpress functions like the_title, the_excerpt, the_content

I had look at the code but I couldnt see any escaping on funcions like `the_title` `the_content` `the_excerpt`etc. I might not be reading it right. Do I need to escape these functions in theme development like: `esc_html ( the_title () )` Edit: as pointed out in the answers below the above code is wrong regardless - the code should have read `esc_html ( get_the_title () )`


Can't Access Subdirectory

I've moved my blog from http://leghumped.com/blog to http://leghumped.com/ and now I can't access my /images directory. I've tried every combination of rules from trawling for people with the same problem, but it seems most of them say it "just started working". This is my root .htaccess               # BEGIN WordPress>     RewriteEngine On     RewriteBase /     RewriteCond %{REQUEST_URI} !^/images/     RewriteCond %{REQUEST_URI} !^/images     RewriteCond %{REQUEST_URI} !.*images(.*)     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /index.php [L]     RewriteRule ^index\.php$ - [L]          # END WordPress     RedirectMatch wp/(.*)$ http://leghumped.com/$1      I know I'm typing the filename correctly, but I can't access anything in /images.


LIKE %...% Meta Query

I have a serialized array as a meta value and I'm trying to run WP Query where it finds a specific value in the serialized array. Here's an example of the serialized array field:               a:6:{i:0;s:3:"173";i:1;s:3:"172";i:2;s:3:"171";i:3...      Here's my query, but it doesn't work: The ID's are numberic I'm doing a search for as well.               $practiceArgs = array(         'post_type' => 'attorney',         'post_status' => 'publish',         'posts_per_page' => -1,         'meta_query' => array(                             array(                                   'key' => 'practice_area',                                   'value' => $post->ID,                                   'compare' => 'LIKE',                                   'type' => 'NUMERIC'                                   )                             )     );      I've tried using `'value' => '%'.$post-ID.'%'` in my queries, but it doesn't seem to work as well. Anyone ever had any experience working on this?


Why is WordPress saving full-urls to the database?

Every time im about to put my local project into staging/production environment im beeing hardly reminded that WordPress saves all the urls as absolute.So i need to rewrite all the urls with a SQL-query, or use something like Search-and-replace script. **But why is WordPress doing this?** What is the benefits? Is it a must for WordPress to work correctly? There are themes like Roots where there are functions like `roots_root_relative_url` using `preg_replace` to remove the full url. Wouldn't it be better to only have relative urls, **what is the downsides of that?** **The benefits of Relative urls in the database can be:** Easy migration from local to stage/production on all links, attachments and so on. Cleaner, shorter urls in html. But, Because WordPress doing absolute urls i sure that its good, im only want to now why and why not.


Insert data on comment post

I am trying to find reference for comment_post to insert custom data to custom table when comment post. I want to insert below things to my custom table   1. Comment's Post ID    2. Custom content (which will done with custom query) Can anyone please help me to do this?


Problem by $output and permalinks

I have a problem by `$output` in a plugin in My custom Template, I do it this:               $output .= "
'".php the_title()."'>
";      But the link doesn't work it return just the normal text and not the link to the post, can somebody help me?


Replacing WordPress Icons (menu,icons32, etc)?

I want to replace wordpress admin sprites. I recreated the images and looked answrs for icon replacement using jquery and simply with CSS BUT what about ones link icons32-2x.png where I can't find the CSS? So I am trying to figure out a simple way to redirect the wordpress admin and includes folder to use my new icons INDIVIDUALLY. Again this is just not for custom post type icons but all. Basically I think through jQuery using replaceWith new icon but how can I replace an image if I don't know where its called in CSS (i.e. retina images) so I need a resolution to direct specific images in admin wp-admin and wp- includes folder.   * mydomain.com/wordpress/wp-admin/images/   * mydomain.com/wordpress/wp-inlcudes/images


Custom post type permalink endpoint

I have a custom post type called "destinations" and I have set the EP mask for the post type to default EP_PERMALINK. I have added a couple of endpoints as follows :               add_filter( 'query_vars', 'add_query_vars');          function add_query_vars($vars){         $vars[] = "tours";         $vars[] = "activities";         return $vars;     }          add_action('init', 'add_endpoints');          function add_endpoints(){         global $wp_rewrite;               add_rewrite_endpoint('tours', EP_PERMALINK);         add_rewrite_endpoint('activities', EP_PERMALINK);              $wp_rewrite->flush_rules();     }      Now if I test this on a normal post it redirects to the template that I need it to (I have a template redirect for the single template hook) ie. somesite.com/test-category/test/activities/ But for the post type (which is hierarchical) it just removes the endpoint from the url and stays on the single-destination.php template ie. somesite.com/destination/south-africa/kruger-national-park/activities/ becomes somesite.com/destination/south-africa/kruger-national-park/ Any help or guidance will be greatly appreciated. I have been struggling with this for hours and no results :( Thanks


Can I display submenus in groups, using wp_list_pages?

Say I have top-level(parentless) pages called **Fruit** , **Animals** , **Cars**. When, say, **Fruit** is selected I would like to show links to the individual **fruit** pages below. I would like to be able to dislpay these **fruits** (or **animals** , or **cars** ) in several groups with a space between each group of fruits.. a bit like this               +---------------+-----------+--------+     |   Fruit       |  Animals  |  Cars  |     +---------------+-----------+--------+        |   Apple       |           |        |     |   Kiwi        |           |        |     |   Watermelon  |           |        |     +---------------+-----------+--------+       |   Banana      |           |        |     |   Lemon       |           |        |     +---------------+-----------+--------+       |   Strawberry  |           |        |     |   Raspberry   |           |        |     +---------------+-----------+--------+        You can see in this case, I have roughy divided the **fruit** by color, putting a space inbetween. For **cars** or **animals** it might be another criteria. This criteria does not have to be explicitly named anywhere. So I wondering how to output this list, in a way which requires little techinical ability for the person who enters the pages in the backend. At the moment I do this to output the child pages:               if( $post->post_parent )         $children = wp_list_pages('depth=1&title_li=&child_of='.$post->post_parent.'&echo=0');      else         $children = wp_list_pages('depth=1&title_li=&child_of='.$post->ID.'&echo=0');          echo $children;      But I can't see a way to limit the output to categories, or something similar, using wp_list_pages. The nearest I can see is the 'authors' option, but it doesn't make much sense to login as different users to create different blocks in the menus...


Show the title of the latest post by author

I have the following function which I use to show the author name,author avatar and the author biography in a div. I need to show the title of the latest post by the author along with this. Can anyone help?               function ajaxified_function()      {          $response = new WP_Ajax_Response();         $id        = $_POST['author_id'];         $auth_name = get_the_author_meta('display_name', $id);         $avatar    = get_avatar($id);         $desc      = get_the_author_meta('description',$id);         $auth_desig  = get_the_author_meta('designation', $id);         $output = "
$auth_name
\n
$auth_desig
\n
$avatar
\n
$desc
\n";         $response->add(array(         'what' => 'has',         'data' => $output     ));      $response->send();     }


What is the action or filter for adding information under the Permalink in Edit Post/Page?

I would like to add some HTML under the "Permalink:" in the Edit Post/Page page. Under here: ![Under Here](http://i.stack.imgur.com/mPAR5.png) So what is the action or filter?


Category Foreach keeps looping?

I'm using the following code to acquire all the child categories of a category and displaying the child posts of the child categories.               <?php     $cats = get_categories( 'child_of='.get_query_var( 'cat' ) );          foreach ( $cats as $cat ) :              $args = array(             'posts_per_page' => 3, // max number of post per category             'category__in'   => array( $cat->term_id )         );         $my_query = new WP_Query( $args );               if ( $my_query->have_posts() ) :             echo '
'.$cat->name.'
';             ?>                  <?php while( $my_query->have_posts() ) : $my_query->the_post(); ?>                 <a href="<?php the_permalink(); ?>"><?php the_title(); ?>
               <?php endwhile; ?>              <?php else : ?>             No Posts for <?php echo $cat->name; ?>         <?php endif; ?>     <?php endforeach; ?>      and i want to acquire this output.                Cat Child 1      -Post1 Child 1      -Post2 Child 1      -Post3 Child 1      -So on... .           Cat Child 2      -Post1 Child 2      -Post2 Child 2      -Post3 Child 2      -So on... .      But instead of that, both the child categories are being repeated over and overagain. Can anybody tell me what the problem is? This is the output I have now.                Cat Child 1      -Post1 Child 1      -Post2 Child 1      -Post3 Child 1      -So on... .           Cat Child 2      -Post1 Child 2      -Post2 Child 2      -Post3 Child 2      -So on... .      Cat Child 1      -Post1 Child 1      -Post2 Child 1      -Post3 Child 1      -So on... .           Cat Child 2      -Post1 Child 2      -Post2 Child 2      -Post3 Child 2      -So on... .      Cat Child 1      -Post1 Child 1      -Post2 Child 1      -Post3 Child 1      -So on... .           Cat Child 2      -Post1 Child 2      -Post2 Child 2      -Post3 Child 2      -So on... .      until it loops 9 times and stops. what is the problem?


W3 Total Cache, RackSpace Cloud Files, and Forcing Downloads

I'm using W3 Total Cache's CDN connection to RackSpace CloudFiles to serve severall hundred media files. My goal is to get the files to download in the user's browser, rather than stream. According to the CloudFiles Documentation (http://docs.rackspacecloud.com/files/api/v1/cf-devguide-20111115.pdf) I can set the Content Disposition headers. Does anyone know how this can be done via W3 Total Cache or, perhaps, around with it? Or, alternatively, do you know of another way to force downloads for files served via the CDN?


how to 301 redirect from a plugin folder

Some how google indexed a directory inside one of the plugins I use. I cannot figure out how to set a 301 redirect from the indexed path to the home page. has anyone else seen or dealt with this? here is what google indexed. I have replace all personal information with generic. http://www.domainname.com/wp-own-dir/wp-content/plugins/plugin-name- here/directory-in-plugin/


Facebook comment box won't show on main page

I have a custom pinterest like theme, you can see it here: http://www.recipetags.com/ If you click an image, the post comes up, but the FB comment box won't show, it's right under the title of the image. If I inspect that area, I can see that the code for the FB comment box IS being inserted, it's just not showing. When you click an image, and look in the address bar, the url to the post is displayed. If you click inside the address bar and go to the post, the comment box DOES show there. I'm using a FB comment plugin, but I get the same result when I use the code supplied by FB developers. What could cause the box NOT to show, even though the code for it is there? I hope my question is clear.


Restrict post to user_id

I only want a post to be viewable by the administrator and one user. (So I would have a post for each user) I am thinking of using the Members plugin and meta-data/custom fields to restrict the content. This would effectively make the post private to only those with access and any one else would not even see the post and if they get the url, they will be denied. So would using the Members plugin be the best choice or should I try a different method? and how?


Problem on the_excerpt(); function <the_excerpt> <the_content>

I am working on wordpress but I have problem when I write   the_content('read more'); then on indexpage each post load full data of post but I want to but when I am using the_excerpt(); then wordpress return a 10-15 word on index page and when i click for read more or click on title of post then 30-40 words just show without images... Please help me what should I do? check here is screenshot


Make Terms Under Custom Taxonomy Use Specific Single.php Template

Yesterday some wonderful people helped me solve the issue here about templates for custom taxonomy terms. Now I have a related question. Again, I have a custom post type set up in my functions.php called "Research" I have a custom taxonomy called "Classifications" Under that taxonomy I have the terms: oldresearch (parent) --- subcat1 --- subcat2 I need all the single pages under this term "Old Research" and in the sub cats to use one template. I already have a single-research.php that is being use elsewhere. So that's not my preferred option. Any ideas? Please be detailed as I'm a PHP newb - sorry. lol Thanks in advance!


How to diplay a div only if at least one author custom profile field is filled?

I try to build a small plugin that adds few social profile fields to WordPress user form and display their social icons to the author meta box on single post. The problem I face is as follow: The frontend social icons are enclosed in a div with a certain height and background color(via css). If no field is filled by the user, my div still appears but empty(normal) with defined height and background color, what is unaesthetic. How can I make that div not appearing if not filled at least one social profile field? Here's my code snippets used so far (pseudo codes), that I think are necessary to illustrate my problem :               class My_Social_Icons {              static $social_icons_array = array(             'digg'          => 'Digg',             'dribbble'      => 'Dribbble',             'facebook'      => 'Facebook',             'flickr'        => 'Flickr',             'github'        => 'Github'             );          } // class end               function social_extra_fields( $extra_fields ) {              foreach ( My_Social_Icons::$social_icons_array as $social_id => $social_name ) {             $extra_fields[$social_id] = $social_name;         }         return $extra_fields;     }     add_filter( 'user_contactmethods', 'social_extra_fields' );      And here is the output that will display the social icons in frontend:               function display_icons( $icons = '' ) {              $social_icons_fields = get_the_author_meta(???);              if ( !empty( $social_icons_fields ) ) { // here I need to check if at least one field is filled             $icons .= '
':     // here is my code to display the social icons, not mentioned here             $icons .= '
';                  return $icons;         }     }     add_filter ( 'the_content', 'display_icons', 0 );      Any help would be greatly appreciated!


Why does a variable work on the front page but return NULL on all other pages?

Hey all. For my theme, I have multiple sidebars. Each sidebar file has a variable of $sidebar_id assigned to it. So, for sidebar-1.php, $sidebar_id = 1, for sidebar-2.php, $sidebar_id = 2, and so on. Each sidebar has an action hook inside of it. Then I write a function to hook on to the sidebar action hook. Within the function, I reference $sidebar_id to display different content in different sidebars. WordPress recognizes the value of $sidebar_id on the front page. But on archive pages, single pages and single posts, $sidebar_id always returns NULL. Even if I declare it as a global in my function. I don't get why the function can recognize the variable on the front page but it can't on all other pages. Any insights would be greatly appreciated. For example, here is my function:               function archive_only() {     global $sidebar_id;     if($sidebar_id == "archives") {     echo "only show on archive sidebar";          }     } add_action('cpress_sidebar_after', 'archive_only');       It works on the front page but doesn't on any other pages. $sidebar_id is defined in the sidebar template files.


convert Custom Fields Option-Values to Tags/Taxonomy

I have Custom Post Type "Places". In that I have Created Custom Fields. Like: **Option Title »** Type of Pub   **Option values »** Sports, Rock, Biker, Beer, Live Band, Restro, Gastro, Irish, Karaoke Bar   **Field Title »** Type of Pub   **Field name »** typeofpub What I want is to convert each title and values to tags. So that I should be able to click on them. And when I click on them it should go to the `archive- tags.php` and display all the posts with that option value.


Pagination Issues using WP_Paginate Plugin

So I have read more posts and articles about this issue than I care to admit and still nothing I can find works. Here is the issue - I can not get the pagination to advance and it shows all the same posts over and over - like I have seen in other posts. **Here is what I am using (2 seperate templates for different categories):**               <?php     $paged = get_query_var( 'page' );     query_posts('cat=4&paged='.$paged);     if(have_posts()) { while(have_posts()) { the_post();      ?>      **It works fine , but then I go to the only other page on the site - which uses the same code in the loop, different category (3) and it does not work there, it is not a typo, etc.** **I have also tired the following:** if(have_posts()){ $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts($query_string . "&cat=4"); while(have_posts()){ the_post(); global $more; $more = 0; **OR**               query_posts('cat=3&paged='.get_current_page());       if(have_posts()){       while(have_posts()){       the_post();       global $more;       $more = 0;      With the get_current_page function, I used this hack, which I was told by WP VIP was not the way to do things (but it worked for both pages):               /* Get current page for paginaton navigation */      function current_page() {      $pageURL = 'http';      //check what if its secure or not      if ($_SERVER["HTTPS"] == "on") {      $pageURL .= "s";      }      //add the protocol      $pageURL .= "://";      //check what port we are on      if ($_SERVER["SERVER_PORT"] != "80") {      $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];      } else {      $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];      }      //cut off everything on the URL except the last 3 characters      $urlEnd = substr($pageURL, -3);      //strip off the two forward shashes      $page = str_replace("/", "", $urlEnd);      //return just the number      return $page;      }      **Please help!!!**


How Do I Link My Whole Featured Article Image?

I'm using the Front Slider plugin to display featured articles on my site. I've done some editing to the plugin to make it look the way I want. Somewhere along the way, I must have missed changing a value, because the top half to the image for the article being displayed links to the article while the bottom half does not. Assuming it's as simple as I think, all I need to know is what code I need to find and replace. Thanks in advance.


Ad rotator script for Adsense/CPA rotations. Ideas? Existing Solutions?

My theme handles Adsense inclusion automatically for the end user. I'm looking to add a feature that allows them to rotate in CPA ads in place of the adsense ads (on a set frequency by percentage). In other words, they can specify an image and url, then assign a weight to the CPA ad unit to determine how often it gets inserted in place of the adsense code. Are there any examples or existing plugins that do this well?


WP 3.0.5: Best way to add custom metaboxes for post categories?

I haven't been working with WP for a while and noticed that there are some new features in WP 3+ such as creating meta data for taxonomies. I'd like to be able to add unique meta data setups for different categories on my posts - what would be the best approach for this? Take for example the following categories: "press releases"   "cases"   "concepts" In the first, I'd like the admin to be able to attach more than just 1 image (the default thumbnail). In the other two I need the option of an additional textbox. Is this easier to do with custom post types? I'd rather work with the regular post categories. Thanks,   -Staffan


How to include PHP files in plugins the correct way

My problem is when on the main plugin file i include a php file something like this:               include(WP_PLUGIN_URL . '/wordpress-group-buying/ipn/paypal-ipn.php');     //or     include_once(WP_PLUGIN_URL . '/wordpress-group-buying/ipn/paypal-ipn.php');     //or     require(WP_PLUGIN_URL . '/wordpress-group-buying/ipn/paypal-ipn.php');     //or     require_once(WP_PLUGIN_URL . '/wordpress-group-buying/ipn/paypal-ipn.php');      and on that file i have a call to a WordPress function like add_action('hook,'callback'); and i get **Fatal Error: Call to undefined function add_action() ....** now before you say "use if( **function_exists** ('add_action')){" if i use that then it just doesn't work. ## the questions:   * what would be the correct way to do that?   * what are the difference between include ,include_once,require and when do i use witch? thanks for any help!


Restore svn trunk of my plugin repository to the initial state?

I messed it up and I don't know how to fix it. I thought it would be easier if I just literally delete all the files and start over again. Is there a way to do it? I tried some tips in google to no avail. Neither 'svn cleanup' nor 'svn delete' works. :-(


permissions on themes directory

I have a `ftp` user like owner of all files and directories. When I try to modify any file (e.g. `styles.css`) with Editor from Admin Panel I see this message:               To save the changes, is needed that the file has write permissions. Visit the codex for more information.      (I've translated the message so it won't be the exact text in english) I've tried to change group owner to my Admin Panel user name and give `0664` permissions to all files inside the theme directory, but it doesn't work:               cd /wp-content/themes     chown -R ftpuser:adminPanel twentythirteen/     find twentythirteen/ -type f | xargs chmod -R 0664 //this will change all files inside `twentythirteen` (not directories) into 0664 mode      The only way I've found to achieve it is giving `666` permissions:               find twentythirteen/ -type f | xargs chmod -R 0666      but I don't want it. How could I handle this?


No "Users" tab for other administrator-level users

I have WP working great for me and I'm the main 'admin' user. I've created Administrator-level accounts for other people in my company. When they log in, they see exactly what I see except they don't see the "Users" tab. Is this a feature of WP, that only the main (original user #1) 'admin' can see the Users tab? Or a bug?


How to retrive Custom Post Type Meta Fields in Custom WP_Query

Can some one let me know How I can render the Custom Post Type Meta Fields (Meta-boxes). I have a Custom Post Type Called "News" and I successfully added a Metabox to my Custom Post Type called "News Info" which is suppose to store :   **A TextField = News Resource      A Select option = News Type      A check box** ![enter image description here](http://i.stack.imgur.com/4s1a9.png) I can retrieve the Custom post Type "News"content using a custom Loop as:               <?php      $args = array( 'post_type' => 'news');      $loop = new WP_Query( $args );      while ( $loop->have_posts() ) : $loop->the_post();         the_title();         echo '
';         the_content();         echo '
';      endwhile;     ?>      But I have no idea how to get the associated meta fields to "news" posts? trust me I Google this a lot but couldn't find any solution all of them just tried to render the Metabox on the admin page but no sample for presenting on the page! Can you please let me know how I can get access and render the data on the page using the wp-query loop? Thanks


Prevent Wordpress from sending emails

It seems like some wordpress installations on my server are sending spam. How can I find out, which script in the wordpress installation is sending it? Are these notifications on comments? Or fake comments? each time suche a mail is sent this shows up in syslog:               grep 6AE861E102E1 syslog                    Sep  6 15:53:49 myserver postfix/pickup[25439]: 6AE861E102E1: uid=33 from=<www-data>       Sep  6 15:53:49 myserver postfix/cleanup[32763]: 6AE861E102E1: message-id=<9a05e17c68fc8e2698d9bfe5943df86f@www.someblog.de>        Sep  6 15:53:49 myserver postfix/qmgr[1768]: 6AE861E102E1: from=<www-data@www1.myserver.de>, size=5334, nrcpt=1 (queue active)      Sep  6 15:53:50 myserver postfix/smtp[32765]: 6AE861E102E1: to=<ba.em@live.de>, relay=mx1.hotmail.com[65.54.188.72]:25, delay=1.6, delays=0.12/0.01/0.49/0.94, dsn=2.0.0, status=sent (250  <9a05e17c68fc8e2698d9bfe5943df86f@www.someblog.de> Queued mail for delivery)                                     Sep  6 15:53:50 myserver postfix/qmgr[1768]: 6AE861E102E1: removed


Custom fields not showing on front-end after xml import

I've just imported 700+ custom posts from one WP install to another using the XML import/export option. Everything seems to be imported fine: the field values are showing in the DB and on the admin side. However, if I try to get the field value on the front end by `get_field('field_name')` (I use Advanced Custom Fields), the value doesn't show. It does show when I save the corresponding post. Now I'm not planning on saving 700+ posts one by one, and I also don't want to do a clean WP install as suggested here.


adding multiple sidebars on pages

I am using twentyten theme and I want there to be two sidebars on my page - one on the left and the second on the right.   Can any one tell me how to do that?


Author must complete profile info before they can publish a post?

I am creating a real estate site where user info is essential part. The author info need to display under their post so that the visitor know how to contact them. Thus, the contact info in profile page is an essential part that the author must be filled. So I like to know is there anyway to force author to complete the profile information before they can publish a post??


One category not displaying template updates

I've tried refreshing, clearing the cache, opening in a new browser, renaming it from index to category.php-- ALL but one category display the correct template. I'm beyond stumped. One clue is that if I omit the loop from the template, the sidebar shows up. Otherwise it gets the 'cached' or previous version of that template page.


Changing wordpress permalinks for new posts only

I currently have many posts using the default permalink structure, domain.com/?p=123 I would like my new posts only to use a different permalink structure, domain.com/year/month/post/ The problem is that if I change permalinks, my social media plugins reset -- e.g. the 'like' counts -- presumably because these plugins store posts by URL. Thus, I would like to change permalinks for my new posts only. Suggestions on the best way to accomplish this?


Pull product info into WordPress page

WooCommerce has several functions that are related to the tabs, but I'm struggling to pull them into a regular wordpress page.               woocommerce_default_product_tabs          woocommerce_output_product_data_tabs      This is what I've tried.               global $woocommerce;     $productTabs = $woocommerce->woocommerce_output_product_data_tabs(35);     echo $productTabs;      With "35", I am trying to pull the product tabs of only that specific product ID. In this case, 35.


How to redirect action=register link on the lostpassword page to a different link?

I have a specific wordpress registration page where I have a new user complete their registration form. However, if someone clicks on the "forgot password" link in the login section of my site and then clicks on register, they'll be able to register for the site without going through the normal registation form. How can I redirect the wp-login.php?action=register page to sample.com/register ? Thanks in advance!


Search through custom post type and custom fields takes 5 minutes

I got strange problem and im stuck. I have custom post type with around 15 custom fields. I moved data from old db (not wp) by using `wp_insert_post` ,`update_post_meta` and `wp_set_object_terms`. All went good. All vcards works fine. I got 3500 vcards and now when i try to search some vcards - search just freeze for 10 minutes then i get timeout. Same thing is in admin panel if i try to search in custom post type menu search takes 10 minutes and dies... So i have a question is wordpress capable to handle that amount of custom post type posts ? or i made some mistake in coding ? If You need any kind of code to show please tell me i will paste it here since now i dont even know where to start search. Best Regards Charles * * * Here is a code: First of all i drop other pages from search - i need only my custom post type               function search_types($query) {     if ( $query->is_search )      {         $query->set('post_type', 'vcard');          }     return $query;      This part of code i found on net and just adjusted it to my needs: I grab all custom fields ( now in code i got only 1 field becouse of testing - normally is about 15)               function custom_fields_search() {     global $wpdb;          $sql = "SELECT meta_key FROM ". $wpdb->prefix . "postmeta mk WHERE mk.meta_key LIKE 'companyKeyWords'";     $results = $wpdb->get_results( $sql );          if ( $results ) :         foreach ($results as $result) {             $custom_fields[] = $result->meta_key;         }     endif;          return $custom_fields;      Now those 3 function with filter               function custom_search_groupby($groupby) {     global $wpdb, $wp_query;          $groupby = "$wpdb->posts.ID";          return $groupby;     function custom_search_join($join) {     global $wpdb, $wp_query;          if ( is_search() && isset($_GET['s']) ) {              $join  = " INNER JOIN $wpdb->term_relationships AS r ON ($wpdb->posts.ID = r.object_id) ";         $join .= " INNER JOIN $wpdb->term_taxonomy AS x ON (r.term_taxonomy_id = x.term_taxonomy_id) ";         $join .= " AND x.taxonomy = '".GO_TAX_CAT."'";                   // if an ad category is selected, limit results to that cat only         $catid = $wp_query->query_vars['cat'];              if ( !empty($catid) ) :                  // put the catid into an array             (array) $include_cats[] = $catid;                  // get all sub cats of catid and put them into the array             $descendants = get_term_children( (int) $catid, GO_TAX_CAT );                  foreach ( $descendants as $key => $value )                 $include_cats[] = $value;                  // take catids out of the array and separate with commas             $include_cats = "'" . implode( "', '", $include_cats ) . "'";                  // add the category filter to show anything within this cat or it's children             $join .= " AND x.term_id IN ($include_cats) ";              endif; // end category filter                   $join .= " INNER JOIN $wpdb->postmeta AS m ON ($wpdb->posts.ID = m.post_id) ";         $join .= " INNER JOIN $wpdb->terms AS t ON x.term_id = t.term_id ";          }          return $join;      }               function custom_search_where($where) {     global $wpdb, $wp_query;     $old_where = $where; // intercept the old where statement     if ( is_search() && isset($_GET['s']) ) {              // get the custom fields to add to search         $custom_fields = custom_fields_search();         $customs = $custom_fields;              $query = '';              $var_q = stripslashes($_GET['s']);         //empty the s parameter if set to default search text         if ( __('What are you looking for?','go') == $var_q ) {             $var_q = '';         }              if ( isset($_GET['sentence']) || $var_q == '' ) {             $search_terms = array($var_q);         }         else {             preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $var_q, $matches);             $search_terms = array_map(create_function('$a', 'return trim($a, "\\"\'\\n\\r ");'), $matches[0]);         }              if (!isset($_GET['exact']) ) $_GET['exact'] = '';              $n = ( $_GET['exact'] ) ? '' : '%';              $searchand = '';              foreach ( (array)$search_terms as $term ) {             $term = addslashes_gpc($term);                  $query .= "{$searchand}(";             $query .= "($wpdb->posts.post_title LIKE '{$n}{$term}{$n}')";             $query .= " OR ($wpdb->posts.post_content LIKE '{$n}{$term}{$n}')";             $query .= " OR ((t.name LIKE '{$n}{$term}{$n}')) OR ((t.slug LIKE '{$n}{$term}{$n}'))";                  foreach ( $customs as $custom ) {                 $query .= " OR (";                 $query .= "(m.meta_key = '$custom')";                 $query .= " AND (m.meta_value  LIKE '{$n}{$term}{$n}')";                 $query .= ")";             }                  $query .= ")";             $searchand = ' AND ';         }              $term = $wpdb->escape($var_q);              if ( !isset($_GET['sentence']) && count($search_terms) > 1 && $search_terms[0] != $var_q ) {             $query .= " OR ($wpdb->posts.post_title LIKE '{$n}{$term}{$n}')";             $query .= " OR ($wpdb->posts.post_content LIKE '{$n}{$term}{$n}')";         }              if ( !empty($query) ) {                  $where = " AND ({$query}) AND ($wpdb->posts.post_status = 'publish') ";                  // setup the array for post types             $post_type_array = array();                  // always include the ads post type             $post_type_array[] = GO_POST_TYPE;                       // build the post type filter sql from the array values             $post_type_filter = "'" . implode("','",$post_type_array). "'";                  // return the post type sql to complete the where clause             $where .= " AND ($wpdb->posts.post_type IN ($post_type_filter)) ";              }     }          return( $where );      At the end, I applyfilters :               add_filter('posts_join', 'custom_search_join');     add_filter('posts_where', 'custom_search_where');     add_filter('posts_groupby', 'custom_search_groupby');


Redirect after post deleted

On the single template, I am using a delete post link generated by the get_delete_post_link function. When I use the link to delete the post I am currently on, it adds a query string of ?trashed=1&ids=10, but, as expected, the page generates a 404 error as that post is now gone. I'm just wondering if anyone knows an action/filter I can use to detect when the post has been deleted, so I re-direct the page somewhere else afterwards? Thanks!


Help with Magpierss and Wordpress

Hoping someone can help. I'm trying to update a friends website - the original developer has gone AWOL unfortunately and left me to pick up the pieces. On the front end of the site the developer has installed Magpierss to have a twitter feed scroll along the bottom. However we've just noticed that in the blog section (powered by wordpress), they've actually hard coded the feed so it never updates. I've tried editing the wordpress footer to reflect that of the one uses on the front-end as per below:

<?=$rss_news_items ?>

      And have updated functions.php with following:                   <?php     define('MAGPIE_DIR','magpierss');          require_once(MAGPIE_DIR.'/rss_fetch.php');          $url = 'http://twitter.com/statuses/user_timeline/421720094.rss';          $num_of_items = 10; //set  $num_of_items = 'All' to show all items;          if ( $url ) {         $rss = fetch_rss( $url , 3600 ); //60 * 60 = 1 hour cache age         $rss_feed_name =  $rss->channel['title'] . ' Updated: '. $rss->channel['lastbuilddate'] ;              if($num_of_items=='All') $num_of_items = sizeof($rss->items);              if(sizeof($rss->items) < $num_of_items)  $num_of_items = sizeof($rss->items);              $rss_news_items = '';         for ($i=0; $i < $num_of_items; $i++) {             $href = $rss->items[$i]['link'];             $title = $rss->items[$i]['title'];             $description = $rss->items[$i]['description'];             $date = $rss->items[$i]['pubdate'];                  $rss_news_items .= '   '.$description.' ';         }          }          ?>      I've uploaded the Magpierss folder to the site's theme folder but I keep getting an error in the wordpress footer saying that the directory doesn't exist. I then thought I could just use the front end version and just call the same footer.php include file that the front end of the site is using from within wordpress' footer.php file. Again - this threw an error saying something about absolute urls' not being allowed. If anyone could help it would be greatly appreciated - I'm still learning wordpress and am primarily a front-end developer rather than a PHP developer - so i'm feeling a bit out of my depth. Thanks


How to customize wp_signon()

I am trying to get a customized sign on process. The features that are absent in WordPress by default are the following:   1. Allow user to choose a password at the time of registration.   2. Allow user to sign in using social networks particularly Facebook, Twitter and Google plus.   3. Verify user's Cell Phone number using sms for activating account.   4. Let the default role of every new user, irrespective of the sign in method, be elevated to `contributor`.   5. Upon successful log in, the user should be directed to his own personalized dashboard instead of the static home page. So my questions are:   * I have looked at numerous plugins which provide social media log ins, but all of them signup the user as a contributor. So, how do it change this behavior?   * How do I send both the email and sms verification before activating the account? Which hook do I need to use here?   * Once the user logs in successfully, how do I redirect him/her?   * How do I let the user select the password, or better still, present the user creation page seen by admin only to the anonymous user?


Register and load scripts

In my `functions.php`                   function load_scripts()              {      wp_enqueue_script( 'jquery' );     wp_register_script( 'modernizr', get_template_directory_uri() .'/js/modernizr.foundation.js' );     wp_enqueue_script( 'modernizr' );     wp_register_script( 'jquery.simpleWeather', get_template_directory_uri() .'/js/jquery.simpleWeather.js', array( 'jquery'));     wp_enqueue_script( 'jquery.simpleWeather' );             }             add_action( 'wp_enqueue_scripts', 'load_scripts ');      I try to register and load scripts to my wp theme. For `jquery.simpleWeather.js` i have a part of code that load in the `header.php`                               Also i edit the code :                     But the scripts didn't register and load. Any idea? Thanks.


Loop through posts and get the list of all terms for a taxonomy

I'm within taxonomies (a) archive and I want to loop through all the posts and retrieve a list of terms for taxonomy (b) then echo that list out with no duplicates. Here's what I have so far in my `taxonomy.php`:               while (have_posts()) : the_post();       $terms = get_the_term_list( $post->ID, 'role-type', ' Role(s): ', ' ', ' ' );       echo $terms;     endwhile;      Lets say there are three posts in the archive this then echos the following: > Role(s): DOS FE RSM RSS Role(s): DOS FE SPMs RSS Role(s): CSO What it should do is display something similar to: > Role(s): DOS FE RSM RSS SPMS CSO What do I need to do? Thanks for your help.


Custom post types working in functions.php but not in plugin

I want to register a WordPress custom post type. This works perfectly fine in the functions.php, but not in my plugin file. The plugin does work except for registration of the CPT. The code is pretty standard. Registering the CPT:               add_action( 'init', 'produkte_menu' );     function produkte_menu() {     register_post_type( 'produkte',     array(     'labels' => array(     'name' => 'Produkte' ),     'public' => true,     'menu_position' => 4,     'add_new' => '',     'supports' => array( 'title' ),     'taxonomies' => array( '' ),     'has_archive' => false,     'exclude_from_search' => true     )     );     }     function toggle_custom_menu_order(){     return true;     }      I don't want the editor for this CPT:               add_action('init', 'init_remove_support',100);     function init_remove_support(){         $post_type = 'produkte';         remove_post_type_support( $post_type, 'editor');     }      Finally, I hide the "add new" button:               add_action('admin_menu', 'hide_add_new_custom_type');     function hide_add_new_custom_type()     {         global $submenu;         unset($submenu['edit.php?post_type=produkte'][10]);     }      I'm stuck here. Any help would be appreciated!


how to change my child theme featured image dimensions?

I am developing a child theme based on the twentyten theme and now i notice the featured image in the WP backend (wp-admin) shows the wrong scaled image. It shows the "twenty ten" size, meaning an image scaled to x198. How do i show the featured image of my chosen size??? regards,


How can I stop access of unregistered user in wp-content/uploads directory without using .htaccess file?

I want to give permission to only registered users into my `wp- content/uploads` directory and stop access for those users which are not members on my site.


Page can not be updated and disappeared in "show all page"

I have a strange problem now. Today I am editing a very old page. I restored to old version and also modified something. Suddenly I found I can never update that page. Then I tried set it pending then set back to published. The "no update" issue still there. What is worst is I can not find it in "page List". As you can see from the picture: All(3): only show 2 When I click Pending(1): No page found I have right to approve page as I am the only user. That page can only be found by clicking "edit this page" link when browse it as a reader. ![Only show 2 pages](http://i.stack.imgur.com/6F9vL.gif) ![The pending 1 page can never be shown!](http://i.stack.imgur.com/rjkJX.gif)


Bootstrap and Respond.js

I'm using Bootstrap in a Wordpress theme and I need to support IE8 I need to load respond.js in wordpress so I can support IE8 I can't get respond.js to load correctly. I've tired: A respond.js plugin - https://wordpress.org/plugins/respondjs/ Using wp_enqueue_script to add resond.js and Adding the respond.js inline in the html. Has anyone added respond.js to wordpress, what is the best way to do it.


Sort posts of custom_post_type according other post_type with metabox

I'll try to be as specific as possible because it's a bit confusing what I require. I'm trying to make a connection between two post_types with the help of a Metabox; This Metabox is showing in both post_types (see picture) ![enter image description here](http://i.stack.imgur.com/dJkLZ.png) I have a page in which I want to make a loop to display the post of 'post_type' => 'politics' (I'm using query_posts), but my question is how to display them in the order I want: If there is a recent post on 'post_type' => 'post' with value 'ENTITY 1' checked I want to show the post of 'post_type' => 'politics' which also has the value 'ENTITY 1' at the beginning and sort them well according to the activity of the posts of 'post_type' => 'post' Thanks and hope i've been sufficiently explicit.


Error when activating child theme: `failed to open stream: No such file or directory`

I get the following error message on wamp after I activated my child theme. what am I doing wrong?               Warning: include(C:\wamp\apps\test/wp-content/themes/test/functions/options-panel/customizer.php) [function.include]: failed to open stream: No such file or directory in C:\wamp\apps\test\wp-content\themes\newcastle\dwframework\theme-options\config.php on line 86         Call Stack         #   Time    Memory  Function    Location         1   0.0016  754008  {main}( )   ..\index.php:0         2   0.0029  871416  require_once( 'C:\wamp\apps\test\wp-admin\admin.php' )  ..\index.php:12         3   0.0036  897368  require_once( 'C:\wamp\apps\test\wp-load.php' ) ..\admin.php:30         4   0.0043  923064  require_once( 'C:\wamp\apps\test\wp-config.php' )   ..\wp-load.php:29         5   0.0063  1054736 require_once( 'C:\wamp\apps\test\wp-settings.php' ) ..\wp-config.php:120         6   1.4685  54915528    include( 'C:\wamp\apps\test\wp-content\themes\newcastle\functions.php' )    ..\wp-settings.php:291         7   1.4693  54951624    include( 'C:\wamp\apps\test\wp-content\themes\newcastle\dwframework\config.php' )   ..\functions.php:5         8   1.4715  54984536    include( 'C:\wamp\apps\test\wp-content\themes\newcastle\dwframework\theme-options\config.php' ) ..\config.php:91


wp_parse_args & category parameter

Am trying to use this code:               function wp_custom_archive($args = '') {             global $wpdb, $wp_locale;                  $defaults = array(                 'cat' => 6, //doing nothing                 'format' => 'html',                 'show_post_count' => true,                 'echo' => 1             );                  $r = wp_parse_args( $args, $defaults );             extract( $r, EXTR_SKIP );                  if ( '' != $limit ) {                 $limit = absint($limit);                 $limit = ' LIMIT '.$limit;             }                  // over-ride general date format ? 0 = no: use the date format set in Options, 1 = yes: over-ride             $archive_date_format_over_ride = 0;                  // options for daily archive (only if you over-ride the general date format)             $archive_day_date_format = 'Y/m/d';                  // options for weekly archive (only if you over-ride the general date format)             $archive_week_start_date_format = 'Y/m/d';             $archive_week_end_date_format   = 'Y/m/d';                  if ( !$archive_date_format_over_ride ) {                 $archive_day_date_format = get_option('date_format');                 $archive_week_start_date_format = get_option('date_format');                 $archive_week_end_date_format = get_option('date_format');             }                  //filters             $where = apply_filters('customarchives_where', "WHERE post_type = 'post' AND post_status = 'publish' AND ", $r );             $join = apply_filters('customarchives_join', "", $r);                  $output = '
';                      $query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC $limit";                      $key = md5($query);                 $cache = wp_cache_get( 'wp_custom_archive' , 'general');                 if ( !isset( $cache[ $key ] ) ) {                     $arcresults = $wpdb->get_results($query);                     $cache[ $key ] = $arcresults;                     wp_cache_set( 'wp_custom_archive', $cache, 'general' );                 } else {                     $arcresults = $cache[ $key ];                 }                      /*echo '
';                 print_r($arcresults);                 echo '
';*/                      if ( $arcresults ) {                     $afterafter = $after;                     foreach ( (array) $arcresults as $arcresult ) {                              $url = get_month_link( $arcresult->year, $arcresult->month );                         // translators: 1: month name, 2: 4-digit year                          $text = sprintf(__('%s'), $wp_locale->get_month($arcresult->month));                         $year_text = sprintf('
%d
', $arcresult->year);                         if ( $show_post_count )                             $after = ' ('.$arcresult->posts.')' . $afterafter;                         $output .= ( $arcresult->year != $temp_year ) ? $year_text : '';                         $output .= get_archives_link($url, $text, $format, $before, $after);                              $temp_year = $arcresult->year;                     }                 }                  $output .= '
';                  if ( $echo )                 echo $output;             else                 return $output;         }      from this post to display archives by year and month with a category parameter but without any luck so far. When i change the `show_post_count` value to `false` it doesn work well, but nothing happens when i add a category parameter as seen here. I've also tried with tags and custom fields, nothing works. I've checked the wp_parse_args function and it seems to accept normal parameters such as wp_query. Any clue?


How can i run the same WordPress install on multiple subdomains?

My site is installed on my main domain, lets say something.com for an example. I have WooCommerce installed and i would like to run the shop part of the site on store.something.com with the same WordPress install. Also, the blog would run on blog.something.com. I think Multisite is not what i'm after based on the "Before You Create A Network" article in the Codex. Is it possible to do this without installing multiple Wordpress on the subdomains?


front end or back end posting?

i want to let my users post their own content to my site. i have tried both the front-end and the back-end ways to do that. problem is: front-end way: can't find a way to display a proper preview of the content (which is trivial on the wordpress back-end) back-end way: can't find a way to fully customize the "add new" form in order to make it simple enough for my users to use. do you know any good solutions for those problems? some general information aobut my site: - using WPML plugin for translations - running as a multisite network


Backing up Wordpress before an update, what's the easiest way to do this?

I'm about to update my Wordpress blog to the latest version. It was recommended that I backup my posts and database first. It seems like a plugin would be the easiest way for me to do this. What's the best plugin available for this? Searching Wordpress' site I found the BackUpWordPress plugin: http://wordpress.org/extend/plugins/backupwordpress/ Alternatively, if a plugin isn't recommended, how should I do this instead?


Is it possible to load a different sidebar in single.php based on a meta_query filter?

I have a custom post type 'speakers' and I have a checkbox custom field (meta_query) to separate my Conference speakers from my Workshop speakers. I can filter my speakers with this meta_query and things are working fine. But how do I use a different sidebar based on the Conference or Workshop speaker meta_query? When I click the speakers for their detail (no matter Conference or Workshop speaker) the detail page loads my single-speakers.php and the code to get the sidebar in my single-speakers.php is:               <?php get_sidebar(); ?>      How can I specify a different sidebar, for example get_sidebar('workshop')? Can I write a conditional code to load a different sidebar based on the speakers meta_query? Does this make sense? Thanks


add_action hook for publish_post not working

I can't get my function to trigger on post update or save. I've found a couple of other forum posts around with the same problem, but never an answer :( My code is as simple as:               function pdfgenerator_update($post_ID) {         global $MYTEST;         $MYTEST["pageID"] = $post_ID;              }     //add_action('trashed_post','pdfgenerator_update');     //add_action('publish_page','pdfgenerator_update');     //add_action('save_post','pdfgenerator_update');     //add_action('edit_post','pdfgenerator_update');     add_action('publish_post','pdfgenerator_update');     add_action('edit_post','pdfgenerator_update');     //add_action('edit_page_form','pdfgenerator_update');          global $MYTEST     $MYTEST["Am I running"] = "YIPPEE";      (N.b. $MYTEST is an array I use to collect debug info which I then print_r in the admin footer.) As you can see, I've tried a number of different hooks. The only one I ever got working was the edit_page_form... but that didn't seem to pass in any parameters. And I do definitely need the parameters. Also, there's a point of principle. If the correct hook is publish_posts then I damn well want to know why it fails for me. The code is in my main plugin file, and that is demonstrably being loaded as the YIPPEE is printing correctly. It seems absurd that this isn't working. I've found so many tutorials and examples exactly like this. I'm frankly getting a little ape here. It should just work! What am I missing? Many thanks for your help. Alastair


Where to upload my new custom ShortCode in Separate .php file?

I wrote my first ShortCode in a file called: myShortCodes.php. Does the add_shortcode go in the same PHP file as the ShortCode itself? Where do I upload it? How does WordPress know to look in my file? I don't have to modify \wp_includes\shortcodes.php do I? So far I have tried uploading myShortCodes.php to   1. wp-includes/myShortCodes.php   2. wp-content/themes/mytheme/skeleton/myShortCodes.php


Modify links under 'help section'?

I am trying to modify the support links under the help section (Contextual help).I want to replace these Documentation on Using Themes and Support Forums with my own .So I removed the links in wp-admin folder from many pages under admin section .But for plugin pages,I can't able to find the files to remove. Is there any way to replace or remove the links site wide ?


Sanitizing search data for use with WP_Query

I'm using heavily-customised WordPress to drive a fishkeeping website. I have two separate search areas: a site-wide search and a fish species search. The latter also has advanced search features which will search certain meta values in the "species" custom post type (to allow users to search for fish that can be kept in a certain water hardness, for instance). I want to use `search.php` to deal with all of these, so I'm using `WP_Query`. The search forms have something along the lines of `<input type="hidden" name="type" value="species" />` to specify the kind of search being performed. The code I'm utilising is as follows:               <?php         if (isset($_GET["s"])) {             $search_term = $_GET["s"];         }              if (isset($_GET["type"])) {             switch ($_GET["type"]) {                 case "profile" :                     $post_type = "species";                     break;                 case "glossary" :                     $post_type = "glossary";                     break;                 default :                     $post_type = "any";                     break;             }         }              $args = array(                     's' => $search_term,                     'post_type' => $post_type                 );              $query = new WP_Query ( $args );     ?>      My (lengthy, with apologies) question is this: what's the best command to use to sanitize the data from the search box? Thanks in advance,


Pagination problem after WP_Query with tag filtering

I have a problem with a custom WP_Query. I want a page with all posts with a specific tag. This is the code I'm using:               <?php      //save old query     $temp = $wp_query;      //clear $wp_query;      $wp_query= null;       ?>           <?php      // The Query     $wp_query = new WP_Query();     $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;     $args = array( 'tag' => 'concurs', 'paged' => $paged );     $wp_query->query($args);     ?>     <?php      // The Loop     while ( $wp_query->have_posts() ) :         $wp_query->the_post();      ?>       [some code that displays the title, excerpt, meta-info (author, category, date) and thumbnail]            <?php endwhile; ?>     <?php posts_nav_link(); ?>                   <?php      //clear again     $wp_query = null;      //reset     $wp_query = $temp;        ?>       The problem is that when I switch to page 2 or 3 I get the same 10 first posts. What I am doing wrong?


In a subdomain network, what .htaccess settings can I use to have WP ignore requests to one subdomain?

I have a subdomain network installed at, say http://example.com. I need to have my webmail running at http://webmail.example.com. When I go to this domain it redirects to a page for creating a new site: http://example.com/wp- signup.php?new=webmail. I know there are some entries WP uses in the .htaccess file, but how can I get WP to ignore requests to webmail.example.com? Thanks.


get rid of random string before an for an image path on wordpress

When visiting my site (WordPress 3.0.3), images are loaded correctly. However, when you hit refresh, or come back to the same entry, the images' path become something like this:               http://tambnguyen.com/wp-content/imgs/ic.cf62525f6780c4cc3784907fe26cbee5.xhassleblad-h4d-40-stainless-steel,j.jpg      Here's the example entry: http://tambnguyen.com/hasselblads-ferrari- branded-h4d-camera-now-available-for-only-a-few-thousands-of-pounds/ Will you please tell me why it's doing that? This string of "ic.cf62525f6780c4cc3784907fe26cbee5.xhassleblad-h4d-40-stainless-steel,j.jpg" is hindering me from sharing the entry's URL correctly on facebook. I've gone through all the includes files to look for anything with "ic." or "md5" and had no luck. please help. Thanks.


How to get the main blog's id and db prefix from a mu plugin?

How can one get the blog ID as well as the database prefix of the main blog in a wordpress multisite installation? Is the main blog's ID always 1? Also how can the main blog's table prefix be acquired from within the mu-plugin's code?


How to use IN array properly in Wordpress?

I have an array containting these values (including the apostrohpes):               'course_3202','course_3201','course_3200','course_3199'      I try to fetch results from these values in postmeta-table.               SELECT * FROM wp_postmeta WHERE meta_key IN (%s) and meta_value=1      I get no result ( _yes, there is data and I should get results_ )               RESULT = Array ( )      My code looks like this:               function get_count_courses_array(array $courseids) {             $tmp = array();         foreach($courseids as $cid) {             $tmp[] = "'" . $cid . "'";         }             $courseids = implode(',',$tmp);              global $wpdb;         $sql = "SELECT * FROM $wpdb->postmeta";         $sql .= " WHERE meta_key IN (%s) and meta_value=1";                 $result = $wpdb->get_results($wpdb->prepare( $sql, $courseids));              return $result;         }      In phpMyAdmin I tried the same and I do get results (as expected):               SELECT * FROM wp_postmeta WHERE meta_key IN ('course_3202','course_3201','course_3200','course_3199') and meta_value=1      **What am I doing wrong?**


How to use current_user_can()?

Because it's not working for me. This code checks if a user has just registered. I want to redirect him to a custom page if so. Otherwise, redirect him to the homepage or admin page.               function mylogin_redirect($redirect_to, $url_redirect_to = '', $user = null) {         if( $user->ID ) {             $user_info = get_userdata( $user->ID );              // If user_registered date/time is less than 48hrs from now             // Message will show for 48hrs after registration             if ( strtotime( $user_info->user_registered ) > ( time() - 172800 ) ) {                 return get_bloginfo('url') . "/custompage/";             } elseif( current_user_can( 'manage_options' )) {                 return admin_url();             } else {                 return get_bloginfo('url');             }         }     }     add_filter('login_redirect', 'mylogin_redirect');      I get the expected results for the two options but the admin. `elseif( current_user_can( 'manage_options' )) { return admin_url(); }` doesn't seem to get parsed.


list child page items (1 level with meta keys)

I need to have a index page and it can pull out the title (with link), meta key description and meta key image (meta keys from custom fields) of its child pages, but only one level down. e.g. I have a index page call WORK, and few child index PRINT, WEB. there will be some pages under PRINT and WEB as well, but I don't want them to be shown on the WORK index. I only need to have PRINT and WEB to be listed and with the meta keys. Anybody can help please? many thanks!


What is the action hook that deletes a taxonomy term from the backend? And how to retireve the term id before deleting it?

I need to delete some `postmeta` when deleting taxonomy terms from the backend. Before deleting the `term`, I need to retrieve the postmeta's `meka_key` and the term `id` that is going to be deleted. Use the term `id` to perform some tasks and then delete the `postmeta` and `term`. I already tried using the action hook `set_object_terms` however, I cannot retrieve the term `id` when deleting the `term` because it returns an empty array. So, I would need to somehow get the term `id` before it gets deleted. How can I retrieve the term id before deleting it?               add_action( 'set_object_terms', function( $object_id, $terms, $tt_ids, $taxonomy ){          //$terms is returning the term's name (when adding an object id),      //it's returning empty when deleting the term.     //I need to have a valid $terms when deleting it, where can I get it?     $user_name = $terms;     $meta_key = '_favorite_relation_added_' . $user_name;            // Customize post type in next line according to your needs. I used 'category' as example       if ( $taxonomy === 'favorite' ) {         $post = get_post( $object_id );             if ( empty( $post ) ) return;              // Customize post type in next line according to your needs. I used 'post' as example         if ( $post->post_type !== 'post' ) return;              // let's see if the post has some terms of this category,         // because the hoook is fired also when terms are removed          $has_terms = get_the_terms( $object_id, $taxonomy );              // here we see if the post already has the custom field         $has = get_post_meta( $post->ID, $meta_key, true );              if ( ! $has && ! empty( $has_terms ) ) {           // if the post has not the custom field but has some terms,           // let's add the custom field setting it to current timestamp                update_post_meta( $post->ID, $meta_key, time() );              } elseif ( $has && empty( $has_terms ) ) {           // on the countrary if the post already has the custom field but has not terms           // (it means terms are all removed from post) remove the custom fields               delete_post_meta( $post->ID, $meta_key );         }       }        }, 10, 4);


Custom permalinks with NextGEN Gallery

i set my wordpress permlink to `/%category%/%postname%` now i'm using Nextgen Gallery so when i have a gallery in a page it will be something like `/cat/page?gallery=10` i want to make it something like `cat/page/gallery id/` i tried alot with wp_rewrite ... but no luck ... any help ? this is what i'm testing on .. it's not my code it's provided from wordpress ... i will put everything in its place when i found the way ... so don't worry i will not `flushRules` on `init` ... thanks a lot               add_filter('rewrite_rules_array','wp_insertMyRewriteRules');     add_filter('query_vars','wp_insertMyRewriteQueryVars');     add_filter('init','flushRules');          // Remember to flush_rules() when adding rules     function flushRules(){      global $wp_rewrite;         $wp_rewrite->flush_rules();     }          // Adding a new rule     function wp_insertMyRewriteRules($rules)     {      $newrules = array();              //i don't know what should i put here      $newrules[''] = '';      return $newrules + $rules;      //     }          // Adding the id var so that WP recognizes it     function wp_insertMyRewriteQueryVars($vars)     {         array_push($vars, 'id');         return $vars;     }


I have a project in WordPress. I am trying to implement dialog box popup on click of hyperlink. On click of this link, function `shownm1()` is called which is placed in `.js` file. The function contains code to open modal dialog. But its showing the following error : > Uncaught TypeError: Object [object Object] has no method 'dialog' .               Click          function shownm1(){           jQuery(document).ready(function($) {       //                    alert(1);         $('#test-div1' ).dialog( "open" );          });     }        I suppose the scripts for dialog popup are not loading. Can anyone suggest how to enqueue scripts for the same? Or is there any other problem?


Can't print out returned value

Function to return the meta value as per author.                <?php           function ac_author_score() {              $userID = get_the_author_meta( 'ID' );         $query = array (             'author' => $userID,             'posts_per_page' => -1         );         $queryObject = new WP_Query($query);              while( $queryObject->have_posts() ) : $queryObject->the_post();              global $post;         $postID = $post->ID;              $score = $score + intval( get_post_meta( 'ratings_score', $postID, true ) );              endwhile;               wp_reset_query();              if ( $score > 0 )             $score = '+' . $score;              return $score;               }     ?>      So it's returning the $score, but I can't get it to output anything with echo etc. How do I actually print/echo the returned value?


How to use wp_nonce_url() in a link?

I am creating a plugin to display all posts from all custom post type. It is something like in edit.php, but instead of displaying single post type,I would like to display all posts in one page from multiple custom post type. I follow the tutorial at here to create the plugin and I did it. However there is one problem now, I want to add the Trash link under every listed posts (just like in edit.php). This field require wpnonce in order to run, but I couldn't get it how it works. Here is my codes:               function column_post_title($item){     $actions = array(             'edit' => sprintf('Edit',$item['ID']),//this part is fine             'trash'=> sprintf('Trash',$item['ID'],$item['ID']),//here I cant get it right!!         );     return sprintf('%1$s %2$s', $item['post_title'], $this->row_actions($actions) );     }      Do I need to create own nonce? Or using the exist one (if there is any). From the code above it give me Wordpress Failure Notice with :Are you sure you want to do this? Please try again. Message. Thanks


Custom Slider Per Page created

I am developing a site that will need to have a slider with 4-8 images, but only on certain page-types. These pages must be editable and the sliders must be able to be updated whenever I'd like. I can easily do the slider and the page theme, it's just the dynamic slider area that is getting me. I've been theming wordpress for a long time but have never run into this situation, it's kicking my butt. Any help would be appreciate, thank you for your time and effort. _Update_ I have the individual templates for the pages. And have looked into the conditional tags which will help for sure. I'm building this for a client who is new to Wordpress so I want to make the process very easy for them. They need to be able to post these slides themselves.


Sort list of Wordpress Page under tag when is_tag() called

I have a site that I'm having so much trouble to try to sort the order of a list of Pages based on their tag. I've build this site over a year ago, with wordpress at the time there isn't any tag support for Page, so I used the plugin called tags4page. And I believe they still don't have tag support for pages ? Anyhow, my problem is if you go this page http://www.patentable.com/index.php/lawyers/ the list of Lawyers are in the right order. I can do this with wordpress build in order by giving each page a different weight. However the **problem is** if you try to sort the list of Lawyers by selecting the drop down manual it will return a list of lawyers that are belong to this tag that you have selected. **PROBLEM** is the order are in **reversed order** for the lawyers. Is there any way to fix this ? Right now my code is simple, basically is the following:               <?php if (have_posts()) : ?>          <?php /* If this is a tag archive */ if( is_tag() ) { ?>
Lawyers in <?php single_tag_title(); ?> Practice Area:
     <?php } ?>          <?php while (have_posts()) : the_post(); ?>
      <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>">      <?php the_title(); ?>
     <?php endwhile; /* rewind or continue if all posts have been fetched */ ?>


Best image hosting service

My girlfriend has a very popular blog, but we are growing beyond current bandwidth limit (1TB). Adsense doesn't pay enough for an expensive CDN. What recommendations can you make about image hosting. Preferably a plugin, or something that can easily be implemented.


Create front end member login

I am very new at all this and not a programmer. I want to know how to create member login section on the site allowing users to see data that is not visible to the public. I am not sure how to go about doing this, is there a widget that one may suggest that does not take a brain surgeon to make it work. I am using the Unite theme and the site I am trying to put together is at tmpfire.com. I would appreciate all the help I can get. Thank you


Default thumb - how to set it

i need the code which will add default thumb, if there is not featured image available. I was using default thumb plus for this but this plugin is using a lot of resource so i need to remove it. I was trying to follow this tutorial But no luck. Inside my widget i have this code               <?php if (  (function_exists('has_post_thumbnail')) && (has_post_thumbnail())  ) { ?>      Edited : And whole code you can see here pastebin.com/715evL1E Any idea how to this ? thanks I tried also with suggested code but i got an error .This is what i try the last in index.php               <?php if (  (function_exists('has_post_thumbnail')) && (has_post_thumbnail())  ) { ?>                               <a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_post_thumbnail('large-thumb'); } ?>       <img src="<?php echo get_template_directory_uri(); ?>/images/transfer-deadline-150x150.jpg" /><?php } ?>


When adding a widget, what kind of widget should I used to add images and text and styling?

Is there such a thing? I would settle for images, text and maybe headers. I know I can add HTML into the text widget. So is that what I should be doing? But how do I add images to the site? That widget doesn't have the image upload option. Thanks!


How to implement WP_List_Table functionality for custom plugins (OR any substitution for wp_list_table plugin) for bulk action

In the WordPress codex, following is highlighted in red for `WP List Table`. > "This class's access is marked as private. That means it is not intended for > use by plugin and theme developers as it is subject to change without > warning in any future WordPress release.". Is there any way to add bulk action and sorting functionalities like (`WP_List_Table` is doing) in custom plugins and how to use it?


Updating comments with replies

I looked around and didn't see any other questions on this topic, so here's a shot in the dark. I am trying to update the meta on a parent comment when it receives a reply. Here's the code I have so far, but I think it might not be working because I'm using the child comment to update the parent, and I am thinking it's running after the fact, but maybe not.               function update_custom_comment_field( $parent_id ) {     global $comment;     if ($comment->comment_parent) {         $parent_comment = get_comment($comment->comment_parent);         $parent_id = $parent_comment->comment_ID;     }     return update_comment_meta( $parent_id, $meta_key, $meta_value, $prev_value);     }     add_action( 'comment_post', 'update_custom_comment_field');      I'm not amazing at php, so please let me know if I'm missing something huge.


Pull latest stable release via git

I'm currently working with a workflow that makes use of Wordpress as a submodule under git. My workflow involves adding a submodule to my project from the following URL:               git://github.com/WordPress/WordPress.git      **The problem:** Doing this seems to grab the most up-to-date Wordpress version, including the non-stable alpha versions. I simply want to grab the most recent stable release, and I'm wondering whether there is some specific syntax I can add to the git URL above that allows me to specify a specific branch perhaps? Thanks


Using my own user table

Quite a broad question but I was wondering if it's possible to remove user management from WordPress and let it be handled by a remote database? I have an existing user table with everything I need and I wish to keep all my users there. Is it possible for WordPress to somewhat ignore it's own user table and use mine instead without duplicates? I understand that I'll probably need to keep admin roles in the user table, but when it comes to commenting or using bbPress I would like all the users to be referenced away from WordPress. I thought about maybe some sync process where the remote and the WordPress tables store the same info, but it opens some serious flood gates. With comments at the moment I just pre-fill the comments fields with their data, which is fine but when the user changes their name/email then it's out of sync. I've just started looking at bbPress and it seems easier to make my own forum plugin rather than hacking it to work with my user table. Thanks for the help.


RSS feed - get specific item from external feed

I am trying to figure out the best way to do this with Wordpress. I want to show a feed of news items on my site - the items are pulled from an external RSS feed. If an item is clicked, I want to show the contents of that specific item on a page within my own site. Looking at the contents of the external feed I am accessing, the unique identifier for each news item is stored in the query string of the link for that story, so I'm not really sure how I can use this to achieve what I want. Does anyone have any ideas at all? Thanks for any help


Multi Author blog with separate categories

I'm setting up a blog with 6 different authors. The main page of the blog is a grid of 6 pictures, one for each, and clicking on one will bring you to that author's "index" (archive.php is being used). I'd like to structure it so the blogs are somewhat "silo-ed" from eachother, as the authors have their own existing audiences. So when viewing an author's index, the categories and tags that show in the sidebar are specific to that author. The main issue I'm having is giving each author their own categories and posts - they shouldn't be able to see or modify others (obviously they can on the front end, but moreso for the feel of "ownership"). EDIT The alternative I've come up with in my research is to set up custom post types for each additional author and enable tags and categories for the CPT. Then, each author would be explicitly granted admin access to their CPT, and the corresponding templates would have to adjusted to show the correct info. The question now is, what is the more efficient way to do this considering site maintenance, server load, etc?


Ban a user and end their session

I'm working on a plugin derived from this tutorial. So far, the plugin adds a checkbox on a user's profile edit page where admins can ban the user. ![checkbox](http://i.stack.imgur.com/scFl6.jpg) If checked, the user will receive a message upon logging in: ![banned](http://i.stack.imgur.com/vSdLB.jpg) It works fine. The problem is, if the user is already logged in (has an active session) and gets banned, the user can continue to interact with the site **until** either the session ends or the user logs out. **How do I end the user's session upon banning so the user is forced out?** Here is the code:               /**      * Admin init      *      * @access      public      * @since       1.0       * @return      void     */     function rc_admin_init(){              // Edit user profile         add_action( 'edit_user_profile', 'rc_edit_user_profile' );         add_action( 'edit_user_profile_update', 'rc_edit_user_profile_update' );          }     add_action('admin_init', 'rc_admin_init' );               /**      * Adds custom checkbox to user edition page      *      * @access      public      * @since       1.0       * @return      void     */     function rc_edit_user_profile() {         if ( !current_user_can( 'edit_users' ) ) {             return;         }              global $user_id;              // User cannot disable itself         $current_user = wp_get_current_user();         $current_user_id = $current_user->ID;         if ( $current_user_id == $user_id ) {             return;         }         ?>
Ban user

             	             <input name="rc_ban" type="checkbox" id="rc_ban"  /> Check to ban user.

         <?php     }               /**      * Save custom checkbox      *      * @access      public      * @since       1.0       * @return      void     */     function rc_edit_user_profile_update() {              if ( !current_user_can( 'edit_users' ) ) {             return;         }              global $user_id;              // User cannot disable itself         $current_user    = wp_get_current_user();         $current_user_id = $current_user->ID;         if ( $current_user_id == $user_id ) {             return;         }              // Lock         if( isset( $_POST['rc_ban'] ) && $_POST['rc_ban'] = 'on' ) {             rc_ban_user( $user_id );         } else { // Unlock             rc_unban_user( $user_id );         }          }               /**      * Ban user      *      * @access      public      * @since       1.0       * @return      void     */     function rc_ban_user( $user_id ) {              $old_status = rc_is_user_banned( $user_id );              // Update status         if ( !$old_status ) {             update_user_option( $user_id, 'rc_banned', true, false );         }     }               /**      * Un-ban user      *      * @access      public      * @since       1.0       * @return      void     */     function rc_unban_user( $user_id ) {              $old_status = rc_is_user_banned( $user_id );              // Update status         if ( $old_status ) {             update_user_option( $user_id, 'rc_banned', false, false );         }     }               /**      * Checks if a user is already banned      *      * @access      public      * @since       1.0       * @return      void     */     function rc_is_user_banned( $user_id ) {         return get_user_option( 'rc_banned', $user_id, false );     }               /**      * Check if user is locked while login process      *      * @access      public      * @since       1.0       * @return      void     */     function rc_authenticate_user( $user ) {              if ( is_wp_error( $user ) ) {             return $user;         }              // Return error if user account is banned         $banned = get_user_option( 'rc_banned', $user->ID, false );         if ( $banned ) {             return new WP_Error( 'rc_banned', __('ERROR: This user account is disabled.', 'rc') );         }              return $user;     }          add_filter( 'wp_authenticate_user', 'rc_authenticate_user', 1 );      So the ending of the session should go in the `rc_ban_user()` function. **EDIT** : Full plugin posted below.


list pages by custom_field?

Is there a way for me to sort these posts alphabetically according to the custom field I have defined (last_name)?               <?php     $page_id = get_the_ID();          $args = array('sort_order'=>'DESC', 'post_type'=>'page', 'child_of'=>$page_id, 'post_status'=>'publish');     $posts_array = get_pages($args);               foreach ($posts_array as $post){         setup_postdata($post);         ?>         <li>             (post content here)         </li>         <?php     }     ?>


Remove images from get_the_excerpt

I'm using a custom function to create a shortcode that displays the latest blog post on the home page of a template. But I'm trying to NOT have it display any images. I know I can use the Advanced Excerpt plugin to have it remove images, but the issue is that it will also remove images from the index.php feed which I want to keep which is using `the_excerpt()` in the template. Here's my custom function that creates the shortcode:               function my_recent_news()     {       global $post;       $html = "";       $my_query = new WP_Query( array(            'post_type' => 'post',            'posts_per_page' => 4       ));            if( $my_query->have_posts() ) : while( $my_query->have_posts() ) : $my_query->the_post();                 $html .= "
            " . get_the_date() . "
" . get_the_title() . "
            " . get_the_excerpt() . "
            ";       endwhile;             endif;            wp_reset_query();            return $html;          }          add_shortcode( 'news', 'my_recent_news' );      I've posted something about this before: get excerpt without images but the solution was to use the Advanced Excerpt plugin, but for this I am trying to use the excerpt on the home and the blog feed page but I want to preserve the `img` markup on the blog feed and remove the img tag from the custom shortcode. I've tried to used just `the_excerpt()` in that custom shortcode function, but that just seems to break the whole function and display some really odd stuff. I'm not too sure if I need to have a filter somewhere to strip that out or what. I'm also not sure that if I do need a filter, where that would go? Before the loop, after the loop, or does it need it's own constructed argument?


Custom Post Type content isn't shown

My problem is to display the content of custom post types. The Dashboard- preview shows the right content (/vita/vita-test/), but I can't see it at the homepage ( /vita/ ). It displays the content of index.php Why isn't found „vita-test“? My permalink is /%post_id%/%postname%/ my post type $args               'rewrite' => array("slug" => "vita"),     'show_in_nav_menus' => true      I also use               query_posts('post_type=vita&post_status=publish');     if ( have_posts() ) : while ( have_posts() ) : the_post();       Do you have an idea where my mistake is? Thanks so much!


wp_trash_post function to only apply to posts, not pages!

I have the following function that deducts at point when a post is removed. But when I remove a page, the wp_trash_post is also called.               // Remove 1 point if their post get removed     function deletePointFromUser($post_id) {     $post = get_post($post_id);     $authorid = $post->post_author;     $currentQPointNumber = get_user_meta($authorid, 'points', true);     // Delete 1 to the current Point Score     update_user_meta($authorid, 'points', $currentQPointNumber-1);       }     add_action('wp_trash_post', 'deletePointFromUser');      Is there a way to restrict this function to only apply to posts and not pages?


Layout Builder.

I recently bought a theme from Theme forest called Enfold: http://www.kriesi.at/themedemo/?theme=enfold The pages have an "Advanced layout" building that lets you build you content how you need. I found some plugins like http://wordpress.org/plugins/page- layout-builder/ that are similar, ie, based on modules like accordion, tab, header, icon list etc that you can use to mold your content. I am really really curious how one would go about creating your own layout builder. IE, is it just an api/interface for shortcodes? I could not find any resources/tutorials so any help in the right direction is appreciated.


Custom pagination for custom post types (by names)

I have two custom post types that deal with people's names. Right now, in browsing views, it just lists them all alphabetically and the pagination breaks them down by numbers, which isn't terribly helpful when you're trying to find a specific person. Specifically, I've been asked to create pagination links for people that look like this:   * A-G    * H-M    * N-Q    * R-Q My problem - I can't figure out how I can query the custom post types by the first letter of one field. Then, I'm not sure how I can go about creating the pagination in this way. Does anybody have any suggestions? Thank you!


WP Admin Bar shown at the bottom

Suddenly, while I was working, the admin bar (that by default appears at the top) has appeared on the bottom of the page and it is unstyled, it is simply a list of links one below the other. I've checked both header.php and footer.php and all seems to be at the right place (wp_head() and wo_footer()). I'm using the last stable version of WordPress (3.1.3). What could be the problem? Thanks


Older entries link within category page

I am building a custom wp theme and I have a category called 'blog'. On here I have all of my posts displaying from the category 'blog' and a link at the bottom that says older entries. When i click the link it goes to 404. The URL is                http://localhost:8888/blog/page/2/      As you can see it's putting the category /blog/ in the url causing a 404. If I remove 'blog' from here it goes back to the home page. and then does show older posts but i need it to stay on the category page and show older posts. It's driving me crazy!


Add custom menu item type

Is there a way to add custom menu type to the menu editor? I know I can add items dynamically with the `wp_get_nav_menu_items` filter, but I would like to have the position of those items configurable.


How to prevent duplicate posts with wp_insert_post on single.php?

I'm getting a really strange bug (WP 3.1.3). My goal is to have users create a new post simply by landing on a single post. In order to make that happen, I have the following code in my single.php:                   <?php         //-- Set up post values         $myPost = array(             'post_status' => 'publish',             'post_type' => 'post',             'post_author' => 2,             'post_title' => 'e3i8ir',             'comment_status' => 'closed',             'ping_status' => 'closed',             'post_category' => array(24),         );              //-- Create the new post         $newPostID = wp_insert_post($myPost);              ?>      By all rights, this should just insert one record, right? When I use this function, however, it creates TWO posts, exactly alike. Looking at the page, the_content only displays once, so it's not like the page is displaying multiple times (and therefore causing two wp_insert_post calls). Does anyone have any ideas what would cause this? Thanks in advance, --eric


Return HTML Template Page with PHP Function

I want to create a form that I can use a shortcode to insert into my site. It would be really nice if I could create the HTML part in a seperate file and then insert it with a PHP shortcode (to seperate the logic of the page from the mechanics of making it into a shortcode). How could I do this? ## -- Update -- This is what I've done: I have two files. One called 'profiletemplate.php' and one called 'scodes'. They are both part of a plugin that I am making for my site with an init.php that initializes them. Here is their content: **init.php**               <?php     require_once(dirname(__FILE__).'/pages/scodes.php');     ?>      **scodes.php**               function jf_testcode() {         include dirname(__FILE__) . 'profiletemplate.php';     }          add_shortcode('testfield', 'jf_testcode');      **profiletemplate.php**               <?php // Template for my form shortcode ?>     <form>     Testing     </form>      I then use the [testfield] shortcode on a page in my site. ## Update 2 So this method is working, but it isn't inserting the HTML where the shortcode is called. Instead it is just inserting the content at the top of the page (like if I said 'echo 'Testing'' instead of 'return 'Testing'' in a function.


Create and style menu

I have been assigned with the task to create a menu that can be added or removed from wordpress admin. Right now the menu is hard coded into the templates. But I want to use default menu function `wp_nav_menu` and the menu should look exactly like before. But trying for the whole day i cannot figure how to make the menu using wp_nav_menu and look exactly like the menu item currently having in this site. I can make the menu using wp_nav_menu but the menu is looking like a mess and not like this.


Plugin: Google Analytics for Dashboard error - Timestamp is too far from current time

Has anyone used the **Google Analytics for Dashboard** plugin? I've installed it successfully, but whenever I try to link it to my Google Account using the Start Login Process button, I keep getting a weird message that goes like:               Timestamp is too far from current time: <a Unix timestamp here>      I'm using WordPress 3.1.3. Any ideas what's happening here? Thanks,   m^e


Without using wordpress cms Is it possible to signup from my html page

Is there any method to signup to **wordpress** site from my html page. So that the registered user details must fairly added to database table. I mean the action must be **similar** to the **process how we generally signup to wordpress cms**. Thank you.


Pasting code into WordPress post - LFs being eaten

I'm sure this is an inappropriate question for this SE because it's not programming related AFAIK but maybe someone here has an idea. I've been posting code into my blog for years and have had no formatting concerns. Now all of a sudden, when I copy and paste code from whatever IDE I'm working in, the LFs are stripped out. I can't imagine what may have changed. Some additional troubleshooting info:   * I'm pasting into the visual editor, not the HTML editor (this is how I've always done it)   * pasting into a PRE section doesn't help   * the CR/LF information is in the clipboard (when I paste into Word for example, the LFs and tabs are preserved)   * pasting using Paste Text has the correct LFs but strips out tabs so that's not an option   * pasting using Paste from Word does the same   * I'm using the latest WP update (as of this time) WP 3.1.2   * I"m using TinyMCE, but have disabled it and that's had no effect; also WP-Syntax, no joy Can anyone suggest something else to look into to figure this out? It's killing me. I've re-read the section in the Codex just to be sure I'm not missing something obvious, but there's nothing that pops up. I've been pasting code into my blog (www.tomauger.com) for years and years now without any special plugins, just sticking it inside PRE tags and have never ever encountered this issue. What could have changed?


First, Here is the full error:               PHP Fatal error:  Call to undefined function download_url() in /path/to/wordpress/wp-admin/includes/media.php on line 562      I have also posted the related functions at the bottom of my question. I am modifying a script for my company's website which allows us to automate the retrieval and uploading of content from our content provider. Due to the way they organize their XML, I need to upload the images related to the articles separately from the main body of the articles. I tried using media_sideload_image() to do this, but I recieved the error: The function (media_sideload_image()) which calls download_url and results in the error:                PHP Fatal error:  Call to undefined function download_url() in /path/to/wordpress/wp-admin/includes/media.php on line 562      As can be seen, I successfully included media.php - and the rest of my script has already been implemented on to the site, and I have not run into any other issues with accessing Wordpress files. The error would appear to be with media.php itself - which I find unusual. Any ideas on how I can resolve this problem? Alternatively, if you know of another function I can use to do this, that would also be appreciated. By all means, if you require any more details on the issue just ask.               /**      * Download an image from the specified URL and attach it to a post.      *      * @since 2.6.0      *      * @param string $file The URL of the image to download      * @param int $post_id The post ID the media is to be associated with      * @param string $desc Optional. Description of the image      * @return string|WP_Error Populated HTML img tag on success      */     function media_sideload_image($file, $post_id, $desc = null) {         if ( ! empty($file) ) {             // Download file to temp location             $tmp = download_url( $file );                  // Set variables for storage             // fix file filename for query strings             preg_match('/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $file, $matches);             $file_array['name'] = basename($matches[0]);             $file_array['tmp_name'] = $tmp;                  // If error storing temporarily, unlink             if ( is_wp_error( $tmp ) ) {                 @unlink($file_array['tmp_name']);                 $file_array['tmp_name'] = '';             }                  // do the validation and storage stuff             $id = media_handle_sideload( $file_array, $post_id, $desc );             // If error storing permanently, unlink             if ( is_wp_error($id) ) {                 @unlink($file_array['tmp_name']);                 return $id;             }                  $src = wp_get_attachment_url( $id );         }              // Finally check to make sure the file has been saved, then return the html         if ( ! empty($src) ) {             $alt = isset($desc) ? esc_attr($desc) : '';             $html = "<img src='$src' alt='$alt' />";             return $html;         }     }      The function where I call media_sideload_image() in my code:               //Upload the image if it exists, and return the post_id     function upload_image($post_id, $image_url) {         require_once('wp-admin/includes/media.php');         $image_url = 'http://admin.gkbusiness.com/gkbusiness/files/2011/04/LOGOGKMBUS1.jpg';         media_sideload_image($image_url, $post_id);         return $post_id;     }