All, published and pending order

On the list tables of the administration panels, I want to change the order of the filters on top of the table. What I want:   1. Pending   2. Published   3. All I tried to act on a line from the "wp-list-table" file which is by default:               $status_links = array_merge(          array_slice( $status_links, 0, $split ),         array_slice( $status_links, 0, $split )      );      The default display is this:   1. All   2. Published   3. Pending And if I change it to this:               $status_links = array_merge(          array_slice( $status_links, 1, $split ),         array_slice( $status_links, 0, $split )      );      I get this order:   1. Published   2. Pending   3. All And if I change it to this:               $status_links = array_merge(          array_slice( $status_links, 2, $split ),         array_slice( $status_links, 0, $split )      );      I get this order:   1. Pending   2. All   3. Published I believe I will never get what I want from there as this only shifts the sequence but doesn't reorder it. How can I do to get my specific order then? PS: I don't use the "Scheduled" status and never will. Thank you. **EDIT:** **I Found the solution:**               $status_links = array     (          $status_links["pending"],         $status_links["publish"],         $status_links["all"]      );      Thank you


Archive links don't work when clicked

I have archive links in my theme that get the archives for a specfic category ('blog) like so:                <?php wp_get_archives('cat=6'); ?>      When i click on the link for the archives is just loads the category page again for the blog. The url does change to:               http://localhost:8888/2012/11/?cat=6      But nothing changes on the page.


Surround uploaded image link with div

When you upload image you have smth like this                                   I need it to be surrounded with div

      Plz help, who know how to do this


Pending status by default for a specific role

I would like to prevent users from one specific role from publishing directly their articles. Only administrators should be able to approve these. The only choice they would ever have is to put their articles as pending or draft. Any other roles may publish if they want. Is there a way to do so without any plugin and without having to dig too deep into the code? Thank you


Where to store the name of a custom table?

I'm extending the `$wpdb` object with properties for my custom tables.               function setup_wpdb()     {         global $wpdb;              // Create properties for custom tables         $wpdb->my_plugin_table1 = $wpdb->prefix.'my_plugin_table1';         $wpdb->my_plugin_table2 = $wpdb->prefix.'my_plugin_table2';     }      Is this a good practice? I guess as long as the properties are prefixed with the plugin name, it should be fine. Defining a constant may work too. What do you prefer and why? Thanks.


Blueimp file uploader inside Smart Wizard page

I have looked around and can't seem to find anything that answers the question, but if I am double posting please direct me to where I should be. I am trying to use the Blueimp File Uploader inside of the Smart Wizard multi- step form here I have implemented the Smart Wizard via `wp_register_script` in the functions.php and then using `wp_enqueue_script` in the page template that I want it to show. I haven't been able to get the file uploader to work, tho. I am not sure if this is a jquery problem or if you just can't load the uploader script inside of the smart wizard pages. I am trying to load the uploader on page 2 of the smart wizard and have done this, after loading the css and scripts into the theme's css and js folders:

Step 2 Content
           <?php                 wp_enqueue_style( 'bootstrap' , 'wp-content/themes/oxygen/assets/css/bootstrap.min.css' );             wp_enqueue_style( 'uploader-style' , '/wp-content/themes/oxygen/assets/css/style.css' );             wp_enqueue_style( 'blueimp-gallery' , 'wp-content/themes/oxygen/assets/css/blueimp-gallery.min.css' );             wp_enqueue_style( 'jquery-fileupload' , '/wp-content/themes/oxygen/assets/css/jquery.fileupload.css' );             wp_enqueue_style( 'jquery-fileupload-ui' , '/wp-content/themes/oxygen/assets/css/jquery.fileupload-ui.css' );                             wp_enqueue_script( 'jquery' );              wp_enqueue_script( 'jquery-ui-widget' , '/wp-content/themes/oxygen/assets/js/jquery.ui.widget.js' );              wp_enqueue_script( 'load-image.min.js' , 'http://blueimp.github.io/JavaScript-Load-Image/js/load-image.min.js' );              wp_enqueue_script( 'canvas-to-blob' , 'http://blueimp.github.io/JavaScript-Canvas-to-Blob/js/canvas-to-blob.min.js' );              wp_enqueue_script( 'upload-bootstrap' , 'http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js' );              wp_enqueue_script( 'jquery-iframe-transport' , '/wp-content/themes/oxygen/assets/js/jquery.iframe-transport.js' );              wp_enqueue_script( 'jquery-fileupload' , '/wp-content/themes/oxygen/assets/js/jquery.fileupload.js' );              wp_enqueue_script( 'jquery-fileupload-process' , '/wp-content/themes/oxygen/assets/js/jquery.fileupload-process.js' );              wp_enqueue_script( 'jquery-fileupload-image' , '/wp-content/themes/oxygen/assets/js/jquery.fileupload-image.js' );              wp_enqueue_script( 'jquery-fileupload-audio' , '/wp-content/themes/oxygen/assets/js/jquery.fileupload-audio.js' );              wp_enqueue_script( 'jquery-fileupload-video' , '/wp-content/themes/oxygen/assets/js/jquery.fileupload-video.js' );              wp_enqueue_script( 'jquery-fileupload-validate' , '/wp-content/themes/oxygen/assets/js/jquery.fileupload-validate.js' );              wp_enqueue_script( 'file-upload-main' , '/wp-content/themes/oxygen/assets/js/main.js' );          ?>     <form id="fileupload" action="" method="POST" enctype="multipart/form-data">                           Add files...                          <input type="file" name="files[]" multiple />

     </form>      My theme is also using jQuery to load things like revolution slider and such. I get no errors on the javascript console when viewing the page. Any suggestions are much appreciated!!


Output categories in something different than a list

I wanted to output all my categories in the sidebar of my wordpress theme. Now I use the function `wp_list_categories();` which works fine. However it always displays the categories in a list and I don't want that. What I want is to display the categories as links so that they are inline elements. I could stay with the list and just style them as inline elements by applying `display: inline-block;` to the list items. I guess it is semantically correct, too. So is there a way of getting rid of the list in WordPress or should I stay with my approach? And is it semantically correct? Thanks for all your answers.


types plugin passing variable to fontawesome image

I'm trying to pass a variable from the types plugin to a custom widget. I'm trying to create a block like the ones featured on this page http://demo.herothemes.com/ Depending on what type of post it is I want a different fontawesome character to be passed to the start of the link. It doesn't seem to be passing the variable through. Also if there's a better way of doing this I would love to know how. This is the code I'm using to grab the chosen value from Types:                   $icontype = types_render_field('icon-type', array());              if($icontype == 'Folder'){                  $posticon = 'fa-folder';         }         elseif($icontype == 'Video'){                  $posticon = 'fa-film';         }         elseif($icontype == 'Audio'){                  $posticon = 'fa-music';         }         elseif($icontype == 'Q+A'){                  $posticon = 'fa-question-circle';         }         elseif($icontype == 'General Text'){                  $posticon = 'fa-file-text';         }         elseif($icontype == 'Images'){                  $posticon = 'fa-picture-o';         }      This is the line that will be printed:               echo '

'.$ident.'

';


Show last 5 posts from featured category on query carousel slider with prev and next button

I managed to set up a query carousel slider on my test-site. How can i adapt the slider to show the 5 latest posts from my featured post category with thumb, title and link to the post instead of the manuel written html parts? **Here is the fiddle** I already find a code to show up the featured posts with following code - but i dont know how to implement the below code (or any other code) into the carousel slider (see fiddle above) to show each featured post in each box... :(
                    <?php                 $default_thumbnail = 'http://.....d-slider.png';                 $the_query = new WP_Query('showposts=5&orderby=desc&category_name=featured');                 while ($the_query->have_posts()) : $the_query->the_post(); ?>
                 <a target="_blank" href="<?php the_permalink()?>" title="<?php the_title_attribute(); ?>">                             <?php                             if (has_post_thumbnail()):                             the_post_thumbnail('default-thumbnail');                             else:                             ?>                             <img src="<?php echo $default_thumbnail; ?>" alt="<?php the_title(); ?>" />                             <?php endif; ?>
<?php the_title(); ?>

                            <?php endwhile; ?>                 <?php wp_reset_query(); ?>
      It would make me very happy if someone can help me out.


Modify built-in post type properties

I have an unusual situation where I need to make the built-in post type 'page' non-hierarchical. I printed the post type object with `var_dump(get_post_type_object('page')); die;` and I got this:               object(stdClass)#164 (26) {       ["labels"]=>       ...       }       ["description"]=>       string(0) ""       ["publicly_queryable"]=>       bool(false)       ["exclude_from_search"]=>       bool(false)       ["capability_type"]=>       string(4) "page"       ["map_meta_cap"]=>       bool(true)       ["_builtin"]=>       bool(true)       ["_edit_link"]=>       string(16) "post.php?post=%d"       ["hierarchical"]=>       bool(true)       ....     }      How might I go about modifying the post-type object so that `["hierarchical"]=>bool(false)`?


Query all posts under one taxonomy? Why is my code not working?

I'm trying to show all the posts associated with a Taxonomy (not a term) but it seems to not work.               <?php          $args = array(         'post_type' => 'projects',         'tax_query' => array(             array(                 'taxonomy' => 'clients',                 'terms' => 'Unilever'             )         )     );     $the_query = new WP_query();     $the_query->query($args);          if($the_query->have_posts()):while($the_query->have_posts()):$the_query->the_post();          php the_title();               endwhile; endif;     wp_reset_query();          ?>


Conditional tag-like function to tell if post is in trash?

What could I put in my theme to tell if a post is in the trash or not? For example:               <?php if (is_trash) echo 'This post is in the trash!' ?>


Can "Recent Posts" widget be filtered by functions.php?

I have my own "Recent Posts" menu, but its not currently implemented as a Widget. I'm just including it in sidebar.php. I had to "roll my own" so to speak in order to filter the menu of certain categories whose posts I don't want to appear in the menu. Would it be possible, via functions.php, to filter the default "Recent Posts: widget's menu items in order to exclude posts belonging to a specific category? If so, I'd really be grateful for an example.


Jquery not working

(function($) {         $(document).ready(function(){             /*$('body').css('position','relative');             $('body').animate({'left':'-9999px'},3000);*/             alert('hello');         });     }(jQuery));      Tried also               $(document).ready(function(){                 /*$('body').css('position','relative');                 $('body').animate({'left':'-9999px'},3000);*/                 alert('hello');             });      And firebug jumps:               jQuery is not defined     [Detener en este error] }(jQuery));


How do I get rid of "category" from my URL structure?

By default WP links to a category like this, mydomain.com/category/travel. Having the word "category" appear in the URL seems unnecessary. I'd prefer have the link read mydomain.com/travel. How can I remove "category" from the URL structure? I don't want to replace it with something else as I can do by entering a new Category Base under Settings/Permalinks. But instead eliminate the Category Base all together so that the category names follows the domain name as in mydomain.com/travel. Thanks in advance for any advice you can offer. Its most appreciated. Eddie


How to add a recent post function to a text widget I created for practice?

I am currently being trained to create widgets and my mentor has asked me to create a text widget then add the ability to display the 5 most recent posts (all categories) on it. I am a little stumped on how to add it in as I am very new to this. I will post the code below along with the url. What I was recommended to use is Function Reference/wp get recent posts from the codex but I am stumped on how to get it to work.               <?php     /*     Plugin Name: Kevins Textbox     Plugin URI:      Description: A text widget created by Kevin Ullyott for practice in creating widgets     Author: Kevin Ullyott     Version: 1.0     Author URI:     */               class kevintext extends WP_Widget {              public function __construct() {         parent::WP_Widget(         // or parent::__construct(             false,              'Kevins Textbox',             array(                 'description' => __('A text widget created by Kevin Ullyott for practice in creating widgets')              )         );         ;     }              public function widget( $args, $instance ) {                       extract( $args );                  $headline = $instance['headline'];                   $text = $instance['text'];                                  echo $before_widget;                  echo $before_title;                  echo "
$headline
";                  echo $after_title;                  echo "
$text
";                  echo $after_widget;                   }              public function update( $new_instance, $old_instance ) {             $instance = array();             $instance['headline'] = ( $new_instance['headline'] );             $instance['text'] = ( $new_instance['text'] );             return $instance;         }                   public function form( $instance ) {                  $headline = $instance[ 'headline' ];             $text = $instance[ 'text' ];                  ?>
             <label for="<?php echo $this->get_field_id( 'headline' ); ?>"><?php _e( 'Headline:' ); ?>              <input class="widefat" id="<?php echo $this->get_field_id( 'headline' ); ?>" name="<?php echo $this->get_field_name( 'headline' ); ?>" type="text" value="<?php echo esc_attr( $headline ); ?>" />

             <label for="<?php echo $this->get_field_id( 'text' ); ?>"><?php _e( 'Text:' ); ?>              <input class="widefat" id="<?php echo $this->get_field_id( 'text' ); ?>" name="<?php echo $this->get_field_name( 'text' ); ?>" type="text" value="<?php echo esc_attr( $text ); ?>" />
                       <?php          }     }          add_action( 'widgets_init', create_function('', 'return register_widget("kevintext");') );               ?>      Link to url: http://www.modmacro.us/wpsandbox/ Link to codex function: http://codex.wordpress.org/Function_Reference/wp_get_recent_posts


How to get page's ID if I know the title only?

Is there an exact opposite funciton to this one:               get_the_title(ID)       I know there's:               get_the_id()      But it doesn't seem to accept any arguments. So, basically, I'm looking for something like:               $title = 'Something';     get_the_id($title);      I already know this solution:                global $wpdb;      $post_name = get_query_var('name');      $post_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_name = $post_name");      But maybe there's something bulit-in that I'm missing?


How to store options in an array

I am creating a custom table to display selected options for a page called "Testimonials". The user will enter their options on a "manage testimonial settings" page, and then those options will display in a Wordpress-style table on a separate page. All the settings are stored in an options array called "testimonials_settings" which is shown below:               if(isset($_POST['testimonials_update_options'])) {        $options = get_option('testimonials_settings');         $options['testimonials_active'] = $_POST['testimonials_active'];        $options['testimonials_name'] = $_POST['testimonials_name'];        $options['testimonials_website_name'] = $_POST['testimonials_website_name'];        $options['testimonials_website_url'] = $_POST['testimonials_website_url'];        $options['testimonials_quote'] = $_POST['testimonials_quote'];     update_option('testimonials_settings', $options);         }     }      In the image below, you can see that I can successfully show these options on a menu page called "Testimonials". ![enter image description here](http://i.stack.imgur.com/Gqu9U.png) Now I'm running into a roadblock because I need to take these settings and display them dynamically in a table for the user to edit/delete/update. So here are my questions:   1. Can I create code that will display these options dynamically in my current table, considering that I've created the table from scratch?   2. If so, what would be the process of displaying these options in my table (i.e. could an example be provided to do this?)


Styling Shortcodes in Visual Editor

Does anyone know how to style the visual editor so that when specific shortcodes are used they are replaced with an image within the visual editor? I have found that many users screw up the shortcode text or delete it by mistake when using the visual editor so I would like for shortcodes to be replaced with paceholder images within the visual editor. HTML editor would still show the codes though.


Conditional add_filter?

I need to apply an add_filter from my functions.php but only if the user has opened media-upload.php from my custom function. Is it possible to send a variable when opening media-upload.php that I could then test for existence of before executing add_filter? Example: Here is my code in which I'm opening the media uploader from my custom icon...               //Custom upload launcher for custom attachments     function wpe_customImages($initcontext)     {         global $post;         ?>              <?php         return $initcontext.          '<input type="hidden" id="post_ID" value="'. $post->ID .'" />         Product Images:         ';     }     add_filter('media_buttons_context', 'wpe_customImages');      Inside the above code, would it be possible to set a global variable or some marker that I can test for in order to execute my add_filter code?                if(isset($myMarker)){       add_filter("attachment_fields_to_save", "rt_image_attachment_fields_to_save", null , 2);       }


Set post terms by term id

I'm trying to add post to custom terms within a custom taxonomy. Not sure if I'm tackling this right. So far we have the custom taxomony 'warehouse', and the custom term 'Old Stock'. Problem is that when I try to add the term to the post using the term_id then it creates a new term with the id as a name. Here is the code I'm using:               //add new product         $id = @wp_insert_post(array(             'post_title' => $name,             'post_content' => $desc,             'post_status' => 'publish',             'post_parent' => $parent,             'tax_input' => array(                 array(                     'warehouse' => $parent                 ))             ), true);              //set terms         wp_set_object_terms($id, array($parent), "warehouse");      As you can see I've tried adding the term_id as '`post_parent`' as '`tax_input`' and also using '`wp_set_object_terms`' If the term_id was 25, then the above would create a new term called "25"! Instead of sticking the post into the term with an id of 25. Any help would be appreciated, cheers


Product admin page breaking with too many product variations

When adding more than 100-155 variations to a variable product our admin page seems to break and loose all it's layout and i'm not able to edit anything to do with the product. Some of our products are going to contain around 500 variations but can't figure out why this is happening. Any advice would be greatly received. Thanks, Adam


Error getting correct blog_id on MU from functions.php

I have script in my functions.php that seeks to locate the media directory of the site in which the theme is installed. This is pretty simple unless the site is an MU site. In that case, the media directory is based on the blog_id. However, my code below is returning the main site id rather than the blog_id of the site in which its being run...               function get_image_list()     {         global $current_site;         $dir=is_multisite() ?  'wp-content/blogs.dir/'.$current_site->blog_id.'/files/' : 'wp-content/uploads/';         $url=is_multisite() ?  get_bloginfo('url').'/wp-content/blogs.dir/'.$current_site->blog_id.'/files/' : get_bloginfo('url').'/wp-content/uploads/';      In this case, the actual blog_id is 3, however, its returning a value of 1 for $current_site->blog_id The error is...               cannot open wp-content/blogs.dir/1/files/


WP_query and pagination?

I have to get some custom post types and need to do that with WP_Query (query_posts doesn't work). How can I do the pagination? Whatever I tried didn't work... any help would be awesome I can't crack this alone...               $args = array(     'tax_query' => array(        'posts_per_page' => 5,         array(         'author' => $user_id,             'taxonomy' => 'custom_taxtype',             'field' => 'slug',             'terms' => 'delicious-food',         )     )      );      $answer_query = new WP_Query( $args );          //// Loop trough the results          while ( $answer_query->have_posts() ) : $answer_query->the_post();          //// do something          endwhile;


WordPress JS- Visual Composer

I am trying to make a sense in which I can put the whole functionality of JavaScript Visual Composer as it is to the front-end of the WordPress site. As I want that user should not use the wp-admin for updating posts and other content. I studied the plugin and try to understand the working, by studying the plugin I understand that it is for the backend only. Here to ask the question is that I want to ask the experts if there is any way to do this. Please help me in this regard


Querystring data gets truncated

When I check "view source > frame info" on the window produced by the jQuery code below, it cuts off the querystring at the &type=image. I'm url encoding the ampersands properly, right?               Address: ...wp-admin/media-upload.php?post_id=28&type=image&          function wpe_customImages($initcontext)     {     global $post;     ?>     <script type="text/javascript">     jQuery(document).ready(function() {     var fileInput = '';     jQuery('#wpe-uploadAttachments').click(function() {         fileInput = jQuery(this).prev('input');         formfield = jQuery('#upload_image').attr('name');         post_id = jQuery('#post_ID').val();         tb_show('', 'media-upload.php?post_id='+post_id+'&type=image&TB_iframe=true&wpe_idCustomAttachment=true');         return false;     });


Display metabox conditionally

I have searched left, right and center and believe that this does not exist as a built in option in WordPress; is there any way to, problematically, display (or not) a metabox in a custom post type edit screen depending on the content of a metakey value? The only idea i have is to display the content of the metakey in a hidden field, retrieving it's value with jQuery and based on its content deleting the div containing the metabox pr not. The content of the metabox is quite resource intensive so i am looking for another solution.


connection to confirm reservation page

I have plugin for reservations that doesn't require WordPress reservation.And when user reservation is ready he must confirm it by pressing link send to his email. And when he goes to this is link the reservation is complete and he can share it on social media sites. So my question is how to make connection from link send to his email to custom wordpress page that template is in my plugin folder. My idea is to use GET and the link plugin send is something like: www.wordpresite.com/reservation6846684562156464 and this numbers are unique reservation slug that confirms it. And user see in the WordPress site your reservation i confirm you can now share ... I hope you understand what I try to do.


Local path included in script url

The hosting service of a website I created crashed, now we're trying to get it up and running again. They restored the website/database from a backup but we're encountering issues. A couple of plugins are no longer working. When visiting the plugin page a bunch of them had an error that said "The Plugin xxx has been inactivated because of an error: The plugin does not have a valid header" or something close to that. You can activate the plugins normally again without any kind of error message, however when visiting the site and checking the console you now see this error: > GET http:// (website domain)/wp-content/plugins/C:/inetpub/wwwroot/(local > folder)/WP-CONTENT/PLUGINS/ajax-event- > calendar/js/jquery.mousewheel.min.js?ver=3.0.6 404 (Not Found) (I hid the domain name and local folder.) Somehow the local address is being included in the url to load the script, and obviously the script is not loaded and the plugin is not working as intended. A bunch of the plugins have the same issues, reinstalling them isn't changing anything. I'm completely stumped, what is this and how is this happening?


WPML language tags (Qtranslate feature)

I for many years used qtranslate plugin for translating my wordpress websites, but for now I decided to use other plugin, called WPML. And now I'm struggled with one problem: I am missing one feature from qtranslate plugin, where with conditional language tags we have possibility simply translate plugins, like wp-pagenavi, Breadcrumb NavXT and etc.. These tags looks secondly:               <!–-:en–->English text<!–-:–-><!–-:de–->German text<!–-:–->      So, for example one standart field of wp-pagenavi plugin in admin area:               Page %CURRENT_PAGE% of %TOTAL_PAGES%      Modified:               <!–-:en–->Page<!–-:–-><!–-:de–->Seite<!–-:–-> %CURRENT_PAGE% <!–-:en–->of<!–-:–-><!–-:de–->von<!–-:–-> %TOTAL_PAGES%      Output in German language must be:               Seite %CURRENT_PAGE% von %TOTAL_PAGES%      So, I will be very thankful for your help...


How do I convince this button to do something when it is clicked?

I'm trying to use ajax to give me an alert when I click a button. Eventually I want it to do some form validation, but for now I would be happy just to see the alert. I've read the docs and about a dozen similar questions, but for some reason I still can't get my version to work. I'm hoping someone else can see whatever it is that I'm missing. This is what I have:               // In the php files          add_action( 'wp_ajax_ecbs_validate_data', 'ecbs_validate_data' );          add_action( 'in_admin_header', 'my_ajax_button' );          function my_ajax_button()     {         // This gets echoed to a form in another function         return '<button id="ecbs-submit" type="button" value="Submit" class="button-primary">Submit</button>';     }          // In the .js file          // Do something when button is clicked?     $j("#ecbs-submit").on('click', function() {         try {             alert('something is happening');             $j.post(ajaxurl, {                 action: 'ecbs_validate_data',                 dataType: 'json',                 success: function(data) {                     //data returned from php                     alert('success');                 }             });         }         catch (err) {             alert(err);         }     });      I assume that since the alert is not happening, the script is not getting called at all. The JavaScript above is not the only thing in the file, though. This is the full script: Maybe a conflict?               var $j = jQuery.noConflict();     $j(document).ready(function() {              // Updates the $ecbs-eit-area div when a template is          // selected from a drop box.         $j("#ecbs_styles").change(function() {             var str = "";             $j("#ecbs_styles option:selected").each(function() {                 str = $j("#ecbs_styles").val();                 //if (str !== 'dummy')                 //{                 try {                     $j.post(ajaxurl, {                         data: {template: str},                         action: 'ecbs_populate_admin_template'                     }, function(response) {                         $j("#ecbs-edit-area").html(response);                     }                     );                 }                 catch (err) {                     alert(err);                 }             });         })                 .change();              // Do something when button is clicked?         $j("#ecbs-submit").on('click', function() {             try {                 alert('something is happening');                 $j.post(ajaxurl, {                 action: 'ecbs_validate_data',                 dataType: 'json',                 success: function(data) {                     //data returned from php                     alert('success');                 }             });             }             catch (err) {                 alert(err);             }         });     });      And, if you're curious, the only thing in `ecbs_validate_data()` is:               function ecbs_validate_data()     {         die ('something happened');     }      * * * The plot thickens! I created another button and changed my javascript to use that button and it works. I'll have to play with it some more to see if I can figure out what the deal is. * * * Ah ha! When the button is inside my edit-area div it doesn't work, but when I put it anywhere outside of there it does. I'm finally getting somewhere with this.


limit characters when posting from form

I have a form were users can post question on my page and I would like to limit the characters in the description part of the form. It would also be a plus if I could get a word counter to work. The form:
Titel
                 <input type="text" id="title" value="" tabindex="1" size="20" name="title2" />

<?php wp_dropdown_categories( 'show_option_none=Kategorier&tab_index=4&taxonomy=register_vote_category&hide_empty=0' ); ?>

Beskrivning
                 <textarea id="description" tabindex="3" name="description2" cols="50" rows="6"></textarea>

<input type="submit" value="Skicka" tabindex="6" id="submit" name="submit2" />
                      <input type="hidden" name="action" value="new_post" />                 <?php wp_nonce_field( 'new-post' ); ?>             </form>      The php:               if(isset($_POST['submit2'])) {                      $title = $_POST['title2'];                 $description = $_POST['description2'];                      if(strlen($title) <= 0 || strlen($description) <= 0){                               echo wpautop( 'Du måste skriva i både titel och beskrivning' );                      }                 else if (strlen($title) >= 1 && strlen($description) >= 1) {                      $new_post = array(                     'post_title'    => $title,                     'post_content'  => $description,                     'post_category' => array($_POST['cat']),  // Usable for custom taxonomies too                     'post_status'   => 'publish',           // Choose: publish, preview, future, draft, etc.                     'post_type' => 'category-vote'  //'post',page' or use a custom post type if you want to                 );                 //save the new post                 $pid = wp_insert_post($new_post);                  //insert taxonomies                 }             };


Is There A Way To Add Weight Or Order To Tags?

I'm wondering if it's possible to add a 'weight' value to tags... similar to how one can specify an 'Order' for pages to indicate their placement on menus. Eg. I may have dozens of keywords but I will -always- want 4 or 5 to appear at the top of a 'tag cloud', regardless of their popularity or slug or ID. I guess I could add a new table to the db and relate that to the term_taxonomy table, but I was hoping there was already a solution.


Read more does not show up when I write my own Excerpt

On my blog on all my main loops I have it set to show the `excerpt` instead of the `content` If I make a longer post and leave the `excerpt` text box empty, then wordpress will make it's own excerpt from my post and show the `[...]` or a custom link at the end. Thats great however if I DO enter my own excerpt into the excerpt textbox, it will show that text but it will not show the read more part added to it. Does anyone know how I can make it always show a read more?


Extending a theme: build new features as plugin or core modules?

I have developed my own WordPress theme based on the Roots starter theme. Because of my clients needs, I'm often required to develop custom features (what I refer to as "modules") that are added to the core: for example a "Projects" custom post type, a "Business Hours" page in the admin, or a custom "Slider" menu, etc. There's a couple reasons why I decided to code these modules and extend the theme instead of using existing plugins:   * It's a great way to learn WordPress   * I need to bundle and activate the modules dynamically in every new projects    * I don't want the clients to be able to deactivate the features (unlike plugins)   * I don't want to rely too much on third-parties   * For consistency matters, I like if the code is similar everywhere   * Flexibility: from my experience home-made modules are often easier to understand, maintain, and improve in the future I do however understand that building my features as plugins would brings a better code separation and have it's benefits. So here's my question: **Should I keep building and adding the new features directly to the theme, or develop them as plugins instead?** What is the best approach based on your knowledge and experience? Any input or documentation would be very appreciated. Thanks!


Non-UTF characters break RSS feed

I have nasty issue occuring every so often where sometime a guest blogger would inadvertently put a non-UTF character or an unbalanced HTML tag into a post, which will then break the RSS feed and will result in FeedBurner not being able to send it to subscribers via email. Is there a technological way to avoid this kind of issues? Thanks!


Using PHP Increment and Conditional Statement to Alternate Loop Background

I'm trying to alternate the background on a theme page that is displaying a custom loop:               $args = array( 'post-type' => 'portfolio', 'posts_per_page' => 10 );                             $loop = new WP_Query( $args );                             $count = 0;                             while ($loop->have_posts() ) : $loop->the_post();          <div class="wrapper <?php if(++$count%2==0) echo 'grey-box'; else echo 'white-box'; ?>">          <div class="portfolio-picture <?php if(++$count%2==0) echo 'portfolio-grey-box'; else echo 'portfolio-white-box'; ?>">                                  <?php $videocode = get_post_meta($post->ID, 'video-embed-code', true); //is the custom field being used?                                  if ($videos) {                                      echo $videocode;                                  }                                  else                                  if ( has_post_thumbnail() ) {                                 the_post_thumbnail('portfolio-picture');                                  };                                  ?>

<?php the_title(); ?>

<?php the_content(); ?>

                     <?php endwhile; ?>      But the styles don't seem to change. Am I missing something?


Add custom shortcode button to Editor

Before the new version of Wordpress 3.0 came out I was using this jQuery code below to add custom buttons for my own shortcodes to the editor toolbar in the admin panel, it worked great. However with version 3 out now, it has stopped working, if I view source in admin panel I can see my code below is being loaded properly, it just doesn't work anymore, does anyone know what has changed or how to fix to work with the newer version?               // Add CUSTOM buttons to html editor in admin!     add_action('admin_footer','custom_editor_buttons');          function custom_editor_buttons() {         ?>         <script type="text/javascript" charset="utf-8">         <!--  Define our Editor buttons -->         edButtons[edButtons.length] = new edButton(             "hed_0",             "Citation",             "[ref]",             "[/ref]",             ""         );         edButtons[edButtons.length] = new edButton(             "hed_1",             "highlight",             "[highlight]",             "[/highlight]",             ""         );              jQuery(document).ready(function (b) {             <!--  Empty editor button tray -->             <!-- then re-build it with our custom buttons -->             jQuery("#ed_toolbar").empty();             function hedShowButtons(button, i) {                 if ( button.id == 'ed_img' ) {                     jQuery("#ed_toolbar").append('<input type="button" id="' + button.id + '" accesskey="' + button.access + '" class="ed_button" onclick="edInsertImage(edCanvas);" value="' + button.display + '" />');                 }else if (button.id == 'ed_link') {                     jQuery("#ed_toolbar").append('<input type="button" id="' + button.id + '" accesskey="' + button.access + '" class="ed_button" onclick="edInsertLink(edCanvas, ' + i + ');" value="' + button.display + '" />');                 }else {                     jQuery("#ed_toolbar").append('<input type="button" id="' + button.id + '" accesskey="' + button.access + '" class="ed_button" onclick="edInsertTag(edCanvas, ' + i + ');" value="' + button.display + '"  />');                 }             }             for ( var i = 0; i < edButtons.length; i++ ) {                 hedShowButtons(edButtons[i], i);             }             jQuery("#ed_toolbar").append('<input type="button" id="ed_tabs" class="ed_button" title="Enable and disable tabbing" value="disable tabs" />');             jQuery("#ed_toolbar").append('<input type="button" onclick="fullscreen.on();" id="ed_fullscreen" class="ed_button" title="Enable and disable fullscreen mode" value="fullscreen" />');             jQuery("#ed_toolbar").append('<input type="button" id="ed_spell" class="ed_button" onclick="edSpell(edCanvas);" title="' + quicktagsL10n.dictionaryLookup + '" value="' + quicktagsL10n.lookup + '" />');             jQuery("#ed_toolbar").append('<input type="button" id="ed_close" class="ed_button" onclick="edCloseAllTags();" title="' + quicktagsL10n.closeAllOpenTags + '" value="' + quicktagsL10n.closeTags + '" />');              });         </script>         <?php     }


Change taxonomy for categories

I am using a plugin called "Recent posts widget extended" with a directory theme where i have directory listings showing as adverts in a sidebar on specific pages. The plugin allows me to show posts from specific categories on certain pages. The directory listings are in categories but not normal WP categories, they are within the themes own categories where the taxonomy name is "ait-dir-item- category" These directory categories are not selectable using the plugin, only the normal categories which are not in use. I have tried to edit the plugin PHP file (there is only one file to the plugin) changing `$categories = get_terms( 'category' );` to `$categories = get_terms( 'ait-dir-item-category' );` but this had no effect. I wonder if you could assist me in changing what taxonomy the plugin looks for for the categories please so that I can filter via the theme categories and not the default WP categories. Thanks. The select list is as follows:               <?php $categories = get_terms( 'category' ); ?>      <?php foreach( $categories as $category ) { ?>         <option value="<?php echo $category->term_id; ?>" <?php if ( is_array( $cat ) && in_array( $category->term_id, $cat ) ) echo ' selected="selected"'; ?>>             <?php echo $category->name; ?>         </option>


Changing a custom post type "has_archive" after registered

Ok, I've seen some similar posts on how to change a custom post type's attributes after it has been registered (in my case, I'm trying to modify a custom post type created by a plugin without modifying the plugin files). This appears to be working for some properties:               function change_wp_object() {       $object = get_post_type_object('easy-rooms');       $object->show_in_menu = true;     }     add_action('init','change_wp_object');      However, I can't seem to get `has_archive` to change - and it appears to be related to the permalinks. I'm guessing a new rule for `/easy-rooms/` isn't being added. I've tried adding `flush_rewrite_rules()` (even though it's a bad idea to run it at `init`) but even that doesn't work. Post type is set to public and if I do change the `has_archive` in the plugin code it does work. Any ideas? Thanks in advance!


How to add date to navigation bar

I've created a new navigation bar on this site: http://www.tomorrowstrends.com/ I'd like to add the date on the right hand side (on the grey menu below the blue one). I thought I could add this to my new navigation php file (thirdnav.php):               <?php echo '      So I would have this:               <?php      if ( has_nav_menu( 'thirdnav' ) ) {     echo '

';       wp_nav_menu( array( 'sort_column' => 'menu_order', 'container_id' => 'thirdnav' , 'menu_class' => 'menu thirdnav superfish sf-js-enabled', 'theme_location' => 'thirdnav') );      echo '

';      } ?>          <?php echo '      But I need to style it and I don't know the proper syntax for creating a class for the date within the echo statement. How is that done? Am I doing this correctly? Thanks in advance for any help.


Display latest sticky post or display nothing

On my Blog http://flattrendz.com/, I currently want to display the latest sticky post. I used the code of http://justintadlock.com/archives/2009/03/28/get-the- latest-sticky-posts-in-wordpress                   <?php     /* Get all sticky posts */     $sticky = get_option( 'sticky_posts' );          /* Sort the stickies with the newest ones at the top */     rsort( $sticky );          /* Get the 2 newest stickies (change 2 for a different number) */     $sticky = array_slice( $sticky, 0, 2 );          /* Query sticky posts */     query_posts( array( 'post__in' => $sticky, 'caller_get_posts' => 1 ) );     ?>               <div class="blog_bar <?php echo $blog_bar_class; ?>">

                          <?php printf(__('From Our Blog', 'dot')); ?>                      <a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php printf(__('%s', 'dot'), get_the_title()); ?>"><?php the_title(); ?>

               <?php endwhile;?>     <?php       }         else { }           /* Restore original Post Data */      wp_reset_query();     ?>      What I need to do is if there are posts marked as sticky post, then display just the latest sticky post, or else simply display the latest post.


WordPress custom post types breaks permalink on theme reinstall

This is a pretty strange problem. I'm creating a WordPress custom post type in my themes functions.php file using the following format:               add_action('init', 'product_register');          function product_register() {     $args = array(         'label' => __('Products'),         'singular_label' => __('Product'),         'public' => true,         'show_ui' => true,         'capability_type' => 'post',         'hierarchical' => false,         'rewrite' => true,         'supports' => array('title', 'editor', 'thumbnail')     );          register_post_type( 'product' , $args );     }      This gives me the following url structure for my products: http://www.mywebsite.com/products/product-name. However, if I switch to another theme (TwentyTen) and then switch back WordPress forgets the permalink, now when I browse to the URL above I get my 404 page. The really strange thing I've noticed is that I can fix this issue by browsing to Settings -> Permalinks in admin. This temporarily fixes the problem until the next theme uninstall/ reinstall. Anyone else had a similar issue?


Create a url structure for my blogs based on categories and sub-cats

My blog design heavily relies on categories and sub-categories. I would like the url structure to be dependent on that. How can I make the url's support the same? I would like it to be like: `http://www.mywordpressblog.com/categoryname/subcategoryname/postname.html` It should also support further sub-categories if any. And if I have any pages, It should follow the same structure just that it should be substituted by the page name. _**Further info:_** > I am using Wordpress 3.0.1 and hence am using the custom menu feature which > allows me to combine my pages and categories into one awesome menu.


How to create a completely private wordpress with multiple membership levels

Hello I would like to create a private WordPress blog for friend and family and I would also require to restrict certain content for only family which the level of friends can't view. It could be entire categories or just a few posts. Is there any plug in that offers such flexibility. I would also like to protect my RSS feed and not allow search engines to index my site. Also I am using an external writer to create content. Its called ScreenSteps, this also allows me to upload content to my blog, all I did was to activate the XML-RPC option from the writing tab on the settings menu. Will this be affected if I make my blog private using a plugin ?


How do I set up "blog" posts to a page other than the main/home page?

Someone set me up with some custom work on top od another them and now I want to add a "what's new"/"blog"/"latest news" type page that is accessible from the main menu and is NOT the home page. How can I do that? It is not obvious to me how that is done. Thanks.


Override GD star rating IP based restrictions

Anyone know if its possible to prevent GD star rating from logging the IP address of a user's machine? I realise this is intended to stop people rating more than once but it prevents people from being able to rate if they are behind a proxy. A couple of thoughts which come to mind:   * override the method which does the logging in my theme's `functions.php`   * do something at the web-server level to mask the IP (potentially fatal probably)


How do I find if a page has a template?

So I'm doing a query like this:                   $the_query = new WP_Query( array( 'meta_key' => 'homepage', 'meta_value' => 'yes',      'post_type' => 'page', 'orderby' => 'modified', 'posts_per_page' => 1 ) );      To get a single page with a specific key value, how do I get the page template from a query like this, if it has one? Thank you!


How does one flush rules on theme activation or deactivation only?

Flushing rules is clearly an important part of creating themes with custom post types. See here and here. Does anyone have any example code of how to flush rules from functions.php? I'm a little surprised this isn't covered in the custom post type pages of the Codex. Update: I tried adding this to functions.php, but it didn't work:               register_deactivation_hook( __FILE__, array(&$this,'deactivate' ) );     function deactivate() {      global $wp_rewrite;      $wp_rewrite->flush_rules();     }


Issues with Saving Dynamic Metabox

So I'm having issues regarding a Dynamic Todo List Metabox. It should be so simple, everything else is working except for saving. I've been looking at it for 5 hours now, and could do with some fresh eyes.                   function webm_todo_box(){         global $post;         ?>
         <?php              //get the saved meta as an arry         $TodoList = get_post_meta($post->ID,'TodoList');              $c = 0;         if ( is_array($TodoList) ) {             foreach( $TodoList as $Todo ) {                 if ( isset( $TodoList['todotitle'] ) ) {                     printf( '
Todo Item Title: <input type="text" name="TodoList[%1$s][todotitle]" value="%2$s" />%4$s
', $c, $TodoList['todotitle'], __( 'Remove Track' ) );                     $c = $c +1;                 }             }         }              ?>          <?php _e('Add Todo Item'); ?>
<?php          }          add_action( 'save_post', 'save_TodoList', 10, 2 );     /* When the post is saved, saves our custom data */     function save_TodoList( $post_id ) {         // verify if this is an auto save routine.          // If it is our form has not been submitted, so we dont want to do anything         if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )              return;              // OK, we're authenticated: we need to find and save the data              $TodoList = $_POST['todotitle'];                   update_post_meta($post_id,'todotitle', $TodoList);     }


Genesis Grid Loop - Category Page

I would like to display posts in a Genesis Grid loop on all archive/category pages. So far I have followed Gary Jone's Tutorial: (http://code.garyjones.co.uk/genesis-grid-loop). Unfortunately, the posts on my site are not displaying properly, here is a link to the site: (http://83338.com/n/category/natural/) I would greatly appreciate is someone can help me out! Kind Regards, Will


Image not appearing when I update in a sidebar widget

Is there a cache or something to empty in wordpress when I make updates? On this site: http://richardclunan.com/ in the sidebar (or down the bottom if you're on a small screen) -- there's a widget with testimonials in it. With each testimonial is an image, and the image at the bottom is appearing sometimes; not appearing other times. Mainly not appearing. Would that be a cache thing? Or something else? How would I fix it? Thanks.


attachment media-template data model (data.size.url)

I'm trying to build a media library where users can choose pictures that are being retrieved from custom folders, which they can specify the basefolder of. I'd like to keep using as much WP functionality as possible, even use WP's attachment template , since it's only other images that need to be shown, but basic functionality stays the same. The problem I'm running into, is that WP won't show the data.size.url in it's template. It stays empty. This is the WP template (I left out the bottom part since it's not relevant to this post):                     And this is my object:               $aFileImgSize = getimagesize($sFolderUrl);          $aImage = array();     $aImage['uploading'] = false;     $aImage['id'] = $sFolderUrl;     $aImage['full'] = $sFolderUrl;     $aImage['thumbnail'] = $sFolderUrl;     $aImage['link'] = $sFolderUrl;     $aImage['caption'] = $sFile;     $aImage['type'] = 'image';     $aImage['size']['url'] = 'test';     $aImage['width'] = $aFileImgSize[0];     $aImage['height'] = $aFileImgSize[1];     $aImage['subtype'] = $aFileImgSize[2];          if($aImage['width'] >= $aImage['height']){         $sOrientation = 'landscape';     }else{         $sOrientation = 'portrait';     }     $aImage['orientation'] = $sOrientation;          $aSize = array();     $aSize['url'] = $sFolderUrl;     $aSize['width'] = $aFileImgSize[0];     $aSize['height'] = $aFileImgSize[1];     $aSize['orientation'] = $sOrientation;     $aImage['size'] = $aSize;          $images[] = $aImage;      I seem to be missing something... The $images array is echo'd back with a json_encode of course When I change the WP template from data.size.url to data.thumbnail, the correct value shows. Probably something stupid, but I hope someone can point out my stupidity then ;) Previous post about this plugin can be found here: print_media_templates not applied in media manager plugin


Trigger a function immeditely after a user posted a comment

I want to trigger a function immidiately after a user posted a comment on a post. I want to read from session data, find the user ID and look his facebook_id if he/she has any. Then i will post the same comment on his/her Facebook page. How can i immidiately know if a user has posted a comment? How can i know which user is that? How can i trigger a function after that?


Jetpack infinite scroll on widget

I would like to add the jetpack infinite scroll (other options would be good as well), to a sidebar widget that shows "additional posts". So instead of paginating (ajax) the whole page, i only want to "infinitely scroll the sidebar widget posts". and example of this functionality can be found here: http://9gag.tv/p/a9aE1B/r%C3%A9mi-gaillard-performs-a-trick-shot-for-every- team-at-2014-world-cup-foot-2014 (on the right side of the video). Will appreciate your help on the matter, as i tried my best. Also seems there are no plugins that offer this functionality (at least based on my search) would be great to have one. Thanks


Count how many articles meet a search after add search field

I create a custom post field named "related_keywords". When i add a post, before save, i fill this field with a list of keywords. After that, I need that it search title posts that meets this search criteria, and show me how many posts have this keyword on title post. I need how to call a function after this field its filled. Thanks and regards Javier


Open Page in Lightbox

I have something I’ve never done before and I’m not sure where to start. I’m working on the portfolio for a client’s site http://graybillcreative.com/arc/projects/. I’m using OTW Portfolio Light for the portfolio. My client wants the project page to pop up in a lightbox when you click on the project from the main portfolio page. Could someone help me figure out where to start? I’ve been working on editing OTW’s page templates and I’ve added rel=”lightbox” to the links but that isn’t working. Any ideas are appreciated!


Change an li class name in a wordpress custom menu walker

I'm building a nav that has a class applied to the main LI's and the nested LI's. Example:

Test

Test

test

test

      I've figured out how to get classes on the UL's and all the LI's, but I can figure out how to get a different class on the nested LI's. Here is my custom walker: This changes the nest UL class                class My_Walker_Nav_Menu extends Walker_Nav_Menu {       function start_lvl(&$output, $depth) {         $indent = str_repeat("\t", $depth);         $output .= "\n$indent
\n";       }      This strips out all the extraneous wordpress classes and adds the class nav- main-item to all the li's                   public function start_el( &$output, $item, $depth, $args )         {                  $attributes  = '';                  ! empty ( $item->attr_title )                 // Avoid redundant titles                 and $item->attr_title !== $item->title                 and $attributes .= ' title="' . esc_attr( $item->attr_title ) .'"';                  ! empty ( $item->url )                 and $attributes .= ' href="' . esc_attr( $item->url ) .'"';                  $attributes  = trim( $attributes );             $title       = apply_filters( 'the_title', $item->title, $item->ID );             $item_output = "$args->before$args->link_before$title"                             . "$args->link_after$args->after";                  // Since $output is called by reference we don't need to return anything.                       $output .= $indent . '
';                  $output .= apply_filters(                 'walker_nav_menu_start_el'                 ,   $item_output                 ,   $item                 ,   $depth                 ,   $args             );         }             }      I just can't figure out how to change the class on the nested LI's. Nothing I've done has worked. Any tips?


Backend option to include a javascript file on specific pages?

I am working on a template that my coworkers will be using to populate content. On some of the pages there will be a slider or multiple sliders but on other pages there won't be any. Because of this, I would like to create an option(maybe a checkbox or something) in the Pages backend that will allow them to include the slider script if necessary. I could enqueue the script only on specific page IDs, but since they will be creating many of these pages, I would rather have an automated way for them to include the Javascript themselves instead of me having to go in and add more page IDs every time they make a new page which uses the Javascript. Additionally I would like to use only 1 page template if possible. What would be the best way to go about this? Thanks!


Changing a WordPress core function without hacking core

I am looking to change one line within a core function. The function is `wp_allow_comment()` located within `/wp-includes/comment.php`               function wp_allow_comment($commentdata) {     global $wpdb;     extract($commentdata, EXTR_SKIP);          // Simple duplicate check     // expected_slashed ($comment_post_ID, $comment_author, $comment_author_email, $comment_content)     $dupe = $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_parent = %s AND comment_approved != 'trash' AND ( comment_author = %s ", wp_unslash( $comment_post_ID ), wp_unslash( $comment_parent ), wp_unslash( $comment_author ) );     if ( $comment_author_email )         $dupe .= $wpdb->prepare( "OR comment_author_email = %s ", wp_unslash( $comment_author_email ) );     $dupe .= $wpdb->prepare( ") AND comment_content = %s LIMIT 1", wp_unslash( $comment_content ) );     if ( $wpdb->get_var($dupe) ) {         /**          * Fires immediately after a duplicate comment is detected.          *          * @since 3.0.0          *          * @param array $commentdata Comment data.          */         do_action( 'comment_duplicate_trigger', $commentdata );         if ( defined('DOING_AJAX') )             die( __('Duplicate comment detected; it looks as though you’ve already said that!') );              wp_die( __('Duplicate comment detected; it looks as though you’ve already said that!') );     }          /**      * Fires immediately before a comment is marked approved.      *      * Allows checking for comment flooding.      *      * @since 2.3.0      *      * @param string $comment_author_IP    Comment author's IP address.      * @param string $comment_author_email Comment author's email.      * @param string $comment_date_gmt     GMT date the comment was posted.      */     do_action( 'check_comment_flood', $comment_author_IP, $comment_author_email, $comment_date_gmt );          if ( ! empty( $user_id ) ) {         $user = get_userdata( $user_id );         $post_author = $wpdb->get_var($wpdb->prepare("SELECT post_author FROM $wpdb->posts WHERE ID = %d LIMIT 1", $comment_post_ID));     }          if ( isset( $user ) && ( $user_id == $post_author || $user->has_cap( 'moderate_comments' ) ) ) {         // The author and the admins get respect.         $approved = 1;     } else {         // Everyone else's comments will be checked.         if ( check_comment($comment_author, $comment_author_email, $comment_author_url, $comment_content, $comment_author_IP, $comment_agent, $comment_type) )             $approved = 1;         else             $approved = 0;         if ( wp_blacklist_check($comment_author, $comment_author_email, $comment_author_url, $comment_content, $comment_author_IP, $comment_agent) )             $approved = 'spam';     }          /**      * Filter a comment's approval status before it is set.      *      * @since 2.1.0      *      * @param bool|string $approved    The approval status. Accepts 1, 0, or 'spam'.      * @param array       $commentdata Comment data.      */     $approved = apply_filters( 'pre_comment_approved', $approved, $commentdata );     return $approved;     }      I would like to change `$approved = 'spam';` to `$approved = 'trash';` - is this something that can be accomplished without hacking the core? I am trying to wrap my head around filters as a possible solution but not having any luck. I have tried something like this:               add_filter('pre_comment_approved', 'custom_blacklist',1, 0);          function custom_blacklist() {         if ( wp_blacklist_check($comment_author, $comment_author_email, $comment_author_url, $comment_content, $comment_author_IP, $comment_agent) )             $approved = 'trash';     }      but it ended up killing spam filtering all together, I am definitely not using filters properly.


Location-Based Pages displaying results near customer

I'm creating a website where the customer will enter their postal code and the pages (with a distance selected of 5, 10, 20 miles) will display on either a Google map or Bing map. The page results will display to the side of the map with a linkable Title and Address to visit the Page. My thought is to add fields to the Page where the address and postal code can be entered. Then add a function on the Index that will pull the results from the Pages. The first piece is the customer will narrow their selection through Categories first. If this function would be easier to pull from Posts, I can change my route. I actually had a dream of how this plugin could add tables to the sql but I've never made anything like this before... thoughts?


unregister_sidebar in child theme not working

I'm woking on a chid theme for Ohsik. I'm trying to unregister a sidebar, but nothing is working Here's my function.php child theme code:               function unregister_footer_sidebar() {     unregister_sidebar( 'sidebar-2' );     }     add_action( 'widgets_init','unregister_footer_sidebar',11);     add_action( 'widgets_init', 'ohsik_widgets_init',12);      What am I doing wrong? Any suggestions to solve the problem?


call stored procedure without parameters

I asked this question last week, but then I deleted it because it was stated to be off-topic because I use a function within buddypress. However, I am convinced that whatever I am doing wrong is more off a wordpress thing than a buddypress thing. So here I am again. I want to perform a stored procedure in MySQL which updates the wp_bp_xprofile_data table with information from a view in MySQL. The procedure should be started when somebody updates his profile. This is the code I use in bp-custom.php.               function something_updated_profile() {            $wpdb->query("CALL dekking_ophalen( )");            }     add_action('xprofile_updated_profile', 'something_updated_profile');      However, when I update my profile I only see a white page ( I have debugger enabled). After doing some research on the buddypress forums I am pretty sure that the error I make is in the `$wpdb->query("CALL dekking_ophalen( )");` line. I use wordpress 3.9.1 & bp 2.0.1. The stored procedure is stated as:                INSERT INTO wp_bp_xprofile_data     ( field_id,  user_id, value )          SELECT 15, User,  dekking_absoluut     FROM  dekking          On duplicate KEY UPDATE      wp_bp_xprofile_data.value=(SELECT dekking.dekking_absoluut       FROM dekking       WHERE dekking.user=wp_bp_xprofile_data.user_id )      This stored procedure doesn't give any results, it just perform an updata on a table. What point am I missing here?


List sibling pages widget, exclude current page

I successfully created a widget that displays sibling pages to the current page I'm on in the sidebar. Only thing is, I'm not capable of excluding the current page - can someone please assist here? I'm still learning and can't handle more complex PHP yet **Edit** : To avoid misunderstandings -   * Page      * Subpage 1      * Subpage 2      * Subpage 3 I want Subpage 2 and 3 being displayed by the widget when I'm currently on Subpage 1. **Edit:** I forgot to post my codesnippet:                   <?php echo $before_widget; ?>                                               <?php                                 global $wp_query;                                 if( empty($wp_query->post->post_parent) ) {                                     $parent = $wp_query->post->ID;                                 } else {                                     $parent = $wp_query->post->post_parent;                                 } ?>                                      <?php                                      if(wp_list_pages("title_li=&child_of=$parent&echo=0" )): ?>                                         <?php if ( $title ) echo $before_title . $title . $after_title; ?>                                             <div id="submenu">                                                 <ul>                                                 <?php wp_list_pages("title_li=&child_of=$parent" ); ?>                                                 </ul>                                             </div>                                 <?php endif; ?>             <?php echo $after_widget; ?>


Wordpress rewrite url help needed

I am using wordpress and very new in wordpress. I need url rewrite method, i guess it doesnot changes in permalinks. I need to work on .htacess file. I am adding locations where i have to add LokId, Now my url is like this.                www.url.com/locations/titlename/.      What Actual I want url like this. > www.url.com/locations/lok id(act city name)/titlename/. Do i need to do work on .htacess file. Please give me idea how to do this ? Thanks


Unable to get the Parent Custom Taxonomy Terms

I am unable to get the Parent Taxonomy Terms here is the code i am writing               $myterms = get_terms( 'iqvis_event_category', array( 'parent' => 0 ) );     echo '<pre>';      print_r($myterms);     echo '</pre>';      What is the Reason is there any Syntax problem ? or the parent argument is not working?? because if i am not giving the parent argument its working and getting all the terms with their children.


Taxonomy term count

I have a custom post type called "RESOURCES" which I used to create a directory of resources on my website. This CPT has the taxonomy called "PRICES". There are three terms   * free   * free trial   * premium So, when someone's viewing my directory and they see in the sidebar "PRICES" with those options underneath, they could click on (for example) FREE and see 18 different free resources listed. What I want is for that term page > mysite.com/price/free to have the headline > 18 free resources How can I achieve this?


Remove Advanced Custom Fields plugin for client?

I just have a quick question... I am using the Advanced Custom Fields plugin on a site for a costumer, just to get a little more power into it.... but I wouldn't want the client to be poking around in there, and get all confused... is there an easy none-obtrusive way to sort of hide the options from the end user, bdut still keep the functionality around? I'm guessing a more generic google search would probably help me out, but it would be great to just get some feedback from u guys :) -cheers kriwis


Change loop order via form or link (jquery, not URL)

I would like to change the loop order via a link or form input, but it can`t load via URL, because i need to orderby=meta-value and this cannot be done via url args (acording the codex) , only like this:               <?php $argsvs = array(                          'post_type' => 'evento',                          'posts_per_page' => -1,                         'meta_key' => 'wpcf-evento-data-inicio1',                         'orderby' => 'meta_value',                         'order'=>'DESC' );     $loop = new WP_Query( $argsvs );     ?>      How would I let the user change the above args to orderby another custom field? ex:                                         'meta_key' => 'wpcf-evento-data-inicio2',                             'orderby' => 'meta_value'      If it was order by title or something like this, i could do it via URL like `?post_type=evento&orderby=title&order=ASC`, but for a `meta_key` and `orderby=>'meta_value'` args, this can't be done via URL


Moving customized core code into plugins?

I am a complete WordPress noob, so please don't mind. I'm working on a project where developers tweaked the core WordPress code. My job is to extract whatever core functions they changed and put them somewhere else so that in the future when the WordPress version is upgraded it will be more maintainable. I did some research and it looks like writing a plugin is the way to go. After reading this: https://codex.wordpress.org/Writing_a_Plugin , I'm under the assumption that WordPress will first look through all the functions in my plugins and if it finds one it won't default to the WordPress core version of the function? So is this equivalent to overriding the WordPress core functions? So from the link I provided, it looks like plugins just require: 1. (by default, unless changed) storing them under `wp- content/plugins/my_plugin_name` 2. comments in the head of the PHP file stating the plugin details. So in this case, can I just make a single file `wp- content/plugins/my_plugin_name/my_plugin_name.php` with all the customized core functions inside of it? Do I not to add any `include "my_plugin_name"` ? It just loads automatically?


WordPress and jQuery

I am fairly new to using jQuery in WordPress and I am trying to write jQuery scripts in a separate file. What is the difference between the following two syntaxes of setting up the external file: ### Version I               jQuery(function() {         jQuery("#radio").buttonset();     });      ### Version II               $(document).ready(function() {         $("#radio").buttonset();     }


Prevent child theme from inheriting a parent theme's required file

My parent theme has a file with a class that defines ads for that specific theme. It is required in functions.php. My child theme needs a duplicate file with different ad parameters so I would like to not include the parent theme's file. Is there an easy way to ensure the parent theme file will not be required in the child theme?


wp_nav_menu - Collapse with PHP

How can wp_nav_menu be used to collapse and expand elements with PHP? Some walker function? Plugin maybe? **What it looks like in wp-admin menus**               About         Customers         Cases     Contact         Contact us         Contact someone else      **On the front page - When I have not selected anything it should look like this**               About     Contact      **When I selected About it should look like this**               About         Customers         Cases     Contact      **When I selected Customers it should look like this**               About     Contact         Contact us         Contact someone else


Redirect page to first post in custom post type

I have a page, let's called it "Artists", that displays a list of posts in a custom post type, again "artists". How can I redirect pepole who visit the Artists page to the first post in the "artists" post type?


using post__in allow duplicate post id

I have an array of ids in a specific order. I use `post__in` in my query to get posts from this array. I have some duplicate post IDs that I need to show twice in the page but the query seems to ignore them. Let's say the array is as follows               array values  = 1,2,3,4,2,5      When I pass this array to `post__in`, it doesn't take value `'2'` twice as i specified in the array. Is there a workaround for this?


Adding dependencies to script enqueing

What is the point of the dependencies parameter when using wp_enqueue_script()? For instance, when I do the following:               wp_enqueue_script(         'jscripts',         get_stylesheet_directory_uri() . "/scripts/jscripts.js",         array('jquery-ui-datepicker'));          echo wp_script_is('jquery-ui-datepicker', 'queue')         ? '
' . '[jquery-ui-datepicker] Script is enqueued' . '
'         : '
' . '[jquery-ui-datepicker] Script not enqueued' . '
';      I get the output 'Script not enqueued' (and the function does not work properly). However, when I do this:               wp_enqueue_script(         'jscripts',         get_stylesheet_directory_uri() . "/scripts/jscripts.js");          wp_enqueue_script('jquery-ui-datepicker');          echo wp_script_is('jquery-ui-datepicker', 'queue')         ? '
' . '[jquery-ui-datepicker] Script is enqueued' . '
'         : '
' . '[jquery-ui-datepicker] Script not enqueued' . '
';      It works properly and it displays 'script is enqueued'. Having read the documentation, it would seem like when you specify the handle of dependencies for a script that you are about to enqueue, it will enqueue those dependencies before enqueing it. But, this doesn't seem to be the case. How does this all work?


Using AJAX to generate front end / viewer end pages

I am currently trying to send certain data via POST method from code in the widget of my plugin to the theme's archive.php page. The code that contains the data for jquery/ajax is :               year .'" data-month="'.$previous->month.'" data-category="'.$category.'" href="' . filter_date_link($category,$previous->year, $previous->month, $day=false) . '" title="' . esc_attr( sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($previous->month), date('Y', mktime(0, 0 , 0, $previous->month, 1, $previous->year)))) . '" id="previous_link">« ' . $wp_locale->get_month_abbrev($wp_locale->get_month($previous->month)) . '	';          $calendar_output .= "\n\t\t".'year .'" data-month="'.$next->month.'" data-category="'.$category.'"href="' . filter_date_link($category,$next->year, $next->month, $day=false) . '" title="' . esc_attr( sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($next->month), date('Y', mktime(0, 0 , 0, $next->month, 1, $next->year))) ) . '" id="next_link">' . $wp_locale->get_month_abbrev($wp_locale->get_month($next->month)) . ' »	';      The js code is:               jQuery(document).ready(function($){               $('#next_link').click(function(e){              e.preventDefault();                   var $aid =$('#next_link'),              year =$aid.data('year'),              month =$aid.data('month'),              category =$aid.data('category');               });              $('#previous_link').click(function(e){              e.preventDefault();                   var $aid =$('#previous_link'),              year =$aid.data('year'),              month =$aid.data('month'),              category =$aid.data('category');               });              console.log('category: ' + category);              $.ajax({              cache: false,              timeout: 8000,              type: 'POST',              data: {year : year, month: month, category: category},              url: '/path/myfile.php',              success: function(data) {},              error: function() {}         });          });      And the page where this code will be used is:               <?php     //Specific class for post listing */     $blog_type = sq_option('blog_type','masonry');     $template_classes = $blog_type . '-listing';     if ($blog_type == 'standard' && sq_option('blog_meta_status', 1) == 1) { $template_classes .= ' with-meta'; }          add_filter('kleo_main_template_classes', create_function('$cls','$cls .=" posts-listing '.$template_classes.'"; return $cls;'));          if(isset($_POST['category'])){                  $category=$_POST['category'];                  $year=$_POST['year'];                  $month=$_POST['month'];                  if(isset($_POST['day'])) {                      $args = array('category_name' => $category ,                  'date_query' => array(                                                    array(                                         'year' => $year,                                                              'month' => $month,                                                                                'day' => $day,                                         ),                                                                                'column' => 'post_date',                                                                    ),                 );      The `$args` array will be used to create a new query in the WP Loop. I am fairly experienced with php yet AJAX and jQuery are a bit new to me. What am I missing what do I need to add/ take away to make it work. **UPDATES:**   * when using the code above and checking console in the debugger I get: _Failed to load resource: the server responded with a status of 404 (Not Found)_   * fixed the above issue by using the solution suggested by the kaiser, however I now get this mistake, on line 29 of my jQuery : _Uncaught ReferenceError: category is not defined_ .   * Question that for now I failed to find a comprehensible answer to : ' Where do I include the localisation and call to jQuery so that the variables are actually passed in post format? Here is the code where I use enqueue to attach the script in my plugins file ( not sure if the right place or the right way ):               add_action( 'wp_enqueue_scripts', 'theme_enqueue_scripts' );          function theme_enqueue_scripts() {            // Enqueue and Localize AJAX JavaScript Functions File        wp_enqueue_script( 'ajax-categories-js', plugins_url( 'events-calendar-manager/inc/js/js.js' ), array('jquery'));          }


Adding scripts to admin page in my theme

In functions.php of my theme I have code to add page in admin area and append scripts to it. But scripts are not loaded. Bellow is code. Commented out add_action lines are the one I did check.                   // functions.php         // Append user style and scripts to Add New Wallpaper menu         function pb_admin_scripts() {           wp_enqueue_script('media-upload');           wp_enqueue_script('thickbox');           wp_register_script('pb-upload', get_template_directory_uri() . '/pb-upload.js');           wp_enqueue_script('pb-upload');         }              function pb_admin_style() {           wp_enqueue_style('thickbox');         }                   function pb_wallpaper_adminmenu() {           $page = add_menu_page('Dodaj Tapetę', 'Dodaj Tapetę', 'edit_posts', 'add-wallpaper', 'pb_add_wallpaper', '', 6);         }         //  add_action( 'admin_head-add-wallpaper', 'pb_admin_scripts');         //  add_action( 'admin_print_scripts-add-wallpaper', 'pb_admin_scripts');         //  add_action( 'admin_print_styles-add-wallpaper', 'pb_admin_style');         //  add_action( 'load-add-wallpaper', 'pb_admin_scripts');         //  add_action( 'load-add-wallpaper', 'pb_admin_style');                   // add new wallpaper         function pb_add_wallpaper() {           ?>

Dodaj Nową Tapetę
           <form method="post" action="">             <input type="hidden" name="action" value="pb_add_wallpaper" />             <input id="upload_image_button" type="button" value="Upload Image" />             <input type="hidden" name="upload_image" id="upload_image" />             <?php wp_nonce_field('pb_add_wallpaper', '_nonce'); ?>           </form>
              <?php         }               add_action('admin_menu', 'pb_wallpaper_adminmenu');


Is it possible to order a query on one taxonomy term by the terms in another, connected taxonomy?

I've seen the negative answer in this question, Using wp_query is it possible to orderby taxonomy?, but I think I have a valid use case for something similar that's less broad than in that previous question. I have a custom post type of "resources", and a linked taxonomy of "resource- category" with terms like "architectural drawings", "tech specs", and "msds". The post type is also linked to a site-wide taxonomy called "business-line", for the different divisions of the company, so that resources, products, blog posts, etc. can all use the same terms for the division of the company they belong to. I created a taxonomy page that will list all the current resources for a particular business-line. I did this by adding the following in my plugin right after I defined the "resources" post type. (I'm omitting my error checking from the quoted code.)                               register_taxonomy_for_object_type( 'business_line', self::POST_TYPE_SLUG );                     add_rewrite_rule(                         'technical-library/line/([^/]+)/?$',                         'index.php?post_type=resources&business_line=$matches[1]',                         'top'                     );      And then I have a template named **_taxonomy-business_line.php_** which gets chosen when this rewrite rule is matched. My only remaining issue with this system is that I would like to group the listing by those resource-categories like this: > **Architectural Specs** > > Resource Foo > > Resource Bar > > **MSDS** > > Resource Baz etc. I'm already using a _pre_get_posts_ action to get all the resources in this case, so I was hoping I could add some kind of order by clause at that point. I trying not to have to duplicate any queries in the template file itself. If I can get the lists of posts to come back the right order, I could just check for when the term changes in the loop, and output a new header at each change. If someone could point me in the right direction, I would really appreciate it. **Edit:** I came up with a workaround, but it is seems incredibly "hacky". I put the following code at the top of my template. It adds the terms for the custom taxonomy to each post object in a "loop before the loop", and extracts the term name into a top-level property, just to make sorting on that name clearer.               if (have_posts()) : while (have_posts()) : the_post();        $post->resource_category = get_the_terms( $post->ID, 'res-cat' );        $term_name = reset( $post->resource_category );        $post->resource_category_name = $term_name->name;     endwhile; endif;          // rewind     rewind_posts();           function compare_resources_by_res_cat_name( $a, $b ) {       return strcmp( $a->resource_category_name, $b->resource_category_name );     }     global $wp_query;     usort ( $wp_query->posts, 'compare_resources_by_res_cat_name' );      This seems to work, but I hate having to use a global, and to "reach inside" the post objects like this. Is there a way to make this safer, or an alternative where I wouldn't have to do this?


how to use the slide show of Skylark in showcase?

I created a page and I set the template as _showcase_ and then I went to setting->reading and as a static page I choose my created page. I'm wondering how I can add slideshows with pictures and sticky posts. I went to documentation in the link but unfortunately I couldn't find anything.


Registration area + reserved area

As the title of this post says i need to create a registration form to let readers register to my site and access to special contents not visible to everybody. Is there some plugin that handles this features? I've tryed some, but after login they redirect me on wordpress admin back-end. I do not want to allow people access to website admin page. Any suggestion?


Wordpress Split Menu

I'm coding my first WordPress Theme and trying to solve this problem: On the desktop version of the website I’d like to split the menu into 2 sections. One would appear on the left of the logo and the other on the right of my logo (the logo is centered). The only way I know how to do this is to create 2 separate MENU objects in WP and then with CSS position each one accordingly. This however causes a problem when I want to convert the menu into a mobile- friendly drop-down menu, because in the approach shown above I end up with 2 separate lists of menu items (Left and Right) and I don’t know how would I merge them into one list for mobile-friendly drop-down menu. I understand I can write custom CSS to add margin between menu item #2 and item #3, for example. But since I’m writing a theme this approach won't work, as it requires to know upfront how many menu items will be present. I need it to be something that would work regardless of the number of menu items and that would allow people to re-arrange menu items using WP Menu UI. Is this the wrong way to tackle this? If you could suggest how to approach this better I’d be very appreciative.


active parent page when clicked on childpage

Hi there Wordpress guru's, i running up against a problem. I've my parent pages in the header.php and childpages in page.php. when i clicked on one of the subpages in a parent page i want that my parent page stay active. How can i get that done? in my header.php i've the following code:
      <?php wp_list_pages('sort_column=menu_order&exclude=2&depth=1&title_li='); ?>
      page.php               <?php if($post->post_parent)                 $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0"); else                 $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");                 if ($children) { ?>

<?php echo 'post_parent).'">'.get_the_title($post->post_parent).'';?>
                 <?php echo $children; ?>

                 <?php } else { ?>             <?php } ?>      U can see the example : here when you click on one of the subpages i want that the parent page (the tab above) stays active. tnx for advance.


How great custom post type can be?

You know how sweet it is WP with its plugins and custom post types. I love WP so much until i have come to a thought that most of any kind of website can be done in WP. Recently my boss want me to build a hotel/accomodation searching website. Its like hotels.com kind of website except there is no booking feature. My question is, can i do this in WP if i use its custom post types ability or worst is create a dedicated plugin for it? what do you think of this as WP expert?


A meta box (in a custom post type) with two different type of fields

![enter image description here](http://i.stack.imgur.com/crchc.png) I want to make a meta box (in a custom post type) with two different type of fields:   * Text    * and select, (maybe put it in array ?)  and display this meta box with this two fields with a single ID like so:               if ( get_post_meta( $post->ID, 'The_ID', true ) != '' ) {         echo get_post_meta( $post->ID, 'The_ID', true );     }      Is this possible?


Apostrophe in permalink results in page not found

I'm working through a migration from Drupal to a WP multisite network, I've got a post meta field that contains the URL of the old post (mostly to maintain social counts and such) that I'm using for the permalink structure. I'm doing this with the following:               add_filter('post_link', 'migration_permalinks', 10, 3 );          function migration_permalinks( $permalink, $post, $leavename ) {               if( ($post->post_type == 'post' ) && ( $the_link = get_post_meta( $post->ID, '_the_old_site_permalink', true) ) ) {             $url = parse_url( $the_link );             $permalink = site_url() . $url['path'];         }              return $permalink;     }      The issue I run into is that if the post title contains an apostrophe, `’` (not a straight single quote `'`), the post URL does not work. Encoded, that converts to `%E2%80%99` . In the browser address bar, if I change the apostrophe to a straight single quote, the URL works and the post displays. The existing Drupal site contains the apostrophe (`%E2%80%99`) without issue. Maintaining the URL as is is pretty important because I don't want any existing links to the page to 404 when the migration occurs. Why is the link not working when it contains an apostrophe?


add_media_page function not creating submenu

I have the following plugin that I'm just testing at the moment.               /*     Plugin Name: Menu Test     Plugin URI: http://codex.wordpress.org/Adding_Administration_Menus     Description: Menu Test     Author: Codex authors     Author URI: http://example.com     */               include('./customFields.php');          // Hook for adding admin menus     add_action('admin_menu', array('customFields', 'buildOptions'));          // action function for above hook      And the class that goes with it in customFields.php               class customFields {              private function createMenu () {             add_media_page('Custom Media Options', 'Add Fields to Media',     'manage_options', 'custom_media_options', $this::createMenuOptionsPage());              }              private function createMenuOptionsPage () {             echo 'test';              }              public function buildOptions () {             $this::createMenu();         }          }        I can't see anything wrong with my syntax, but the submenu under media never appears. Can someone help me please?


Why does pagination always break when used on any form of a home page?

Why does WP pagination break when used on the homepage? If you take the code below and use it in a page template it works perfectly (make sure you have 3 or more posts). However, as soon as you use the same code on home.php, front-page.php, index.php or even as a page template but set as a static homepage, it breaks. The URL shows `/page/2/` but you get a 404 page. If you change the URL to `/?page=2` it works. I have seen so many questions related to this all over the place, yet none have a solution that works. For the sake of simplicity I have simplified the loop below and I'm using the default WP next and previous posts links. I don't wish to use a plugin such as WP-PageNavi or similar.               <?php get_header(); ?>              <?php                  // taken from https://codex.wordpress.org/Pagination             if ( get_query_var('paged') ) {                  $paged = get_query_var('paged');              }              else if ( get_query_var('page') ) {                 $paged = get_query_var('page');              }              else {                 $paged = 1;             }                  $wp_query = new WP_Query( array(                  'posts_per_page' => 2,                 'paged' => $paged             ));              ?>              <?php if ( $wp_query->have_posts() ) : while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>                   <?php the_title(); ?>              <?php endwhile; endif; ?>              <?php previous_posts_link(); ?>         <?php next_posts_link(); ?>              <?php wp_reset_query(); ?>          <?php get_footer(); ?>


Custom order for Mysql array

I have a Page of Posts, each post has a Custom Field "expired" which contains a date in the format YYYY-MM-DD which is used to order the posts. This date is used for a script that tells the visitor if an offer has either expired or is valid for X days more. My array is as follows:               $postid = get_the_ID();     $meta1 = get_post_meta($postid, 'shop', true);     $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;          $args = array(     'post_type' => 'post',     'meta_query' => array(         array(             'key' => 'shop',             'value' => $meta1         )     ),     'paged' => $paged,     'posts_per_page' => '4',     'meta_key' => 'expired',     'orderby' => 'meta_value',     'order' => 'ASC'     );          $query = new WP_Query( $args );      This orders the posts using the meta_value of "expired", earliest date at the top. When the "expired" meta_value date is before 'TODAY' the post script will show "EXPIRED" When the "expired" meta_value date is after 'TODAY' the script will show "Expires in X days" **How posts currently display:** When a post 'expires' it currently stays at the top of the post list.               Post 1: Expired     Post 2: Expired     Post 3: Expires in 3 days     Post 4: Expires in 4 days     Post 5: Expires in 6 days      **Instead, I'd like to automatically order it thus:** (note Post # for comparison to above)               Post 3: Expires in 3 days     Post 4: Expires in 4 days     Post 5: Expires in 6 days     Post 2: Expired     Post 1: Expired      How can I create a custom order where once a post expires (ie. it's 'expired' date is before Today's date) it is put to the back of the post list yet still above older expired posts? Thank you.


Add custom attributes to a post

My blog is mainly composed of posts describing hiking. Actually, since I just moved from a Wordpress.com blog to a self-hosted Wordpress blog, every hike is inserted in a simple post. However, every hike has certain parameters (e.g.: ascent, length, difficulty, ...) I'd like to save in the database in form of attribute and not simple text. My idea would be to use Wordpress to:   1. Automatically fill-in the hiking list page.   2. Add a search form that will help the reader to find the best hike for him, on the basis of certain parameters (for example: "I do not want to exceed 1'000 meters of ascent"). Essential requirement is that the permalink URLs will not change because the blog has been active for a few years. I was wondering: might the _Wordpress Custom Post Types_ work for my specific case? Or are there better solutions? Might I use the _Custom Meta Boxes_ for the hike's attributes like ascent, length and difficulty? To create the hiking list page could I use the _Shortcodes_? How can I implement the search form that will help the reader to find the best hike for him?


how to place a link on the first post only using a plugin

i want to add a link to the first post of every WP blog that i have. For example this simple function adds the link to every post.                   function add_link($link){              $link .= 'Link';     return $link;         }         add_filter('the_content','add_link');      so basically instead of the link showing below each post, I want it to show only at the bottom of the first post only. thanks.


All URLs are having '/blog/' appended to them.

I just made a WP theme, and I'm using a custom page template for the blog and for the home. The problem is that all the URLs now have /blog/ appended to them (which, I believe is the name of the page that's using the Blog Page Template). Following an article in the Codex, I made the Blog page template empty, and instead added the blog content to `home.php`. What am I doing wrong?


Why a SlideShow (made using JQuery FlexSlider) can't work if I load it form functions.php but work if I load it from my footer.php file?

I have the following situation: I am carrying this pure HTML theme (that use BootStrap CSS framework) into a WordPress theme. This is the original pure HTML demo theme (I have the entire source code because it is a downlodable example): http://www.html.it/guide/img/bootstrap/demo/home.html And this is my personal WP theme on wich I am working on: http://onofri.org/WP_BootStrap/ As you can see the only difference from the original demo website and my personal WP theme is that in the second one the SlideShow in the header (made using the flexslider JQuery plugin) is not shown. I have do the following operations: 1) In my footer.php file I have disabled the JavaScript loading commenting them and I call **wp_footer()** , in this way:                   <!--         <script src="http://code.jquery.com/jquery.js"></script>         <script src="/wordpress/wp-content/themes/AsperTheme/assets/bootstrap/js/bootstrap.min.js"></script>         <script src="/wordpress/wp-content/themes/AsperTheme/assets/plugins/flexslider/jquery.flexslider.js"></script>         <script src="/wordpress/wp-content/themes/AsperTheme/assets/plugins/fancybox/jquery.fancybox.pack.js"></script>         <script src="/wordpress/wp-content/themes/AsperTheme/assets/js/scripts.js"></script>         -->         <?php wp_footer(); ?>     </body>      2) I have insert the following code into my functions.php file to load all the previous JavaScript using the WP standard way:               /* Function automatically executed by the hook 'load_java_scripts':      * 1) Load all my JavaScripts      */     function load_java_scripts() {              // Load JQuery:         wp_enqueue_script('jquery');         // Load FlexSlider JavaScript         wp_enqueue_script('flexSlider-js', get_template_directory_uri() . '/assets/plugins/flexslider/jquery.flexslider.js', array('jquery'), 'v2.1', true);         // Load bootstrap.min.js:         wp_enqueue_script('bootstrap.min-js', get_template_directory_uri() . '/assets/bootstrap/js/bootstrap.min.js', array('jquery'), 'v3.0.3', true);              // Load FancyBox:         wp_enqueue_script('fancy-js', get_template_directory_uri() . '/assets/plugins/fancybox/jquery.fancybox.pack.js', array('jquery'), 'v2.1.5', true);         // Load scripts.js:         wp_enqueue_script('myScripts-js', get_template_directory_uri() . '/assets/js/scripts.js', array('jquery'), '1.0', true);         // Load Modernizer:         wp_enqueue_script('myodernizer-js', get_template_directory_uri() . '/assets/js/modernizr.custom.js', array('jquery'), '2.6.2', true);          }     add_action('wp_enqueue_scripts', 'load_java_scripts');      As you can see I set all scripts depend on JQuery so JQuery is loaded first. But as you can see the **jquery** and\or the **jquery.flexslider.js** can't work. The strange thing is that I change the end of my **footer.php** file in this way the SlideShow is correctly shown:                   <script src="http://code.jquery.com/jquery.js"></script>         <script src="/wordpress/wp-content/themes/AsperTheme/assets/plugins/flexslider/jquery.flexslider.js"></script>              <?php wp_footer(); ?>     </body>     </html>      So what am I missing? What could be the problem? Looking at the source code of my website (into FireFox) it seems to me that all the JavaScript is loaded but can't work, the SlideShow not appear. What is the difference?