title: How to get my [shortcode] rendered on the home page, other pages are fine

text:
I'm using a child theme of Pixlex. The theme has a options panel to let me choose wether I want 2 or 3 columns on the home page and if those columns are to be filled with a post or page. I have one of the columns is set to be filled with a page that has been created and that page has a shortcode for a button placed in it. (the shortcode is provided by the themes code itself) My problem is that when the home page is rendered the column that pulls in the page shows the shortcode as not being parsed and I am left with: `[bigbutton url="http://somelink.com" color="yellow"]The Button[/bigbutton]` I was hoping someone here might see something that I am not. Here is the code in the homepage template that is pulling in the 3rd column.               <?php            if($options['basic_homebox3'] && $options['basic_homebox3']!=2){           $args = array('page_id' =>$options['basic_homebox3'], );     $post_h = get_post($options['basic_homebox3']);     $title = $post_h->post_title;     $sjc_excerpt = explode( '', $post_h->post_content);      $permalink = get_permalink( $options['basic_homebox3'] );     $i=1;     ?>          <?php if (have_posts()) : ?>        <?php while (have_posts()) : the_post();            if($i<2){           ?>

<?php echo $title; ?>

                           <?php echo wpautop( $sjc_excerpt[0] ); ?>

                     <?php                }              $i++;              endwhile; ?>              <?php               endif;              }else{              ?>

Third box

Suspendisse nisl.

            <?php     } ?>


title: Is it possible to generate an alternate structure for multi-tag urls?

text: I know that one can query multiple tags with the + syntax, as in www.example.com?tag=?test+test2+test3 I'm looking for a solution where the URL would be in this format instead: www.example.com/foo/test/test2/test3 Can anyone give any tips how best to arrive at this solution?


title: Query by post type or category

text: I now that WP_Query can query by post_type and category but i need to get data from custom post type or from category which is standard post type. Adding category to my custom post type is not an option. Any suggestion how to aproach this?


title: Upgrading WP Version + Keeping Customized Core Code?

text: I'm a WP noob, so please bear with me. I'm working on my first WP project, and my task is to extract all the customized core WP code and put them into other files so that in the future when we upgrade the WP version, it'll be more maintainable and our customized core code won't be deleted. 1. I noticed that there are a few PHP embedded HTML pages such as `/wordpress-3.2.1/wp-includes/admin-bar.php` where the difference is that this                   function _admin_bar_bump_cb() { ?>         <style type="text/css" media="screen">             html { margin-top: 28px !important; }             * html body { margin-top: 28px !important; }         </style>         <?php         }      becomes this:                   function _admin_bar_bump_cb() { ?>         <!-- <style type="text/css" media="screen">             html { margin-top: 28px !important; }             * html body { margin-top: 28px !important; }         </style> -->         <?php      I also have a page where I add customized javascript `<script>...</script>` in my `wordpress-3.0.5/wp-admin/admin-header.php` file. Where would I place it to make sure it's loaded when I upgrade the WP version? 2. And how about customized functions? Here's an example of one of the methods in `wp-admin/includes/template.php` : Original code:                   function meta_form() {             global $wpdb;             $limit = (int) apply_filters( 'postmeta_form_limit', 30 );             $keys = $wpdb->get_col( "                 SELECT meta_key                 FROM $wpdb->postmeta                 GROUP BY meta_key                 HAVING meta_key NOT LIKE '\_%'                 ORDER BY meta_key                 LIMIT $limit" );             if ( $keys )                 natcasesort($keys);         ?>      Customized version:               function meta_form() {         global $wpdb;            if ( isset($_GET['post']) )         $post_id = (int) $_GET['post'];       elseif ( isset($_POST['post_ID']) )         $post_id = (int) $_POST['post_ID'];       else         $post_id = 0;            if ( $post_id ) {         $post_ = get_post($post_id);            }            if ($post_->post_type == 'video_photo' ){         $limit = (int) apply_filters( 'postmeta_form_limit', 30 );         $keys = $wpdb->get_col( "             SELECT meta_key             FROM $wpdb->postmeta         where meta_key like 'tqmcf_%'             GROUP BY meta_key             HAVING meta_key NOT LIKE '\_%'             ORDER BY meta_key             LIMIT $limit" );       }else{         $limit = (int) apply_filters( 'postmeta_form_limit', 30 );         $keys = $wpdb->get_col( "             SELECT meta_key             FROM $wpdb->postmeta                  GROUP BY meta_key             HAVING meta_key NOT LIKE '\_%'             ORDER BY meta_key             LIMIT $limit" );       }              if ( $keys )             natcasesort($keys);     ?>      Where exactly would I define my `meta_form()` function to make sure it overwrites the core method? I read stuff on add_filter and add_action, but I have no clue how to implement them or how they actually work.


title: Search posts by post author name

text: I want to search posts publish by particular author. For this purpose I added a filter in `functions.php`:               function wpse_29570_where_filter($where){             global $wpdb;             if( is_search() ) {                 $search= get_query_var('s');                 $query=$wpdb->prepare("SELECT $wpdb->users.ID  FROM $wpdb->users WHERE  $wpdb->users.display_name LIKE '%%%s%%' ", $search );                 $authorID= $wpdb->get_var( $query );//die;                      if($authorID){                     $where = "  AND  ( atl_posts.post_author = {$authorID} ) ";                 }                 //echo $where;              }              return $where;         }              add_filter('posts_where','wpse_29570_where_filter');      It I echo the `where` condition it gives               AND ( atl_posts.post_author = 1 )       but when I search by typing `admin` it shows a blank result. Please help me to make it work.   Can anyone tell me a better way to do it?


title: wp_enqueue_script won't load in header?

text: Read up on this, and I believe I'm doing everything right. Everything is getting loaded in the footer. Here is my code:               function load_kenburns() {     if ( !is_admin() ) {     wp_register_script( 'kenburns', get_template_directory_uri() . '/js/bannerscollection_kenburns.js', '', '', false);     wp_register_script( 'jquery-ui', get_template_directory_uri() . '/js/jquery-ui-1.8.16.custom.min.js', '', '', false);     wp_register_script( 'jquery-touch', get_template_directory_uri() . '/js/jquery.ui.touch-punch.min.js', '', '', false);     wp_register_script( 'kbsettings', get_template_directory_uri() . '/js/kenburnsettings.js', '', '', false);     }     }     add_action( 'wp_enqueue_scripts', 'load_kenburns' );      I then enqueue the script on the page I need it.               <?php      wp_enqueue_script( 'kbsettings' );      wp_enqueue_script( 'kenburns' );      wp_enqueue_script( 'jquery-ui' );      wp_enqueue_script( 'jquery-touch' );     ?>      Any ideas why they won't load in the head? Any help is appreciated.


title: Child Theme > Template

text: I incorrectly updated the Template variable in the style sheet of a Child theme. However, the site was still OK. The only indication I had was in the Admin section it said this theme did not exist. So, my question is - is this variable actually used when rendering a page or is it just a hint for the control panel to notify the user?


title: get Insert id for meta field

text: I'm in a situation where i also need to get the id of the inserted meta( `meta_id` for post meta and `umeta_id` for user meta) For eg i add a user meta               add_user_meta($user_id,'some_key',$some_value,false);      is there a built in method of getting the umeta_id for this meta field without using custom query? Same case for retrieving meta value with meta id. I had to use this               $sql_query = 'select umeta_id as my_key_id, meta_value from  wp_usermeta where user_id = "'.$user_id.'" and meta_key = "some_key" order by my_key_id asc';      Any better alternative?


title: Setting a post's featured image from an embedded YouTube video

text: If I create a post that has an embedded YouTube video in it (so all I do is paste the YouTube URL into the post and let Wordpress automatically embed it for me), is there a way to have the thumbnail image of the video set as the post's featured image?


title: Extract all shortcode data from post into loop variables?

text: My client wants to have several pages in which he can edit small, separate parts of a Wordpress page. For example, there is a callout box in the upper left corner. There is also a small piece of text showing contact information in the lower right corner. I'd like to be able to have all of these pieces of text editable in the same place. My idea is to have a post structured using shortcodes; something like this:               [top-callout]     This is the top callout text.     [/top-callout]          [bottom-contact-info]     341 Address Rd.     City Comma State 23422     [/bottom-contact-info]          [other-text]     ...     [/other-text]      and so on. Is there a way to extract the content of the shortcodes into loop variables? That way in a theme php file I could do something like:               <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>         ...         <?php echo $post->top_callout; ?>         ...         <?php echo $post->bottom_contact_info; ?>         ...     <?php endwhile; ?>      Or, is there a better way to do this?


title: Give a condition to a wordpress menu item to change its offerid for each landing page I create

text: So my wordpress site has a one header and one footer with a big CTA as one of the menu items. I want to create a bunch of landing pages but I want to be able to change the offerid in the url for each landing page for that big CTA so I can track. By offerid I mean http://www.example.com/customers/?offerid=weyhw68963. I'm am stuck on how to do this since the menu is a global menu and the link is the same on every page. My thought is that I would make a condition in the header.php file because I'm using bootstrap and I activated the menu in the header file.                   <?php         if(is_front_page()) {             $args = array(                   'menu'         => 'header-menu',                   'menu_class'   =>'nav navbar-nav navbar-right',                   'container'    =>'false'                   );           } else {             $args = array(                   'menu'         => 'page-menu',                   'menu_class'   =>'nav navbar-nav navbar-right',                   'container'    =>'false'                   );           }           wp_nav_menu( $args );               ?>      I'm thinking something like starting with is_page("offerid") then using custom_key but to be honest I'm very lost.


title: Why is my WP_Query outputting my entries twice?

text:
I am using a small shortcode to output a list of movie titles arranged by decades. `decades` is my custom taxonomy with terms like `1930s` `1940s` etc. Here is my shortcode:               [fashionfilms type=fashionfilms  tax=decades]      and here is how that shortcode is parsed:               add_shortcode('fashionfilms', 'cw_output_fashion_films');          function cw_output_fashion_films($atts){              $post_type = $atts['type'];         $tax = $atts['tax'];         $tax_terms = get_terms($tax);              if ($tax_terms) {           echo "
";           foreach ($tax_terms  as $tax_term) {             $args=array(               'post_type' => $post_type,               "$tax" => $tax_term->slug,               'post_status' => 'publish',               'posts_per_page' => -1,               'ignore_sticky_posts'=> 1             );                  $my_query = null;             $my_query = new WP_Query($args);             if( $my_query->have_posts() ) {               echo "
" . $tax_term->name . "
";               while ($my_query->have_posts()) : $my_query->the_post(); ?>
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?>
                 <?php               endwhile;             }             wp_reset_query();           } //end foreach loop           echo "
";         }     }      The problem is I am getting a doubled output for my entries. To see the doubled outout, please check my live link here. Here is my page template code too:
                 <?php while ( have_posts() ) : the_post(); ?>                 <div <?php post_class(); ?>>
<?php the_title();?>

                         <?php the_content() ?>

             <?php endwhile; ?>             <?php bootstrapwp_content_nav('nav-below');?>
      What am I doing wrong? How can I fix this?


title: How to create an archive page (with links) for a date range?

text: Is there a plugin which can create an Archive page for a limited date range? Thanks.


title: Click thumbnail, change main image - NextGen or somethign else?

text: I'm trying to get the main image to change depending on the thumbnail image clicked. I would want the main image to take its new src from the a tag of the thumbnail that was clicked. Good example is Gallery in 4 Lines but I'm looking for some kind of an existing solution (plugin) for Wordpress. Not sure if NextGen can do that. Thanks


title: Custom CSS without css.php file

text: i'm creating and theme and would like the user to be able to select their font family. Typically, i see that people use css.php files and pass user defined variables inside it. I'm a bit concerned of that approach though, i would not like my css file actually be a php file, it also makes things a bit more difficult to maintain. So, i would like to ask if maybe wordpress creators have thought of that and have added another way of specifying such custom values. Does anybody know if that can happen somehow without messing php with style.css itself ?


title: AJAX wp-mysql running too slow

text:
I have made a function of ajax, which returns all the posts starting with a particular alphabet, suppose a user clicks on letter A, then all the posts starting with letter A will be displayed, any how I am successful in making this function run, but only if I use normal mysql, but I want to use wp-mysql, My code shall speak for me ;)               echo $_GET['letter'];     $getLetter = $_GET['letter'];     global $wpdb;     global $post;          $result = $wpdb->get_results('SELECT * FROM wp_posts where post_title LIKE "'.$getLetter.'%" AND post_status = "publish" AND post_type="post"');     while($row = $result)     {       echo '' . $row['post_title'] . '
';     }      I am using this code which is getting a letter through URL and searching it for in database, but if I use the above code, it takes too long to search for a post(it takes more then a minute), but if I use the below code               echo $_GET['letter'];     $getLetter = $_GET['letter'];     $con = mysql_connect('localhost', 'root', '');     mysql_select_db("wordpress", $con);     $result = mysql_query('SELECT * FROM wp_posts where post_title LIKE "'.$getLetter.'%" AND post_status = "publish" AND post_type="post"');     while($row = mysql_fetch_array($result))     {       echo '' . $row['post_title'] . '
';     }      then everything works quickly, Can anyone explain me this? I don't know wp-db that much, but I want this to be worked in wpdb Am I doing something wrong? EDITED AJAX CODE:


title: Options not saving

text: My options were saving properly then I edited the files and it's not saving anymore. I undo the changes on the files and I'm sure that those were the only files that I edited. One section saved properly all the fields while the other section didn't. Is there any reason why option1 was saved properly and option2 didn't? EDIT: here's the code               function init_theme_options() {              //Header Settings         if ( false == get_option( 'theme_header_options' ) ) {             add_option('theme_header_options');         }         register_setting( 'theme_header_options', 'theme_header_options' );         add_settings_section(              'theme_header_section',              __( 'Header Settings', TEXTDOMAIN ),              'section_callback',              'theme_header_options'         );         add_settings_field(              'header_show_social_icons',              __( 'Social Icons', TEXTDOMAIN ),              'create_text_field',              'theme_header_options',              'theme_header_section',             array(                 'id'         => 'header_show_social_icons',                 'type'       => 'text',                 'option_name'=> 'theme_header_options',                 'desc'       => '',             )         );              //Footer Settings         if ( false == get_option( 'theme_footer_options' ) ) {              add_option( 'theme_footer_options' );         }         register_setting 'theme_footer_options', 'theme_footer_options' );         add_settings_section(             'theme_footer_section',              __( 'Footer Settings', TEXTDOMAIN ),              'section_callback',              'theme_footer_options'         );         add_settings_field(             'footer_background_color',              __( 'Footer Background Color', TEXTDOMAIN ),             'create_text_field',              'theme_footer_options',              'theme_footer_section',             array(                 'id'          => 'footer_background_color',                 'type'        => 'text',                 'option_name' =>'theme_footer_options',                 'desc'        => '',             )         );     }     add_action('admin_init','init_theme_options');          function create_text_field( $cb_args ) {         extract( $cb_args );         $theme_settings = get_option( $option_name );         $theme_settings[ $id ] = ( isset( $theme_settings[$id] ) )             ? esc_attr( stripslashes( $theme_settings[ $id ] ) )             :'';         echo "<input id ='$id' name='".$option_name."[$id]' type='$type' value='$theme_settings[$id]'><label for='$id'>$desc</label>";     }     function section_callback(){}


title: Custom post type Events - archives-events.php filter by date

text: I've created a Custom Post Type called Events, so I can manage my events on my wordpress site. My CPT Events has the following custom fields called : event_local, event_date_start and event_date_end. By default it generates permalink "/events" for the archives-events.php, and "/events/event-name" for the single-events.php. Until then everything works normally. **Problem:** I have a horizontal menu in archives-events.php that lists the last 12 months, starting from the current month. Something like: Jan/2014 | feb/2014 | mar/2014 | apr/2014 | may/2014 ... I wish, for example by clicking on "mar/2014" he filtered my events based on event_date_start field, generating permalink "/events/month/year". Any suggestions?


title: Using a specific template for front page only

text: I am using supersized full slider for my themes, but it need all the script and stylesheet gets enqueued before wp_head. So it becomes the part of the header. Now whenever I use the header template (which is essential) Supersized also get included in all pages. I want to use it in front and home page only. I have a default home page for sliders only.


title: Displaying the most recently used tags

text: Is it possible to just show the most recent tags from e.g. the latest 10 posts as a tag cloud? The only things that I found were the WP Recent Tags plugin which is a bit outdated and no tags are displayed when I use the widget. I found the following posts: > How can I get a list of the most recent tags in a wordpress database?   >  Get recent tags in wordpress But they don’t work for me either.


title: Meta query: get posts with value in a multidimensional array

text: I have a custom post type, Album, which has a custom field called 'tracklist'. Tracklist is a multidimensional array which contains a track title and track link, like so:               $tracklist = array(       [0] => array(         [title] => 'Stairway to Heaven'         [link]  => 'stairway.mp3'       )       [1] => array(         [title] => 'Battle of Evermore'         [link]  => 'battle.mp3'       )     );      I want to use get_posts to find all the albums with the song 'Stairway to Heaven.' Something like this (I know this won't work, but hopefully it will explain my intentions):               $albums = get_posts(array(       'post_type'  => 'collection',       'meta_query' => array(         array(           'key'   => 'tracklist',           'value' => array(             'key'   => 'track'             'value' => array(               'key'   => 'title',               'value' => 'Starway to Heaven'             )           )         )       )     ));      It's easy enough to use meta_query to look for a custom field that returns a single string, but in this case I'm looking a for a value buried a few levelsdeep. How would I do this?


title: Help with a function in a widget

text:
I'm new to custom widgets and functions, and need a bit of help understanding how to achieve something. On my bookstore site I need to display links to books on external site using their ISBN numbers. I'm already getting their Google Books preview with a function in my theme's functions.php, but now I want to put other links in a sidebar widget. I've managed to make a new blank widget and get it to show up. This is the code I've tried to get the ISBN from the post meta data (meta key is isbn_metadata), but I'm not getting it right.               function get_kalahari_affiliate_link() {     $isbn_metadata = get_post_meta( get_the_ID(), '_isbn' );      return (                 'http://etrader.kalahari.net/referral.asp?linkid=5&partnerid=5710&ISBN=' .          $isbn_metadata      );     }     echo get_kalahari_affiliate_link( get_post_meta( get_the_ID(), '_isbn' ) );      I get a link to appear, but it's:               http://etrader.kalahari.net/referral.asp?linkid=5&partnerid=5710&ISBN=Array      The second problem is that it only appears on my primary sidebar, and not in any of the custom "widget areas" (http://docs.woothemes.com/documentation/plugins/woosidebars/) which might mean the plugin is not properly registered for those? I'd appreciate some help! Here is the update - the widget is stolen from a widget template tutorial here http://www.makeuseof.com/tag/how-to-create-wordpress-widgets/ Skip down to "Widget code goes here".               <?php     /*     Plugin Name: Random Post Widget     Plugin URI: http://jamesbruce.me/     Description: Random Post Widget grabs a random post and the associated thumbnail to display on your sidebar     Author: James Bruce     Version: 1     Author URI: http://jamesbruce.me/     */               class RandomPostWidget extends WP_Widget     {       function RandomPostWidget()       {         $widget_ops = array('classname' => 'RandomPostWidget', 'description' => 'Displays a random post with thumbnail' );         $this->WP_Widget('RandomPostWidget', 'Random Post and Thumbnail', $widget_ops);       }            function form($instance)       {         $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );         $title = $instance['title'];     ?>
<label for="<?php echo $this->get_field_id('title'); ?>">Title: <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo attribute_escape($title); ?>" />
     <?php       }            function update($new_instance, $old_instance)       {     $instance = $old_instance;     $instance['title'] = $new_instance['title'];     return $instance;       }            function widget($args, $instance)       {         extract($args, EXTR_SKIP);          echo $before_widget;     $title = empty($instance['title']) ? ' ' : apply_filters('widget_title', $instance['title']);          if (!empty($title))       echo $before_title . $title . $after_title;;                    // WIDGET CODE GOES HERE            echo "
This is my new widget!
";               function get_kalahari_affiliate_link() {         $isbn_metadata = get_post_meta( get_the_ID(), 'isbn_metadata' );      return (                 'http://etrader.kalahari.net/referral.asp?linkid=5&partnerid=5710&ISBN=' .          $isbn_metadata      );     }     echo get_kalahari_affiliate_link( get_post_meta( get_the_ID(), 'isbn_metadata' ) );          echo $after_widget;       }          }     add_action( 'widgets_init', create_function('', 'return     register_widget("RandomPostWidget");') );?>


title: ask and edit an extra comment field

text: I have been trying for two weeks to add a edit custom meta field to the admin edit comment form. I managed to show the field in the form, but it can't get it to update. I would also like to add this field to the registration form and profile. this is what I have so far               add_action( 'comment_post', 'save_comment_meta_data' );     function save_comment_meta_data( $comment_id ) {         add_comment_meta( $comment_id, 'location', $_POST['location'] );     }          add_action( 'add_meta_boxes', 'location_meta' );     function location_meta() {         add_meta_box( 'location_meta_id', 'Location of the Comment Author', 'location_meta_call', 'comment', 'normal', 'high' );     }          function location_meta_call(){         $location = get_comment_meta(get_comment_ID(),'location', true);         ?>         <label for="location">Location:</label>         <input type="text" name="location_meta_box_text"  value="<?php echo $location ?>" id="location_meta_box_text" />         <?php     }          add_filter('comment_save_pre','location_save');     function location_save($comment_content){         global $wpdb;              $id = get_comment_ID();         $text = $_POST['location_meta_box_text'];         $data = compact('text');         $rval= $wpdb ->update($wpdb->comments,$data,compact('id'));              update_comment_meta($id,'location',$text);              return $comment_content;          }


title: Add class from custom field into widget class

text: How would I add a class coming from a custom field to a widget? I know I should put it somewhere into $before_widget ... in my case this is               'before_widget' => '<aside id="%1$s" class="widget %2$s grid-33'.$color.'">',      I tried using $color and adding               global $post;     $color = get_post_meta($post->post_parent, 'bg_color', true );      above, but obviously I am not doing it the right way since it doesn't spit out the color class.


title: Under heavy cache conditions, updating the parent theme don't reflect changes with child theme enabled

text: I use W3 Total Cache, Cloudflare (and CloudFront for media files). I use a Child Theme to customize specifically for my site while maintaining the core theme with the parent theme. Whenever I update the Parent Theme, the changes are not reflected while the Child Theme is the Active Theme. However, if I re-upload or update the Child Theme's Style.css, it does reflect the new changes. I'm guessing it's the cache. What do I do, so I don't have to worry about the Child Theme when the updates are with the Parent Theme (while I continue to have the Child Theme as my Active Theme)?


title: Wordpress custom admin functions security

text: i have a case in my admin panel where i need to call my own function that resides in my own php file, with a GET request. This function is actually removing entries from the database. So, i would like to make sure that this cannot be invoked from anybody else than the admin user. What is the best way of doing that ? Notice that my 'example.php?filename=..' script is executed directly and should return with refreshing the page on the admin panel. How do i secure that properly ? Is there a better way of doing that while being controlled by Wordpress default security measures ? It would be also great to be able to execute things like get_option in the context of my php code.


title: WP 3.8 – Preview button not working for editor

text: After finishing developing my site I updated WordPress to 3.8. Everything works, but for some reason, an editor cannot click on the `Preview` button in the backend. Visiting the link `http://www.domain.com/?p=160&preview=true` manually works though! I don't know if this is really a 3.8 problem as I did not test this before.


title: Moving WordPress site to a new server - Admin not loading

text: I'm trying to move a WordPress Database from one server to another. I've done this a few times with other sites and servers and I use Sublime to do the find and replace and I've had no issues up to now. This time however, the admin won't load! The admin has a strange url also > http://saturdaysinmusic.com/wp- > admin/customize.php?url=http%3A%2F%2Fsaturdaysinmusic.com%2F%3Flang%3Den I noticed also, in the wp-config file of the original site - the database user name doesn't have and doesn't seem to need the username prefix before it. So the new site has `/** MySQL database username */ define('DB_USER', 'jaibles_saturday');` and the old site has just `/** MySQL database username */ define('DB_USER', 'bethlehem');` When I import the database it says > Import has been successfully finished, 51 queries executed. Anyone know what might be going wrong? Cheers, Ciarán


title: Multi-site get_bloginfo('stylesheet_directory') referring to sub-folder

text: I am using multi-site instance, but want each site to use the same themes throughout. When I reference               get_bloginfo('stylesheet_directory');      I was expecting:               http://domain.com/mainsite/wp-content/themes/my-theme       instead I get:               http://domain.com/mainsite/subsite1/wp-content/themes/my-theme     http://domain.com/mainsite/subsite2/wp-content/themes/my-theme      Is their a WP function I can use to get the main them directory only, and not have WP include each site's directory name?


title: Rewriting URLs in Wordpress

text: I am trying to solve a rewrite problem but don't fully understand how to read the below code. I believe the `event/industry/(.+)/?$'` is stating the format I want in my new url after rewritten, which should be example.com/event/industry/someterm/ And this part appears to be the parameter. `=> 'index.php?post_type=eg_event&industry=' . $wp_rewrite->preg_index(1)` Is this a correct understanding? What is telling this code what value to place in my new url where this is: `(.+)/?$'` Is it the `$wp_rewrite->preg_index(1)` and what exactly does the `preg_index(1)` mean? `$new_rules = array( 'event/industry/(.+)/?$' => 'index.php?post_type=eg_event&industry=' . $wp_rewrite->preg_index(1) ); $wp_rewrite->rules = $new_rules + $wp_rewrite->rules; }` Any assistance you can provide with helping me understand the logic above it much appreciated.


title: Primary site file uploads failing, subdirectory subsites upload fine

text: Pardon the cross-posting (also up at Wordpress.org): We're tearing our hair out here. We have multisite configuration working, subdirectory style. File uploads work to the subsites, but the primary (blog 1) site doesn't see any upload traffic. We're running on Ubuntu so have the Debian style configuration layout. /etc/wordpress/htaccess:               # BEGIN WordPress     RewriteEngine On     RewriteBase /     RewriteRule ^index\.php$ - [L]          # viewing attached files     RewriteRule ^/wp-uploads/(.*)$ /srv/www/wp-uploads/%{HTTP_HOST}/$1 [L]          # force HTTPS always     RewriteCond %{HTTPS} off     RewriteCond %{ENV:IS_HTTP} !1     RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R,L=301]          # uploaded files     RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]          # add a trailing slash to /wp-admin     RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]          RewriteCond %{REQUEST_FILENAME} -f [OR]     RewriteCond %{REQUEST_FILENAME} -d     RewriteRule ^ - [L]     RewriteRule  ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]     RewriteRule  ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]     RewriteRule . index.php [L]      /etc/wordpress/config-bclaconnect.ca.php:               $upload_path = "/srv/www/wp-uploads/bclaconnect.ca";     $upload_url_path = "http://bclaconnect.ca/wp-uploads";          # Support for WP Networks functionality     define( 'MULTISITE', true );     define( 'SUBDOMAIN_INSTALL', false );     $base = '/';     define( 'DOMAIN_CURRENT_SITE', 'bclaconnect.ca' );     define( 'PATH_CURRENT_SITE', '/' );     define( 'SITE_ID_CURRENT_SITE', 1 );     define( 'BLOG_ID_CURRENT_SITE', 1 );      And finally, /etc/wordpress/wp-config.php:               define('ABSPATH', '/usr/share/wordpress/');     define('WP_ALLOW_MULTISITE', true);      There is no trace of the uploads in log files anywhere on the system. What on earth is going on? Anyone? Frantic, in Vancouver, Erik


title: AJAX function returning -1

text: I recently developed a small plugin for my site, that uses AJAX, and now I am trying to implement the same AJAX techniques for the same site's templates, but I keep getting `-1` as the result, here is my code, functions.php:                   //Front end AJAX functions              function eu_custom_query(){             global $post;             global $wpdb;                  echo "yo";                  die();         }          function enque_template_scripts() {              wp_deregister_script( 'jquery' );         wp_register_script( 'jquery', 'http://code.jquery.com/jquery-1.6.2.js');         wp_enqueue_script( 'jquery' );                   // embed the javascript file that makes the AJAX request         wp_register_script( 'scripts.js', get_bloginfo('template_directory').'/scripts/scripts.js');         wp_enqueue_script( 'scripts.js' );              // declare the URL to the file that handles the AJAX request (wp-admin/admin-ajax.php)         wp_localize_script( 'scripts.js', 'wp_ajax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );           }                       add_action('wp_ajax_custom_query', 'eu_custom_query');         add_action('wp_ajax_nopriv_custom_query', 'eu_custom_query');         add_action('get_header', 'enque_template_scripts');      scripts.js:               $(document).ready(function(){         $("#do_ajax").click(function(){                 $.post(wp_ajax.ajaxurl, { action: 'eu_custom_query' }, function(data){                     alert(data);                 });         });     });      I'm using Wordpress version 3.2.1 Any ideas on what I'm doing wrong?


title: start_lvl ignored in custom walker_nav_menu

text:
This is my first project involving wordpress and i've got stuck trying to create a custom walker for a footer menu. I basically want to change the menu from the `<ul> <li></li> </ul>` structure to a `<p> <span></span> </p>` structure. The menu and stuff is displaying file and I have been able to adjust the `start_el` and `end_el` functions without issue so I now get this: `<ul> <span>*link*</span> <span>*link*</span> </ul>` Which is obviously half way there, I have written the `start_lvl()` and `end_lvl()` tags as shown below but they are ignored by wordpress - nothing I put in them (even `die()`) is executed (which is a bit suspicious) but I know the class is being called because of the `start_el()` function.               function start_lvl(&$output, $depth = 0, $args = array()) {         $output = "\n
\n";     }          function end_lvl(&$output, $depth = 0, $args = array()) {         $output .= "\n
\n";     }      Does anyone know why this is happening - have I missed something really obvious!? I am running the latest version of wordpress on apache with php 5.3.6 if it helps. Thanks in advance, Felix :)


title: Removing width and height attributes from wp-get-attachment

text: I'm using this http://www.ghosthorses.co.uk/production-diary/removing-inline- img-dimensions-for-responsive-wordpress-websites/ to remove the height and width attributes of images. Everything works fine except that it messes up the masonry container because of the images have no height. How could I apply this filter only to a determined div id/class?


title: login_redirect for Mobile Web

text: I have a mobile version of my website at `mywebsite.com/mobile` and there is a login form which posts to `wp-login.php`. Currently, when users login from the homepage, they are redirected to their Buddypress profile if they are not admin.   I would like to keep this in place if they login from the home page, but, if they login from `mywebsite.com/mobile`, I would like them to be redirected to `mywebsite.com/mobile/dash`.               //REDIRECT USERS TO ACTIVITY PAGE WHEN THEY LOGIN     add_filter( "login_redirect", "bpdev_redirect_to_profile", 10, 3 );          function bpdev_redirect_to_profile( $redirect_to_calculated, $redirect_url_specified, $user )     {         /* If logging in from website.com/mobile,             which has a login form which posts to wp-login.php,             redirect to website.com/mobile/dash         */         if( empty( $redirect_to_calculated ) )             $redirect_to_calculated = admin_url();              /* If the user is not site admin,redirect to his/her profile*/         if( !is_site_admin( $user->user_login ) )             return bp_core_get_user_domain( $user->ID );              /* If site admin or not logged in,do not do anything much */         else             return $redirect_to_calculated;      }


title: Custom post type admin search

text: Is it possible to search in custom post type meta fields? I have posts, with many custom meta fields. Wordpress by default search only in title and in content. How can I change it? **If you didn't understand what I am saying, please take a look at myscreenshot.**


title: Sorting Custom Posts by category

text: I want to sort posts of my custom post type on a page. i.e. any visitor can select a category from drop down to list posts of that category on top. Can any one help to do this task? I tried a lot and get tired.


title: Separate URL for a specific page

text: I have 3 sections to a website, each it's own page. A page for the company and one each for the two founders. Each of the founders would like their page to be under their own domain, but still be able to update from the main Wordpress site. At the moment I am using iframes for their pages, but obviously this is not a great way of doing it. Can I set a custom URL for specific pages? Thanks


title: Is there a ready-made fix to make the admin bar not obscure content?

text: I have a situation where the Wordpress 3 Admin Bar (which is cool and I do want to have) obscures some important information on my page. Before I start fiddling with the CSS myself (which I'm sure will break stuff): Is there an existing patch to change this so the Admin Bar starts "above" the actual page? I realize there may be CSS complications (especially with absolutely positioned elements), but it should be possible.


title: How can i get custom field to apear on my wordpress admin area (post_type)

text: I had an issue with WordPress posts_type , the custom fields which are normally at the bottom of each post page were missing. At the top of your WordPress post page you will see a small grey box that says.. Screen Options. Click this option and then it will provide you with a drop down menu. I ceck the custom field, it apears but after i Publish The page it disepear again.. I disable all the plugin but no sucess... the same... How i register my custom post type...               /* ------------ Post Type Stiri -----------*/     register_post_type('stiri', array(  'label' => 'Stiri','description' => '','public' => true,'show_ui' => true,'show_in_menu' => true,'capability_type' => 'post','hierarchical' => true,     'rewrite' => array('slug' => ''),     'query_var' => true,'has_archive' => true,     'menu_position' => 5,'supports' => array('title','editor','custom-fields','category', 'post_tag',),     'labels' => array (     'name' => 'Stiri',       'singular_name' => 'Stire',       'menu_name' => 'Stiri',       'add_new' => 'Add Stire',       'add_new_item' => 'Add New Stire',       'edit' => 'Edit',       'edit_item' => 'Edit Stire',       'new_item' => 'New Stire',       'view' => 'View Stire',       'view_item' => 'View Stire',       'search_items' => 'Search Stiri',       'not_found' => 'No Stiri Found',       'not_found_in_trash' => 'No Stiri Found in Trash',       'parent' => 'Parent Stire',     ),) );          register_taxonomy("stire","stiri", array("hierarchical" => true, "label" => "Cat Stiri", 'show_ui' => true, 'query_var' => true, "singular_label" => "stire", "rewrite" => true , 'with_front' => true));      If annyone have a solution please post here


title: Using a _GET gives me a debug error (over my head)

text: Just looking for some advice on something that is bugging me. Please bear in mind I am a PHP noob :-) I am passing a variable in the url to my WP index page like so:               <a href="<?php bloginfo('url');?>/?do=thing">Thing      I am the catching that variable, and using it to show content like so:               <?php $do_that = $_GET["do"]; if($do_that == 'thing') : ?> etc      Naturally I am getting debug errors when the variable is not passed :-)               "Undefined index: do"      My question is what am I missing wrong? Obvious I spose? Also is this bad practice?


title: Image doesn't show since 3.5.2

text: I have a Wordpress blog which has a self written plugin for the front page. For every article you write you can upload an image and it gets directly sent to the front page. For the last months everything worked just fine. Until today I tried to upload an new image and nothing happend. There was no error or similar at all - it just didn't show up (usually u see it already on the admin page as a thumb) All the other images on this blog work just fine. U can upload, download and delete them as you want to. I already disabled all plugins, but nothing changes. Is there any known problem about the image_upload in 3.5.2? (especially with the command: move_uploaded_file(...) ) I really don't know, if that's the issue in my case, but at least that's one part which changed in the last three weeks.. Thank you so much already in advance, take care


title: Add category attribute to custom shortcode

text:
I have created a custom post type called "faq". The custom post type uses categories. I have created a shortcode [faq] that displays all the faq posts. What I would like to do is add an attribute to the shortcode that specifies an faq category. So instead of using the shortcode [faq] it would be something like [faq category="travel"] and it would only display the posts from the "travel" category. I am using the following code for the shortcode at the moment. I just need to add the category attribute somehow:               add_shortcode('faq', function() {              $posts = get_posts(array(  //Get the FAQ Custom Post Type             'numberposts' => -1,             'orderby' => 'menu_order',             'order' => 'ASC',             'post_type' => 'faq',         ));              $faq  = '
'; //Open the container         foreach ( $posts as $post ) { // Generate the markup for each Question             $faq .= sprintf(('
%1$s

%2$s
'),                 $post->post_title,                 wpautop($post->post_content)             );         }         $faq .= '
'; //Close the container              return $faq; //Return the HTML.     });


title: Make title field multiline in the add new custom post page?

text: I have a custom post type named "news". The title field holds the raw news and i added another custom field that holds the published news. The published news field is a text area so i can use enter button when editing. Is there a way to make the title field behave like that, to edit in multiline? thanks


title: Dynamic image crop in WP 3.0+?

text: Since WP 3.0 does not support hard crop anymore (the only way to crop is in media manager), how am I suppose to dynamically crop my thumbnails? I don't want to crop them manually one by one...


title: Am I allowed to resell Wordpress Premium Plugins under GPL?

text: I have seen a few websites around that resell premium plugins and extensions such as the Woocommerce Extensions, is this allowed? Not too sure where to ask this question either.


title: how to show posts on different pages if number of post per page is one

text:
i have a category named "services". when "our services" is clicked control go to category.php file. in that i need to show all the posts in that service category. i can show all of them in a single page. but i need to show them with pagination where there should be one post per page. i use the below portion to give pagination.
                         <?php global $cat_name;          $cat_name = get_category(get_query_var('cat'))->name;          echo '
'.$cat_name.'
';               ?>                         <?php if ( have_posts() ) :                                   ?>                         <?php query_posts('category_name='.$cat_name.'&posts_per_page=1&order=ASC'); ?>             <?php while (have_posts()) : the_post();?>                   <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

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

      <?php the_excerpt();?>

             <?php endwhile; ?>                     <?php endif; ?>
<?php previous_posts_link('« Previous') ?>

<?php next_posts_link('Next »') ?>
      i have totally 3 posts in the service category.as per the code it shows only one post per page. but when i click next page not found error is occuring. what should i do?


title: I want to replace a media file (pdf) with an updated version

text: I have an updated version of a pdf file which is linked to several pages and pending posts. I want to replace the old version with the new one and keep all the existing links. Thank Priya


title: How can I redirect on a url after successful registration?

text: I am a newbie to Wordpress. I am currently working on registration and login. I have a page restrict url let `http://xyz.com/abc`. Login/registration is required for this url. I need that when a user register or login then it should be redirected on this previous url. In login I have added the following hook :               add_filter('login_redirect', 'redirect_previous_page', 10);          function redirect_previous_page(){              global $user;         $request = $_SERVER["HTTP_REFERER"];              if ( in_array( $user->roles[0], array( 'administrator') ) ) {                  return admin_url();             return $redirect_to;              } elseif ( in_array( $user->roles[0], array( 'subscriber') ) ) {                  return $request;             return $redirect_to;              }           }      It is working for me, but I am not getting how can I redirect on this url after successful registration. I have registration link on the login page


title: Is it possible to create a login for restricted visibility?

text: I use eStore (from Elegant Themes) with Woocommerce to build a webshop. I want to add a login page for wholesalers to login and have access to different products (2014 collection) and different price of the current collection. The 2nd wholesale webshop should not be visible unless the user is logged in. Would Multisite be the solution? (But would I still have to connect iDeal to both sites?)


title: How to stop Navigation

text: When we click on next, prev buttons of image browser it is working fine. suppose if we have 10 images when we are one tenth image.when we click next it is showing again first image. That shouls not happen. how to stop this. Similarly when we are on first image if we click prev it is showing tenth image.. That should not happen. how to stop this navigation


title: wp_nav_menu() reutrns HTTPS?

text: We have SSL for our domain. But there's only one page want to use SSL to appear on (`https://mydomain.com/secure-page/`). All others should be regular `http://` pages. So we've set **siturl** and **homeurl** both to `http://domain.com` and hardcoded link to secure-page. On regular pages, all the navigation and others links appear non-ssl (`http://`) which is fine. But when on `https://domain.com/secure-page`, wp_nav_menu() returns `https://` URLs for all other pages of site which we don't want. Remember, siteurl and homeurl both are `http://`. Why is it returning all https:// links for nav items? **EDIT** It is client's requirement unfortunately. There's only one page in site with HTTPS.


title: Find out in which kind of archive am I

text: in `archive.php` file, I want to know, which type of archive I i'm in. For example, if I i'm in archive for category **Personal** I'd like to be able to display it in header of the archive. Of course, I can create file like `category-12.php`, `category-13.php` ... and then harcode it in the file, but it doesn't seem to be very good example of code reuse. Thanks for answers.


title: Pagination Adding Numbers in Strange Fashion

text: Below is my pagination code. It can be seen in action at this link. When I start on page one it displays the first 3 pages and page 9 (the last page). When I go to the second it displays the first 4 and page 9. I find this to be odd behavior and expect the numbers to be added in a traditional behavior, like that code found on CSS tricks. Does anybody know what I've done incorrectly in my code below?                // the block for pagination             global $wp_query;             $big = 999999999; // need an unlikely integer             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                 )             );


title: Generating custom URL before post is published

text: I have implemented a `post_type_link` filter for my custom post and this is working great. However, the only downside is that the final URL only seems to be created when the post is published. What I'd like is to create the custom URL after a user has typed in a title for the post. I'm having trouble finding the correct hook (filter/action) to accomplish this. Does anyone know what the best way is to hook into the URL generation before a post is published?


title: Get Tags by specific Category of Custom Post Type

text:
Hey there & merry Christmas Experts :-), if want to have the following Scenario: Custom Post Type "Portfolio" with Tags (Filters) and Categories (Portfolio Groups) Let's say a 1\. Webdesign Category with Tags (for Filters) PHP, HTML, CSS 2\. Photography Category with Tags (for Filters) Animals, Landscape Now I can choose in the Backend from a Metabox from which Category/Categories I want to show the Portfolio. (That's what I have so far) I Struggle with the Frontend: In the Frontend I now have to Pull the Tag-List from the chosen Portfolio Categories. Then Pull the entries (title, permalink, ...) from the chosen Categories and display the appropriate tags. Custom Post Type is called: portfolio Portfolio Tags called: portfolio_tag Portfolio Categories called: portfolio_category That's what I have so far: Tags don't get pulled by selected categories, instead from all categories :/....

            <?php $tags = get_categories('taxonomy=portfolio_tag&title_li=');            foreach ($tags as $tag){ ?>
<a href="#" data-filter=".term-<?php echo $tag->name;?>" title="<?php echo $tag->count;?> <?php _e('Items', 'minti'); ?> "><?php echo $tag->name;?>
            <?php } ?>

          // Array of selected categories:      // wp_get_object_terms( get_the_ID(), 'portfolio_category'      I'm searching for the easiest, cleanest way to do this and I'm a PHP noobie :-) Hope you can help me out. Thanks


title: custom changes removed after plugin update

text: Ok that's something normal, files are being downloaded again and the code changes. What should I do if I don't want some changes to take place? For example a gallery plugin I use recently updated and a border I didn't want to appear in the gallery now exists again. Updates should always take place for security reasons but how should I override such behavior? Is there a way I can have another file that doesn't allow for example that border effect to take place ? Maybe with jQuery somehow ?


title: Customize comment list markup

text: While creating a new theme, we'll have to customize the comment flow. For doing so there are two functions: `wp_list_comments()` and `get_comments()`. I am not very sure how to style the inner elements that appear from it such as Gravatar, comment description, comment author, etc. In order to do some styling for them, I first of all need to know the DOM elements assigned to them. Where can I go to find about them? I've tried in almost all the sources, I am unable to understand properly.


title: Wordpress post count not showing for custom post type author

text: I've created a few custom post types based on Dave Rupert's boilerplate and then migrated existing posts to these newly created CPTs via Post Type Switcher plugin. I did not make any changes to the boilerplate apart from changing CPT name and `support*` attributes.               'supports' => array(        'title',        'editor',        'author',        'thumbnail',        'excerpt',        'comments'     ),      Migrated posts correctly display their authors and it is possible to change posts' author. However, when I view author list in **Users** section, the post counter for non-admin authors is **zero (0)**. Temporarily changing author role to admin and back again does not help to show the correct count of posts for individual authors. I checked the database records as well (pls check view from _wp_posts_ table below). Authors IDs seem to be correctly assigned to individual posts. Still I think I broke the post-author relation somewhere in the database, but I can figure out where. Does anyone know how to tackle this issue? ![view from wp_posts table](http://i.stack.imgur.com/u9AWa.png)


title: "post-format" code snippets list

text: ### What is it about? This Q shall become a collection of code snippets about post-formats and their use cases. ### What to add? Please add snippets/functions/classes/project-links about...   * Pulling & transforming specific data from the post for presentation. For e.g. "link"   * Improvements for the admin UI. For e.g. filtering the list view, adding meta boxes & custom fields to new posts. ### How to add Please add a h3-heading first. It should contain the post-format it's about or "admin UI detail/list", so the thread is easily readable. Please then add a short description and then your snippet. Commented code is highly appreciated. Thank you!


title: How to add post meta to post permalink with still keeping a good performance?

text: the following problem - I want to completly change my post permalink structure to be like this: www.example.com/%post_id%/%post_meta_value1%-%post_meta_value2%-.... It would even be more nice to have a permalink structure like this: www.example.com/%post_meta_value1%-%post_meta_value2%-.... The problem is not that I did not find a work-arround how to achieve this:               add_action('save_post', 'set_slug');          function set_slug($post_id){         $new_slug = get_post_meta($post_id,'meta_key1', true)."-".get_post_meta($post_id,'meta_key2', true);             $post_args = array(             'ID' => $post_id,             'post_name' => $new_slug,         );              wp_update_post($post_args);     }      The problem is that I am expecting a very, very large number of posts and I am afraid that the performance will be really bad? So how can I make sure, that WordPress will find the correct correspondig post fast, although using such an exotic permalink structure? Or is there (for what reason?) no performance problem to be expected?


title: Reduce number of SQL queries inside WP_Query loop to fetch author data

text: This question applies to scale and does not concern typical blog implementations. I'm working on a web app where I'm running standard WP_Query to fetch some custom post types. This usually results in running of about 10 SQL queries. Within the loop I need to access both `post meta` for the post and `user meta` for the author of the post. Accessing post meta is trivial with use of `get_post_meta` inside of the loop. WordPress caches results of WP_Query and hence "does not make" additional queries each time `get_post_meta` called within the loop. However, things get ugly when retrieving user data for the post author. Typically I would need to call `get_user_by` within the loop to fetch user data. Here comes the problem. If I use `WP_Query` to fetch 50 posts `each by a different author`, calling `get_user_by` within the loop results in 100 SQL queries (two queries for each user for fetching data from `users` table and `usermeta` table). This is in addition to the 10 SQL queries I mentioned earlier. 110 SQL queries! — this is insane. Next, I thought of using `WP_User_Query` to fetch user data before the loop runs.                   $custom_query = new WP_Query($args);         foreach($custom_query->posts as $post) {             $post_authors[] = (int)$post->post_author;         }         $user_query = new WP_User_Query( array('include' => $post_authors) );      I expected `WP_User_Query` to be smart like `WP_Query` and reduce the number of queries. This did reduce queries to 51 as opposed to 100 earlier. One query hit the `users` table `for all users` and 50 queries hit the `usermeta` table `one for each user`. Better, but not what I expected. How do I reduce the queries for my scenario?


title: Integrating Nextgen Gallery with Gallerific

text:
First time posting in the Wordpress area of Stack Exchange. Hopefully someone will be able to help me with an issue. I have successfully integrated Gallerific with the NextGen plugin.The one issue that I am having is that I simply cannot figure out how to rotate the image description with the image. I can only get the image description to appear under the thumbnails. I'm sure it's something simple, but I have been staring at it for so long that I am probably missing the obvious. Any help is greatly appreciated! Here is my code: The NextGen custom template:               <?php                /**      Template Page for the gallery overview          Follow variables are useable :          $gallery     : Contain all about the gallery     $images      : Contain all images, path, title     $pagination  : Contain the pagination content           You can check the content when you insert the tag <?php var_dump($variable) ?>      If you would like to show the timestamp of the image ,you can use <?php echo      $exif['created_timestamp'] ?>**/     ?>          <?php if (!defined ('ABSPATH')) die ('No direct access allowed'); ?><?php if (!empty ($gallery)) : ?>          <div class="ngg-galleryoverview" id="<?php echo $gallery->anchor ?>">          <?php     /**     *GALLERIFFIC     */     ?>

          <?php foreach ($images as $image) : ?>
     <a class="thumb" href="<?php echo $image->imageURL ?>" title="<?php echo $image- >description ?>" <?php echo $image->thumbcode ?> >     <img title="<?php echo $image->alttext ?>" alt="<?php echo $image->alttext ?>" src="<?php echo $image->thumbnailURL ?>" width="125" height="100"<?php // echo $image->size ?> />

<?php echo $image->description ?>

     <?php endforeach; ?>
          <?php echo $pagination ?>
     <?php endif; ?>      And here is the custom Wordpress page template with the Gallerific javascript:               <?php     /*     Template Name: Photo Gallery 2     */     get_header();     ?>

     <?php if (have_posts()) : while (have_posts()) : the_post(); ?>     <div <?php post_class() ?> id="post-<?php the_ID(); ?>">
     <?php the_content(); ?>

     <?php endwhile; else: ?>     <?php endif; ?>

              <?php get_footer(); ?>


title: Filter/Remove HTML Elements on all posts and pages

text:
I'm working on a migration from Drupal to WP. The database conversion and import went smoothly, but there is a lot of 'crap' in each post content such as divs with inline styles. Basically, in each post (over 800 of them) I need to sort through them, remove all div tags but keep the actual content between the div tags. Examples A post with content like this:

Dear Neil: I am 55, and find myself single all over again. Trying to find a relationship is radically different than it was when I was in my 20s. I want to remarry, but it's harder to date at this age, and it is very difficult to evaluate whether someone would be compatible with me. I know I'm not as “hot” as I used to be, and the people I'm meeting aren't likely to win “sexiest man alive” contests anytime soon as well. Is there anything that could help me evaluate whether someone is a good potential intimate partner for me? There are millions of us in the second half of our lives trying to find each other. Can you help?

More content.....

      I need to run some sort of script (with regex?) that will remove the 'crap' but keep the text between div and span tags :               Dear Neil: I am 55, and find myself single all over again. Trying to find a relationship     is radically different than it was when I was in my 20s. I want to remarry, but it's harder to date at this age, and it is very difficult to evaluate whether someone would be compatible with me. I know I'm not as “hot” as I used to be, and the people I'm meeting aren't likely to win “sexiest man alive” contests anytime soon as well. Is there anything that could help me evaluate whether someone is a good potential intimate partner for me? There are millions of us in the second half of our lives trying to find each other. Can you help?          More content.....      Any ideas on the best way to accomplish this? Help is greatly appreciated.


title: Are transients garbage collected?

text: This question got me thinking Transient RSS feeds in wp_options not removed automatically? Transients are supposed to expire and be deleted. However the only way I see this handled is when transient is expired and requested, then it is deleted during request. What if transient is expired but never requested after that? From description in Codex I thought that some kind of garbage collection is implied. Now I am not so sure and can't find any code that performs such. So will it just be stuck in database forever?


title: My WordPress installation isn't updating the feed when a new post is published

text: My WordPress installation was working quite well, however it recently stopped properly updating feeds when new posts are published. I may have deleted a tranistent feed table using the Clean Options WordPress plugin. I don't know if that's the cause, but I can force it to update by changing one of the Feed settings manually each time. How can I get it working properly again? Any suggestion would be appreciated. Thanks!


title: fetch images and videos

text: Is it possible to fetch videos and images of a particular website and put it into post? i mean i am thinking of writing a function, where i will just write the website name, and then with the help of website url, all or latest images and videos are posted to my post. Is this possible?


title: Append varible to url or set session

text: I just wrote a little plugin that detects if the user is on a mobile browser and if so detects them away from the WordPress site to a mobile (simple) version of part of the site. As I got to thinking I'm redirecting user who may want to see the full site. I can easily add a check by creating a URL such as `http://example.org?force_web=true` The only problem is my plugin checks the top of each page to see if it's mobile so I would need to set `force_web=true` on all pages. The other idea would be to use sessions but it seems WordPress doesn't support sessions unless you add `session_start();` to your `wp_config.php` file which I don't want to ask the plugin users to do. Is this something others have experienced? Is the best way to re-write all permalinks with the addition of my variable? Open to ideas and suggestions


title: Unable to center menu and header image twenty twelve

text: I have a really simple site at cyriljoyce.com on the 2012 theme I created a child theme to center the header and menu bar but just cannot seem to make it work. The child theme text is below The line at the bottom used to center the header image but when I changed the menu on the site it stopped working.               /*     Theme Name:     Twenty Twelve Child     Theme URI:      http://cyriljoyce.com/     Description:    Child theme for the Twenty Twelve theme     Author:         Cyril Joyce     Author URI:     http://cyriljoyce.com/about/     Template:       twentytwelve     Version:        0.1.0     */     @import url("../twentytwelve/style.css");          .header-image { margin-left: auto; margin-right: auto; display:block; }


title: Conditional Statement custom post type category

text: I would like to display a text depends of my custom taxonomy category, like: if _custom post type category_ is _X_ , then echo _Text Y_. I've tried this, but its not working:               global $post;      if (($post->post_type == 'myposttype') && is _category('slug-name-of-cat')) {      echo 'My text'           }      any ideias?


title: Change default upload images size for contributors

text: When a contributor uploads an image to a post, the default image size option is set to Medium. How can I change it to Large or Full?


title: Tag, Category and Single Conditionals

text: We have this sample: This function call Backgrounds in different places in the WP I add it to the `<body>`               <?php          function backgrounds(){       global $wp_query;            if(is_home() || is_front_page()){         echo "style=\"background-image:none;\"";            } elseif(is_category('1') ||  is_tag('2')) {         echo "style=\"background-image:url(image1.jpg); background-repeat:no-repeat; background-position:top center\"";            } elseif(is_single('3')) {         echo "style=\"background-image:url(image20.jpg);\"";            } elseif(is_category('4') ||is_single('100') || is_single('101')) {         echo "style=\"background-image:url(image90.jpg); \"";            } elseif (!is_category() || is_tag('5')) {              echo "style=\"background-image:url(image4.jpg);\"";            } elseif(is_category('6')) {         echo "style=\"background-image:none;\"";            } elseif(is_category('7')) {         echo "style=\"background-image:none;\"";            } elseif(is_single('8')) {         echo "style=\"background-image:url(image9.jpg\")";       }                    }          ?>      Scenario: I add a new post and I select the tag 5 which will have a different background and this post belongs to Category 1 which this category(category.php) have another background. Context: tag-5.php is showing the correct background single of Category 1 that Tag 1 was added is showing the correct background (tag 1 background) with has_tag(). then Category 1(category.php) is showing the background of tag 1 , and this is wrong How can I prevent this? thanks


title: How to include css for plugin setting page?

text: I have created a plugin settings page in the WordPress dashboard menu. I want to include css file for that settings page. How can I do that? I am trying following in my plugin, but it does not include the css file on the plugins settings page:               function my_enqueue_styles() {         wp_enqueue_style( 'my_plugin', plugins_url('my_plugin/plugin.css') );     }     add_action( 'wp_enqueue_scripts', 'my_enqueue_styles' );


title: Check php version before theme activation

text:
I've got theme that requires php 5.3+ version. If older - fatal error occurs with it. So what I need to do when user try to activate this theme is to check php version before going into theme code and then, if php version is too old, show some message and **don't** activate my theme, but stay with the one that was active before Is it possible? I've got this code to check version               define("THEME_REQUIRED_PHP_VERSION", '5.3.0');     define("THEME_IGNORE_PHP_VERSION", 0);                  //check if good php version             if ( !THEME_IGNORE_PHP_VERSION&& version_compare(phpversion(), THEME_REQUIRED_PHP_VERSION, '<')) {                 // php version isn't high enough                 wp_die("
You need to update php version.
Too old version of PHP to run Circle Theme. Actual version is " . phpversion() . ", required is " . CIRCLE_REQUIRED_PHP_VERSION . ".", "Theme");             }      However this cannot be becouse theme is activated anyway and user can't do anything.


title: Moving a remote Wordpress multisite installation to local

text: I hope someone here can point me to some good resources to start moving my Wordpress multisite installation (already running for a year) to my local environment. A lot of the tutorials out there are doing it the other way around (moving local WPMU to remote) or there about installing a clean install of WPMU locally, but I want to move everything with all my content right now. I'm a Mac user so I got everything I need to run it locally. MAMP is working, I have my sync folder running to the remote location, but I'm getting stuck at moving the database to local and I have this plugin installed called 'domain mapping' and I'm not sure how this is going to work locally. The software I prefer to use MAC: Sublime text 2|3, MAMP pro, Codekit, SFTP, Chrome WEB: PHPmyadmin, wp Migrate DB Pro, WordPress MU Domain Mapping, Bitbucket


title: Forgot password not working

text: I have been trying to reset my admin password for my local install of wordpress running on MAMP. Previously had been working fine but I forgot the password but when I go through the process of 'Lost your password' I am meant to get an email with new password but it never arrives in my hotmail (also checked the junk) I know these can sometimes take a while to come through but it has been a day now.. Any ideas I could try? Thanks


title: Custom "radio button meta box" not saving correctly

text:
I'm having trouble with my "custom meta box/write panel" script that contains radio buttons. (see below)...It currently does not seem to save the selection made after publishing the custom post type, not sure what Ive missed??? _How I plan to utilize this essentially is by letting the client choose one of the radio button choices, and depending on what selection is made I will output that as a class into an anchor tag to help instantiate a specific image overlay._ Thank you for your help!               <?php     add_action( 'add_meta_boxes', 'musicreleases_linktype_meta_box_add' );     function musicreleases_linktype_meta_box_add()     {         add_meta_box( 'musicreleases_linktype_meta_id', 'Link Type (Optional)', 'musicreleases_linktype_meta_box_cb', 'eprmusicrelease', 'normal', 'low' );     }          function musicreleases_linktype_meta_box_cb( $post )     {         $values = get_post_custom( $post->ID );         $radio = isset( $values['meta_box_musicreleases_linktype'] ) ? esc_attr( $values['meta_box_musicreleases_linktype'][0] ) : '';         wp_nonce_field( 'my_meta_box_nonce', 'meta_box_nonce' );         ?>
             <input type="radio" name="linktype" value="freedownload_album" <?php echo ($radio); ?>/> Free
             <input type="radio" name="linktype" value="buyonitunes_album" <?php echo ($radio); ?>/> iTunes
             <input type="radio" name="linktype" value="none_album" <?php echo ($radio); ?>/> None

         <?php        }          add_action( 'save_post', 'musicreleases_linktype_meta_box_save' );     function musicreleases_linktype_meta_box_save( $post_id )     {         if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;         if( !isset( $_POST['meta_box_nonce'] ) || !wp_verify_nonce( $_POST['meta_box_nonce'], 'my_meta_box_nonce' ) ) return;         if( !current_user_can( 'edit_post' ) ) return;              $allowed = array(              'a' => array(                  'href' => array()              )         );              if( isset( $_POST['meta_box_musicreleases_linktype'] ) )             update_post_meta( $post_id, 'meta_box_musicreleases_linktype', wp_kses( $_POST['meta_box_musicreleases_linktype'], $allowed ) );     }     ?>         ## EDIT #1 Seems to be working great now, thank you for the help!   Only problem now as I mentioned is its not showing which radio button has been selected after hitting publish...(see below) ![enter image description here](http://i.stack.imgur.com/SSuNm.png)    ## EDIT #2 Also curious how it may be possible to output the "pretty version" of each inputs _value_ for my custom columns so that they appear like - "iTunes", rather then "buyonitunes_album". ## EDIT #3 No big deal if this isnt possible, but is there any way to potentially make the values appear neater for the columns? ie. **"freedownload_album" -> "Free", for example**. ( _See below_ ) ![enter image description here](http://i.stack.imgur.com/YnIrA.png) This is how Im currently outputting the value to my columns...               function eprmusicrelease_custom_columns($column){         global $post;         switch ($column)         {             case "albumthumb":                 if (has_post_thumbnail($post->ID))                     echo get_the_post_thumbnail($post->ID, 'music-release-img-col');                 else                     echo 'No Image Available';                 break;             case "albumlink":                 if (get_post_meta($post->ID, 'meta_box_musicreleases_url', true))                     echo make_clickable (get_post_meta ($post->ID, 'meta_box_musicreleases_url', true));                 else                     echo 'No URL Chosen';                 break;             case "linktype":                 echo get_post_meta($post->ID, 'meta_box_musicreleases_linktype', true);                 break;             case 'author':                 echo get_post_meta( $post->ID , 'author' , true );                  break;             case 'date':                 echo get_post_meta( $post->ID , 'date' , true );                  break;         }     }     ?>


title: Webdav with permalink in Wordpress v3.3.1

text: I've deployed wordpress and I'm using it with postgreSQL, I've configured permalinks successfully, but my webdav folder stoped to work. When I try to access my webdav folder it prompt to use my login and password, but when I proceed it return me 403 forbidden. Is there some way to make both work together?               <VirtualHost *:80>             ServerAdmin yamash.ox@gmail.com             DocumentRoot /usr/share/wordpress/             <Directory />                     Options FollowSymLinks                     AllowOverride none             </Directory>             <Directory /usr/share/wordpress>                     Options Indexes FollowSymLinks MultiViews                     AllowOverride all                     Order allow,deny                     allow from all             </Directory>          <Location /webdav>         Options Indexes         DAV On         AuthType Basic         AuthName "webdav"         AuthUserFile /etc/apache2/webdav.password         Require valid-user     </Location>      I´ve found my own answer for this problem, I've edited my /site- avaiable/default/, added `Alias /webdav "/var/www/webdav"` And I've moved my folder to /var/www/webdav/, now its working when I try to access it by using `http://10.0.0.36/webdav`.


title: External link nested in wp_list_pages

text:
I'm using `wp_list_pages` to return the children of a page. I want to 'replace' one of the returned links with a link to an external page. Currently I am using exclude to exclude the page I wish to replace               $children = wp_list_pages('exclude=111&title_li=&child_of=' . $post->ID . '&depth=1&echo=0');      and simply add the page in a list above the returned list

Google
     <?php echo $children; ?>
      This is ok as it returns the link at the top of the returned list, but I wish to replace / insert the external link within the returned list. I tried str replace, but I couldn't get it to work. There must be an easier way?


title: Why isn't wp_enqueue_script('jquery-masonry') working?

text: I'm trying to add masonry sript to my site, but `wp_enqueue_script('jquery- masonry');` is not adding the script. Instead I have to use:               wp_register_script('jquery_masonry', includes_url(). '/js/jquery/jquery.masonry.min.js', 'jquery');     wp_enqueue_script('jquery_masonry');      Why is that?


title: How to add multiple images in a page

text: I am developing a WordPress Theme and I've got stuck in a point. What I want to do is to add a box at the right of page editor so the admin of the site can add multiple images on the fly in this concrete page. I've found that WooCommerce has this box enabled at the product creation editor. Do anybody know how can I create this box and how to access the uploaded images from the frontend? Thank you in advance.


title: Sorting posts according to view counts not working

text: I use the code snippet below to get views count of each post on my sidebar.php . everything works but the sorting does not. also it does not get 4 posts, it only shows 1 post although I've written `'numberposts' => 4` . I guess the problem comes from post query. because when I'm on homepage, it shows the last post of website not in my custom post type. ( e.g. the "Hello World!" post) when I'm in archive page, it gives the last post of my custom post type. Can anybody find the problem ? Thanks **THE FUNCTION :**               function getPostViews($postID){         $count_key = 'post_views_count';         $count = get_post_meta($postID, $count_key, true);         if($count==''){             delete_post_meta($postID, $count_key);             add_post_meta($postID, $count_key, '0');             return '0';         }         return $count;     }          // function to count views.     function setPostViews($postID) {         $count_key = 'post_views_count';         $count = get_post_meta($postID, $count_key, true);         if($count==''){             $count = 0;             delete_post_meta($postID, $count_key);             add_post_meta($postID, $count_key, '0');         }else{             $count++;             update_post_meta($postID, $count_key, $count);         }     }      **THE CODE I ADD TO SINGLE.PHP:**               <?php setPostViews(get_the_ID()); ?>      **THE CODE I USE AS POST QUERY TO GET AND SORT POSTS:**               query_posts(array(             'numberposts'  => 4,  /* get 4 posts, or set -1 for all */             'orderby'      => 'meta_value_num',  /* this will look at the meta_key you set below */             'meta_key'     => 'post_views_count',             'order'        => 'DESC',             'post_type' => array('news','database'),             'post_status'  => 'publish'         ));         $myposts = get_posts( $args );             foreach( $myposts as $mypost ) { ?>             <a href="<?php the_permalink(); ?>"><?php the_title(); ?>         <?php             }             wp_reset_query();         ?>


title: Silly Problem Referencing a Post ID

text: Hey there I have a stupid problem I'm having trying to integrate a button in wordpress. I have a plugin called wp azon builder which has an onsite cart button (add to cart stays on site) then I have the theme knightzon which has a cart button but the knightzon button links to amazon directly. I need to change this so it adds to onsitecart like the plugin. I have it mostly figured out I just can't seem to reference the post id from outside the plugin framework. Sounds easy I'm just tired of it. http://www.syracusefanpages.com   You can see what I'm trying to do in the slider I have it almost working LOL, and I included a working button example in the list view, but its pointing to a static product for demonstration purposes. I'd like to use the gray button image. **Update** I need to know how to call the page ID, I guess? This is what I was using:               <?php the_post(); ?>      Here is the plugin button code from the source, (what I want):               // on-site cart      if (get_option('amzn-onsitecart') == "Yes") {          $addtocartcode = '';      }      Here is what I have currently (it doesn't see the button function I'm guessing from not properly calling the post id)               <a rel="nofollow" target="_blank" title="<?php the_title(); ?>" href= '#' onclick="amzn_onsitecartAdd('<?php the_post(); ?>');" class="amzn_buynowimage amzn_addtocart_onsite_link">;      The gray button from theme is what I'd like to use but that's not important, I just can't get the function to function, :-)


title: Attach custom gallery to a page

text: I am developing my first WordPress website and am trying to find a way to do the following. Website editor needs to be able to create image gallery pages by attaching multiple images with metadata when creating a new page. For each gallery image there are full size and thumbnail images as well as image description. I would like to use some plugin similar to NextGen gallery to manage picture libraries in Wordpress but i don't want this plugin to actually display any pictures - I have a custom made jQuery gallery for this. My html code will have to be produced by a custom page template. So, I am looking for either a plugin which would allow me to "attach" grouped custom fields to a page (images or image URLs and descriptions), or may be a direction how to customize a plugin like NextGen Gallery so that it didn't add any of it's code to my pages. Also, possibly please consider that I am not a PHP dev and I won't be able to do difficult code customizations without good guidance. Many thanks for any help.


title: Formatting custom meta box date from YYYY/MM/DD to a more readable alternative

text: ## QUESTION This is following a previous question that was graciously answered by Milo earlier here - How to sort CPT by custom meta value (date), and return posts month by month In short, I'm having some issues with properly formatting my custom meta box date's in a few areas... Namely, in the back-end in my custom columns, and then in the front-end in my archive template. For example, in my archive template I'm trying to return the current date that the posts belong to via the code pasted below, but when I visit a month with no posts my template returns the date "January 1970" instead.               <?php $calendar_month = get_post_meta($post->ID, 'epr_startdate', TRUE);?>     <?php $this_month = strtotime($calendar_month); ?>     <?php echo date( 'F Y', $this_month ); ?>      Additionally, in the back-end I'm trying to have it so that if just the "start date" is created then ONLY output that information, whereas, if the user enters both a "start date" and an "end date" then retun both dates, but when I use the code example below my start dates are returned in duplicate like this instead: Mar 3, 2013 — Mar 3, 2013.               case "eventdate":                     $eventstart = get_post_meta($post->ID, 'epr_startdate', true);                     $eventstart_col = strtotime($eventstart);                          $eventend = get_post_meta($post->ID, 'epr_enddate', true);                     $eventend_col = strtotime($eventend);                          if ( get_post_meta($post->ID, 'epr_startdate', true) && ! get_post_meta($post->ID, 'epr_enddate', true) )                         echo date( 'M n, Y', $eventstart_col );                     elseif ( get_post_meta($post->ID, 'epr_enddate', true) )                         echo date( 'M n, Y', $eventstart_col ) . ' — ' . date( 'M n, Y', $eventend_col );                     else                         echo 'NA';                     break;      Thank you in advance for your time.   Best * * * ## FINAL SOLUTION Big thank you to s_ha_dum for his patience and support!   Pasted below are the final working solutions to my question... **Correctly outputting the date when no posts exist for the currently queried month:**               <?php $this_month = strtotime($calendar_month);     if (false === $this_month) {     $this_month = strtotime(get_query_var( 'calendar_year' ) . get_query_var( 'calendar_month' ) .'01');     } ?>     <?php echo date( 'F Y', $this_month ); ?><?php     ?>      **Custom columns:**                 case "eventdate":                     $start_date = get_post_meta($post->ID, 'epr_startdate', true);                     $start_date_col = strtotime($start_date);                                $end_date = get_post_meta($post->ID, 'epr_enddate', true);                     $end_date_col = strtotime($end_date);                          if ( $start_date_col && !$end_date_col )                          echo date( 'M d, Y', $start_date_col );                     elseif ( $start_date_col && $end_date_col )                         echo date( 'M d, Y', $start_date_col ) . ' — ' . date( 'M d, Y', $end_date_col );                       else                         echo 'NA';                     break;      **Redirecting /calendar -> /calendar/yyyy/mm:**               function redirect_empty_archive() {     $m = get_query_var('calendar_month');     $y = get_query_var('calendar_year');         if (             is_post_type_archive('calendar') &&             ( empty($m) || empty($y) )         ) {             wp_safe_redirect( '/calendar' . date('/Y/m') );         }     }     add_action('template_redirect','redirect_empty_archive');


title: One color to category link depending on category ID

text: I would like to style a category link depending on its ID, for instance, if the category ID is 2, then I want the link to be pink. I cannot find a way to do the same thing to links. What type of solutions are available? Please be detailed in your reply as my coding knowledge is limited. Thanks a lot :)


title: How to get and use the the number of days since the last comment?

text: How would I achieve this condition ...                   if lastest comment is < 7 days old              echo 'New Comment';         else ''


title: Calling Images from a Gallery when Post is Clicked

text: http://acesystech.com/edge/ Im wanting to do something simlar to this, where the customer can click a project and see a scrolling images block of the images, however i want to do i with like click buttons. would this be possible as a gallery? And call the gallery posts or categories?


title: Special characters showing in fallback font

text: 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)


title: How do I programatically insert a new menu item?

text:
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?


title: Optimal way to redirect home page to category archive?

text: ## 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".


title: Change page according to fetched GET Parameters

text: 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.


title: Adding Relevant Post Images

text: 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.


title: Is there a common structure for a wordpress formular?

text: 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 ;)


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

text: 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?


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

text:
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?