IE 301 Redirect Issue - WordPress

Hoping someone might be able to help... I don't think this is a WordPress issue, hence posting here instead... I run the latest ISPConfig version, with Apache and MySQL, and have an odd issue with a site I host. In Chrome, the WordPress site (with Permalinks on) works correctly, however in IE it doesn't. It will load the homepage correctly, but any other pages take a while to load, then IE shows a generic "This page can't be displayed" error. I started by removing all WordPress plugins, but the error didn't go away. Switching Permalinks off solves the issue. Switching Permalinks back on brings the issue back. I've even gone as far as scrapping the WordPress install, and starting again, in case any plugins had left some rubbish behind that was causing the problem. However, my "clean install" has this problem now. If I look at the access logs after attempting to access a page with IE, all I see this;               x.xx.xx.xxx - - [15/Jul/2013:21:34:18 +0100] "GET /category/blog HTTP/1.1" 301 20 "-" "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)"     x.xx.xx.xxx - - [15/Jul/2013:21:34:19 +0100] "GET /category/blog HTTP/1.1" 301 20 "-" "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)"     x.xx.xx.xxx - - [15/Jul/2013:21:34:19 +0100] "GET /category/blog HTTP/1.1" 301 20 "-" "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)"     x.xx.xx.xxx - - [15/Jul/2013:21:34:19 +0100] "GET /category/blog HTTP/1.1" 301 20 "-" "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)"     x.xx.xx.xxx - - [15/Jul/2013:21:34:19 +0100] "GET /category/blog HTTP/1.1" 301 20 "-" "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)"     x.xx.xx.xxx - - [15/Jul/2013:21:34:19 +0100] "GET /category/blog HTTP/1.1" 301 20 "-" "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)"     x.xx.xx.xxx - - [15/Jul/2013:21:34:19 +0100] "GET /category/blog HTTP/1.1" 301 20 "-" "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)"     x.xx.xx.xxx - - [15/Jul/2013:21:34:19 +0100] "GET /category/blog HTTP/1.1" 301 20 "-" "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)"     x.xx.xx.xxx - - [15/Jul/2013:21:34:19 +0100] "GET /category/blog HTTP/1.1" 301 20 "-" "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)"     x.xx.xx.xxx - - [15/Jul/2013:21:34:19 +0100] "GET /category/blog HTTP/1.1" 301 20 "-" "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)"     x.xx.xx.xxx - - [15/Jul/2013:21:34:19 +0100] "GET /category/blog HTTP/1.1" 301 20 "-" "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)"     x.xx.xx.xxx - - [15/Jul/2013:21:34:19 +0100] "GET /category/blog HTTP/1.1" 301 20 "-" "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)"     x.xx.xx.xxx - - [15/Jul/2013:21:34:19 +0100] "GET /category/blog HTTP/1.1" 301 20 "-" "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)"     x.xx.xx.xxx - - [15/Jul/2013:21:34:19 +0100] "GET /category/blog HTTP/1.1" 301 20 "-" "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)"     x.xx.xx.xxx - - [15/Jul/2013:21:34:19 +0100] "GET /category/blog HTTP/1.1" 301 20 "-" "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)"     x.xx.xx.xxx - - [15/Jul/2013:21:34:19 +0100] "GET /category/blog HTTP/1.1" 301 20 "-" "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)"     x.xx.xx.xxx - - [15/Jul/2013:21:34:19 +0100] "GET /category/blog HTTP/1.1" 301 20 "-" "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)"      etc etc Accessing the site with Chrome works fine, and I see correct logs in the access.log file. I have two other WordPress sites, both on top level domains, and they work correctly. I thought it might be an odd issue with the site being on a subdomain, so instead of using a subdomain acting as a website (setup as a website through ISPConfig), I tried with a manual subdomain - ie, a redirect into a directory. The site loaded fine for a couple of pages, and then suddenly stopped working, and 301 errors were thrown up. Any help would be greatly appreciated, as this is extremely frustrating.


WordPress Admin Bar Not Displaying Both Custom Drop-down Menus

I'm having trouble displaying two custom drop-down menus in the WP admin bar. What I want is the first drop-down to display the back-end (editing part) links of every page and the other to display the front-end links of every page. Right now, only the last foreach statement being called displays. Any suggestions are much appreciated.               function admin_bar_link() {          global $wp_admin_bar;     if ( !is_super_admin() || !is_admin_bar_showing() )     return;          $pages = get_pages();     $nurs = get_site_url();          $wp_admin_bar->add_menu( array(         'id' => 'this',         'title' => __($nurs),         'href' => $nurs     ) );     $wp_admin_bar->add_menu(array (         'id' => 'edit_pages_links',         'title' => __('Edit Pages'),     'href' => false     ) );     $wp_admin_bar->add_menu(array (         'id' => 'view_pages_links',         'title' => __('View Pages'),         'href' => false     ) );          // added edit pages link 12-20-13 mlm     foreach ( $pages as $page ) {         $title = $page->post_title;         $url = get_permalink ( $page->ID )  . 'wp-admin/post.php?post=' . $page->ID . '&action=edit'; //edit post url                  $wp_admin_bar->add_menu ( array ( //display top-level menu item 'edit pages'             'title' => $title,             'href' => $url,             'parent' => 'edit_pages_links'             )         );          }//end foreach            foreach ( $pages as $page ) {     $title = $page->post_title;     $url = get_permalink ( $page->ID ) . '?p='. $page->ID;              $wp_admin_bar->add_menu ( array ( //display top-level menu item 'edit pages'             'title' => $title,             'href' => $url,             'parent' => 'view_pages_links'             )         );                                }//end foreach           }     add_action('admin_bar_menu', 'admin_bar_link');


Deprecating functions in a plugin class

I'm updating one of my plugins and I'm a little stuck with deprecating functions. Originally, my plugin had a global variable and the plugin's main class was instantiated and stored in the global variable. This way users could use the global to access functions in the plugin class.               $GLOBALS['my_custom_plugin'] = new my_custom_plugin();      Then, for example, in my FAQ I had code that showed how to remove one of my class' functions from a specific hook and add to to a different hook:               function move_input(){          global $my_custom_plugin;         remove_action( 'before_main_content', array( $my_custom_plugin, 'display_input') );         add_action( 'after_main_content', array( $my_custom_plugin, 'display_input' ) );     }     add_action( 'wp_head' , 'move_input' );      Now, in my update the `display_input()` function has been moved to another class and I want to let people know how to access it. I tried replacing the original function (in the main plugin class) with the following deprecation notice:               public function display_input() {          _deprecated_function( 'display_price', '2.0', 'my_custom_plugin()->display->display_input' );         return $this->display->display_input();     }      However, the `add_action` and `remove_action` functions don't seem to trigger the deprecation notice. Weirdly, completely removing the function doesn't cause an error either even though `array( $my_custom_plugin, 'display_input')` doesn't exist. If someone tries to access the function directly:               $my_custom_plugin->display_input();      Then I do see the debug notices. Is this the expected outcome for `_deprecated_function()`? or am I missing something? Is it possible to show a debug notice when someone tries to remove or add an action using a deprecated function? **Update** I realized that I was simply not seeing the debug message for the `add_action` as I was adding it pretty low on the page. #facepalm! However, I am still not seeing any debug notice for the `remove_action`.


Show latest and related articles from 3 different blogs

Say I have 3 sites, abc.com, def.com and xyz.com. And all the 3 sites have different wordpress installation and different databases. Now What I want to show all the latest articles of all three sites in sidebar of main site say abc.com. Secondly in story page I want that related articles should come from all the three sites. Is this possible from any plugin? I am not talking about multisite. Regards Girish


Would manually deleting the dumping data fix a "#1062 - Duplicate entry '1' for key 'PRIMARY'" phpMyAdmin error?

I'm new to PHP! I'm trying to import an SQL database file into myPhpAdmin for a WordPress I'm migrating, but I keep getting this error message:               SQL query:          `-- -- Dumping data for table `wp_commentmeta` -- INSERT INTO `wp_commentmeta` (`meta_id`, `comment_id`, `meta_key`, `meta_value`) VALUES (1, 3, 'rating', '5'), (37, 39, 'rating', '5'), (35, 37, 'is_customer_note', '0'), (4, 6, 'is_customer_note', '0'), (5, 7, 'is_customer_note', '0'), (6, 8, 'is_customer_note', '0'), (7, 9, 'is_customer_note', '0'), (8, 10, 'is_customer_note', '0'), (9, 11, 'is_customer_note', '0'), (10, 12, 'is_customer_note', '0'), (11, 13, 'is_customer_note', '0'), (34, 36, 'is_customer_note', '0'), (13, 15, 'is_customer_note', '0'), (14, 16, 'is_customer_note', '0'), (15, 17, 'is_customer_note', '0'), (16, 18, 'is_customer_note', '0'), (17, 19, 'is_customer_note', '0'), (18, 20, 'is_customer_note', '0'), (19, 21, 'is_customer_note', '0'), (45, 44, 'rating', '4'), (46, 45, 'rating', '4'), (22, 24, 'is_customer_note', '0'), (23, 25, 'is_customer_note', '0'), (24, 26, 'is_customer_note', '0'), (25, 27, 'is_customer_note', '0'), (26, 28, 'is_customer_note', '0'), (2[...]          MySQL said: Documentation          #1062 - Duplicate entry '1' for key 'PRIMARY'      From looking at the SQL file, I see:               INSERT INTO `wp_commentmeta` (`meta_id`, `comment_id`, `meta_key`, `meta_value`) VALUES      followed by a list of table data with different values. Would deleting this section of code fix the error I'm getting?


Add content before/after admin post wp-list-table

I know there are two hooks to add content before and after a taxonomy wp-list- table. Is there an action to add content after the post type wp-list-table on the edit.php page? * * * For $taxonomy List Tables:               add_action( 'category' . '_pre_add_form', 'copy_above_form' );     function copy_above_form( $taxonomy ) {         echo '
Above the WP-List-Table
';     }          add_action( 'after-' . 'category' . '-table', 'copy_below_table' );     function copy_below_table( $taxonomy ) {         echo '
Below the WP-List-Table
';     }      Reference: https://trepmal.com/action_hook/after-category-table/ Thanks!


localhost/wp-admin on my local redirects to production site's /wp-admin

So when I go on localhost, my development environment loads fine. But when I try to go to `/wp-admin`, I get redirected to the production URL `mysite.com/wp-admin`. Where is this being set? I don't want to be redirected.


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

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     } ?>


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

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?


Query by post type or category

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?


Upgrading WP Version + Keeping Customized Core Code?

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.


Search posts by post author name

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?


wp_enqueue_script won't load in header?

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.


Child Theme > Template

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?


get Insert id for meta field

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?


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

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?


Extract all shortcode data from post into loop variables?

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?


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

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.


Why is my WP_Query outputting my entries twice?

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?


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

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


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

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


Custom CSS without css.php file

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 ?


AJAX wp-mysql running too slow

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:


Options not saving

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(){}


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

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?


Using a specific template for front page only

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.


Displaying the most recently used tags

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.


Meta query: get posts with value in a multidimensional array

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?


Help with a function in a widget

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");') );?>


ask and edit an extra comment field

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;          }


Add class from custom field into widget class

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.


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

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)?


Wordpress custom admin functions security

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.


WP 3.8 – Preview button not working for editor

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.


Moving WordPress site to a new server - Admin not loading

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


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

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?


Rewriting URLs in Wordpress

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.


Primary site file uploads failing, subdirectory subsites upload fine

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


AJAX function returning -1

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?


start_lvl ignored in custom walker_nav_menu

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


Removing width and height attributes from wp-get-attachment

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?


login_redirect for Mobile Web

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;      }


Custom post type admin search

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.**


Sorting Custom Posts by category

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.


Separate URL for a specific page

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


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

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.


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

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


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

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?


Image doesn't show since 3.5.2

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


Add category attribute to custom shortcode

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.     });


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

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


Dynamic image crop in WP 3.0+?

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


Am I allowed to resell Wordpress Premium Plugins under GPL?

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.


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

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?


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

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


How can I redirect on a url after successful registration?

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


Is it possible to create a login for restricted visibility?

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?)


How to stop Navigation

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


wp_nav_menu() reutrns HTTPS?

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.


Find out in which kind of archive am I

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.


Pagination Adding Numbers in Strange Fashion

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


Generating custom URL before post is published

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?


Get Tags by specific Category of Custom Post Type

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


custom changes removed after plugin update

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 ?


Customize comment list markup

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.


Wordpress post count not showing for custom post type author

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)


"post-format" code snippets list

### 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!


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

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?


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

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?


Integrating Nextgen Gallery with Gallerific

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(); ?>


Filter/Remove HTML Elements on all posts and pages

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.


Are transients garbage collected?

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?


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

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!


fetch images and videos

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?


Append varible to url or set session

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


Unable to center menu and header image twenty twelve

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; }


Conditional Statement custom post type category

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?


Change default upload images size for contributors

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?


Tag, Category and Single Conditionals

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


How to include css for plugin setting page?

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' );


Check php version before theme activation

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.


Moving a remote Wordpress multisite installation to local

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


Forgot password not working

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


Custom "radio button meta box" not saving correctly

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;         }     }     ?>


Webdav with permalink in Wordpress v3.3.1

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`.


External link nested in wp_list_pages

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?


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

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?


How to add multiple images in a page

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.


Sorting posts according to view counts not working

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();         ?>


Silly Problem Referencing a Post ID

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


Attach custom gallery to a page

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.


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

## 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');


One color to category link depending on category ID

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


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

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


Calling Images from a Gallery when Post is Clicked

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?