Warning when author has no post

i have a page who display the latest posts of an author. But when the author has no post i get a display message > Warning: rsort() expects parameter 1 to be array, null given in ... Here the script               function wpmu_latest_post_auther($authorId,$how_many = 10, $how_many_words = 50, $more_text = "[...]", $remove_html = true, $sort_by = 'post_date') {     global $wpdb;          //first, gat all blog id     $query = "SELECT blog_id FROM $wpdb->blogs WHERE blog_id !='1'";     $blogs = $wpdb->get_col($query);          if ($blogs) {         //we use blog id to loop post query         foreach ($blogs as $blog) {             $blogPostsTable = 'wp_'.$blog.'_posts';                   $db_query = "SELECT $blogPostsTable.ID,                         $blogPostsTable.post_author,                         $blogPostsTable.post_title,                         $blogPostsTable.guid,                         $blogPostsTable.post_date,                         $blogPostsTable.post_content,                         $blogPostsTable.post_modified,                         $blogPostsTable.comment_count                         FROM $blogPostsTable WHERE $blogPostsTable.post_status = 'publish'                         AND $blogPostsTable.post_author = $authorId                          AND $blogPostsTable.post_type = 'post'";                  $thispos = $wpdb->get_results($db_query);                  foreach($thispos as $thispost) {             if($sort_by == 'post_date') {                 $order = $thispost->post_date;             }             else{                 $order = $thispost->post_modified;                 }                      $post_dates[]           = $order;                 $post_guids[$order]     = $thispost->guid;                 $blog_IDs[$order]       = $blog;                 $post_IDs[$order]       = $thispost->ID;                 $post_titles[$order]    = $thispost->post_title;                 $post_authors[$order]   = $thispost->post_author;                 $post_contents[$order]  = $thispost->post_content;                 $comments[$order]       = $thispost->comment_count;                 }             }                   rsort($post_dates);         $union_results  = array_unique($post_dates);         $ResultArray    = array_slice($union_results, 0, $how_many);              foreach ($ResultArray as $date) {             $ID                 = $post_IDs[$date];             $blogID             = $blog_IDs[$date];             $id_author          = $post_authors[$date];             $post_url           = get_blog_permalink($blog_IDs[$date], $ID);/*$post_guids[$date];*/             $post_title         = $post_titles[$date];             $post_content       = $post_contents[$date];             $post_date          = mysql2date(get_option('date_format'), $date);             $post_time          = mysql2date(get_option('time_format'), $date);             $total_comment      = $comments[$date];             $user_info          = get_userdata($id_author);             $author_blog_url    = get_blogaddress_by_id($user_info->primary_blog);             $author_url         = $user_info->user_url;             $author_email       = $user_info->user_email;                  if($user_info->first_name) {                 $author_name = $user_info->first_name.' '.$user_info->last_name;             }             else{                 $author_name = $user_info->nickname;             }                  if($remove_html) {                 $post_content = wpmu_cleanup_post($post_content);             }                  $results = array();                  $results['ID']              = $ID;             $results['blogID']          = $blogID;             $results['post_url']        = $post_url;             $results['post_title']      = $post_title;             $results['post_content']    = wpmu_cut_article_by_words($post_content, $how_many_words);             if ($results['post_content'] != $post_content)                 $results['post_content'] .= sprintf('  %s', $post_url, $more_text);             $results['author_blog_url'] = $author_blog_url;             $results['author_url']      = $author_url;             $results['author_email']    = $author_email;             $results['author_name']     = $author_name;             $results['post_date']       = $post_date;             $results['post_time']       = $post_time;             $results['comment_count']   = $total_comment;                  $returns[] = $results;         }              $latest_posts = wpmu_bind_array_to_object($returns);         return $latest_posts;     } }      Is someone has an idea on how to not display the warning when the author as no post added. Regards


301 Redirect To Post ID

* I have an existing asp based blog where all posts contain a post id in their URL (`template_permalink.asp?id=123`).   * I have a blank WordPress blog. I will have to recreate all of my posts manually, because the feed from my existing blog doesn't contain the original images (it just has a CDATA block) so I can't import them.   * I need to to redirect the original posts to their equivalent WordPress post. I have tried:   * To 301 redirect all `template_permalink.asp?id=xxx` URLs to a post id using htaccess but it retains the original id so to make this work I would have to manually change the WordPress post id—which I can't work out to do—so it doesn't hit the right page. My code:              Redirect 301 /template_permalink.asp http://www.example.com/      What I would ideally like is to be able to either:   * Change the WordPress post id manually to match the original id. Is there a way to do this?   * Or even better would be to manually add the 200 posts in htaccess and redirect to a pretty URL, in which case please could you advise of how to format this for htaccess?


How to automatically add paragraph tags in the Visual Editor

From my Googling, it appears as though the default behavior in Wordpress is to _add_ paragraphs automatically, but in the HTML view, regardless of what style I choose in the Visual Editor's style drop-down (paragraph, for example), paragraph tags never appear. I also do not see `wpautop()` called anywhere in my theme (which I inherited from a now departed developer). What can I do to set this straight? Adding `<p>` tags to everything is obviously not going to fly with the content editors.


Using a different template per Custom Taxonomies for single term archive pages

I have 2 custom taxonomies, each with a number of terms:               tax1       term1_1       term1_2     tax2       term2_1       term2_2       term2_3      I am trying to have each taxonomy usea different template file for each its single-term archive pages. I.E. `term1_1 and term1_2` use one template, while `term2_1 - 3` use a second one. I can of course just load different php files conditionally from the main `archive.php` file - but I would like to know if there is a way to do this within the standard template hierarchy. As far as I can tell, taxonomy-tax1.php doesn't work for this (unless I'm messing up royally)


How to make WordPress blog accessible for people with disabilities?

How do you make your wordpress blog accessible for people with disabilities ? are there any special plugins you are using ? are there any friendly themes you recommend ? is there an auto-detect in the browser if the operating system accessibility tools are running ? aka is there a way to build an auto-detect that will load a special theme onces accessibility tools are enabled. thanks for the help and suggestions


How to get the_post_thumbnail caption?

I want to show the caption of the post thumbnail, there's a couple of methods out there, but none of them displays the caption properly, the caption just float and not displayed under the image! I want to wrap the image in wp- caption div, like any other images with caption. Here is the function I've tried               function monahans_thumbnail_caption($html, $post_id, $post_thumbnail_id, $size, $attr)     {       $attachment =& get_post($post_thumbnail_id);            // post_title => image title       // post_excerpt => image caption       // post_content => image description            if ($attachment->post_excerpt || $attachment->post_content) {         $html .= '';         if ($attachment->post_excerpt) {           $html .= ''.$attachment->post_excerpt.' ';         }         $html .= $attachment->post_content.'          ';       }            return $html;     }          add_action('post_thumbnail_html', 'monahans_thumbnail_caption', null, 5);      As I said, the caption doesn't show properly at all:      ![enter image description here](http://i.stack.imgur.com/1AHU3.png)      I want a function to wrap the image inside `wp-caption` div, and wrap the caption text inside `wp-caption-text`      ![enter image description here](http://i.stack.imgur.com/eRcSA.png)


str_replace the_title(); blues

I have a dilemma, well a new blog which im developing and a few of the posts titles are like this 'Tutorial: Build your first App' or 'Tutorial: Start your business with xensuithia' I have a page called tutorials that display the posts from this category. I need the title to not display the 'Tutorial:' part on this page, I tried:               str_replace('Tutorial:',' ', the_title());       However it does not work. It just outputs the full title.


Cannot Edit Custom Template In WP Editor

Following several well-written articles on creating a custom page template, I made one for my WordPress site hosted at wpengine. **The good news:** My custom template works just fine. I can add pages that use it (for example, it displays in the drop-down menu for selecting template- to-use for a new page). My workflow has been to edit the file in notepad++, upload it to the WP staging site via SFTP (using FileZilla), and "debugging" it via FireBug. So I have it working nicely. But I thought, hey, why not try editing it in the dashboard, like all the other template files? The custom template is:   * a simple php file (effectively a call to get_header() and get_footer(), with some content generated by normal php code in between those calls)   * saved with the naming convention "page_mytemplate_one.php"   * in a child theme folder, co-equal in level with the theme I'm using   * using same permissions as all other php files in the theme folder   * showing up as expected in the file list on the side panel Seems all right to me. I click on that file when in Editor mode... it appears to take a moment to load, then displays the filename above the edit window, and also includes all of the function calls used therein in the handy function lookup dropdown below the edit window. Clearly it found the file and extracted information from it. **The bad news:** No code shows up in the edit window. Not a line of it. Is this a problem with the fact that I'm using a child theme in a "staging" area? Do I need to register something? Thanks * * * **UPDATE:** It's not related to using a staging area. After moving the staging version into the site proper, I get the same behavior. **2nd UPDATE:** The behavior persists, despite a major rewrite of the code (meaning it's no longer quite so simple) and adding to the header information to make it "well formed," according to the PHP docs. I'm left wondering if the fact that the file has over 200 lines of code (mostly data definition) has anything to do with this.


Change posts URL

> **Possible Duplicate:**   >  Permalink: postname EXCEPT for blog I have relented converted my website to wordpress and I have used index.php as homepage and blog.php(template for blog posts), but when I create any new post it makes permalink like pages for example...               http://www.domain.com/post-name      instead of `http://www.domain.com/blog/post-1` Can you please help how can I assign /blog for all blog posts. Thanks for help.


update_option not working in stand-alone PHP script

I have a standalone PHP script in my WordPress theme's directory that I run once every hour through a cron job (or manually if needed). All other WordPress functions are working except the `update_option()` function. A simplified version of my script looks like this:               require_once('/path/to/site/wp-load.php');          $value = my_function();     update_option('my_option', $value);      and in one of my theme's files, I am running the following code:               echo get_option('my_option');      Nothing is printed, and a `var_dump` shows that the returned value is `false`. My `wp-admin/options.php` page doesn't list `my_option` either. I'm at a loss, because below those lines, I am using the following WordPress functions to interact with my WordPress database successfully:   * get_posts   * delete_post_meta   * add_post_meta Debugging my script, `my_function` returns a string (about 10 characters) and no errors are thrown with my PHP error settings at `E_ALL`. Do I need to include other WordPress core files? I thought that `wp-load.php` was all you needed. * * * WordPress version: 3.7


Pull post name from value of a specific meta key

I am looking for help on how to pull post name from custom field value for example in wp_posts post id = 200, and there are corresponding meta key and values with post_id= 200 in wp_postmeta I want to update wp_posts set post_name= ...... a value of a specific meta key in wp_postmeta. Please help. Thanks!


Currency (price) formating on custom fields

I need to format a custom field in admin area (post edit) as a currency, eq: 12.000,00 , with user typing only the numbers, the , and . automatic. Ive searched arround, with no sucess.. Anyone? thank The code i am trying to use to enqueue script in admin is               function enqueue_admin() {              wp_enqueue_script( 'jquery' ); //adding Jquery to admin. Not sure if is needed or already there         wp_register_script( 'autonum', THEME_DIR . '/js/vendor/autoNumeric.js', array( 'jquery' ), '1', false ); //this is autoNumeric for currency format         wp_enqueue_script( 'autonum' );          }     add_action( 'admin_enqueue_scripts', 'enqueue_admin' );      Also, not sure if i need to change all the $ to JQuery in autoNumeric.js, because of wordpress compatibility


user definable sidebar per page

I'm searching for a solution where the user can define some sidebar widgets for himself (only text and images). The user should have the possibility to choose a different sidebar for a different page. WidgetLogic and so on only allow the configuration on which page a sidebar widget should be shown (also a standard user has in this case no rights and I'd have to change that). There are other solutions which are more comfortable but the user would still have to know HTML to define the sidebar. Do you know any practicable solution?


Insert a Featured Video

I'm trying to put a video as featured in my theme, i mean, to be shown by the tag "the_post_thumbnail ('')", without using any plugin. Is this possible? Thank you!


How can I display widget in a Page or Post?

I am trying to display some widgets (Quora & Goodreads) widgets inside Page or Post. How do I do that without displaying it inside Sidebar?


Create mobile site with same content just different theme

I have a wordpress site and want to create a different theme for mobile. I'd like to create a subdomain such as m.domain.com which will use a mobile optimized theme much different than the desktop version theme. I understand multisite will handle the subdomain problem but I want all the content, custom posts, plugins, etc to be in a single site in the admin. Is there anything out there that will allow me to create a mobile subdomain and have a separate theme applied to that subdomained site while keeping the content, posts, plugins in a single site in the admin? Thanks!


WordPress Scalability - One Instance or Several?

My company is currently outsourcing development of 170 WordPress sites and I recently learned that they are developing all 170 in one instance of WordPress. I am not a WordPress expert, but have seen scalability problems with other CMS products in the past where 50 or so sites in one instance experienced major performance issues over time as the site content and traffic grew. As I said, I am far from a WordPress expert, so I thought I would reach out to the community on this one. Is this a potential problem? Or does WordPress scale well when used this way?


For performance is it better to build custom functionality into the theme or a plugin

This question is related to this question: http://wordpress.stackexchange.com/questions/222/do-deactivated-plugins-slow- down-a-wordpress-site When developing a website with custom functionality for a client, particularly a site that will expect lots of traffic, what is better from a performance perspective. To build the functionality into the theme itself or to build it into a plugin? Or is there any performance difference at all?


How safe is it to delete old posts edits to save database space?

After this question: http://wordpress.stackexchange.com/a/93902/27148 There is an answer that suggests deleting past edits directly from database, which would be nice, because I could create queries to delete specific edits only. But, Is this safe? Why?


Multiple sites that share some pages, but not others

I'm pretty new to WordPress... I'm trying to set up a few sites, each with their own top level domain name. What I want them to do is share some of the pages, but not others. For example - they would all share Services, Contact, and Team pages; but would each have their own Biography page. When one of the shared pages is updated, they're all updated. I can't figure out if WP multisite is this or not? Thanks for your help.


Custom Taxonomy not working with posts_per_page in new WP_query (pagination problem)

OK, so i'm messing with Custom Taxonomies for the second time and in both instances i've run into this problem where using the posts_per_page argument in either a query_posts or WP_query scenario.. basically, if i set a custom limit on posts per page, clicking the "next" or "previous" buttons give me 404 errors .. doesnt matter if i use a custom permalink structure or any of the defaults, same result. the only way ive successfully managed to control number of posts on a page is through the Reading Settings in the Dashboard. i've found quite a few mentions of this same problem but have yet to find a working solution aside from above mentioned Dashboard settings: _**wordpress.org/support/topic/custom-taxonomy-navigation-problem- paged1-works-paged2-doesnt?replies=8#post-2093828_** _**core.trac.wordpress.org/ticket/16168_** _**wordpress.org/support/topic/custom-taxonomies-with-pagination- getting-404-page-not-found?replies=6#post-2093414_** so, here's the site im working on with the problem: http://www.purekreation.com (click on any of the sections in the nav and then try to navigate to previous pages at the bottom) and here's my current (non-working) code:                   <?php get_header(); ?>
                  <?php global $query_string, $paged, $wp_query, $wp;             $count = 0;             $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;             echo $paged;             ?>             <?php $term = get_query_var('term'); echo $term;?>             <?php $tax = get_query_var('taxonomy'); echo $tax;?>             <?php             $taxquery=new WP_Query(array('tax_query'=>array(array('taxonomy'=>$tax,'field'=>'slug','terms'=>$term)),'post_type'=>'art','showposts'=>1,'paged'=>$paged));             while ( $taxquery->have_posts() ) : $taxquery->the_post(); ?>              <?php $genre = wp_get_post_terms($post->ID, 'genre');?>             <div id="post-<?php the_ID(); ?>" <?php post_class('post-'.$genre[0]->slug.' post-art');?>>
<?php the_title();?>
                 <?php get_the_10(); ?>
                     <?php the_content(); ?>
                                      <?php $terms = get_the_term_list( $post->ID, 'genre', 'Portfolio: ', ' ', '' );  echo $terms;?>                     Project: <?php the_tags( '',', ','');?>                     Client: <?php $meta = get_post_meta($post->ID, 'client', true); if($meta==''){echo 'Self';}else{echo $meta;}?>                     Back to top

                 <?php $count++; ?>             <?php endwhile; ?>
             <?php if($taxquery->max_num_pages>1){?>                 <?php                 for($i=1;$i<=$taxquery->max_num_pages;$i++){?>                         <a href="<?php bloginfo('url');?>/?<?php echo $tax;?>=<?php echo $term;?>&<?php echo 'paged=' . $i; ?>" <?php echo ($paged==$i)? 'class="selected"':'';?>><?php echo $i;?>                         <?php                 }                 if($paged!=$taxquery->max_num_pages){?>                         <a href="<?php bloginfo('url');?>/?<?php echo $tax;?>=<?php echo $term;?>&<?php echo 'paged=' . $i; //next link ?>">>                 <?php } ?>         <?php } ?>
                 <?php // Reset Post Data                 wp_reset_postdata();                  // End the loop. Whew.?>
         <?php get_footer(); ?>      im not the most skilled PHP guy but i know a decent amount about Wordpress and this problem has me literally losing sleep over it. if anyone has some input on this matter, it'd be GREATLY appreciated.


Post Categories Meta Box: Customize Most Used Tab

On the Edit Post page, within the Categories meta box, I’m looking for a way to put custom categories into the Most Used tab for easy category selection. The issue: There are a large amount of categories to choose from in the Categories meta box and it is becoming cumbersome for users to locate the category they want to use for their posts. There are already high post counts for the categories that are showing up in the Most Used tab so its hard to override them with the categories I want in there. Any of the following would help my cause:   1. Is there a plugin that modifies the Categories meta box? If there is I haven’t been able to come across one.   2. How to increase the max number of “Most Used” categories to higher than the limit of 10?   3. How to add a search feature to the Categories meta box? It would be something similar to the one available in the Categories box for WP Menus (not sure why this isn’t already built into the core).    4. How to manually set a category count value to a high number and get it to increment from there without resetting to its actual value? I noticed that the Most Used Categories are determined by the category “count” field in the wp_term_taxonomy table. I found one of the categories I want to include in Most Used, so I manually changed the count of that category to a large number. I noticed this caused the category to show up at the top of the Most Used list (temporarily). As soon as I added a post to the category it reset the post count back to its real number. I'm hoping there's a way to keep this number high even if it doesn't accurately reflect how many posts are in that specific category.


How to use post_class function?

I would like to use this function, but I don't know correctly what is the perfect way.. The code:               <li  id="post-<?php the_ID(); ?>" <?php post_class(get_the_content() == "" ? "no-content" : ""); ?> <?php post_class(has_post_thumbnail() ? "" : "no-image"); ?>>      There are two if statements. Currently only the first working, the second not but if I remove the first `<?php post_class(get_the_content() == "" ? "no- content" : ""); ?>` the second working. How can in combine these lines?


How to get Text Selection in WordPress Editor

I want something like if I select any word in WordPress Visual Editor, it will get replaced with my own text. Actually Visual Editor is an iFrame. We can do this thing in textarea, but how can we implement this in iFrame (WordPress Visual Editor)? Any help would be appreciated.


Links are not working on All Plugins Page

I apologigize for the question, as it sounds silly. But I am forced to ask this question, as I didn't find it's answer anywhere. I have about 3 sites on WordPress, and 2 are working absolutely fine. But the 3rd one have some problem with links. I mean, If I go to **All Plugins** page, and click on **Activate** or **Deactivate** or **Delete** , then nothing happens. However if I copy the URL by mouse right clicking (and copying url), and visit after pasting it in browser, then it works properly. I have WordPress 3.5.1 with theme twenty twelve on all sites. I have also tried changing theme and removing all plugins, but still the problem exists. Can someone knows the resolution of this issue.


How to insert widget areas specific to certain pages (or posts, etc.)?

I am developing a theme the pages of which (as well as posts) are so different from the home page that I want different widgets on their sidebars.   Is there a way to do it? I'm calling the sidebar on _single.php_ this way, exactly as it's on _index.php_ :               <?php get_sidebar(); ?>      The _sidebar.php_ is this way:               <?php     /**      * The Sidebar containing the primary and secondary widget areas.      ?>              <aside>             <ul>          <?php         /* When we call the dynamic_sidebar() function, it'll spit out          * the widgets for that widget area. If it instead returns false,          * then the sidebar simply doesn't exist, so we'll hard-code in          * some default sidebar stuff just in case.      */     if ( ! dynamic_sidebar( 'primary-widget-area' ) ) : ?>                   <?php endif; // end primary widget area ?>         </ul>          <?php         // A second sidebar for widgets, just because.         if ( is_active_sidebar( 'secondary-widget-area' ) ) : ?>                  <ul>                     <?php dynamic_sidebar( 'secondary-widget-area' ); ?>             </ul>          <?php endif; ?>              </aside>


Custom Post Type Causes Error: Warning: call_user_func_array()

I have a custom post type created called 'missions'. When developing the site on my Dedicated Virtual, I had no problems. But I moved the site to a shared hosting grid server (mt) and now receive this error through out the admin. > Warning: call_user_func_array() [function.call-user-func-array]: First > argument is expected to be a valid callback, 'add_mission' was given in > /nfs/c08/h02/mnt/125591/domains/mydomain.org/html/wp-includes/plugin.php on > line 395 The only place that 'add_mission' is used in my theme code is in the functions when setting up the post type. Here is the code I have for that.               add_action( 'init', 'create_mission' );     function create_mission() {         register_post_type( 'missions',             array(                 'labels' => array(                     'name' => __( 'Missions' ),                     'singular_name' => __( 'Mission' ),                     'add_new' => __( 'Add New' ),                     'add_new_item' => __( 'Add New Mission' ),                     'edit' => __( 'Edit' ),                     'edit_item' => __( 'Edit Mission' ),                     'new_item' => __( 'New Mission' ),                     'view' => __( 'View Mission' ),                     'view_item' => __( 'View Mission' ),                     'search_items' => __( 'Search Missions' ),                     'not_found' => __( 'No missions found' ),                     'not_found_in_trash' => __( 'No missions found in Trash' ),                     'parent' => __( 'Parent Mission' ),                 ),                 'public' => true,                 'menu_position' => 4,                 'show_ui' => true,                 'capability_type' => 'post',                 '_edit_link' =>  'post.php?post=%d',                 'hierarchical' => true,                 'rewrite' => array( 'slug' => 'missions', 'with_front' => true ),                 'supports' => array(                              'title',                             'editor',                             'author',                             'thumbnail',                             'excerpt',                             'trackbacks',                             'custom-fields',                             'comments' ,                             'page-attributes',                             'templates' ),                 'menu_icon' => get_stylesheet_directory_uri() . '/assets/imgs/icon_posttype.png',                 'register_meta_box_cb' => 'add_mission_metaboxes'             )         );     }     add_action('admin_init', 'add_mission');      **More Info** I know that the issue is with my theme, as switching to the twentyten theme removes the error. PHP Version 5.2.14 WordPress 3.1.2 **Question** Is this a server issue? Or can I fix this through my code? I've searched google and have been unable to find an instance of this error being thrown from a custom post type in wordpress.


Email sent from WordPress has html tags

Instead of:               Hello,          Thank you dfasdfasdfasdf asdf asdf asdfas dfs          Please, feelasdf asdf asdf       I am getting something like this in the email that arrives to my mailbox:
Hello,

Thank you dfasdfasdfasdf asdf asdf asdfas dfs

Please, feel asdfads fad f
       So, I guess the HTML is not turned on for the wp_mail() function? How to turn it on, so the mail will arrive as it should and the `<p>` and `<br>` tags are interpreted correctly? I am using this to send my mail from functions.php when the submit button is pressed:                  $headers = 'From: XXXXXX.com <info@xxxxx.com>' . "\r\n";        $subject = 'Registration from xxxxx.com' . "\r\n";         $message = $result_email_text;        wp_mail($_POST['admin_email'], $subject, $message, $headers );


Registering dependency on 'wp-posts-to-posts' from a custom plugin

I have custom plugin which registers multiple CPT's and i want to reuse the features of wp-posts-to-posts to define relationships. I'm just wondering what is the correct/best way to include the api.php file within my own plugin?               function my_connection_types() {              require_once( ABSPATH . 'wp-content/plugins/posts-to-posts/core/api.php' );         // Make sure the Posts 2 Posts plugin is active.         if ( !function_exists( 'p2p_register_connection_type' ) )             return;              p2p_register_connection_type( array(                 'name' => 'events_to_races',                 'from' => 'event',                 'to' => 'race',                 'cardinality' => 'one-to-many'         ) );     }


foreach repeat html structure after every nth for attachment

I am trying to achieve result with below structure in foreach loop where after every two images it will repeat entire structure. I have some basic knowledge for something I can use eg. counter++; and than %2 but don't know syntax and how to use it for my code.               <?php         function dt_attached($postid=0, $size='thumbnail', $attributes='', $linksize='full', $count=-1) {             if ($postid<1) $postid = get_the_ID();             if ($images = get_children(array(                 'post_parent' => $postid,                 'post_type' => 'attachment',                 'numberposts' => $count,                 'post_mime_type' => 'image',)))                      foreach($images as $image) {                     $attachment=wp_get_attachment_image_src($image->ID, 'thumbnail');                     $small_image = wp_get_attachment_image_src($image->ID, 'midium');                     $big_image = wp_get_attachment_image_src($image->ID, 'full');                     ?>

                             <a href='<?php echo $big_image[0]; ?>' class='cloud-zoom-gallery' title='Thumbnail 1' rel="useZoom: 'zoom1', smallImage: '<?php echo $small_image[0]; ?>' ">                                 <img src="<?php echo $attachment[0]; ?>" <?php echo $attributes; ?> />

                             <a href='<?php echo $big_image[0]; ?>' class='cloud-zoom-gallery' title='Thumbnail 1' rel="useZoom: 'zoom1', smallImage: '<?php echo $small_image[0]; ?>' ">                                 <img src="<?php echo $attachment[0]; ?>" <?php echo $attributes; ?> />

                          <?php //the_attachment_link($image->ID, false, true, false); ?>             <?php }         }     ?>      So what I want is if there is more than two images it will repeat entire html structure. Thanks a lot for your help


Overriding FB Auto Connect plugin function displayed in footer

I have FB Auto Login plugin installed and i have wrote my own custom javascript to handle logins. Now my question is how do i override the jfb_output_facebook_init function with my own function which echos "Hello World" for example?               add_action('wp_footer', 'jfb_output_facebook_init');     function jfb_output_facebook_init()     {     global $jfb_name, $jfb_version, $opt_jfb_app_id, $opt_jfb_api_key, $opt_jfb_valid;     if( !get_option($opt_jfb_valid) ) return;          $channelURL = plugins_url(dirname(plugin_basename(__FILE__))) . "/facebook-platform/channel.html";     echo "\n\n";     ?>

               }


Set menu item class into body

I set css class for menu items. I want to get css class of current menu item and set it to body tag. What should i do ?


How to associate an image with a term taxononmy and publish it on frontpage?

I couldn't find the solution anywhere else, so I believe is a valid question for this website. I think my problem is divided in two parts. I created a custom taxonomy called "Type" and within it, I have terms (tags) like "cool", "sad", "amazing"..and so on. 1) I want to associate an icon for each one of my terms. 2) I want to display those icons (within link to the term archive) in my front page, like a feature image for each post. No idea how to do that. Help please.


Associate an image with a category?

Is it possible to associate an image with a category in Wordpress? I'm outputting a list of all categories and would like to feature an image alongside each category name.


Use WP_Query or query_posts() or get_posts() for optimizing a site?

I have read other answers, but I don't understand which is more fast (the best and simple for slow server running)? I have a website with over 1 000 000 hits /day and a slow server with limitations at database connections, so I want to optimise my site. What do you recommend me to use: WP_Query or query_posts() or get_posts()? And if I want to show articles in different positions, with different styles can I repeat the function [WP_Query or query_posts() or get_posts()] on every article that I show, or it is best to use it one time and use if $i == 1,2,3 for different styles?


Which filters or actions involve with index page for plugin?

I decide to manipulate index page or all pages except admin page with plugin but I don't know which filters or actions control index page. for example if I want write plugin that shows a link to admin page which filter or action responsible for it?


Inserting HTML elements into table with TinyMCE, security

I am working on a wordpress plugin where the administrator can fill out a form that adds products to a table. For most inputs I am using `sanitize_text_field()`, and then inserting the data. But for the description field I am using TinyMCE, and I want the user to be able to paste paypal buttons into it. This means that elements and elements would need to be allowed. I am new to the whole security thing, so I am wondering if there a secure way to do this? For output sanitization I am thinking of using `wp_kses()` sort of like this               $allowed_html = array(         'form' => array(),         'input' => array()     );          wp_kses($string, $allowed_html, $allowed_protocols);      Now that I think about it, `wp_kses()` could be used the same way for input validation as well. Would this be secure? Thanks


Any way to update_post_meta with html content? It gets stripped and becomes empty

So I am cloning some divs created from an array using jQuery. Here is an example. I have a drop down list that contains items to add to the meta box. The add button clones a hidden div based on the name in the drop down that matches the rel of the div. This then gets appended into my meta box. So it ends up looking like this.                       echo '
';             // content gets cloned into here             // example div that gets added

                             <input type="button" value="+" class="increase-size">                             <input type="button" value="-" class="decrease-size">                             Quote
                         <input type="hidden" id="page-option-item-type" class="page-option-item-type" value="Tab" name="">                         <input type="hidden" id="page-option-item-size" class="page-option-item-size" value="element1-4" name="">
                             1/4
                                         <input type="button" value="edit" rel="edit-box" id="page-element-edit-box" class="edit-element">                                         <input type="button" value="Remove" class="remove-element" id="delete-element">

Quote
                     <input type="text" id="_cmb_page-option-quote" name="_cmb_page-option-quote" class="cmb_text_small">

             // end example div that gets added                  // getting the values for displaying after save             $values = get_post_custom( $post->ID );             $selected = isset( $values['addddData'] ) ? $values['addddData'][0] : '';             echo $selected;             echo '
';               // Save data from metabox     function save( $post_id, $post )  {              // verify nonce         if ( ! isset( $_POST['wp_meta_box_nonce'] ) || !wp_verify_nonce( $_POST['wp_meta_box_nonce'], basename(__FILE__) ) ) {             return $post_id;         }              // check autosave         if ( defined('DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {             return $post_id;         }              // check permissions         if ( 'page' == $_POST['post_type'] ) {             if ( !current_user_can( 'edit_page', $post_id ) ) {                 return $post_id;             }         } elseif ( !current_user_can( 'edit_post', $post_id ) ) {             return $post_id;         }              $cloned = $_POST['page_selected_elements'];         update_post_meta( $post_id, 'addddData', $cloned );              //print_r($_POST);              }      Now the problem is it will not save the contents inside of the div page_selected_elements I can see the key is added via phpmyadmin, but the meta_value is always empty when I save after cloning items "adding items from drop down". As a test I manually edited the meta_value using phpmyadmin and pasted the example clone div as the value, refreshed and the div was displayed. However once I updated the page the value was removed. As a test I changed the div page_selected_elements to a textarea to test my save function, and that works just fine, text I enter into the text area gets updated and displayed back on the page after the update. Can anyone think what the problem might be? Could it have to do with dynamically added content? Maybe the update is not seeing it. I see the cloned items the whole time during the update but once it reloads the page they are gone and the meta_value is empty.


Multisite in subfolder - How to make new sites to be in same level subfolders as the main site

I have following situation. I have a WP Multisite installed in subdirectory:               my-domain.com/subfolder/wp-multisite-root      Now normally next sites added would be created like that               my-domain.com/subfolder/wp-multisite-root     my-domain.com/subfolder/wp-multisite-root/site1     my-domain.com/subfolder/wp-multisite-root/site2     my-domain.com/subfolder/wp-multisite-root/site3      Is there any way to have it created like this?               my-domain.com/subfolder/wp-multisite-root     my-domain.com/subfolder/site1     my-domain.com/subfolder/site2     my-domain.com/subfolder/site3      There is one more trick. my-domain.com/subfolder/ contains another non wordpress application.


How do I change the value of lang=en-US

I have noticed that in the `<html>` tag on my WP site that the language is defined as US English.               <html lang="en-US" prefix="og: http://ogp.me/ns#">      I would like to change it to British English `en-GB` but I'm not sure of the best way. I dug around and found `language_attributes()` in `general-template.php` which makes a call to `get_bloginfo('language')`. I could manually insert the value here but that doesn't seem like the best way to do it. What is the proper way to change this value?


Join two wp_query

So, i have custom posts with this settings: Example 1: have meta_key " **price** " Example 2: have meta_key " **no_price** " So, i want to list this posts ordered by " **price** ". I just want to join these two wp queries:               global $wp_query;          $wpcc_query_args = array(     //'wpcc_archives' => 'yeap',      'tax_query' => array( array( 'taxonomy' => 'wpcc_post_category', 'terms' => $cat_id_arr ) ),     'meta_query' => array( array( 'key' => 'pd_country', 'value' => 'USA' )),     'meta_key' => 'price',     'orderby' => 'meta_value_num',     'order' => 'ASC',     'post_type' => 'wpccposts',     'post_status' => 'publish',     'showposts' => (int)$per_page,     'paged' => $paged     );          $no_price_query = array(     //'wpcc_archives' => 'yeap',      'tax_query' => array( array( 'taxonomy' => 'wpcc_post_category', 'terms' => $cat_id_arr ) ),     'meta_query' => array( array( 'key' => 'pd_country', 'value' => 'USA' )),     'meta_key' => 'no_price',     'post_type' => 'wpccposts',     'post_status' => 'publish',     'showposts' => (int)$per_page,     'paged' => $paged     );      Here is a code to the first query:                       $wpcc_archives = new WP_Query( $wpcc_query_args );     $TEMP_query = $wp_query;         $wp_query = NULL;         $wp_query = $wpcc_archives;      Anyway to join these queries? Example of what i want:   * Title X - 50 dollars   * Title Y - 100 dollars   * Title Z - N/A   * Title F - Contact Us 50, 100 = meta_key price N/A, Contact Us = meta_key no_price


Installed WordPress Location

can i install wordpress on my sub-domain while all its contents/post are on the root domain? Ex. `admin.mydomain.com/wp-admin....` then the contents/post or homepage must be in `mydomain.com` and `mydomain.com/hello-world` ?


How to loop through custom posts in admin edit screen

How can I access the loop that displays all the custom posts in a custom post type's `edit.php` page? Is there some sort of hook for this? I want to do some condition checking on the data that is being pulled during the loop and it doesn't seem like WP offers any obvious solution.


Custom Post Types vs. Advanced Custom Fields (with Repeater Field add-on)

My goal is to give end users on my projects the maximum amount of control without making them work with any code. I've been using Advanced Custom Fields ("ACF") along with the Repeater Field add-on for some time now with great results, but I'm torn between two setups. **The problem:** A site needs to list employees on a page. They will not and should not be visible anywhere else. **Old way:** In the past I would setup a CPT for employees, plug in a quick `WP_Query` on that page template and be done with it. Then I added ACF and the Repeater Field add-on to my workflow. The new workflow allows me to setup a repeatable field where the admin can select a post object from a dropdown (filterable by post type). Admins can select the employee CPT object and keep adding or removing these as needed with the Repeater Field. They can even drag and drop the fields to reorder them. **Problem with the old setup:** The drawbacks I found to this approach are the repercussions of creating a CPT: mainly that the CPT is individually visible should a visitor stumble upon its URL and can be indexed by search engines. Template redirects and `robots.txt` can solve these issues but I wonder if there is a more efficient way... **The alternative:** Why not setup the repeatable fields directly on the page that's meant to display the employee data and include ACF fields I would normally include in the employee custom post type like name, image, bio, etc.? To me, this is a far cleaner and more efficient solution. This way, admins don't need to create a CPT and then go to the employees page and add the CPT they just added to the repeatable field that's setup there; they just input the employee data directly on the page where it's meant to be displayed. No template redirects or `robots.txt` tweaks necessary and they edit everything from within one window. I realize this solution may only be workable in a scenario where these **faux CPTs** only need to display on one particular page. Can anyone make a good case for or against a setup like this?


add <div> to end of post in the loop with plugin

I'm looking to add a `<div>` with some more html content to the bottom of specific posts in the loop. The `the_post` action can be used to add the `<div>` to the beginning of the post in the loop, but I'm hoping to add it to the end. EDIT The closest things I've been able to do is to add a classname to the desired post in the loop using `post_class`. Then I used `jQuery(.classname).append('<div>custom content</div>)` to add the custom content. The problem is, mixing jQuery and php in this manner seems to be less than optimal because I want to pass php info to the custom content...


Add index for post_title field to get similar post using full-text search

Currently, there are too many of my blog posts (about 700,000 articles) In my blog function "related articles" I'm thinking to use full-text search function to display the following related articles: Index field: `POST_TITLE (wp_posts)`               ALTER TABLE wp_posts ADD INDEX (POST_TITLE (300));      Use with full-text search query:               $ sql = "SELECT ID FROM wp_posts WHERE MATCH (POST_TITLE) AGAINST ($ title)      Where `$ title` is `POST_TITLE` the current article I am hesitated to do this So if I do have the data on display are all related and not speed up query?


how to use tax_query to apply both terms or one if one is empty

I'm having trouble with getting tax_query to act as a filter for posts. What I would like is to have it so it will display cpt's that have the terms of county and status but also work if terms are not provided for status or county. So have the posts show if it has the term of "Adams" county in the County taxonomy and the the term of "Locked" in the Status taxonomy. But it needs to also work if a County is not provided, just a status and vice-versa. Here is my code:                   <?php         $args = array(             'post_type' => 'property',             'posts_per_page' => 5000,             'tax_query' => array(                 'relation' => 'AND',                 array(                 'taxonomy' => 'Status',                 'field' => 'slug',                 'terms' => explode( ',', $st_term_final_string    )                 ),                 array(                 'taxonomy' => 'County',                 'field' => 'slug',                 'terms' =>  explode( ',', $il_term_final_string )                 )             )         );         $loop = new WP_Query( $args );         while ( $loop->have_posts() ) : $loop->the_post();             the_title();             echo '
';             echo get_the_post_thumbnail();             the_content();             echo '
';         endwhile;         ?>      Any hints to put me in the right direction? Thanks in advance


wordpress changing host breaks image links

I recently migrated my wordpress install from godaddy to a VPS that I setup. So far, everything but the images works. Not too sure why, but the images in posts appear broken, though if they are clicked on they will open the correct image. I've looked for a solution, but everything seems to be related to changing domains, whereas my domain remains the same, just redirected. Thanks,


How do I filter title and alt attributes in the gallery shortcode?

I am displaying a post gallery inside a custom post type, using the following in my single-custom.php template: `<?php echo do_shortcode('[gallery id="'.$post->ID.'" link="file" columns="5" orderby="menu_order"]'); ?>` One of the things included in the output is `title="filename"` in the `<img>` tag, like so: `<img width="150" height="150" src="http://mydomain.com/wp- content/uploads/DSC_0036-150x150.jpg" class="attachment-thumbnail" alt="DSC_0036" title="DSC_0036" />` I do not want to output the title attribute. Mostly, I don't want crappy filenames in the hover-over text, but there are hundreds of images and I'm not prepared to go into the Media Gallery and edit the title for each one. I'd prefer to also change the `alt` attribute to the post name, perhaps. Is there a way to filter the gallery to output the post name in the alt and title attributes, instead of the filename?


Creating a wordpress plugin where users can override templates

I see plugins where users can override the plugin templates by creating files inside of their own theme folder, how does this work? Is this a built-in part of wordpress or does it have to be written in?


How do i link gallery thumbnails to different url's using the wp native gallery?

Is it possible to link each gallery thumbnail if i use the built in WordPress native gallery?


Can't style custom menu

I have a Wordpress menu on my site generated by code:               <?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-primary' ) ); ?>      When I assign the menu called "Categories" to the "Primary Menu" location, this generates front end code of:

             Environmental

      The following CSS is not being applied:               .nav-primary {         display: block;     }     .nav-primary ul {         list-style-type: none !important;         background-color: rgba(0,0,0,0.25) !important;         padding: 5px !important;         border-radius: 8px !important;         -moz-border-radius: 8px !important;         -webkit-border-radius: 8px !important;     }     .nav-primary ul li {         display: inline-block !important;         background-color: rgba(0,0,0,0.25) !important;         margin-right: 5px !important;         height: 32px !important;         padding-top: 8px !important;         border-radius: 8px !important;         -moz-border-radius: 8px !important;         -webkit-border-radius: 8px !important;     }     .nav-primary ul li a {         text-decoration: none !important;         color: #fff !important;         margin: 8px 14px 0 14px !important;     }      How do I style this menu when the ID being output on the front end is generated from the name of the menu in Appearance > Menus ? If I deploy this theme to the public, I will never be able to anticipate what the name of the menu will be, and the generated ID will always take precedence over the class.


Content of post does not end up in "ShareThis" mail

I am using the ShareThis plugin in my blog. When I click on the email tab and send a mail to my friend, only the post title and post link is included in the mail. Contents are not showing up in the mail. What can I do to change this?


If has $title in widgets

I'm writing a widget to display 125 x 125 pixel ads. There are 6 spaces for the ads and currently all works. However, I would to add some conditional logic so that if nothing is entered in the values in the widget admin for an ad, then no add is shown. I think this can be done by using PHP if or something, I can't remember what it is exactly. I need it with the `<?php & ?>` tags on. It needs to check if `$adone` exists and if not display an empty space. I know this code here is wrong but something like this:               <?php if_has($adone_img)  ?>     /** Ad 1 code here */     <?php else : ?>     <?php endif; ?>      **The widget class:**               <?php     /**      * square_ad Class      */     class square_ad extends WP_Widget {         /** constructor */         function square_ad() {             $widget_ops = array('classname' => 'square_ad', 'description' => 'Up to 6 125px by 125px ads for your sidebar.');             $control_ops = array('id_base' => 'square_ad');             $this->WP_Widget('square_ad', 'SILVERLINE 125 Ad', $widget_ops, $control_ops);           }              /** @see WP_Widget::widget */         function widget( $args, $instance ) {             extract( $args );             $title = apply_filters( 'widget_title', $instance['title'] );                  $adone_img = apply_filters( 'adone', $instance['adone_img'] );             $adone_link = apply_filters( 'adone', $instance['adone_link'] );                  $adtwo_img = apply_filters( 'adtwo', $instance['adtwo_img'] );             $adtwo_link = apply_filters( 'adtwo', $instance['adtwo_link'] );                      $adthree_img = apply_filters( 'adthree', $instance['adthree_img'] );             $adthree_link = apply_filters( 'adthree', $instance['adthree_link'] );                  $adfour_img = apply_filters( 'adfour', $instance['adfour_img'] );             $adfour_link = apply_filters( 'adfour', $instance['adfour_link'] );                  $adfive_img = apply_filters( 'adfive', $instance['adfive_img'] );             $adfive_link = apply_filters( 'adfive', $instance['adfive_link'] );                  $adsix_img = apply_filters( 'adsix', $instance['adsix_img'] );             $adsix_link = apply_filters( 'adsix', $instance['adsix_link'] );                  echo('
');             echo($title);             echo('
');             echo('
');      ?>                    <a href="<?php echo ($adone_link);?>"><img class="box-container" src="<?php echo ($adone_img);?>" width="125" height="125" />     <a href="<?php echo ($adtwo_link);?>"><img align="right" class="box-container" src="<?php echo ($adtwo_img);?>"  width="125" height="125" />
     <a href="<?php echo ($adthree_link);?>"><img class="box-container" src="<?php echo ($adthree_img);?>" width="125" height="125" />     <a href="<?php echo ($adfour_link);?>"><img align="right" class="box-container" src="<?php echo ($adfour_img);?>"  width="125" height="125" />
     <a href="<?php echo ($adfive_link);?>"><img class="box-container" src="<?php echo ($adfive_img);?>" width="125" height="125" />     <a href="<?php echo ($adsix_link);?>"><img class="box-container" src="<?php echo ($adsix_img);?>" width="125" height="125" />

                  <?php          }              /** @see WP_Widget::update */         function update( $new_instance, $old_instance ) {             $instance = $old_instance;             $instance['title'] = strip_tags($new_instance['title']);                  $instance['adone_img'] = strip_tags($new_instance['adone_img']);             $instance['adone_link'] = strip_tags($new_instance['adone_link']);                  $instance['adtwo_img'] = strip_tags($new_instance['adtwo_img']);             $instance['adtwo_link'] = strip_tags($new_instance['adtwo_link']);                  $instance['adthree_img'] = strip_tags($new_instance['adthree_img']);             $instance['adthree_link'] = strip_tags($new_instance['adthree_link']);                  $instance['adfour_img'] = strip_tags($new_instance['adfour_img']);             $instance['adfour_link'] = strip_tags($new_instance['adfour_link']);                  $instance['adfive_img'] = strip_tags($new_instance['adfive_img']);             $instance['adfive_link'] = strip_tags($new_instance['adfive_link']);                  $instance['adsix_img'] = strip_tags($new_instance['adsix_img']);             $instance['adsix_link'] = strip_tags($new_instance['adsix_link']);             return $instance;         }              /** @see WP_Widget::form */         function form( $instance ) {             if ( $instance ) {                 $title = esc_attr( $instance[ 'title' ] );                 $adone_img = esc_attr( $instance[ 'adone_img' ] );                 $adone_link = esc_attr( $instance[ 'adone_link' ] );                      $adtwo_img = esc_attr( $instance[ 'adtwo_img' ] );                 $adtwo_link = esc_attr( $instance[ 'adtwo_link' ] );                      $adthree_img = esc_attr( $instance[ 'adthree_img' ] );                 $adthree_link = esc_attr( $instance[ 'adthree_link' ] );                      $adfour_img = esc_attr( $instance[ 'adfour_img' ] );                 $adfour_link = esc_attr( $instance[ 'adfour_link' ] );                      $adfive_img = esc_attr( $instance[ 'adfive_img' ] );                 $adfive_link = esc_attr( $instance[ 'adfive_link' ] );                      $adsix_img = esc_attr( $instance[ 'adsix_img' ] );                 $adsix_link = esc_attr( $instance[ 'adsix_link' ] );             }             else {                 $title = __( '', 'text_domain' );             }             ?>
             <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?>             <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" />
Ad One
             <label for="<?php echo $this->get_field_id('adone_img'); ?>"><?php _e('Image URL:'); ?>             <input class="widefat" id="<?php echo $this->get_field_id('adone_img'); ?>" name="<?php echo $this->get_field_name('adone_img'); ?>" type="text" value="<?php echo $adone_img; ?>" />             <label for="<?php echo $this->get_field_id('adone_link'); ?>"><?php _e('AD Link:'); ?>             <input class="widefat" id="<?php echo $this->get_field_id('adone_link'); ?>" name="<?php echo $this->get_field_name('adone_link'); ?>" type="text" value="<?php echo $adone_link; ?>" />
Ad Two
             <label for="<?php echo $this->get_field_id('adtwo_img'); ?>"><?php _e('Image URL:'); ?>             <input class="widefat" id="<?php echo $this->get_field_id('adtwo_img'); ?>" name="<?php echo $this->get_field_name('adtwo_img'); ?>" type="text" value="<?php echo $adtwo_img; ?>" />             <label for="<?php echo $this->get_field_id('adtwo_link'); ?>"><?php _e('AD Link:'); ?>             <input class="widefat" id="<?php echo $this->get_field_id('adtwo_link'); ?>" name="<?php echo $this->get_field_name('adtwo_link'); ?>" type="text" value="<?php echo $adtwo_link; ?>" />
Ad Three
             <label for="<?php echo $this->get_field_id('adthree_img'); ?>"><?php _e('Image URL:'); ?>             <input class="widefat" id="<?php echo $this->get_field_id('adthree_img'); ?>" name="<?php echo $this->get_field_name('adthree_img'); ?>" type="text" value="<?php echo $adthree_img; ?>" />             <label for="<?php echo $this->get_field_id('adthree_link'); ?>"><?php _e('AD Link:'); ?>             <input class="widefat" id="<?php echo $this->get_field_id('adthree_link'); ?>" name="<?php echo $this->get_field_name('adthree_link'); ?>" type="text" value="<?php echo $adthree_link; ?>" />
Ad Four
             <label for="<?php echo $this->get_field_id('adfour_img'); ?>"><?php _e('Image URL:'); ?>             <input class="widefat" id="<?php echo $this->get_field_id('adfour_img'); ?>" name="<?php echo $this->get_field_name('adfour_img'); ?>" type="text" value="<?php echo $adfour_img; ?>" />             <label for="<?php echo $this->get_field_id('adfour_link'); ?>"><?php _e('AD Link:'); ?>             <input class="widefat" id="<?php echo $this->get_field_id('adfour_link'); ?>" name="<?php echo $this->get_field_name('adfour_link'); ?>" type="text" value="<?php echo $adfour_link; ?>" />
Ad Five
             <label for="<?php echo $this->get_field_id('adfive_img'); ?>"><?php _e('Image URL:'); ?>             <input class="widefat" id="<?php echo $this->get_field_id('adfive_img'); ?>" name="<?php echo $this->get_field_name('adfive_img'); ?>" type="text" value="<?php echo $adfive_img; ?>" />             <label for="<?php echo $this->get_field_id('adfive_link'); ?>"><?php _e('AD Link:'); ?>             <input class="widefat" id="<?php echo $this->get_field_id('adfive_link'); ?>" name="<?php echo $this->get_field_name('adfive_link'); ?>" type="text" value="<?php echo $adfive_link; ?>" />
Ad Six
             <label for="<?php echo $this->get_field_id('adsix_img'); ?>"><?php _e('Image URL::'); ?>             <input class="widefat" id="<?php echo $this->get_field_id('adsix_img'); ?>" name="<?php echo $this->get_field_name('adsix_img'); ?>" type="text" value="<?php echo $adsix_img; ?>" />             <label for="<?php echo $this->get_field_id('adsix_link'); ?>"><?php _e('AD Link:'); ?>             <input class="widefat" id="<?php echo $this->get_field_id('adsix_link'); ?>" name="<?php echo $this->get_field_name('adsix_link'); ?>" type="text" value="<?php echo $adsix_link; ?>" />
             <?php          }          } // class square_ad          // register square_ad widget     add_action( 'widgets_init', create_function( '', 'return register_widget("square_ad");' ) );


In which directory do I find the HTML file of my wordpress pages?

I would like to manually edit the code my my wordpress pages. The WP interface only allows me to individually edit the CSS or PHP. The Page Edit feature gives me access to a certain part of the code, excluding the Body Tag. Kindly help me locate my files on the server. Thanks for your help! :)


Add javascript to wp_head with call to plugin options?

I am trying to write a plugin in wordpress and have been doing it in stages, I understand how to add javascript to the wp_head however adding multiple function calls to the plugins options is something I don't think I'm understanding. This is my first attempt at trying to write a plugin so I know I am going about this wrong. Any feedback is greatly appreciated! If I have:                   function tweet_feed_it() {         echo '<script type="text/javascript">             $(document).ready(function() {                 $(".tweet").tweet({                 modpath: "path/to/plugin/twitter/",                 username: "twitter_username",                 join_text: "auto",                 count: tweet_count,                 auto_join_text_default: "We tweeted,",                  auto_join_text_ed: "We",                 auto_join_text_ing: "We were",                 auto_join_text_reply: "We replied to",                 auto_join_text_url: "We were checking out",                 loading_text: "loading tweets..."                         });                      });                </script>'};     // Add to head     add_action('wp_head', 'tweet_feed_it');      The script shows up in wp_head fine. But in my wordpress plugin I have set some options and I want to call them to use within the script tags. I will show what i have tried so you get an idea of what I am trying to accomplish at least:                   class TweetFeedIt {         function tweet_feed_it() {             function twitter_username_callback() {                 function tweet_count_callback() {         printf( '<script type="text/javascript">                 $(document).ready(function() {                 $(".tweet").tweet({                 modpath: "http://test.phoenixlaef.com.au/wp-content/plugins/Tweet-Feed/twitter/",                 username: "twitter_username",                 join_text: "auto",                 count: tweet_count,                 auto_join_text_default: "We tweeted,",                  auto_join_text_ed: "We",                 auto_join_text_ing: "We were",                 auto_join_text_reply: "We replied to",                 auto_join_text_url: "We were checking out",                 loading_text: "loading tweets..."             });         });     </script>     '     , esc_attr( $this->options['twitter_username']), esc_attr( $this->options['tweet_count'])                     );                 }             }         }     }     // Add to head     add_action('wp_head', 'tweet_feed_it', 'twitter_username_callback', 'tweet_count_callback');      Do I need to register the option settings to use it like this or is what I am trying to do just not practical? Thanks for your help in advance :)


On home page remove link from logo

I'd like to remove the link that is generated around the logo when users are on the home page. Does wordpress have a built in function so I can wrap an if condition around the logo in the template so if the current page is the home page I can have the output without the a tag, and the else would simply be the current code.


What are some examples of well-written plugins that exemplify wordpress plugin best practices?

I've searched through the stack exchange for wordpress and was unable to come up with an answer to this question. All of the wordpress codex's examples and external resources come from 2004-2006. I'd love an example of a popular Wordpress plugin that is also well-written. As I'm fairly new to programming (less than 1 year in), this would be immensely helpful.


How To Add Custom Form Fields To The User Profile Page?

The user profile page has the following fields: Username   First Name   Last Name   Nickname Display name Contact Info E-mail Website AIM Yahoo IM   Jabber / Google Talk How can more fields be added to this section. Field such as Phone number, address, or anything else.


Customize field names in backend profile edit page through function.php

> **Possible Duplicate:**   >  How To Add Custom Form Fields To The User Profile Page? I want to change a the names of some of the fields in the edit profile page in the backend. For instance, instead of it saying "Twitter", I want it to display "Enter Twitter ID". I am aware that I can do this by editing the core WP files, but to avoid redoing the same process, how can I do this through the function.php file? What code can I enter that would make this possible?


Is wordpress big enough for my project

I have a site some having job postings running using jobber base. Now I am going to shift it in WP using jobroller theme that is of 99 USD. I am a developer who always like MVC rather than these CMS. I was thinking of doing it in Yii. But now I came to know about job roller. So I have 2 questions? Is jobroller worth 99 USD and will it work for my product? Can WP handle this if I want to do changes every week. As I told earlier, I am also a developer. So I will be doing changes in it but I doubt that I will not be able to do this in such friendly way as it can be easily done in an MVC framework. I am always in favor of OOP and MVC. But I actually don't have much time to develop my own. So guys please advise me that should I spend some more time and do it in MVC once or I should once continue with WP? Can any one tell me about big sites that are developed in WP? I will be thankful if any one can give me good advise?


How to protect uploads in multisite if user is not logged in?

I am trying to set up a multisite intranet (using subdomains) where content on each sub-site is only accessible to users logged into their respective site. The problem I am having is trying to restrict access to uploaded files (e.g. http://example.org/wp-content/uploads/2011/12/dummy.pdf) to logged in users only. Similar to How to Protect Uploads, if User is not Logged In?, how would I enable one of the solutions proposed by hakre or Frank Bueltge for a multisite installation? I have been scouring the net and Wordress Answers but haven’t managed to find something that I can get to work. Related answers are:   * How to make media upload private?   * Protect Uploads in Multisite Also, I am new to PHP and still learning how WordPress works under the hood, so detailed information about what I need to do and what goes where would be much appreciated. Thanks!


Hiding posts and pages in panel

I found out this code and works ok for hide pages in admin page listing, but I need someway to do this to thousand pages:               add_action( 'pre_get_posts' ,'hide_pages_87ff65f5f' );          function hide_pages_87ff65f5f( $query ) {              if( !is_admin() )             return $query;              global $currentpage;            $pages = array('2389','2605','2640','2970','2626');            if( 'edit.php' == $currentpage && ( get_query_var('post_type') && 'page' == get_query_var('post_type') ) )         $query->set( 'post__not_in', $pages );              return $query;     }      Because I migrated a large static site I want to hide several pages and posts types from this specific month and year, I tried query and get_posts but something is not working, or maybe is not possible here :S Infact I need to hide the content on every context in admin panel such parent option box, but this is quite enough for now. Thanks a lot for any help!


Displaying categories items among posts

I'm making a website with lots of custom posts as well as custom hierarchical taxonomies. Default index (archive) page is made of bricks with photo, title and excerpt from posts. And here comes the problem, cause those index/archive pages mustn't contain only posts items (bricks), it should also contain (among the normal post items) bricks showing sub-categories of current. Is it a good way of doing such a thing using categories, and if it is - how to achieve it? EXPLANATION EDIT: By bricks i understand floating containers, just the visual representation of post (or category) data. Floating thumbnails with descriptions. Category archive page would contain items of two types: 1) posts located in current category (not subcategories) and 2) subcategories of current category. It'd be kind like files and folders structure.


Sidebar slideshow widget

Anyone know any quality image slideshow widgets that can be put on a sidebar?


Trying to use .htaccess to redirect /profile to /login-2?action=profile

I have a plugin Theme My Login for WordPress 3.0.1 which causes my user's profile pages to be here: domain.com/login-2?action=profile instead of here: domain.com/profile So I am trying to fix it with mod_rewrite like this: RewriteRule ^profile /login-2?action=profile But it seems to do nothing. I suspect it's some weird thing happening in WordPress but wanted to ask folks here if my rewrite rule looks correct before I dig further. Did I do it right? Update: I had someone suggest I use wp_rewrite - which I noticed has some flush rules functions associated with it; perhaps wp is not noticing my changes to htaccess because a flush is needed first?


How to check if certain plugin exists and in expected version

I've created plugin that goes to wordpress plugin repositories. Now, I need to create another plugin (sub plugin or child plugin you may call) that require this certain plugin to be already installed and activated. I know I can use `register_activation_hook`. However, how do I check using that hook? Or, maybe there's another solution exists?


Import and export links from WordPress.com to private site

Is there some way to export/import links from a wordpress.com site to a private site? I have a rather large directory of links. I fetch the opml file and the category levels are there, but when I use the Bloggroller importer, it doesn't create the categories? Help would be appreciated.


Questions about meta box: nonce and parameters available

1st question is: is a nonce required for a meta box? i read on the wordpress codex `add_meta_box` and they have a nonce for the meta box, i'd thought that maybe the add post form will already include a nonce?               echo '<input type="hidden" name="myplugin_noncename" id="myplugin_noncename" value="' . wp_create_nonce( plugin_basename(__FILE__) ) . '" />';      2nd question is: whats the parameters available for the function that creates the markup of the meta box. from what i read in profesional wordpress looks like               function pp_meta($post, $box)      how will i know what parameters are available in such functions? and what does `box` refer to?


Get fuzzy matches from get_term_by

I would like to get a term, knowing only part of its slug. The way my slugs are set up, make it so the category name appears before a language code, and I sometimes need to get the term just from the category name and language code concatenated together, but if that exact term doesn't exist, I don't get anything from get_term_by. That would be okay, except, some of my terms are in multiple languages, and when I know the category and the language, say it's apple in french and english, and I need to find that term from just knowing that I am dealing with apple, and I'm in english. More concrete example: > term name: apple_en_fr > > I want to search for apple_en or apple_fr and get that term. How could one go about getting a fuzzy match, like that?


Change post status based on user role

I have a site I'm working on where users pay a monthly fee to be able to add content to the site and they are assigned a custom user role when registered. When their subscription is up their user role is changed to a subscriber. It's using Gravity Forms and their authorize.net plugin for the subscription.               // Set user role to subscriber after subscription expires     add_action( 'gform_authorizenet_subscription_canceled', 'downgrade_user_role', 10, 4 );          function downgrade_user_role( $entry, $subscription_id, $transaction_id, $new_payment_amount ) {         $user = GFUserData::get_user_by_entry_id( $entry['id'] );         $user->set_role( 'subscriber' );     }      I'm then trying to figure out how to change the post status once their subscription is up so the content wouldn't be active unless their subscription was. I was thinking of changing the post status to draft when the user role is changed to a subscriber but not sure how to go about doing that. Another option would be to only include the posts by certain user roles in the query but haven't been able to find a way to do that either. Anyone have any thoughts or ideas on how I could achieve this? Thanks


Use another menu when logged in

Before the update to WP 3.6 I could add this code in the header.php of the theme, which made it possible to have another menu when logged in:                       <?php             if( is_user_logged_in() ) {                 $menu = 'logged-in';             } else {                 $menu = 'logged-out';             }                  wp_nav_menu( array(                 'menu'              => $menu,                 'theme_location'    => 'menu',                 'sort_column'       => 'menu_order',                 'menu_class'        => 'sf-menu',                 'fallback_cb'       => 'default_menu'             )); ?>      I have made the two menus called "logged-in" and "logged-out" in the WP admin panel. But after the update, this doesn't work anymore. How can I change the menu when logged in in the correct way? _(PS: The theme is WPExplorer's Adapt theme.)_ **Note:** Actually, all I need is to change one specific button in the menu, so it is different when the user is logged in - in that case that menu button will be a "Member profile" button instead of a "Log in" button. If that can be done without changing the entire menu, that would be much better.


wp_next_scheduled not working with variables

Here is the code:                   <?php while ($parent->have_posts() ) : $parent->the_post(); ?>         <?php $timi = get_field('timi', $post->ID); ?>         <?php $timi2 = $timi / 2;               //$int_timi = intval($timi2);               $current_id = $post->ID;               //$curent_id_str = strval($curent_id);               echo $timi2;               echo $current_id;               $next_time = wp_next_scheduled( 'dothisinanhourhook', array( $current_id, $timi2));               echo $next_time;               ?>      The cron is running normaly, even though, I can't get next timestamp due to $current_id. If I enter its value as a string, it works. Any ideas?


Post/Custom Post Type URL Access

Is there a way to prevent people from visiting a post's permalink? A lot of times we create posts or custom post types that end up being included as part of the content of a page or some other feature and are not always intended to be viewed individually. A good example might be for a slideshow. You create a few posts where each individual post is the content of a slide in the slideshow. Each one of those posts has a unique permalink, something like `example.com/slide-one`. There's no reason for someone to be able to access that individual post so I would like to "hide" it.


Use custom category in more than one custom post

I am using a custom category in more that one custom posts.                   register_taxonomy( 'location', array('holiday','resorts' , array(              'hierarchical' => true,              'labels'       => array (                   'name' => 'Locations',                     'singular_name' => 'Location',                         'search_items' => 'Search Location',                        'all_items' => 'All Locations',                     'parent_name' => 'Parent Location',                         'parent_item_colon' => 'Parent Location',                        'edit_item' => 'Edit Location',                      'update_item' => 'Update Location',                    'add_new_item' => 'Add New Location',                        'new_item_name' => 'New Location Name',                      'choose_from_most_used' => 'Choose from the most used Location',                   'separate_items_with_commas' => 'Seperate Location with commas'              ),              'show_ui'       => true,              'query_var'       => true,         );      I have a location category which I am using it in custom posts holiday and resorts I need to display only holidays in taxonomy page? And also the post count shows sum of both custom posts. How to show the counts of each post separately?


Set the limit to allow author when make post!

I would like to ask something here, The question is, is there any way to set the limit of post that an author can post? For example, I have a few authors on my site, but I want to allow each of them to make only 1 post and edit only post that they have posted. Appreciate your answers. Thank you!


Editor can't login after WP Visited Countries plugin is installed

I have installed http://wordpress.org/plugins/wp-visited-countries/ plugin. When the user (Role: Editor) try to login - I got "You do not have sufficient permissions to access this page." When I disable the plugin it allows user to login.


Better to make new wp_query or only modify main query each time?

I have a theme where I need multiple queries for each column. Is it better to modify the main query with pre_get_post and reset the loop or create a new query for each of my columns?


How to get attached file in wordpress from custom post

I am using the Download monitor plugin I am listing the posts by category the following way               $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );           <?php                      $args = array(                     'post_type' => 'dlm_download',                     'posts_per_page' =>25,                     'numberposts' => null,                     'dlm_download_category' => $term->slug                 );                          $downloads = get_posts($args);                          foreach ($downloads as $download) {                              echo '
';                                  echo '
                                                                          '.$download->post_title.'
';                                   echo '
'.$download->post_excerpt.'
';                              echo '
';                     }                       ?>      But i have no idea how to show custom post attached file. The file is contained i the wp_postmeta table, I tryed with `wp_get_attached_ur($download->ID)` but it returns an empty string Anybodycould please give me a hint?


WordPress displays post on subcategory only

I'm using WordPress on developing a site and a self-made template. I got 1 page to display all categories with its post. This is what I want to do:   * Main Category      * subcategory1        * post 1       * subcategory1.2          * post 1.2.1         * post 1.2.2     * subcategory2     * subcategory3 I used `wp_link_category()` to display the category and I searched how to display category with post but the problem is: the post from subcategory 1.2 is also displayed on subcategory 1.   * Main Category      * subcategory1        * post 1       * post 1.2.1       * post 1.2.2       * subcategory1.2          * post 1.2.1         * post 1.2.2     * subcategory2     * subcategory3 How can I remove the post from subcategory 1.2 on subcategory 1? Here's the code I copied and pasted from StackOverflow:               $categories =  get_categories('child_of=4');       foreach  ($categories as $category) {         //Display the sub category information using $category values like $category->cat_name         echo '
'.$category->name.'
';         echo '
';              foreach (get_posts('cat='.$category->term_id) as $post) {             setup_postdata( $post );             echo '
ID).'">'.get_the_title().'
';            }           echo '
';     }      I hope you understand me.


Why does Google Webmaster Tools say my whole site is blocked by robots.txt when I have no robots.txt?

I submitted a sitemap for my WordPress site to Google Webmaster Tools. Several times. I keep getting the same messages: "Url blocked by robots.txt." and "Sitemap contains urls which are blocked by robots.txt." But I have no robots.txt anywhere. It seems my entire site and every link on it is blocked from being crawled by Googlebot. I was using WordPress' Yoast SEO plugin and Cloudflare, but I disabled them and cleared my cache, to no avail. I thought it was Yoast's fault at first. WordPress' "Search engine visibility" setting has "Discourage search engines from indexing this site" unchecked, like it should. Now I'm wondering if WordPress creates its own virtual robots.txt or something that doesn't show up in the site root. What gives? Do I need to wait a few days? I never had a robots.txt to begin with!


wp Query Posts to display in Nivo Slider

i have coded a slider into my wordpress theme to use query posts to display the thumbnail and the content however it appears that its displaying the whole posts? and not just the one relating to the slide at that time?

             <?php $the_query = new WP_Query( 'showposts=5' ); ?>             <?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>                 <?php the_post_thumbnail(); ?>

<?php the_title(); ?>
                     <?php the_content(); ?>            <?php endwhile;?>
        Please can someone advise what I'm doing wrong? http://www.milknhny.co.uk/PeterWork This is the NIVO Mark up:

         This is an example of a HTML caption with a link.
      As you can see the caption for this is completely outside the wrappers?


wordpress custom modules/widget areas on the page? can i make my own?

im kind of a wordpress noob so please excuse my inexperience. so long story short, ive been tasked with creating a WP theme (kinda simple) but, one of the areas, around footer area, has a few things they want, like a 2ndary menu/ bread crumbs etc...maybe even custom html box etc that i can do other things with later on, which i know WP provides via plugins / widgets etc but, my question is how can i make a custom area to "hook" these onto a specific area of a page? for example, in joomla, i can mark any part of a page with **named** hooks and thereafter, select whatever module i want to work with, assign said widget to the area by name and thats it, style it there after. Does wordpress have anything like this?i know theyre different platforms but is there anything like it or a wordpress equivalent to achieve this. i see for example that most of the widgets etc, go into the wp_sidebar. can i make my own area or are there other hooks that simulate what i described above? Any tips/answers, links to read/research i gladly and humbly appreciate. Thank you in advanced.


Add multiple custom meta boxes to different custom post types

I want to add one custom meta box to a specific custom meta type "chifres" and two custom meta boxes to a specific custom meta type "presse". This is how far I've gotten: Here is my code:               //Add custom metadata     function add_custom_metadata_boxes() {             add_meta_box(             'custom_meta_box', // $id             'Values', // $title             'show_custom_boxes', // $callback             'foo1', //Custom post types             'normal', // $context             'high' // $priority         );     }          $prefix = 'custom_';     $custom_meta_fields = array(         array(                 'name' => 'number',                 'label' => 'Number',                 'id' => $prefix . 'number',                 'type' => 'number',                 'std' => ''         )     );          // The Callback for the first one     function show_custom_boxes() {     global $custom_meta_fields, $post;     // Use nonce for verification     echo '<input type="hidden" name="custom_meta_box_nonce" value="'.wp_create_nonce(basename(__FILE__)).'" />';              // Begin the field table and loop         echo '
';         foreach ($custom_meta_fields as $field) {             // get value of this field if it exists for this post             $meta = get_post_meta($post->ID, $field['id'], true);             // begin a table row with             echo '
                    '.$field['label'].'	                    ';                     switch($field['type']) {                         // checkbox                                             case 'number':                                     echo '<input type="number" min="0" step="1" pattern="\d+" placeholder="Fill in a number" name="', $field['id'], '" id="', $field['id'], '" value="', $meta ? $meta : $field['std'], '" size="30" style="width:97%" />', '
', $field['desc'];                             break;                     } //end switch             echo '
';         } // end foreach         echo '
'; // end table     }          add_action('add_meta_boxes', 'add_custom_metadata_boxes');          function save_custom_meta($post_id) {         global $custom_meta_fields;              // verify nonce         if (!wp_verify_nonce($_POST['custom_meta_box_nonce'], basename(__FILE__)))             return $post_id;         // check autosave         if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)             return $post_id;         // check permissions         if ('page' == $_POST['post_type']) {             if (!current_user_can('edit_page', $post_id))                 return $post_id;             } elseif (!current_user_can('edit_post', $post_id)) {                 return $post_id;         }              // loop through fields and save the data         foreach ($custom_meta_fields as $field) {             $old = get_post_meta($post_id, $field['id'], true);             $new = $_POST[$field['id']];             if ($new && $new != $old) {                 update_post_meta($post_id, $field['id'], $new);             } elseif ('' == $new && $old) {                 delete_post_meta($post_id, $field['id'], $old);             }         } // end foreach     }     add_action('save_post', 'save_custom_meta');      The "chifres" box works perfectly, I just can't figure out how I can add other custom meta boxes to another custom post type. Any suggestions?


query_post and wpdb returning different results

I am trying to get the woocommerce products by category.. When I query using the wpdb it gets the product correctly which exists in the backend products list. But when I query using the query_posts it gets another set of products that is not listed in the backend. Why this discrepancy?                    global $post, $wpdb;                                      $query = "SELECT $wpdb->posts.* FROM $wpdb->posts         LEFT JOIN $wpdb->term_relationships ON         ($wpdb->posts.ID = $wpdb->term_relationships.object_id)         LEFT JOIN $wpdb->term_taxonomy ON         ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)         WHERE $wpdb->posts.post_status = 'publish'         AND $wpdb->term_taxonomy.taxonomy = 'product_cat'         AND $wpdb->term_taxonomy.term_id = 1         $childcond         ORDER BY post_date DESC";               if ($wpdb->num_rows > 0) {             foreach ($postresults as $post) {                    //process product item             }         }      using query_post                query_posts('cat=1&showposts=-1');


Wordpress multi-site for subdomains and different domains with one database?

I'm working onf a wordpress that has lots of posts. They're not in any language (they are either just images or addresses) but I want to make my site available in other languages (for wordpress texts) using subdomains or completly different domains. For example: My site is in Spanish and this is its URL:               example.es      Now I want to make it available in Basque with the following URL:               eu.example.es      But I also want to make it international and for those cases I want to use a different domain, for example, in french:               example-en-francaise.fr      Each of them would be in a different language but they would all be sharing the same database. What would be the best option for this? Would it be possible to only show the posts that are in the language of the domain (Spanish for .es, French for .fr, etc.)? Thank you in advance.


WordPress is hard cropping large and medium images

I have a Woo Canvas theme site and sometime in the recent past the image sizing functions stopped working as expected. When you upload an image into the media library and try to insert into a page, the size options are thumb (150x150) medium (300x300) large (1024x1024) and full size. The problem is when you choose medium or large, it crops the image as it would to a hard cropped thumbnail. It is not using the "maximum" size, but cropping the image square to those sizes. The height will be fine (say 1024) but the left and right get cropped to a 1024 width. If you use 'full size' you can then scale the image down fine, retaining aspect ratio. I have dozens of other Canvas sites, I've never seen this before. All the settings in both the WP Settings and Canvas Dynamic Images are the same as a few of the others, but the other sites all soft crop the medium and large to best fit, maintaining aspect ratio. What I've Tried: Disabled all plugins - no change Switched to 2014 theme - the only change is the size of medium/large, it still crops it square. Updated all plugins, and WP core. Canvas is not the most recent, but since it was happening with 2014, didn't think it was an issue. Found nothing in any of the function files. Ideas?


How to store widget fields data as an array?

I am creating a widget, it needs to store about 10 IDs. Right now I'm using following field method to store each of the ID in a separate field. It stores data of each field in a separately in the wordpress. Is it possible to store the data of all fields in just one row in wordpress for examlpe using an array?               <input          class="widefat"          id="<?php echo $this->get_field_id('item1_id'); ?>"          name="<?php echo $this->get_field_name('item1_id'); ?>"          value="<?php echo $instance['item1_id']; ?>"          />          <input          class="widefat"          id="<?php echo $this->get_field_id('item2_id'); ?>"          name="<?php echo $this->get_field_name('item2_id'); ?>"          value="<?php echo $instance['item2_id']; ?>"          />


Modify the output of wp_nav_menu in a very specific way?

I am trying to get wp_nav_menu to output something like this:

Home

|

Contact Us

|

Services

      I'm close, but I can't quite get there. This is what I've done so far, and the output I get: Code:                   <?php              $defaults = array(                 'theme_location'  => 'Primary Menu',                 'menu'            => 'Primary Menu',                 'container'       => 'div',                 'container_class' => 'spanningMenu noPrint',                  'container_id'    => 'topMenu',                 'fallback_cb'     => '',                 'after'           => '
|
',                 'items_wrap'      => '

%3$s

',                  );                  wp_nav_menu($defaults);              ?>      Result:

Home
|

Contact Us
|

Services
|

      So there are three things I still need to do, and I have no idea how to do them:   1. Get rid of all the id and class tags on the li, I'm not sure where these are being generated.   2. Somehow get the "[li class="topMenuDivider"]|[/li]" to appear after the closing li rather than before it.   3. Get rid of the last li that inserts a | Is this possible? Edit: I have solved #2 by changing these lines as follows. It's kind of a hack, but it works:                           'after'           => '

|',                 'items_wrap'      => '

%3$s

',


How to search using query LIKE?

I'm using Wordpress with Woocommerce and I have a product with name "L-Glutamine". If I search _Gluta_ the site returns me nothing found. If I search _l-gluta_ the site returns me the respective product. This is my site www.lojabrasilsuplementos.com.br How can change the search to find all posts/products whose names matches the search term?


are there any downsides to increasing the number of most recent items in a feed

The default number of items to show in a rss feed is 10 (Settings-Reading) Is there any reason why I shouldn't show all items. When I use feeds from other sources (not wordpress) it seems like they show all the items. Is there any performance hit on the server for showing a large number of items?


Thumbs and pictures not showing anymore

After moving my site to a new VPS cloud server, things worked fine for a couple of days, but this morning all of the thumbs and pictures stopped showing, even though they're still in the same directory as before. Also, if I open the media library through WP console, all of the pictures show and when opening any of the posts for editing the pictures are also there. After contacting my hosting service, I was told that they were not going to help me, even though they changed something, as they were working on another issue overnight. The message below shows the message I get when following any of the pictures path on the browser: > A TimThumb error has occured   >  The following error(s) occured: > > You may not fetch images from that site. To enable this site in timthumb, > you can either add it to $ALLOWED_SITES and set ALLOW_EXTERNAL=true. Or you > can set ALLOW_ALL_EXTERNAL_SITES=true, depending on your security needs. > > Query String: `src=http://i0.wp.com/ovnihoje.com/wp- > content/uploads/2013/04/dyatlov.jpg?resize=269%2C80&h=80&w=269&a=t&zc=1` > > TimThumb version : 2.8 The timthumb file is set to 'allow_external' but even so it doesn't work. Also, I don't know where that "i0.wp.com" in the URL came from, because the URL for my site is only ovnihoje.com.


Returning error upon comment being flagged as spam

Hello Im using a custom filter that hooks to `pre_comment_approved` to look for bad words in a custom way. Now when the comment gets flagged it returns `spam`. How could I post back an error to the comments page so the user is aware that his/her email was sent to spam because of the use of a blacklisted word? Thanks               function my_wp_blacklist_check( $approved , $commentdata ) {          $mod_keys = trim( get_option('blacklist_keys') );     if ( '' == $mod_keys )         return false; // If moderation keys are empty     $words = explode("\n", $mod_keys );          foreach ( (array) $words as $word ) {         $word = trim($word);         str_pad($word, 1, STR_PAD_BOTH);         // Skip empty lines         if ( empty($word) ) { continue; }              // Do some escaping magic so that '#' chars in the         // spam words don't break things:         $word = preg_quote($word, '#');              $pattern = "#\b$word\b#i";         if (preg_match($pattern, $commentdata['comment_content'])) {             return 'spam';         }     }     return true;     }     add_filter( 'pre_comment_approved' , 'my_wp_blacklist_check' , '99', 2 );


tax_query not working in template

I have a custom post type called 'product' with a registered taxonomy 'product-type'. I want to display all post from a particular taxonomy from custom post type. In my case I want to display all the posts from 'product' post type with a term of 'software'.                   <?php $args = array(              'post_type' => 'product',              'tax_query' => array(                 'taxonomy' => 'product-type',                 'terms' => array('software'),                 'field' => 'slug'             ),             'posts_per_page' => 9,              'orderby' => 'menu_order',              'order' => 'ASC'          );              $query = new WP_Query( $args ); ?>              <ul class="list-products clearfix">              <?php while ( $query->have_posts() ) : $query->the_post(); ?>      This is producing me no results. It's empty. But if I remove the entire `tax_query` from `$arg`               'tax_query' => array(         'taxonomy' => 'product-type',     'terms' => array('software'),     'field' => 'slug'     ),      Everything works fine. I get all the posts from 'product' custom post type.


Shortcode is displaying the wrong post_title

I have got a shortcode that displays a custom post type, via a `foreach`. The shortcode has been used in the standard post type. I have used `the_title();` in the shortcode. `the_title();` outputs the post_title of the standard post type (which the shortcode is in), rather than `the_title();` of the custom post type. My code:               function faq_register_shortcode()  {         add_shortcode( 'display_faqs', 'mp_faq_shortcode' );       }       function mp_faq_shortcode() {           $args = array( 'post_type' => 'faq_type_mp', 'numberposts' => 3, 'post_status' => 'any', 'post_parent' => null );          $attachments = get_posts( $args );         if ($attachments) {            foreach ( $attachments as $post ) {                       the_title();               the_content();           }         }      }      So for example, if the standard post type (which the shortcode is in), had a `post_title` of 'this is the standard post type', this is what is outputted in the shortcode. I want to display the `post_title` which belongs to the custom post type, NOT the standard post (which the shortcode is in). What have I done wrong please?