Special characters showing in fallback font

I have created a widget that displays some text using a custom font imported with CSS @font-face. The font **have support** for scandinavian characters åäö, but when I display these characters in my widget it looks like they fallback to another font. The text is all wrapped in the same element, no individual styling for the special characters. ![custom font problem](http://i.stack.imgur.com/ReVGz.png) This problem occurs when I get the text from the widget instance object. If I just echo text with these special characters then there's no issue. In the widget's _update()_ function I run strip_tags() with the text inputted by a user, then store it in the widget instance.               public function update( $new_instance, $old_instance ) {         $instance = array();         $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';         $instance['text'] = ( ! empty( $new_instance['text'] ) ) ? strip_tags( $new_instance['text'] ) : '';         return $instance;     }      In _widget()_ where the text is printed it's not manipulated in any way before being printed:               public function widget($args, $instance) {         echo $args['before_widget'];         $text = $instance['text'];         if (!empty( $title)) echo $args['before_title'] . $title . $args['after_title'];         if (!empty($text)) echo $text;         echo $args['after_widget'];     }      How to make text from the widget's field data display properly? **EDIT:** Seems like it's an encoding issue. Used asciivalue.com to lookup an ö character that I get from the widget field, and compare it to an ö character that I look up. The result for string "ö ö", with the first one( **not** working) being from the widget and the second one(working) input directly by me: ![ASCII lookup](http://i.stack.imgur.com/sUS50.png)


How do I programatically insert a new menu item?

I'm developing a plugin and I want to insert menu items programmatically. When my theme creates a menu, it uses this call:               wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu' ) );      Which resulted in something like this in the HTML:

menu-item-1

menu item 2

      I want to be able to intercept this somehow and insert my own HTML programmatically before the closing `</ul>`. How do I hook it up?


Optimal way to redirect home page to category archive?

## Question What'd be an optimal way to redirect the home page of a WordPress site to a category archive without involving external factors (e.g. Apache's .htaccess) i.e. within WordPress? ## Why? (Only to justify the question. Please let this not turn the question into _too localized_.) It's a news site. The categories are used as _Editions_ , for example:   * US: `http://example.com/main/`   * UK: `http://example.com/uk/`   * Japan: `http://example.com/jp/` (The category based is removed.) The visitor is to be taken to the US edition (`http://example.com/main/`) by default no matter where he/she is from, and that is why I want the redirect. ## Options Considered I know I can simply modify the main query and have the home page only include posts from the specific category (Edition). But the way the features of the site are constructed, I find the redirect to be more feasible and moreover appropriate. Aside from that, I want the URLs to make the current location clear to the visitor. As for why I can't use the simpler and better performant .htaccess-based redirection -- all the functionality needs to be either within the theme or as a separate plugin. Hence, looking for the best way to do it with WordPress/PHP. I've also considered adding this in `home.php` template file:               <?php         wp_redirect( 'http://example.com/main/' );     ?>      And decided against it as it "almost doubles server load for home page".


Change page according to fetched GET Parameters

I want to write plugin which has the ability to change the start page according to a get parameter: The following code is the full plugin.               function GET_Different_Page_on_front_parameter() {     if (!session_id()) {             session_start();         }          if(!($_SESSION['start'])){     $_SESSION['start']=$_GET['view'];         }         else{}               }          add_action( 'init', 'GET_Different_Page_on_front_parameter');               add_action( 'pre_get_posts', 'redirect_another_homepage');     function redirect_another_homepage(){     $front_page_slug=$_SESSION['start'];     $front_page_id=get_page_by_path($front_page_slug);     $content = $content.$front_page_id->ID;     if(is_home()){     $page=get_permalink($front_page_id->ID);     ?>     <script type="text/javascript">     <!--     window.location.href = "<?php echo $page;?>";     //–>     </script>     <?php     }else{}}      I thought it was working yesterday but maybe it just look like it was working. I also could put you as contributor in WordPress plugin repository.


Adding Relevant Post Images

I want to add relevant posts at the end of each of my posts page **with an image** in my newly created website http://www.techberita.com But being a beginner this is a great problem for me as I can't do that as I don't have that much knowledge of PHP and wordpress. I search out for plugins but couldn't find a good one for the purpose. I hope to get a reply soon. A php code for the purpose is highly preferable.


Is there a common structure for a wordpress formular?

I am working on a plugin for wordpress and was wondering if there is any common standard for the html and css structure and naming which I should use if I create a html form? so is there a definition how the DOM of a WP form shell look like, and if so: what is the proposed syntax? sorry for my english ;)


Overwrite functions.php of a theme - What if the theme is updated?

I have added a shortcode inside a functions.php file of my a Theme. I am wondering that if the theme changes, it might overwrite the current functions.php file. So, is this true? If so, where should I place my shortcode so that even if I update the theme it doesn't go away?


Function working in single.php but not working in custom template file

I defined in my functions.php the following code:               function fix_footnotes($content){                    return preg_replace('/href\s*=\s*"[^"]+(#[^"]+)"/','href="$1"', $content);           }      When I call this function in single.php, it is performing well. I use:               <?php echo fix_footnotes(get_the_content());?>      But when I call it inside of `wp_update_post` in custom template, it doesn't work. The template is responsible of updating posts from front end:               $post_information = array(             'ID' => $current_post,             'post_content' => fix_footnotes($_POST['contentEditorBox']),             'post_type' => 'aya-bi-aya',             'post_status' => 'publish'         );          $post_id = wp_update_post($post_information);      What can be the reasons behind such disfunctionning. Your assistance is highly invaluable.Thank you. **Edit** : **S_HA_DUM:** when I var_dump `$_POST['contentEditorBox']` it gives me the correct result. This is representing what `wp_editor` sends to server:               wp_editor($content, 'contentEditorBox', $settings2 );      **Edit 2:** Following is a sample of my content in `$_POST['contentEditorBox']` and `$content` respectively:
التحليل البلاغي للآيات رقم :49-51 من سورة المدثر.

التحليل البلاغي للآيات رقم :49-51 من سورة المدثر.
      As you can see, everything is wrapped by `\&quot`. What I don't undersrand, is that after sending the form the content appears as it should be. In other words, the adding of `\&quot` is temporary, it happens only inside `$_POST['contentEditorBox']` but not persisted in database. Any insights?


WP UI style within shortcode - Any Suggestions?

I am using the wp-ui Wordpress plugin to create vertical tabbed content. What I want to do is add a span to part of the tab title - to add some additional style, but the shortcode/plugin strips my "span" code               [wptabs mode="vertical" effect="fade"]      [wptabtitle] Silent auction - More title here.[/wptabtitle]     [wptabcontent] Content goes here [/wptabcontent]     [/wptabs]      Is there a simple way to keep the shortcode/plugin from stripping my added code. The plugin shortcode is easier for the client otherwise, I'd try something different. Help? Can anyone explain what I need to do with the code below to get the result above? I found this code:               add_shortcode( 'wptabtitle',    array(&$this, 'sc_wptabtitle'));      Then, I located this in the same file.               /**      *  [wptabtitle]      */     function sc_wptabtitle( $atts, $content = null ) {         extract(shortcode_atts(array(             'header'    =>  'h3',             'hclass'    =>  'wp-tab-title',             'label'     =>  'text',             'image_size'=>  '24,24',             '_id'       =>  false,             'load'      =>  '',             'post'      =>  '',             'page'      =>  '',             'cat'       =>  '',             'category_name' => '',             'tag'       =>  '',             'tag_name'      =>  '',             'number'    =>  '4',             'exclude'   =>  '',             'tag'       =>  '',             'feed'      =>  '',             'hide'      =>  "false",             'elength'   =>  $this->options['excerpt_length'],             'before_post'   =>  '',             'after_post'    =>  '',             'template'      =>  '1',             'icon'      =>  false         ), $atts));              global $wpui_id_remove_chars;              if ( str_ireplace( $wpui_id_remove_chars, '', $_id ) != $_id )             $_id = false;              $tmpl = ( isset( $this->options[ 'post_template_' . $template ] ) ) ?                     $this->options[ 'post_template_' . $template ] :                     $this->options[ 'post_template_1' ];               if ( isset( $this->options[ 'title_template' ] ) && $this->options[ 'title_template' ] != '' ) {              $title_template = $this->options[ 'title_template' ];             if ( $_id ) {                 $title_template = str_ireplace( '>{$title}', 'id="' . $_id . '">{$title}', $title_template );             }          } else {              $title_template = '<' . $header;              $title_template .= ' class="' . $hclass . '"';              if ( $_id ) {                  $title_template .= ' id="' . $_id . '"';              }              $title_template .= '>{$title}</' . $header . '>';           }              if ( $hide == "true" ) $hclass .= ' wpui-hidden-tab';              $data = false;              // Get the post contents.         if ( $post != '' ) {             $data = $this->wpuiPosts->wpui_get_post( $post, $elength );         } elseif ( $page != '' ) {             $data = $this->wpuiPosts->wpui_get_post( $page, $elength );         } elseif ( $feed != '' ) {             $data = $this->wpuiPosts->wpui_get_feeds( array(                             'url'       =>  $feed,                             'number'    =>  $number                         ));              } elseif ( $cat != '' || $category_name != '' || $tag != '' || $tag_name != '' ) {             $data = $this->wpuiPosts->wpui_get_posts( array(                                         'cat'       =>  $cat,                                         'category_name' => $category_name,                                         'tag'       =>  $tag,                                         'tag_name'  =>  $tag_name,                                         'number'    =>  $number,                                         'exclude'   =>  $exclude,                                         'length'    =>  $elength                                     ));         }              if ( $load != '' ) {             $content = '' . $content . '';         }                   $title_str = str_ireplace( '{$title}', $content, $title_template );                   if ( $icon && $icon != '' ) {             $title_str = str_replace( '{$thumbnail}', htmlspecialchars_decode( $icon ), $title_str );         }              if ( is_array( $data ) ) {             if ( isset( $data[ 'title' ] ) ) {                 $title_str = $this->wpuiPosts->replace_tags( $title_template, $data );                 $data = $before_post . $this->wpuiPosts->replace_tags( $tmpl, $data ) . $after_post;             } else {                 $scra = '';                 foreach( $data as $index=>$values ) {                     $scra .= $this->wpuiPosts->replace_tags( $tmpl, $values );                 }                 $data = $before_post . $scra . $after_post;             }         }                   $title_str = preg_replace( '/\{.*\}/', '', $title_str );              $output = $title_str;              if ( $data ) {             $output .= do_shortcode( "[wptabcontent]" . $data . "[/wptabcontent]" );         }              return $output;               } // END function sc_wptabtitle      Thanks, Louise


Displaying tweets problem with @username

I'm getting a problem displaying tweets that include reply's (ie when you @username someone). It's showing the @ symbol but then cutting off the rest of the tweet. (Check out www.teamworksdesign.com in the bottom right hand corner) Can anyone help with this or suggest a good plugin?               <?php          function parseTweet($text) {     $pattern_url = '~(?>[a-z+]{2,}://|www\.)(?:[a-z0-9]+(?:\.[a-z0-9]+)?@)?(?:(?:[a-z](?:[a-z0-9]|(?<!-)-)*[a-z0-9])(?:\.[a-z](?:[a-z0-9]|(?<!-)-)*[a-z0-9])+|(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))(?:/[^\\/:?*"|\n]*[a-z0-9])*/?(?:\?[a-z0-9_.%]+(?:=[a-z0-9_.%:/+-]*)?(?:&[a-z0-9_.%]+(?:=[a-z0-9_.%:/+-]*)?)*)?(?:#[a-z0-9_%.]+)?~i';     '@([A-Za-z0-9_]+)';     $tweet = preg_replace('/(^|\s)#(\w+)/', '\1#\2', $text);     $tweet = preg_replace('/(^|\s)@(\w+)/', '\1@\2', $tweet);     $tweet = preg_replace("#(^|[\n ])(([\w]+?://[\w\#$%&~.\-;:=,?@\[\]+]*)(/[\w\#$%&~/.\-;:=,?@\[\]+]*)?)#is", "\\1[link]", $tweet);     return $tweet;     }          $username='teamworksdesign'; // set user name     $format='json'; // set format     $tweet=json_decode(file_get_contents("http://api.twitter.com/1/statuses/user_timeline/{$username}.{$format}")); // get tweets and decode them into a variable          $theTweet = parseTweet($tweet[0]->text);     $newTweet = substr($theTweet,0,65);     echo ' "' . $newTweet . '..."';          ?>


No access to global variables?

In `main.js`, I have a script, which is sending an ajax request to `script.php`.               $.ajax({         type: "POST",         url:  "wp-content/themes/roots/script.php",         data: registerdata,         success: function(result)         {             alert(result);         }     });     return false;      `script.php` validate some data and write the data into the database. For this, I use the `$wpdb` object by WordPress `($wpdb->insert())`. Normally, WordPress provides a global variable, `$wpdb`, which is an instantiation of the class already set up to talk to the WordPress database. But not in my case. I get the following error > Fatal error: Call to a member function insert() on a non-object If I do               if(class_exists('wpdb') == false){         echo 'class wpdb doesnt exist';     }     else{         echo 'class wpdb exists';     }      in `script.php`, it told me all the time 'class wpdb doesnt exist'. If I do the same in `function.php`, class wpdb exists. But why? `Script.php` and `function.php` are in the same directory. And `$wpdb` is auto loaded and set up to global by WordPress. So I have access all the time, doesn't matter in which directory I am, right?!               realpath(ABSPATH . WPINC . '/wp-db.php')      .... also doesnt work. Constants are undefined in `script.php`, too. Where is my fault? `register_globals = on` in `php.ini`. changed nothing. :/


How to escape shortcode content? Do I even need to escape or validate?

I've written a small shortcode that wraps it's content into a HTML element, like so:               [my_shortcode]The sun is shining today.[/my_shortcode]      In my shortcode function, I basically return the string like this:               $string = '<span>' . do_shortcode( $content ) . '</span>';      return $string;      You see, I don't escape or validate `$content` in any way, but in the Shortcode API Codex it says > It is the responsibility of the handler function to provide any necessary > escaping or encoding of the raw content string, and include it in the > output. Thats why I _think_ I still need to do something to `$content`, either using a Wordpress function or a plain PHP one.   The problem is: I just have tested everything to see what happens when I write HTML inside the shortcode. I have noticed that certain characters seem to be transformed into their entity, meaning HTML or script tags won't be executed (this is completely ok for me). Do I still need to validate or escape `$content`?


How do I keep the page I'm on within the URL when running a search on a taxonomy?

I'm trying out a couple of plugins to aid in searching of taxonomy terms. One is called "Query Multiple Taxonomies" and the other is called "Drop-down- custom-taxonomy". What I'm wanting to keep the page I'm searching from when I begin the search. For example if the page I'm on is dogs (www.site.com/dogs) and I run a search on this page for a taxonomy called "breed", and find all dogs that are a "beagle", the url is changed to this: www.site.com/?breed=beagle How can I get the url to stay with /dogs in it? www.site.com/dogs/?breed=beagle Based on my limited knowledge, I'd say this is a job for url rewriting? I did try adding some code for a base url for Query Multiple Taxonomies but this did not work with my permalink structure of /%year%/%postname%/


Image Layout in Posts

I was working on the company blog today and just had a question. Currently, the staff posts a blurb and then inserts images of the new products which makes the post really long. I was wondering if anyone knew of a plugin or knew of a way to get said images to be like 3 x 3.


Installed WordPress with Softaculous. Should I upgradeManually or with Softaculous?

I've setup my first blog with WordPress and I love the framework. I've created sites from scratch on a LAMP stack so I've even been able to tweak my theme and write a plugin or two. So, here's my question: I installed WordPress with Softaculous because it was easy and it worked the first time. Now, I've been upgrading WordPress and all of my themes and plugins manually from the admin panel on the blog. I thought this was a good way to go but I just logged into Softaculous to create a new blog and I noticed that it was telling me to upgrade the first blog that I created. Can I ignore the upgrade message in Softaculous and continue to upgrade the blog manually? Should I just use Softaculous to make it easy to upgrade multiple installs? Can I mix the two? Thanks for your hints, tips and tricks.


Content management for static pages

A corporate website has a few static pages, each with a specific layout, several independent blocks of text (located in different columns or zones of the page) and images. So far I handled this by designing a unique page template for each unique such page. But what if a client wants the ability to content manage these (a request which from his point of view sounds natural enough)? Is there an easy way to achieve that?


Insert blog template on home template

i need to include "blog_page_2_column.php" into homepage. I insert this into homepage template:               <?php include(TEMPLATEPATH . '/blog_page_2_column.php');?>      Works fine but i cant change the page of blog... This is the web: http://ucrburna2013.com.ar/ Any idea?


Create wp_cront events dynamically upon user submission

Is it possible to set up new wp_cron jobs dynamically upon a certain action? I have a form submission (I'm using Gravity Forms, so have several functions set up on several of their hooks already) process which creates a post of a specific post type when a user completes and submits the form. What I'd like to do is set up a cron job when this submission happens. Each form submission will set up a new cron event (don't worry they'll get cleared after a certain amount of time, normally within 48 hours). My understanding is that when you use `wp_schedule_event()` you're basically creating a new action hook, which you then hook into with a custom function. So in essence I need to dynamically create a new hook (which needs to be unique for each) and then a custom function for each (again, unique). i.e. something like               function lmk_alter_method_name( $entry, $form )     {              //.... some code (which sets up a $post object) ...              wp_update_post( $post );              //Call some dynamic wp_cron -related thing here         lmk_set_up_cron( $post->ID );          }          add_action( 'gform_after_submission', 'lmk_alter_method_name', 10, 2 );                    function lmk_set_up_cron( $post_id )     {              if( !wp_next_scheduled( 'lmk_cron_' . $post_id ) )             wp_schedule_event( time() + 3600, 'hourly', 'lmk_cron_' . $post_id, $post_id );          }      The idea there is that it'll create a hook called lmk_cron_123 but that then how do I go about actually hooking into that, dynamically. I'm convinced there's an easier way, but I can't quite see it at the moment. Any suggestions?


How do you create a custom edit.php / edit pages page

I need to create 3 custom `edit.php` pages which only display pages with a certain parent and the Post New button links to a new page with the corresponding parent. The closest answer I can is do not edit core files and just remove meta boxes etc. How can I customize "Pages" admin (edit.php) and "Edit Page" admin (post.php) for bulk edit of custom content type? But I cannot do this. Any suggestions how I can duplicate the `edit.php` page? So far I duplicated the code into my template but it displays no pages: ![custom edit page](http://i.stack.imgur.com/2wn0g.png)


Add button in TinyMCE editor to insert text

I'm searching a way to add a custom button to the TinyMCE editor when clicked insert into the visual editor some text. For example: button called "Hi" when clicked insert into the editor `"Hello I'm <B>Mark</b>!"` Is it possible? And how?


Delete duplicate posts where meta_key is the same

I have imported some posts and this has caused some to be duplicated Each post (of a custom post type "property") should have a unique meta_key "import__id" value I need to delete all duplicate posts which have the same "import__id" as others keeping either the one with the lowest post_id OR (ideally) the most number of items in an array or another meta_key "images" I would very much like some help on the SQL query to run this as from what I have seen online so far all duplicate post SQL queries use wither post_title or post_content WHICH IS NOT WHAT I NEED as some posts may have the same title and post content but have different "import__id"s and so need to be kept **Edit** I can get the duplicates from the post_meta by ths SQL query               SELECT post_id, meta_key, meta_value              FROM wp_postmeta AS one             WHERE meta_key='import__id'             GROUP BY meta_value              HAVING COUNT( * ) > 1      this lists all duplicates including the original. I need to join that with the same table with MIN( post_id) AS min_id and then make a comparison to make sure that first_table.post_id <> second_table.min_id to get just duplicates (so that I can delete them from wp_posts by id) :)


What's the proper way to add a favicon in Wordpress without a plugin?

What's the proper way to add a favicon in Wordpress **without a plugin**? Do I just place a file called favicon.ico with my icon grafik into the root of my site? Do I also need this code or is that necessary?               <link rel="shortcut icon" href="http://example.com/favicon.ico" type="image/x-icon" />      Some say it's this code:               <link rel="icon" type="image/png" href="http://yourblog.com/favicon.png" />      And this is for iPhones? Any suggestions on software to create it or to convert it from a thumbnail? And what types of files are supported - just .ico? I saw another thread (below) with so many methods and I was unclear what is the best practice for this simple task. How to change the WordPress favicon?


How do I Split one Table into to lists for two seperate drop down boxes

I am driving myself crazy trying to find an answer, although I know it would most likely be something simple.\ I have a mysql table with the following columns: id first_name family_name date_of_birth family_id post_id father_id mother_id sex I am trying to create two dropdown lists from this table. One for the Males and one for the females. This is were I get stuck. The code I have is:               $sql="SELECT * FROM $table_name ORDER BY first_name";          $result=mysql_query($sql);               $options="";               while ($row=mysql_fetch_array($result)) {               $id=$row["id"];          $first_name=$row["first_name"];          $family_name=$row["family_name"];          $date_of_birth=$row["date_of_birth"];         $options.="<OPTION VALUE='". $row['id']. "'>".$id."   ---  ".$first_name ." ".$family_name."   ---  ".$date_of_birth;          }          ?>
         <form action="<?php echo plugins_url( 'add_a_family_member_data.php', __FILE__ );?>" method="post">
Select the person whose family member you are adding. *
         <select name="id">         <option><?=$options?> </option>         </select>
Select the type of relationship;*
                   <input type="radio" name="family_type" value="Father"  > Father         <input type="radio" name="family_type" value="Mother" > Mother         <input type="radio" name="family_type" value="Sibling" > Sibling

              First and Middle Names              <input name="first_name" type="text" id="first_name" style="float: right;" " maxlength="30" />

 Family Name               <input name="family_name" type="text" id="family_name" style="float: right;" maxlength="50" />

                     Male / Female *                          <select name="sex" style="float: right;" maxlength="50">                     <option></option>                     <option value="Male"> Male </option>                     <option value="Female"> Female </option>                          </select>

         Date of Birth                   <input type="text" name="date_of_birth" id="date_of_birth"  style="float: right;"  maxlength="10"/>

         Date Of Death              <input type="text" name="date_of_death" id="date_of_death"  style="float: right;" " maxlength="10"" />

         <input type="submit" name="submit" id="submit" value="Submit" />
          </form>      This form works successfully except both drop down boxes contain the full list of people whether they are male or female. Thanks in Advance Warwick Any Assistance would be appreciated.


Query sub subpages based on specific date?

I have an Events section as follows: >   1. ⤍ Page 1) >   2. ∟ Subpages 2) >   3. ∟ Sub subpages > 1) Own template, w/o sidebars, but `query_posts()` and `get_title/excerpt()` from N°2 2) Other subpages are listed in a sidebar left menu - and `query_posts()` N°3 How can I list N°3 titles/excerpt on N°3 subpages, if they are before and after a date? Where, or how, can I set the Date? Basically, I need a   * "coming events" section    * and a "past events" section  ...on every subpage (N°2) with links to N°3 sub subpages of the relevant sub page. I would then create a sub subpage, give it a date and - on my subpage - (if the date of the sub subpage is in the past) I will list in "past events". If the date is still later than the current date, I will list it in "coming events".


What tags should be used for themes to show the type of layout?

In the Tag Filter the old tags 'fixed-width' and 'flexible-width' were renamed to 'fixed-layout' and 'fluid-layout'. Also new 'responsive-layout' tag appears. **Should users duplicate new tag 'fluid-layout' with old tag 'flexible- width'?** Or is it safe to use only new tags?


Saving attachment custom fields

I want to establish a relationship between individual post attachments and Users.   So far I've got my users listing just fine, but it isn't saving/updating.               add_filter("attachment_fields_to_edit", "my_image_attachment_fields_to_edit", null, 2);          function my_image_attachment_fields_to_edit($form_fields, $post) {              $form_fields["belongs_to"]["label"] = 'Belongs to';           $form_fields["belongs_to"]["input"] = "html";           $form_fields["belongs_to"]["html"] = '';              $wp_user_query = new WP_User_Query( array( 'orderby' => 'display_name' ) );         $authors = $wp_user_query->get_results();     if (!empty($authors)) {          foreach ($authors as $author) {             $author_info = get_userdata($author->ID);                                    $form_fields["belongs_to"]["html"] .= "
                 <input type='checkbox' value='$author_info->ID' name='attachments[{$post->ID}][belongs_to][]' id='belongs_to_user-$author_info->ID' />                 ID'>$author_info->first_name $author_info->last_name
";         }     }          return $form_fields;     }               add_filter("attachment_fields_to_save", "my_image_attachment_fields_to_save", null, 2);     function my_image_attachment_fields_to_save($post, $attachment) {     if( isset($attachment['my_field']) ){         // update_post_meta(postID, meta_key, meta_value);         update_post_meta($post['ID'], 'belongs_to', $attachment['belongs_to']);     }     return $post;     }      I was trying to populate an array with user-IDs, but perhaps that's not the best way to handle it. Any ideas? Thanks in advance!


Using foreach inside an ajax function

This is my first attempt to create an ajax function. My script takes the selected value of a dropdown list                     $('#state').change(function () {                var state = $('#state option:selected').val();                 $.ajax({                     type: 'POST',                     url: 'http://localhost/website/wp-admin/admin-ajax.php',                     dataType: 'json',                     data: {                         'action' : 'myFunction',                         'state' : state                     },                     success: function( data ){                         console.log(data);                     },                     error: function (data) {                         console.log('error' + data);                     }                 });             });      The value is received by a PHP function that uses it to pick the cities of selected state                  function myFunction(){             $term_id = $_POST['state'];             $taxonomy_name = 'state';             $cities = get_term_children( $term_id, $taxonomy_name );                  foreach ( $cities as $city ) {                $term = get_term_by( 'id', $city, $taxonomy_name );                $list =  '<option value="'.$term->term_id.'">'.$term->name.'</option>';             }                  echo $list;             die();            }       add_action('wp_ajax_myFunction', 'myFunction');       add_action('wp_ajax_nopriv_myFunction', 'myFunction');      But how to send all values generated by foreach in a variable?


Support Multiple featured images

I've created a WordPress theme where in one of my pages I need to use two feature images, I know already how to add support for the featured image and I'm using it. My need is how to add a second featured image support for my theme WITHOUT using any plugin? Thanks for any hint, support :)


Multiple, nested tax_query relation

I have been stuck on a particular problem for a while now and have yet to find a way around it. I have custom widgets and for each widget I have added the ability to filter posts based on category AND/OR tags (this functionality works). I am now trying to expand on that by including in each widget a custom field where you can enter the ID of a category you wish to exclude (the custom field is already in the widget and stores user input). Let me show you what I have so far to help understand:                       $args = array(                 'post_type'         => 'post',                 'post_status'       => 'publish',                 'posts_per_page'    => $num_posts,                 'cat'               => -5,                 'tax_query'         => array(                     'relation'      => 'OR',                     array(                         'taxonomy'  => 'category',                         'field'     => 'id',                         'terms'     => $category,                     ),                     array(                         'taxonomy'  => 'post_tag',                         'field'     => 'id',                         'terms'     => $tags                     ),                 ),                 'offset'            => 1,             );      As you can see I am taking in two arrays of input for both $category and $tags (this is working fine), but what does not seem to be working is:               'cat'               => -5,      If I remove the tax_query array completely, the exclude category works perfectly fine, so it appears that tax_query is overriding the exclude? If someone could point me in the right direct, that would be great :) Thanks!


Wordpress Scripts Being Loaded in Footer

I've bought a theme for a Wordpress site. I noticed that the theme author has added the javascript to the footer for load time, but as I use Gravity forms, I understand that some of scripts need to be in the head. I don't know anything about enqueue or which scripts to put into the head, all I know is the majority of the scripts are currently in the footer. As far as I'm aware all the scripts are being registered/enqueued from the functions.php file and this is causing me a real headache. What information do I need to provide to have a little help?


How to have permalink like domain.com/term/postname?

I'm trying without success to have a URL structure like **domain.com/term/postname** , but I just get 404 for all non-CPT pages.               function add_video_post_type() {              $labels = array(             'name'                => _x( 'Videos', 'Post Type General Name', 'kibble' ),             'singular_name'       => _x( 'Video', 'Post Type Singular Name', 'kibble' ),             'menu_name'           => __( 'Videos', 'kibble' ),             'parent_item_colon'   => __( 'Parent Item:', 'kibble' ),             'all_items'           => __( 'All Items', 'kibble' ),             'view_item'           => __( 'View Item', 'kibble' ),             'add_new_item'        => __( 'Add New Item', 'kibble' ),             'add_new'             => __( 'Add New', 'kibble' ),             'edit_item'           => __( 'Edit Item', 'kibble' ),             'update_item'         => __( 'Update Item', 'kibble' ),             'search_items'        => __( 'Search Item', 'kibble' ),             'not_found'           => __( 'Not found', 'kibble' ),             'not_found_in_trash'  => __( 'Not found in Trash', 'kibble' ),         );         $rewrite = array(             'slug'                => '%video_genre%',             'with_front'          => true,             'pages'               => true,             'feeds'               => true,         );         $args = array(             'label'               => __( 'video_type', 'kibble' ),             'description'         => __( 'Video Posts', 'kibble' ),             'labels'              => $labels,             'supports'            => array( 'title', 'editor', 'thumbnail', ),             'taxonomies'          => array( 'video_genre' ),             'hierarchical'        => false,             'public'              => true,             'show_ui'             => true,             'show_in_menu'        => true,             'show_in_nav_menus'   => true,             'show_in_admin_bar'   => true,             'menu_position'       => 5,             'menu_icon'           => 'dashicons-format-video',             'can_export'          => true,             'has_archive'         => true,             'exclude_from_search' => false,             'publicly_queryable'  => true,             'rewrite'             => $rewrite,             'capability_type'     => 'page',         );         register_post_type( 'video_type', $args );          }          add_action( 'init', 'add_video_post_type', 0 );          function custom_video_genre() {              $labels = array(             'name'                       => _x( 'Video Categories', 'Taxonomy General Name', 'kibble' ),             'singular_name'              => _x( 'Video Category', 'Taxonomy Singular Name', 'kibble' ),             'menu_name'                  => __( 'Categories', 'kibble' ),             'all_items'                  => __( 'All Items', 'kibble' ),             'parent_item'                => __( 'Parent Item', 'kibble' ),             'parent_item_colon'          => __( 'Parent Item:', 'kibble' ),             'new_item_name'              => __( 'New Item Name', 'kibble' ),             'add_new_item'               => __( 'Add New Item', 'kibble' ),             'edit_item'                  => __( 'Edit Item', 'kibble' ),             'update_item'                => __( 'Update Item', 'kibble' ),             'separate_items_with_commas' => __( 'Separate items with commas', 'kibble' ),             'search_items'               => __( 'Search Items', 'kibble' ),             'add_or_remove_items'        => __( 'Add or remove items', 'kibble' ),             'choose_from_most_used'      => __( 'Choose from the most used items', 'kibble' ),             'not_found'                  => __( 'Not Found', 'kibble' ),         );         $args = array(             'labels'                     => $labels,             'hierarchical'               => true,             'public'                     => true,             'show_ui'                    => true,             'show_admin_column'          => true,             'show_in_nav_menus'          => true,             'show_tagcloud'              => true,         );         register_taxonomy( 'video_genre', 'video_type', $args );              }              add_action( 'init', 'custom_video_genre', 0 );              add_filter('post_type_link', 'filter_post_type_link', 10, 2);              function filter_post_type_link( $link, $post ) {              if ( strpos( $link, '%video_genre%' ) === false )             return $link;              $terms = wp_get_object_terms( $post->ID, 'video_genre' );              if ( current( $terms ) ) :                  $new_parent = current( $terms );                  foreach ( $terms as $term ) {                 if ( $term->parent == 0 ) {                     $new_parent = $term;                     break;                 }             }                  $new_parent = $new_parent ? $new_parent : $terms[0];                  $category_string = $new_parent->slug;                  $category_string = trim( $category_string, '/' );              endif;              // set a default         $category_string = ( isset( $category_string ) && $category_string ) ? $category_string : 'uncategorized';              $link = str_replace( '%video_genre%', $category_string, $link );         return $link;     }


foreach $FILES create post how to

I know this is probably super easy and I am overlooking something here. I have a form on the front-end of our website where users can upload an image via a form and it creates a product in our shop. Currently everything works fine when uploading one image, How would I make this work for when a user uploads multiple images? In the form I changed `<input type="file" name="thumbnail" id="thumbnail" />` to `<input type="file" name="thumbnail" id="thumbnail" multiple />`and I thought wrapping the below in something like this would work:               if ($_FILES) {       foreach ($_FILES as $file => $array) {         // do necessary code       }     }      But it doesn't. Here is what I have that creates the post. Im not sure why wrapping it in the foreach $FILES won't work?               $current_user = wp_get_current_user();          if(isset($_POST['submitted']) && isset($_POST['post_nonce_field']) && wp_verify_nonce($_POST['post_nonce_field'], 'post_nonce')) {                       $postTitle = trim($_POST['postTitle']);                   if($post_id)         {             wp_redirect(home_url());             exit;         }              //random sku     $skuu = rand();          $new_post = array(     'post_title' => $skuu,     'post_content' => '', //add anything here like link to vendor or whatever     'post_status' => 'publish',     'post_type' => 'product'     );               //insert and update post     $post_id = wp_insert_post($new_post);     update_post_meta($post_id, '_sku', $skuu );          if ($_FILES) {       foreach ($_FILES as $file => $array) {         $newupload = insert_attachment($file,$post_id);       }     }          //find available attributes     $avail_attributes = Array(         'high-resolution',         'medium-resolution',         'low-resolution'     );          //set terms (variations and attributes)     wp_set_object_terms ($post_id, 'variable', 'product_type');     wp_set_object_terms( $post_id, $avail_attributes, 'pa_resolution' );               //Categories     wp_set_object_terms( $post_id, array(esc_attr(strip_tags($_POST['postCat'])), esc_attr(strip_tags($_POST['raceCat']))), 'product_cat' );          // set variable data     $thedata = Array('pa_resolution'=>Array(     'name'=>'pa_resolution',     'value'=>'',     'is_visible' => '1',     'is_variation' => '1',     'is_taxonomy' => '1'     ));          update_post_meta( $post_id,'_product_attributes',$thedata);     update_post_meta( $post_id, '_visibility', 'visible' );     update_post_meta( $post_id, '_stock_status', 'instock');     //update_post_meta( $post_id, '_product_vendors_commission', '25');          //insert variations post_type     $i=1;     while ($i<=3) {     $my_post = array(           'post_title'    => 'Variation #' . $i . ' of ' . esc_attr(strip_tags($_POST['postTitle'])),           'post_name'     => 'product-' . $post_id . '-variation-' . $i,           'post_status'   => 'publish',           'post_parent'   => $post_id,           'post_type'     => 'product_variation',           'guid'          =>  home_url() . '/?product_variation=product-' . $post_id . '-variation-' . $i,           'post_author'   => $vendor_data->term_id         );              // Insert the post into the database         wp_insert_post( $my_post );              $variable_id = $post_id + 2;         $variable_two = $variable_id + 1;         $variable_three = $variable_two + 1;              //get user prices         global $current_user;         $low_price = get_user_meta($current_user->ID, '_low_price', true);         $medium_price = get_user_meta($current_user->ID, '_medium_price', true);         $high_price = get_user_meta($current_user->ID, '_high_price', true);              //downloadable file paths         $download_id = get_post_thumbnail_id( $post_id );         $lowRes_src  = wp_get_attachment_image_src( $download_id, 'low-resolution' );         $medRes_src  = wp_get_attachment_image_src( $download_id, 'medium-resolution' );         $highRes_src  = wp_get_attachment_image_src( $download_id, 'high-resolution' );              $low_downloadable_images = array();         $medium_downloadable_images = array();         $high_downloadable_images = array();              foreach ($lowRes_src as $lowRes_url) {             $lowRes_url = $lowRes_src[0];             $low_downloadable_images[md5( $lowRes_url )] = $lowRes_url;         }              foreach ($medRes_src as $medRes_url) {             $medRes_url = $medRes_src[0];             $medium_downloadable_images[md5( $medRes_url )] = $medRes_url;         }              foreach ($highRes_src as $highRes_url) {             $highRes_url = $highRes_src[0];             $high_downloadable_images[md5( $highRes_url )] = $highRes_url;         }              //echo $rand;              update_post_meta( $variable_id, 'attribute_pa_resolution', 'high-resolution');         update_post_meta( $variable_id, '_price', $high_price );         update_post_meta( $variable_id, '_regular_price', $high_price);         update_post_meta( $variable_id, '_virtual', 'yes');         update_post_meta( $variable_id, '_downloadable', 'yes');         update_post_meta( $variable_id, '_file_paths', $high_downloadable_images);              update_post_meta( $variable_two, 'attribute_pa_resolution', 'medium-resolution');         update_post_meta( $variable_two, '_price', $medium_price );         update_post_meta( $variable_two, '_regular_price', $medium_price);         update_post_meta( $variable_two, '_virtual', 'yes');         update_post_meta( $variable_two, '_downloadable', 'yes');         update_post_meta( $variable_two, '_file_paths', $medium_downloadable_images);              update_post_meta( $variable_three, 'attribute_pa_resolution', 'low-resolution');         update_post_meta( $variable_three, '_price', $low_price );         update_post_meta( $variable_three, '_regular_price', $low_price);         update_post_meta( $variable_three, '_virtual', 'yes');         update_post_meta( $variable_three, '_downloadable', 'yes');         update_post_meta( $variable_three, '_file_paths', $low_downloadable_images);              $i++;         }               }          //attach vendor to product     $vendor = get_user_vendor();     if( isset( $vendor->slug ) && strlen( $vendor->slug ) > 0 ) {         wp_set_object_terms( $post_id, $vendor->slug, 'shop_vendor', false );     }      In short I just need a way for the above code to create the post for each file uploaded, instead of just one file uploaded like it currently does.. Im all out of ideas


How do you remove the ability for a user to make a comment or post on a page?

I am building a new website on Wordpress, and all my pages have the add comment box at the bottom. I wish fo rthis to be removed from pages such as Home, Contact Us, About etc etc, but want it to remain on the blogs and galleries. I have read this question but do not really understand what this means to do. is there an easier way to do it. I do not have this option under Settings -> Discussions.


How to add archives (with pagination) to page template?

So the site I'm building has a few different archives pages. For the newest one I'm building, I tried to copy the `archive.php` I've got: **page-archives.php** :               <?php get_header(); ?>

Archives
              <?php get_template_part('inc/loops/default','default-loop'); ?>              <?php custom_pagination(); ?>
          <?php get_sidebar(); ?>          <?php get_footer(); ?>      **inc/loops/default.php** :               <?php          global $query_string;     $results = new WP_Query($query_string);          if ($results->have_posts()) :         while ($results->have_posts()) :             $results->the_post();                         // DO STUFF HERE.                  endwhile;         endif;          ?>      And the `custom_pagination` function in **functions.php** :               function custom_pagination() {         global $wp_query;         $big = 999999999;         echo paginate_links(array(             'base' => str_replace($big, '%#%', get_pagenum_link($big)),             'format' => '?paged=%#%',             'current' => max(1, get_query_var('paged')),             'total' => $wp_query->max_num_pages,             'type' => 'list'         ));      }      Whenever I do `global $query_string` or `global $wp_query`, it thinks the query is for the Archives page (which it is) and I'm not sure how to break out of that. I can work around that by putting the loop directly in the `page-archives.php` without `$query_string` and call `paginate_links()` instead of calling it's wrapper, _but I'd rather not do that_. Also, I have an `archive.php` which is basically this, but I can't figure out how to get it to work for all posts. I need to answer this question anyways for a few other custom archives.


WordPress Multisite: Automatically run importer upon creating new site

Is it possible to automatically run the WP Importer when creating a new site in WordPress Multisite? I think this would need to be a function that runs when **wpmu_new_blog** is called but can't find anything that's helped.


Custom rewrites for pages and categories

I am trying to understand how can create custom rewrites for pages/categories. Ex i have `example.com/?page_id=178` and for this page have a contact form and i want this: `%slug%.php`               example.com/contact.php      In the permalinks i have two choices. 1) Is the **Post name** and the 2) is the **Custom Structure** : %postname%/ . With both cases i didn't have the result that i want. It is possible to do that?


Multiple URLs with Numbers

I am trying to correct a problem on a Wordpress site which is producing duplicate pages in the format of: /about-us/connecticut/3/3 /about-us/connecticut/3/3 /about-us/connecticut/3/ /about-us/connecticut/3 /about-us/connecticut/ I cannot determine what is causing this to happen. Can anyone suggest ways to stop this from happening? Thanks, Josh


Cannot get post thumbnails to display

I'm stumped. I've pored over all the articles here and beyond to no avail. I'm trying to simply display the post thumbnail in a template page, but it will not show up. I have thumbnails enabled for the theme in functions.php: `add_theme_support ('post-thumbnails');` I removed the sizing function `set_post_thumbnail_size( 150, 150 );` from functions.php and added `array(150,150)` as an argument to `get_the_post_thumbnail` I've set the Featured Image in a couple posts to test it out. I tried echoing out `get_the_post_thumbnail` and using `the_post_thumbnail` template tag. I tried both `get_posts` (along with `setup_postdata($post);`) and `new WP_query` methods. No such luck. I don't think it matters, but I'm using a child of the Twenty Eleven theme. I have a template page set up and I'm calling a function I created in functions.php to list the posts. I'd like to use get_posts and echo it out like this: `get_the_post_thumbnail( $post->ID, array(150,150) )`. I've also tried inserting the function straight into the template page. I've made every tweak I could think of. I don't see anything I'm overlooking, seems pretty straight forward. Any ideas? Any help would be greatly appreciated. Here's the code I had initially before trying all the tweaks mentioned above. **In the functions.php file:**               if ( function_exists( 'add_theme_support' ) ) {      add_theme_support( 'post-thumbnails' );      }          set_post_thumbnail_size( 150, 150 );      **And in my page template file:**               function list_posts_by_cat_auth_year ($cat_text, $cat_id, $author, $year) {          echo '
'.$cat_text.'

';     global $post;          $args = array( 'posts_per_page' => -1, 'numberposts' => 0, 'category' => $cat_id, 'author' => $author, 'order' => 'desc' );          $myposts = get_posts( $args );         foreach( $myposts as $post ) {             $author = get_userdata($post->post_author);             echo '

'             .get_the_post_thumbnail( $post->ID, array(150,150) ).'
             '.get_the_title().'
             Posted on '.get_the_time('D, M jS, Y').' by '.$author->first_name.             '
'.             get_the_tag_list('Tagged:  ',' , ','').'
             ';                  echo '

';         };     echo '
     ';     }


Installing One Plugin on a Few Blogs on a MultiSite

I would like to install a plugin on 3 out of the 20 blogs I have going on my MutliSite WP 3.0. Is this possible?


How to position custom dashboard widgets on side column

**My Question:**   Is it possible to add custom dashboard widgets in the right hand column instead of only on the left hands side? I use `wp_add_dashboard_plugin( $widget_id, $widget_name, $callback, $control_callback = null )` to add the plugin code, but it doesn't have any options to allow you to set the position. Any suggestions? **My Comments:**   The Version 2.8 of WordPress suggests that it's possible, but I can't see anything in the code (/wp-admin/includes/dashboard.php) that is related to this. It seems only to add the dashboard plugin if its name is in the `$side_widgets` array, the contents of which are: `array('dashboard_quick_press', 'dashboard_recent_drafts', 'dashboard_primary', 'dashboard_secondary');` My thoughts are that I'd have to directly modify `$wp_meta_boxes['dashboard']` \- but I'm not sure of the consequences of this.


List custom taxonomies associated to an author's posts

On the author template, I would like to display a list of the custom taxonomies associated to the posts written by that author. In details: I have a "clubs" taxonomy, which is non-hierarchical and applies to Posts. On the author template, I need to display a list of the "clubs" used by that author's Posts, as links. In this manner, i can list the clubs to which this author participates in. Is that possible?


Safe way to find last inserted id in a table?

Is it safe to use `$wpdb->insert_id;` to find the `id` of a last updated `row id` just after an update? ex:                $sql = $wpdb->insert($table_name, $arrayWithDataToInsert, array('%s','%s'));                 $results['new_created_id'] = $wpdb->insert_id;      or am I running into the possibility that I will catch the id of another row that was inserted immediatly after mine? Thanks!


How to make multicheck for post/page meta box

Please help me understand how to make Multicheck type for metabox. Search for all internet and nothing. Thanks. * * * ##  UPDATE @Jan I have a headache from this function. I dont know whats wrong.I'm trying your method but nothing, then I'm trying get_posts but with this method I have too many troubles. With your method I get this error before content:               Warning: urldecode() expects parameter 1 to be string, array given in Z:\home\mysite.net\www\wp-includes\query.php on line 1878      Here is my code:               <?php             $catids = get_post_meta($post->ID,'_mtb_multicheck',false);             $limit = 10;             query_posts( array('posts_per_page' => $limit, 'cat' => $catids, 'paged' => get_query_var('paged') ) );         ?>     <?php if (have_posts()) : ?>     <?php while (have_posts()) : the_post(); ?>                  <!-- Content-->          <?php endwhile; ?>                   <?php pagination(); ?>     <?php else : ?>                 <!--Error message here-->          <?php endif; ?>      I want to know what my vatiables return. Make this:               query_posts( array('posts_per_page' => $limit, 'cat' => print_r($catids), 'paged' => get_query_var('paged') ) );      and get this on my page:               Array ( [0] => 5 [1] => 5 [2] => 3 )      I think it's my query_posts printed, not $catids. It's a big, big trouble. I feel myself like a nerd. Please help me.


Why is my subdomain returning a 403 status?

I have a Wordpress installation at www.mysite.com. Wordpress is installed in `/public_html/` I created a sub domain test.mysite.com. cPanel asks for the directory in my file system. I pointed it to `/public_html/wp-content/themes/mytheme/test/`. When I do this, I get a 403 error. When I point it to `/public_html/`, it works - displays main page of my website. How do I get test.mysite.com to show what I have in `/public_html/wp- content/themes/mytheme/test/`


W3 Total cache not minify after modifying minify settings

I use W3 total cache manual minify. Because it works perfectly on my blog. However, today after I added another 3 JS and two CSS files to W3TC minify URL, this plugin stopped minify my HTML, JS and CSS. Then I wiped cache (empty all cache), nothing happened, Then I manually deleted /wp-content/cache/ folder, but nothing happens. I disabled and enabled HTML, JS and CSS minify. No luck. (I can only fix it delete plugin and delete remain w3tc files in wp-content folder. But it's not a good solution) Still Google page speed insight display I have to minify my HTML, JS and CSS. Earlier it doesn't show that message. So how do I fix this issue? Anybody has an idea?


WP-CLI works on non WP-CLI installed Wordpress instance?

I came across WP-CLI via the tutorial at http://centminmod.com/nginx_configure_wordpress_ffpc_plugin.html and was wondering does WP-CLI work on Wordpress instances which were NOT initially installed with WP-CLI but installed via normal FTP upload Wordpress installs ? So can I manage plugins, core updates via WP-CLI on non WP-CLI installed Wordpress installs ?


Adding 2 CPT with multiple custom taxonomies to permalinks

I have two custom post types with hierarchical custom taxonomies that I'd like to add to my permalink structure. I'd like to achieve this:               http://example.com/cpt1//%region%//%country%/%state%/%city%/%postname%/      and this:               http://example.com/cpt2//%region%//%country%/%city%/%postname%/      The `'state'` part of the permalink for CPT1, ideally, should only print if the `'region'` equals North America. For example the custom taxonomy for region is :               $labels = array(         'name' => _x( 'Regions', 'taxonomy general name' ),         'singular_name' => _x( 'Region', 'taxonomy singular name' ),         'search_items' =>  __( 'Search Regions' ),         'all_items' => __( 'All Regions' ),         'parent_item' => __( 'Parent Region' ),         'parent_item_colon' => __( 'Parent Region:' ),         'edit_item' => __( 'Edit Region' ),          'update_item' => __( 'Update Region' ),         'add_new_item' => __( 'Add New Region' ),         'new_item_name' => __( 'New Region Name' ),         'menu_name' => __( 'Regions' ),     );            register_taxonomy( 'region', array( 'jazz club', 'jazz festivals' ), array(           'hierarchical' => true,           'labels' => $labels,           'show_ui' => true,           'show_admin_column' => true,           'query_var' => true,           'rewrite' => array( 'slug' => 'region' ),     ) );      I tried this to test on the `'city'` taxonomy and hook into the permalink generation but ended up with a bunch of errors:               add_filter( 'post_link', 'city_permalink', 10, 3 );     add_filter( 'post_type_link', 'city_permalink', 10, 3 );          function city_permalink( $permalink, $post_id, $leavename ) {         if ( strpos( $permalink, '%city%' ) === FALSE )                        return $permalink;              $post = get_post( $post_id );         if ( ! $post )                  return $permalink;              $terms = wp_get_object_terms( $post->ID, 'city' );           if ( ! is_wp_error( $terms ) && ! empty( $terms ) && is_object( $terms[0] ) )                 $taxonomy_slug = $terms[0]->slug;         else                 $taxonomy_slug = 'no-city';              return str_replace( '%city%', $taxonomy_slug, $permalink );     }       Can the filter be used for multiple custom taxonomies? Actually I'm not sure if the filter is even correct due to the errors.


different single.php for different page templates

I have 4 page templates with same query. Is it possible to write conditional statement?   1. If I go to single post view (`single.php`) from page template 1 (`page-main.php`) display something (for example show div),   2. else if I go to single page view (`single.php`) from page template 2 (`page-second.php`) display something,   3. else etc.


When submitting more than 200 menus, I get "Service Temporarily Unavailable"

I have a site with a large number of nested menus. I solved the problem after following the solution proposed here Menu limit, cannot add new menu items and including max_input_vars setting. For some time this worked but now when I attempt to save menus I get               Service Temporarily Unavailable          The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.      and the logs report nothing. I try to increase to max_input_vars setting to 20000 but to no avail. Any help would be invaluable. Thank you.


Loading one meta box only on post-new.php with a forward link

I need to load a meta box for editors to choose the parent post first before editing. But dont see the wide meta box i expect and the normal edit page just loads: This is the code at the begining of wp-admin/post-new.php :                           if ( $post_type == 'news' && !isset($_GET['parent_id']) ):                            //checking if parent_id exists on querystring                      //Give them the news meta box only                 add_action('add_meta_boxes', function() { add_meta_box('news-parent', 'Please select the Parent Project for this news:', 'news_attributes_meta_box', 'news', 'normal', 'high');});//add wide meta box                        function news_attributes_meta_box($post) {                       $parentselectbox = wp_dropdown_pages(array(                       'post_type' => 'project',                       'name' => 'parent_id',                       'show_option_none' => __('(no parent)'),                       'sort_column'=> 'menu_order,                       post_title',                       'echo' => 0                       ));                       if ( ! empty($parentselectbox) ) {                         echo $parentselectbox;                       } // end empty pages check                     };                      exit;//stop page load after meta box is loaded                 //if chosen, give a move forward link with parent_id on querystring                 endif;


How to add an option for "nofollow" to the Link editor's existing "Link Relationship(XFN) options list?

How difficult would it be to add an option for "nofollow" to the Link editor's existing "Link Relationship(XFN) options list? Alternately, or better yet, in addition, add an item to the "Bulk Actions" listing called "Make links no follow" that would make all selected links rel="nofollow". I'd like to add this feature to my theme's functions.php


Custom Field Date Problem

I have a custom field called expiry_date with a value of let's say 2010-12-11 00:00:00. What I would like to do is, in my query loop, only return posts with this expiry_date custom field attached to posts and the following condition:   * The date in the expiry_date custom field has to be within 24 hours of expiring, if it past the current date, the post is 'expired' and will not show in the loop or if the post is within 25 hours of expiring, it will also not show etc. Any idea at all please


How to create a new copy of a theme currently being used?

I want to copy the theme I am using now, so that I can change it an test online (using the Theme Test Drive plugin). At this moment I haven't ftp, telnet or even access to the database. Is there any way I can re-install the theme I am using under another name? So that I could change that?


"No Data Received" error in Chrome every time i try to update the theme functions file

Under Appearance --> Editor --> functions.php ( Theme functions ), whenever i try to modify a piece of code in it and click Update, i get this "No Data Received" error in Chrome. I never get this error when i click on any other area in WordPress or theme options, custom css etc. I don't know why i am getting this error. I use GoDaddy hosting. Can someone please help me out on this issue. Thanks !


Add text to the bottom of particular pages

I want to add               [one_third][responsive]               [/responsive][/one_third]     [one_third][responsive]               [/responsive][/one_third]     [one_third_last][responsive]               [/responsive][/one_third_last]      In the bottom of all the pages parent to my Entrepreneurship page. Is their a way to add it to the pages parent to entrepreneurship without going on every single page and paste it at the bottom? * * * I used this code below but its also showing in the Entrepreuneurship page and I wanted it to only show in the parent pages of entrepreneurship but that's oke I can hide it in the entrepreneurship page by css (display: none;) FYI my page ID is 267 and to recapitulate what I wanted is to have a code inserted in the bottom of the pages parent to 267 (entrepreneurship). If someone can improve this code it would help me very much. Thanks.                           <?php                 $entrepreneurshipObject = get_page_by_title( 'Entrepreneurship' );                 $entrepreneurshipID = $entrepreneurshipObject->ID;                 $shortcode = '

';                      if($post->ID == $entrepreneurshipID || $post->post_parent == $entrepreneurshipID){                     echo do_shortcode($shortcode);                 }                 ?>


How to get latest posts from each category in regular order

let's say I have a main query and it displays posts from Movies and Music categories. I want the query to show always 5 latest posts from Movies and 5 latest posts from Music category. When I create a new post in Movies category the query will show 6 posts From Movies and 4 posts from Music category. But I need a way to show always 5 latest posts from each categories on homepage. In other words, I still want the regular query where posts are ordered by date and not categorized but want to limit the number of posts per category displayed on homepage. I found some solutions to display latest post/posts from each categories but all those solutions categorizes posts. I still want the regular wp query. Here are two solutions: http://eisabainyo.net/weblog/2010/03/10/display-5-latest-posts-in-each- category-in-wordpress/ First post of each category As you can see posts are categorized and are not in regular order. When there is a new post it will not be at the top and will go under its own category. I really googled for hours, tried many solutions but none of them does what I want. UPDATE: This question was marked as duplicate however I tried the mentioned answer and realized it's not what I'm looking for. I already found similar solutions but they all categorize posts. e.g. First Movie Post - Second Movie Post - Third Movie Post (then) First Mucis Post - Second Mucis Post - Third Mucis Post Posts should be displayed as if it's a regular wp query where posts are displayed by date no matter which category they belong. But each category should be limited by 5 posts. So the mentioned answer is close but not exactly what I'm looking for. Sorry for my terrible English.


Plugin update error message

I'm working on a client website where the framework requires a specific plugin version to work properly. With the follow lines of code in my **functions.php** file, it stops the plugin from updating itself and displaying an update message to the admin user:               // Disable Cherry Plugin Updates     function filter_plugin_updates( $value ) {         if(isset($value->response['cherry-plugin/cherry-plugin.php'])) {             unset($value->response['cherry-plugin/cherry-plugin.php']);         }     }      The code above works fine, however, it will sometimes throw a PHP error message when making certain changes from the WordPress backend menu, and doesn't seem to be consistant on a specific change:               "Fatal error: Cannot use object of type WP_Error as array in ../public_html/wp-content/plugins/cherry-plugin/admin/plugin-updater.php on line 63"      Viewing the above file, line 63 is:               if ($response['response']['code']!='200') {         return;     }      And the entire function it is within is:               // Remote query, function return any data of xml file on server     function cherry_plugin_remote_query($atts){         global $wp_version;              $default = array(                     'remote_server' =>  CHERRY_PLUGIN_REMOTE_SERVER,                     'data_type' =>      '',//framework, plugin, notice, info (Or any channel in xml)                     'output_type' =>    'return'//return, echo, notice                 );         extract(array_merge($default, $atts));         if($data_type == 'framework' && defined('CHERRY_VER')){             $current_version = CHERRY_VER;         }else if($data_type == 'plugin'){             $current_version = CHERRY_PLUGIN_VERSION;         }else{             $current_version = '';         }              $response = wp_remote_post( $remote_server, array(                 'body' => array('data_type' => $data_type,                                 'current_version' => $current_version,                                 'api-key' => md5(get_bloginfo('url'))),                 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo('url')             )         );              if ($response['response']['code']!='200') {             return;         }         $response = unserialize($response['body']);         if($response==null){             return;         }              switch ($output_type) {             case 'notice':;                 if(!empty($response) && isset($response['action']) && !empty($response['notice_content'])){                     global $notice_attr;                     $notice_attr =array();                     if(isset($response['wrapper_id'])) $notice_attr['wrapper_id'] = $response['wrapper_id'] ;                     if(isset($response['wrapper_class'])) $notice_attr['wrapper_class'] = $response['wrapper_class'] ;                     if(isset($response['notice_content'])) $notice_attr['notice_content'] = $response['notice_content'] ;                          add_action($response['action'], 'cherry_call_function_add_notice');                     function cherry_call_function_add_notice(){                         global $notice_attr;                         echo cherry_add_notice($notice_attr);                     }                 }             break;                  case 'echo':                 echo $response;             break;                  default:                 return $response;             break;         }     }      How would I be able to stop the plugin from updating, displaying an update message to the admin user, as well as not throw any PHP errors?


Remove "Time to upgrade" message from dashboard

So far I've been using the following code to remove the dashboard update message ("WordPress 3.5 is available! Please update now."):               remove_action('wp_version_check', 'wp_version_check');     remove_action('admin_init', '_maybe_update_core');     add_filter('pre_transient_update_core', create_function( '$a', "return null;"));      However, it doesn't seem to work any more with current WordPress versions. Is there a new way to removing this message that is compatible with later WordPress versions?


Getting Plugin directory and url

In one of my theme the path and directory is set by               if( !defined('ADMIN_PATH') )     define( 'ADMIN_PATH', get_template_directory() . '/admin/' );     if( !defined('ADMIN_DIR') )     define( 'ADMIN_DIR', get_template_directory_uri() . '/admin/' );      If I want to convert it into plugin what will be the correct way?I have tried plugins_url(), plugin_dir_url() but those didn't work.


redirect with conditions

in woocommerce-functions.php I tried to redirect after login with conditions : log from my account page or an other 'connexion' in sell process: cart->CONNEXION->parrainage->checkout. I tried to modify like this:               if ( ! empty( $_POST['redirect'] ) ) {                     $redirect = esc_url( $_POST['redirect'] );                 } elseif ( wp_get_referer() ) {                     $redirect = esc_url( wp_get_referer() );                 } else {                                        $prev = get_permalink(get_adjacent_post(false,'',false));                                        if ( $prev = 'http://www.variodis.com/wordpres/panier/connexion');{                                           $redirect = esc_url( 'my_url_1' );                                        } else {                                            $redirect = esc_url( 'my_url_2');                                               }                      wp_redirect( apply_filters( 'woocommerce_login_redirect', $redirect, $user ) );                 exit;      Working BUT always redirect to first url in any case... Can you give me some help? I read some topics with discuss about redirect but can't find this one. Thx


Template for different category on woocommerce product

I've made a custom template for a category called "shop" on the products tab. I've read some of the previous topics that mention doing an if conditional to the templete checking the category its in. I've tried this and had no luck so went to making a template called single- product-shop.php, I then wrote a conditional to load the particular page template and placed it within single-product.php. However Now I seem to generate a php warning.                           <?php while ( have_posts() ) : the_post(); ?>          <?php             if( has_term( 'shop', 'product_cat' ) ) {                 $file = 'single-product-shop.php';             } else {                 $file = 'single-product-default.php';             }                  global $woocommerce;                  load_template( $woocommerce->template_url . $file );     ?>                          <?php endwhile; // end of the loop. ?>      If someone could please point out what I'm doing wrong, I would be most greatful. Thanks


Include either name or slug in the include parameter using wp_list_categories?

I'm working both locally and remotely, pushing code via git. I have the current code set up below, which looks for tags and outputs them as a list using `wp_list_categories`. I need to use the `include` parameter as there is no hierarchy with tags (I can't use categories in this instance). However, as I am working locally and remotely, there's a chance that the IDs from local to remote won't be the same. So, ideally, I'd like to include by `name` or `slug`, but I know the `include` parameter only allows IDs. Is there any way to include either `name` or `slug` in the `include` parameter? Idea: My friend said we could have a list of names, and loop through them all and use get_term_by to get the id – but I'm not exactly sure where to start... Thanks in advance, R               <?php $sector_args = array(         'taxonomy' => 'post_tag',         'show_count' => 0,         'pad_counts' => 0,         'title_li' => '',         'include' => '5,6,7'     ); ?>          <ul>         <?php wp_list_categories( $sector_args ); ?>     </ul>


how to get image full path from WP_Post Object?

i want to get image full path so that i can apply it in the src attribute of image element. what i am getting right now is the image, generated from function: the_post_thumbnail(); which i can't apply to image element what i did so far is:                           <?php                     $d=get_cat_ID( 'news' );                     $catquery = new WP_Query( 'cat='.$d.'&posts_per_page=1&order=DESC' );                     while($catquery->have_posts()) : $catquery->the_post();                           the_post_thumbnail();                     endwhile;                 ?>      what i want is; path of image with its name as below: http://example.com/folder1/wp-content/uploads/2013/12/image.jpeg


How to write this conditional statement?

What is the correct way to write a conditional statement?                                   <?php if is_tag( 'Premium' ){                          <a href="<?php the_permalink(); ?>" class="info"> Subscribe                              }else {                              <a href="<?php the_permalink(); ?>" class="info">Read More                         }                         ?>                         Help Needed.


Static Page Titles for Genesis Single Post Page

I would like to have a static Page title not post title to my single post pages. Right now i have my News page and Events page. that's using a custom query. I'm not really sure how to explain it. I guess this would help... www.mysite/news/ * * * NEWS * * * Post Title 1   Excerpt here... Post Title 2   Excerpt here... \--then when i click one of the post.. It becomes like this * * * Post Title 1 * * * Content Here... \--what i want is: * * * News * * * Post Title 1   Content Here...      \--and here is my Genesis code in my function.php               // Page Title  //     add_action( 'template_redirect', 'wpse_124609_remove_titles' );     function wpse_124609_remove_titles() {              if ( is_front_page() ) {            remove_action('genesis_entry_header', 'genesis_do_post_title');              } else if ( is_page()) {             remove_action( 'genesis_entry_header', 'genesis_do_post_title' );             add_action( 'genesis_before_content_sidebar_wrap', 'page_title_and_bread' );         }         else if ( is_singular( 'events' ) ) {             add_action( 'genesis_entry_header', 'genesis_do_post_title' );             add_action( 'genesis_before_content_sidebar_wrap', 'events_static_title' );         }             else if ( is_singular( 'news' ) ) {             add_action( 'genesis_entry_header', 'genesis_do_post_title' );             add_action( 'genesis_before_content_sidebar_wrap', 'news_static_title' );         }          }     function page_title_and_bread() {         echo "
";         echo "
";         echo get_the_title();         echo "
";         echo "
";         genesis_do_breadcrumbs();         echo "
";         echo "
";     }          function events_static_title() {         echo "
";         echo "
";         echo "Events";         echo "
";         echo "
";         genesis_do_breadcrumbs();         echo "
";         echo "
";     }          function news_static_title() {         echo "
";         echo "
";         echo "News";         echo "
";         echo "
";         genesis_do_breadcrumbs();         echo "
";         echo "
";     }      I hope my explanation is clear. Thanks


Custom post types with date based archive

I'm trying to create an archive for a custom post type. My custom post type is called `journal` and I'm running WordPress 3.3.1. My understanding is that from WordPress 3.1 this should be an included feature so navigating to `www.mywebsite.com/journal/2013` should simply return a collection of posts from 2013 using the `archive-journal.php` template. My issue is this doesn't work. I have posts from 2013 but going to that link simply returns a 404. `www.mywebsite.com/journal/` works fine but trying to add any date filter to the end of the url with cause 404s. This is the code I'm using to register the post type. I haven't included the `$labels` array in below but it's in my `functions.php`                   $journal_args = array(         'labels' => $labels,         'public' => true,         'publicly_queryable' => true,         'show_ui' => true,         'query_var' => true,         'rewrite' => array('slug' => 'journal', 'with_front' => true),         'has_archive' => true,         'capability_type' => 'post',         'hierarchical' => false,         'menu_position' => null,         'supports' => array('title','editor','thumbnail', 'comments'),       );           register_post_type( 'journal' , $journal_args );      Have I missed anything? Has anyone got any idea why the date archives are not working?


What would be the correct way to manage a multiple locale site with Wordpress

We are a professional company with lots of big clients and have adopted Wordpress 2 years ago to build professionnal grade websites. Being locate in a multiple language country, we have to make our sites bilingual. We found that using WPML has been the best solution so far to support multiple locales and/or languages. Our problem is at several levels:   1. WPML supports languages but binds a locale, how do you actually make it work with locales such as fr-CA, en-CA, en-US at the same time without create a strange language code?   2. Is there a way to put your wordpress in an invariant state? For example, creating a template with __e('something') creates a string in WPML that you'll have to translate in other languages than the default of the your blog. What happens if you have to change your default string to something else? You have to retranslate all your translations and it clutters the interface... We have a couple of ideas how to achieve this, but we'ld like to know what is the best possible method to achieve this. Thanks


Set a User as Author of all 'New Posts' posted

An Author 'XYZ' is need to be set as the Default author of all **New Posts**. Irrespective of the actual Author posting the content, the post should be **saved** by this author 'XYZ'. Is there a Plugin or custom functions, which serves this purpose? `Note : The existing posts should stay as it is, no 'change of author' for old posts, only new one should be effected.`


How to create color scheme for my custom theme?

I would like to create color scheme for my custom template that can be changed inside my **admin panel**. According to **this thread** it can "easily" be done.   Author quotes: "create your color styles in seperate style sheets and name them like so. blue.css - black.css - brown.css - ect.... Then in your **admin options** panel you could add something simple like this":               array( "name" => "Color Scheme",  //color scheme     "desc" => "Select the color scheme for the theme",     "id" => $shortname."_color_scheme",     "type" => "select",     "options" => array("black","blue","brown","green","grey","orange","purple","red","white","yellow"),     "std" => "blue/blue"),      Now what I don't understand is **Where to add that code?** I tried adding this to my: **functions.php** and **index.php** but it breaks my theme! This is my first time I am trying to create something like this so i am sorry for my noob question.   Can somebody help me how to add this functionality?   Thank you guys!!


Custom post type not saving the meta fields

I need a second set of eyes, because its late and I can't see this anymore. Why won't this save? What am I missing?               /****************************************/     // 1. Custom Post Type Registration (Football Tips)          add_action( 'init', 'create_football_tip_postype' );          function create_football_tip_postype() {          $labels = array(     'name' => _x('Football Tips', 'post type general name'),     'singular_name' => _x('Football Tip', 'post type singular name'),     'add_new' => _x('Add New', 'tips'),     'add_new_item' => __('Add New Tip'),     'edit_item' => __('Edit Tip'),     'new_item' => __('New Tip'),     'view_item' => __('View Tip'),     'search_items' => __('Search Tips'),     'not_found' =>  __('No tips found'),     'not_found_in_trash' => __('No tips found in Trash'),     'parent_item_colon' => '',     );          $args = array(     'label' => __('Tips'),     'labels' => $labels,     'public' => true,     'can_export' => true,     'show_ui' => true,     '_builtin' => false,     'capability_type' => 'post',     'hierarchical' => false,     'rewrite' => array( "slug" => "tips" ),     'supports'=> array('title', 'thumbnail', 'excerpt', 'editor') ,     'show_in_nav_menus' => true,     'taxonomies' => array( 'tf_tipcategory', 'post_tag')     );          register_post_type( 'tf_tips', $args);          }                    // 2. Custom Taxonomy Registration (Football Tip Types: Win/Loss)          function create_tipcategory_taxonomy() {          $labels = array(         'name' => _x( 'Categories', 'taxonomy general name' ),         'singular_name' => _x( 'Category', 'taxonomy singular name' ),         'search_items' =>  __( 'Search Categories' ),         'popular_items' => __( 'Popular Categories' ),         'all_items' => __( 'All Categories' ),         'parent_item' => null,         'parent_item_colon' => null,         'edit_item' => __( 'Edit Category' ),         'update_item' => __( 'Update Category' ),         'add_new_item' => __( 'Add New Category' ),         'new_item_name' => __( 'New Category Name' ),         'separate_items_with_commas' => __( 'Separate categories with commas' ),         'add_or_remove_items' => __( 'Add or remove categories' ),         'choose_from_most_used' => __( 'Choose from the most used categories' ),     );          register_taxonomy('tf_tipcategory','tf_tips', array(         'label' => __('Tip Category'),         'labels' => $labels,         'hierarchical' => true,         'show_ui' => true,         'query_var' => true,         'rewrite' => array( 'slug' => 'tip-category' ),     ));          }          add_action( 'init', 'create_tipcategory_taxonomy', 0 );               // 3. Show Columns          add_filter ("manage_edit-tf_tips_columns", "tf_tips_edit_columns");     add_action ("manage_posts_custom_column", "tf_tips_custom_columns");          function tf_tips_edit_columns($columns) {          $columns = array(         "cb" => "<input type=\"checkbox\" />",         "_category" => "Category",         "_date" => "Tip Date",         "_league" => "League",         "_hometeam" => "Home Team",     "_awayteam" => "Away Team",     "_tip" => "Tip",     "_odd" => "Odd",     "_result" => "Result",     "_score" => "Score",        );          return $columns;          }          function tf_tips_custom_columns($column) {          global $post;     $custom = get_post_custom();     switch ($column)              {             case "_category":                 // - show taxonomy terms -              /*   $tipcats = get_the_terms($post->ID, "tf_tipcategory");                 $tipcats_html = array();                 if ($tipcats) {                     foreach ($tipcats as $tipcat)                     array_push($tipcats_html, $tipcat->name);                     echo implode($tipcats_html, ", ");                 } else {                 _e('None', 'themeforce');;                 } */             break;         case "_date":         echo $custom["tf_tips_date"][0];             break;             case "_league":         echo $custom["tf_tips_league"][0];             break;         case "_hometeam":         echo $custom["tf_tips_home_team"][0];             break;         case "_awayteam":         echo $custom["tf_tips_away_team"][0];             break;         case "_tip":         echo $custom["tf_tips_tip"][0];             break;         case "_odd":         echo $custom["tf_tips_odd"][0];             break;         case "_result":         echo $custom["tf_tips_result"][0];             break;         case "_score":         echo $custom["tf_tips_score"][0];             break;              }     }               // 4. Show Meta-Box          add_action( 'admin_init', 'tf_tips_create' );          function tf_tips_create() {     add_meta_box('tf_tips_meta', 'Tips', 'tf_tips_meta', 'tf_tips', 'normal', 'default');     }          function tf_tips_meta () {          // - grab data -          global $post;     $custom = get_post_custom($post->ID);     $date = $custom["tf_tips_date"][0];     $league = $custom["tf_tips_league"][0];     $hometeam = $custom["tf_tips_home_team"][0];     $awayteam = $custom["tf_tips_away_team"][0];     $tip = $custom["tf_tips_tip"][0];     $odd = $custom["tf_tips_odd"][0];     $result = $custom["tf_tips_result"][0];     $score = $custom["tf_tips_score"][0];                   // - security -          echo '<input type="hidden" name="tf-tips-noncename" id="tf-tips-noncename" value="' .     wp_create_nonce( 'tf-tips-nonce' ) . '" />';               // - output -          ?>

Tip Date<input name="tf_tips_date" value="<?php echo $date; ?>" />

League<input name="tf_tips_league" value="<?php echo $league; ?>" />

Home Team<input name="tf_tips_home_team" value="<?php echo $hometeam; ?>" />

Away Team<input name="tf_tips_away_team" value="<?php echo $awayteam; ?>" />

Tip<input name="tf_tips_tip" value="<?php echo $tip; ?>" />

Odd<input name="tf_tips_odd" value="<?php echo $odd; ?>" />

Result<input name="tf_tips_result" value="<?php echo $result; ?>" />

Score<input name="tf_tips_score" value="<?php echo $score; ?>" />

     <?php     }               // 5. Save Data          add_action ('save_post', 'save_tf_tips', 10, 2);          function save_tf_tips(){          global $post;          //skip auto save     if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {         return $post->ID;     }          if ( get_post_type($post) != 'tf_tips')         return $post->ID;          // - still require nonce          if (isset($_POST['tf-tips-noncename'])){         if ( !wp_verify_nonce( $_POST['tf-tips-noncename'], 'tf-tips-nonce' ))             return $post->ID;     }     else{ return $post->ID; }          if ( !current_user_can( 'edit_post', $post->ID ))         return $post->ID;           // - convert back to unix & update post          if(isset($_POST["tf_tips_date"])){         $updatedate = $_POST["tf_tips_date"];         update_post_meta($post->ID, "tf_tips_date", $updatedate);     }          if(isset($_POST["tf_tips_league"])){         $updateleague = $_POST["tf_tips_league"];         update_post_meta($post->ID, "tf_tips_league", $updateleague);     }          if(isset($_POST["tf_tips_home_team"])){         $updatehometeam = $_POST["tf_tips_home_team"];         update_post_meta($post->ID, "tf_tips_home_team", $updatehometeam);     }          if(isset($_POST["tf_tips_away_team"])){         $updateawayteam = $_POST["tf_tips_away_team"];         update_post_meta($post->ID, "tf_tips_away_team", $updateawayteam);     }          if(isset($_POST["tf_tips_tip"])){         $updatetip = $_POST["tf_tips_tip"];         update_post_meta($post->ID, "tf_tips_tip", $updatetip);     }          if(isset($_POST["tf_tips_odd"])){         $updateodd = $_POST["tf_tips_odd"];         update_post_meta($post->ID, "tf_tips_odd", $updateodd);     }          if(isset($_POST["tf_tips_result"])){         $updateresult = $_POST["tf_tips_result"];         update_post_meta($post->ID, "tf_tips_result", $updateresult);     }          if(isset($_POST["tf_tips_score"])){         $updatescore = $_POST["tf_tips_score"];         update_post_meta($post->ID, "tf_tips_score", $updatescore);     }          }


How to optimize performance without transient?

I've built a widget to output some fancy content from an API. I realize today I added a transient system so everytime the widget is updated transient is deleted and everything is alright. What I missed is that the generated content is actually different according URL. So my system is not appropriate, for now the content remains the same on each post. How would you handle this? I think one transient per post is bad bad idea, isn't it? I could delete the transient code but this increase page load.


Check & remove special characters in a field?

I would like to check whether a field has special characters, remove those characters and output (save) the value to another field. I am creating a user search function that search various fields, but those fields might (or might not) have special characters in them that will return unexpected results, or no results at all. I need to be able to remove any special characters and save/output the clean value to another field, which I will then include in my search function. **Example:** **Original value:** G-P's Bargain Shop **After removing special characters:** GPs Bargin Shop Then **save new value** (GPs Bargain Shop) to **another field** Can someone tell me how to achieve this? Or of a better solution for what Im trying to accomplish. Thanks for any help with this.


Check if a field is capitalized?

I want to check the if the first letter of a field is capitalized. Example: If (First Name field) is capitalized { Capitalized! } else { Not Capitalized! } Thanks Thank you


the_permalink() not working

I have WordPress installed in a subfolder called `news`, but links to comments, posts, categories, etc all link to `domain.com/?p=99` instead of `domain.com/news/?p=99`. The only link that points to the correct folder is the `edit post` link. I have set my WP folder to, `domain.com/news`, and my site domain, `domain.com`. I also tried deleting my `.htaccess` file. Nothing has helped! Part of the issue might step from the fact that WP _used_ to be installed in the root folder. Any idea what I can do? :(


2 accounts under same email preventing me from loging in

A year ago I set up a WP account with email account A. I was unable to work with WP effectively. I came back a year later with more knowledge & brought WP into a domain ( _abc_ ) I already owned. I linked this second account to email A as well. I have made a website with _abc_ using WP. After making the website, I decided to switch hosting providers from Go Daddy to Fat Cow. Somewhere in the process of switching the website from one provider to the next, my word press account got lost in cyberspace. I have attempted calling Go Daddy & Fat cow for support help, however they say I have to get ahold of WP support. Not only is my word press account gone, but also I somehow have to get my "SQL dump file" to Fat Cow. It may be obvious b/c of the language I'm using, but I am fairly new to this whole website design thing. The second part to my problem, is that everytime I try to log into my new WP account that is linked to _abc_ , it sayis I am using the incorrect password. I know i am using the correct password as I wrote down what it was. I got to the password reset link, & it has me enter my email so that it can send me an email with another password reset link. However, when I go to my email to find the password reset email from WP, I go to reset my password & it is directed to my first WP account that I built over a year ago. It's as though WP has deleted my _abc_ account & is telliung me I ccan only access my account from a year ago. Please help me.


Programatically changing template of a page

Is there a way to change the **Template** of a **page** from **Default Template** to another programatically?


how do I add "home" menu item conditionally to custom menus?

**Original question** _How do I get menu items using slug and not ID_ > I need to get a specific menu, but I can't use ID, since the menu ID on my > dev is not the same as on my staging and prod server. > > WP doc says that `wp_get_nav_menu_items`can be used with menu slug. But how > do I know what slug is created? I tested with what I thought would be a > slug, but I got no menu items. My initial though was that I needed to fetch a menu in order to get menu items in an array / object so that I could add an extra menu item. There is little documentation on how one can get a menu item by using a slug, so I got a bit stuck. If you should have the answer, please add this as well. My goal was to add a 'home' link based on a specific condition. Thanks to the feedback, I have rewritten my question so it makes more sense ;)


How can I run custom function when post status is changed?

I can hook custom function to each of `trash_post`, `edit_post`, `private_to_publish` etc. to meet some of my requirements, but I need also to check for more possible transitions like _'pending to draft'_ , _'private to draft'_ and so on. Something similar to this inexistent function:               if( post_status_changed($post_id) ) {         my_custom_function();     }