How to query custom post types with mixed AND & OR statements for custom fields

I have a custom post type "`events`" which includes the custom fields "`is_premium`" (which is a true/false) and "`premium_expiry_date`" which is a date picker. On my front end, I want to have "`events`" which are premium and their `premium_expiry_date` has not passed to be displayed on the top of the results. I have managed to do half of that by `WP_Query` querying "`events`" for which the `is_premium==true && premium_expiry_date>$today` (my code shown below). I pull them successfully in a table which appears ton top of my page. My problem is with displaying the rest, and avoiding double posts. Essentially, I would need a query like `[ is_premium==false OR (is_premium==true AND premium_expiry_date<$today ) ]` but I know that `AND` and `OR` cannot be mixed in `WP_Query`. I have tried to go into using `$wpdb` but with no luck (I am lacking SQL knowledge...) My question is, could somebody either help me with how to syntax this using `$wpdb`, or direct me to a different path for achieving my desired result?                       // This is the code I use to show the premium events which have not occurred yet,             // and their premium date has not passed             $today = date('Ymd');             $args = array(             'post_type' => 'event',             'orderby'   => 'event_date',             'meta_key'  => 'event_date',             'order' => 'ASC',             'relation' => 'AND',             'meta_query' => array(                          array(                     'key'       => $the_key, //I read this from a _GET value. It resembles another custom field                     'compare'   => 'LIKE',                     'value'     => $current_region->name, //filter based on current region                     ),                          array(                     'key'       => 'event_date',                     'compare'   => '>=',                     'value'     => $today                     ),                          array(                     'key'       => 'is_premium',                     'compare'   => '==',                     'value'     => 1                     ),                          array(                     'key'       => 'premium_expiry_date',                     'compare'   => '>=',                     'value'     => $today                         ),                          ),                   );              ?>              <?php $the_query = new WP_Query( $args ); ?>              <?php if( $the_query->have_posts() ): ?>              <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>          ... END       Thanks a lot in advance edit: This is the output of `<?php var_dump($GLOBALS['wpdb']->last_query) ?>` when placed right after `<?php $the_query = new WP_Query( $args ); ?> `               string(97) "SELECT post_id, meta_key, meta_value FROM wp_postmeta WHERE post_id IN (147) ORDER BY meta_id ASC"


Editing a theme's templates

I have installed the template successfully. I know how to work with modules and articles and menu creation. I don't know how to work with code parts.   * How can I change the styles on css.   * How to modify the template   * How to modify the home page I have tried many times finding the folder on the installation directory but couldn't. How can I find it and change it.


How i can widget ID get after drag for wordpress with jquery?

I create custom widget with select option image but first time selected option image are not showing after saving this function work perfectly,I need this function only load after Drag in sidebar then load function?               jQuery(document).ready(function() {         jQuery('body').on('change', '.selector', change_image);              function change_image(){             var $path = jQuery(this).find('option:selected').val();             jQuery('.image_path').attr('src',$path);         }     });


Add highlighting to new Admin Dashboard Menu Item

I have implemented a Custom menu item in my wordpress dashboard using the following command in the functions.php               function create_menu() {         $settings_page = add_menu_page('Edit_Post_69', 'Edit_Post_69', 'add_users', '/post.php?post=69&action=edit', '', get_stylesheet_directory_uri() . '/editicon.png', 2);     }      This works great and has added the icon into the dashmenu, included the icon and when clicked, takes me to the Edit Post page on post #69. ![enter image description here](http://i.stack.imgur.com/LRbqg.jpg) The problem I am facing is that even though I have clicked my custom link, the page it is currently on is the Edit Post page, this causes the Highlighted arrow to be on the Post section rather than my custom section as in the image below. ![snapshot2](http://i.stack.imgur.com/sExSY.jpg) What I need is for my custom item to be highlighted as well, I have tried looking at filters and dug out _wp_menu_output, the idea being to filter the html and change the id class of the item to give it its highlighting. Can anyone point me in the right direction of resolving this issue?


How to Customize number of blog posts on first page?

Under Reading Settings, I can specify how many blog posts to display on a page. However, I would like to customize this a bit. For example, I want to only display 2 posts on the "/" page, but 3 posts on "/page/2", "/page/3", etc. Any way to customize the homepage to display one less post than the other pages?


Give Editor Access To Sidebar

I want to give the Editor Role access to editing the sidebar and it's contents. I have a text widget in there and in order to edit this text widget the user needs to be an admin - this sucks. How do I grant permission to the Editor Role that will give him access to edit the sidebar?


Where can I edit Admin Panel Page file

I need to edit the "Help" section of the "Page" page in the Admin panel. Since wordpress doesn't allow multiple line breaks I need to make sure the user knows that if they add the "   " tag in the HTML section they will achieve the line break so I figure what better place to add this than the help section. I can't seem to find the Page file though. Directory Help?


wp_remote_get sslv3 alert handshake failure

I'm attempting to retrieve remote content with wp_remote_get but I'm getting the following error returned : 'sslv3 alert handshake failure'. I've tried using 'sslverify' => false in the args array, but to no avail. This was working fine on the dev server, but no more, so I'm assuming it's a server/apache configuration issue. Any ideas on how I can address this, either by modifying the calling function or server config?


Trying to save custom post type from frontend partially working

I've created the following custom post type (lugares means places) with a custom taxonomy of tacos and it works fine form the backend:               /**     *   Custom post-type lugares     **/          add_action('init', 'lugares_register');          function lugares_register() {              $labels = array(             'name' => _x('Lugares', 'post type general name'),             'singular_name' => _x('Lugar', 'post type singular name'),             'add_new' => _x('Agregar nuevo', 'lugar'),             'add_new_item' => __('Agregar lugar'),             'edit_item' => __('Editar lugar'),             'new_item' => __('Nuevo lugar'),             'view_item' => __('Ver lugar'),             'search_items' => __('Buscar lugares'),             'not_found' =>  __('No hay lugares'),             'not_found_in_trash' => __('No hay lugares en la papelera'),             'parent_item_colon' => ''         );              $args = array(             'labels' => $labels,             'public' => true,             'publicly_queryable' => true,             'show_ui' => true,             'query_var' => true,             'rewrite' => true,             'capability_type' => 'post',             'hierarchical' => false,             'menu_position' => null,             'supports' => array('title','editor','thumbnail','comments','custom-fields','revisions')           );              register_post_type( 'lugares' , $args );     }          register_taxonomy("tacos", array("lugares"), array("hierarchical" => true, "label" => "Tacos", "singular_label" => "Tacos", "rewrite" => true));          add_action("admin_init", "admin_init_lugares");          function admin_init_lugares(){         add_meta_box("descripcion_usuario", "Descripción usuario", "descripcion_usuario", "lugares", "normal", "low");         add_meta_box("direccion", "Dirección", "direccion", "lugares", "normal", "low");         add_meta_box("horarios", "Horarios", "horarios", "lugares", "normal", "low");         add_meta_box("telefonos", "Teléfonos", "telefonos", "lugares", "side", "low");         add_meta_box("garantia_tdt", "Garantía TourDelTaco", "garantia_tdt", "lugares", "side", "low");         add_meta_box("servicio_a_domicilio", "Servicio a domicilio", "servicio_a_domicilio", "lugares", "side", "low");     }          function descripcion_usuario() {         global $post;         $custom = get_post_custom($post->ID);         $descripcion_usuario = ( !empty($custom["descripcion_usuario"][0]) ) ? $custom["descripcion_usuario"][0] : "";         ?>
Descripción usuario:
         <textarea cols="50" rows="5" name="descripcion_usuario"><?php echo $descripcion_usuario; ?></textarea>
         <?php     }          function direccion(){         global $post;         $custom = get_post_custom($post->ID);         $direccion = ( !empty($custom["direccion"][0]) ) ? $custom["direccion"][0] : "";         ?>
Dirección:
         <textarea cols="50" rows="5" name="direccion"><?php echo $direccion; ?></textarea>
         <?php     }          function horarios() {         global $post;         $custom = get_post_custom($post->ID);         $horarios = ( !empty($custom["horarios"][0]) ) ? $custom["horarios"][0]: "";         ?>
Horarios:
             <input type="text" name="horarios" value="<?php echo $horarios; ?>"/>
         <?php     }          function telefonos() {         global $post;         $custom = get_post_custom($post->ID);         $telefonos = ( !empty($custom["telefonos"][0]) ) ? $custom["telefonos"][0] : "";         ?>
Teléfonos:
         <textarea cols="38" rows="3" name="telefonos"><?php echo $telefonos; ?></textarea>
         <?php     }          function garantia_tdt() {         global $post;         $custom = get_post_custom($post->ID);         $garantia_tdt = ( !empty($custom["garantia_tdt"][0]) ) ? $custom["garantia_tdt"][0] : "";         ?>
Garantía TourDelTaco:
         <input type="radio" id="garantia_tdt" name="garantia_tdt" value="si" <?php if ($garantia_tdt == 'si') echo 'checked';?>/> Si
         <input type="radio" id="garantia_tdt" name="garantia_tdt" value="no" <?php if ($garantia_tdt == 'no') echo 'checked';?>/> No
         <?php     }          function servicio_a_domicilio() {         global $post;         $custom = get_post_custom($post->ID);         $servicio_a_domicilio = (!empty($custom["servicio_a_domicilio"][0])) ? $custom["servicio_a_domicilio"][0] : "";         ?>
¿Cuenta con servicio a domicilio?:
         <input type="radio" id="servicio_a_domicilio" name="servicio_a_domicilio" value="si" <?php if ($servicio_a_domicilio == 'si') echo 'checked';?>/> Si
         <input type="radio" id="servicio_a_domicilio" name="servicio_a_domicilio" value="no" <?php if ($servicio_a_domicilio == 'no') echo 'checked';?>/> No
         <?php     }          add_action('save_post', 'save_details_lugares');          function save_details_lugares(){         global $post;         $custom_meta_fields = array( 'horarios','direccion','descripcion_usuario','garantia_tdt','telefonos','servicio_a_domicilio' );              foreach( $custom_meta_fields as $custom_meta_field ):             if(isset($_POST[$custom_meta_field]) && $_POST[$custom_meta_field] != ""):                 update_post_meta($post->ID, $custom_meta_field, $_POST[$custom_meta_field]);             endif;         endforeach;          }          add_action("manage_posts_custom_column",  "lugares_custom_columns");     add_filter("manage_edit-lugares_columns", "lugares_edit_columns");          function lugares_custom_columns($column){         global $post;              switch ($column) {             case "description":                 the_excerpt();             break;             case "direccion":                 $custom = get_post_custom();                 echo $custom["direccion"][0];             break;             case "horarios":                 $custom = get_post_custom();                 echo $custom["horarios"][0];             break;             case "descripcion_usuario":                 $custom = get_post_custom();                 echo $custom["descripcion_usuario"][0];             break;             case "tacos":                 echo get_the_term_list($post->ID, 'tacos', '', ', ','');             break;         }     }          function lugares_edit_columns($columns){         $columns = array(             "cb" => "<input type=\"checkbox\" />",             "title" => "Nombre del lugar",             "description" => "Descripción",             "direccion" => "Dirección",             "horarios" => "Horarios",             "descripcion_usuario" => "Descripción usuario",             "tacos" => "Tacos"         );              return $columns;     }      Adding new entries from a front-end form is partially working. The code to the form is this:               <?php if ( empty($_POST) && !isset($_POST['agregar_lugar']) ) : ?>
Agregar un lugar...
         <form id="" class="" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">         Nombre:<input type="text" name="title" id="title" />         Dirección:<input type="text" name="direccion" id="direccion" />         Horarios:<input type="text" name="horarios" id="horarios" />         Descripción:<input type="text" name="descripcion_usuario" id="descripcion_usuario" />         Servicio a domicilio:<input type="radio" name="servicio_a_domicilio" id="servicio_a_domicilio_si" value="si" />Sí<input type="radio" name="servicio_a_domicilio" id="servicio_a_domicilio_no" value="no" />No         Teléfonos:<input type="text" name="telefonos" id="telefonos" />              <input type="submit" name="agregar_lugar" id="agregar-lugar" value="Agregar lugar">         </form>     <?php else:               $title = $_POST['title'];         $direccion = $_POST['direccion'];         $horarios = $_POST['horarios'];         $descripcion_usuario = $_POST['descripcion_usuario'];         $servicio_a_domicilio = $_POST['servicio_a_domicilio'];         $telefonos = $_POST['telefonos'];              $errores = array();         //title         if(empty($title))             $errores['title'] = 'Es obligatorio introducir un nombre.';              //direccion         if( empty($direccion) )             $errores['direccion'] = 'Es obligatorio introducir una dirección.';              if($servicio_a_domicilio !== 'si') $servicio_a_domicilio = 'no';              // guardar         $post = array(             'post_title'    => $title,             'post_status'   => 'draft',               'post_type' => 'Lugares',                   'post_author'   => 2         );              $lugares_post_ID = wp_insert_post($post);     endif;      [And it just doesn't work. I could use some tips for debugging this because even with wp's debug set to true, I don't get a lot of information.] Edit: it's partially working now. That is, posts are saved, but can't be edited from the backend. I can't see what I'm doing wrong


Building Gravatar Code

I'm building Gravatar code for a theme for SEO reasons, basically don't like the default WordPress Gravatar code because for each avatar it adds an image to the page with no alt text which could have a negative SEO impact. Instead using the image as a background image with has no SEO impact. Have the code working, but not with Mystery Man or Blank setting. Looked at /wp-includes/pluggable.php and found the issue around line 1712 which is Mystery Man code, basically one Gravatar image is used (this image http://0.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536) for all Mystery Men avatars except when the person has set a custom Gravatar. Similar idea with Blank. Fixing Blank was easy enough, but what I've come up with so far means custom Gravatars (user selected ones) don't work when Mystery Man is selected. With the code below the default Mystery Man image is always used. I've looked through the WordPress Gravatar code and can't figure out how the custom Gravatars are selected?               <?php /*echo get_avatar($comment, 60);*/     $email = $comment->comment_author_email;     $size = 60;     $rating = get_option('avatar_rating');     $gravtype = get_option('avatar_default');     if ($gravtype=='mystery')     $grav_url = "http://0.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=" . $size ."&d=" . $gravtype ."&r=". $rating;     elseif ($gravtype=='blank')     $grav_url = "/wp-includes/images/blank.gif";     else      $grav_url = "http://0.gravatar.com/avatar/" . md5($email) . "?s=" . $size ."&d=" . $gravtype ."&r=". $rating;     ?>     <div class="gravatars" style="background: url(<?php echo $grav_url ?>)">
      Thanks David UPdate : Solved Thanks to the suggestion from Bainternet using this code below which apears to work so far (not tested extensivly yet):               <?php /*echo get_avatar($comment, 60);*/     $email = $comment->comment_author_email;     $size = 60;     $rating = get_option('avatar_rating');     $gravtype = get_option('avatar_default');     $default = urlencode( 'http://www.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=' . $size );     if ($gravtype=='mystery')     $grav_url = 'http://www.gravatar.com/avatar/'. md5( strtolower( trim( $email ) ) ). '?s=' . $size . '&r=' . $rating . '&d=' . $default;     elseif ($gravtype=='blank')     $grav_url = "/wp-includes/images/blank.gif";     else      $grav_url = "http://0.gravatar.com/avatar/" . md5( strtolower( trim( $email ) ) ) . "?s=" . $size ."&d=" . $gravtype ."&r=". $rating;     ?>     <div class="gravatars" style="background: url(<?php echo $grav_url ?>)">
      David


how to remove the gallery shortcode in wordpress?

Your `warmHome_cutstr` function causes in the inline stylesheet of the gallery to be displayed. See gallery-post.jpg.[http://themes.trac.wordpress.org/attachment/ticket/4560/gallery-post.jpg][1] To solve this, you need to hook into the_content and remove the gallery shortcode. In functions.php:              add_filter( 'the_content', 'warmHome_content_filter' );         function warmHome_content_filter( $text )  {             $text = strip_shortcodes( $text );             return $text;         }      the following is my `warmHome_cutstr` function. how to correct it. i have added the above function. but don't know how to remove the gallery shortcode.               function warmHome_cutstr($string, $length) {                  $string =strip_tags($string);              $strcut= '';              if(strlen($string) > $length) {             preg_match_all("/[\x01-\x7f]|[\xc2-\xdf][\x80-\xbf]|\xe0[\xa0-\xbf][\x80-\xbf]|[\xe1-\xef][\x80-\xbf][\x80-\xbf]|\xf0[\x90-\xbf][\x80-\xbf][\x80-\xbf]|[\xf1-\xf7][\x80-\xbf][\x80-\xbf][\x80-\xbf]/", $string, $info);              $j = 0;             for($i=0; $i<count($info[0]); $i++) {                          $strcut .= $info[0][$i];                          $j = ord($info[0][$i]) > 127 ? $j + 2 : $j + 1;                     if ($j > $length - 3) {                             return $strcut." ...";                     }             }             return join('', $info[0]);                      } else {                               return $string;                      }     }


How to create automatic posts in wordpress?

I have a very intensive data backed WordPress application. Currently I create WordPress posts by using a baseshortcode plugin which pulls data from database and displays in tabular format. I would like to automate this process where in the posts are created automatically in draft state.


How i can obtain all the post meta for a specific post as an array?

<?php $fields = get_post_custom($ID); ?>      This will fetch the custom fields (`$key => $value`) for `$ID` in to the array `$fields`. I want ALL the fields (both custom & standard WP fields) associated with the `$ID` in one `array $fields_all`. How to do this in a simpler way?....is there a single function available in WP?


Is it possible to rewrite URLs in this situation?

I am using a fantastic plugin called _Query Multiple Taxonomies_ which provides a widget to "drill down" by category / tag and other custom taxonomies you may have. The site is livetonom.com. The widget (on the sidebar) gives URLS ending:               /?category_name=restaurants&locations=london      Is it possible to rewrite that to something like:               /restaurants/london      I tried using a rewrite rule generators but stuff like this added directly to `.htaccess` did not work:                   RewriteEngine On         RewriteRule ^([^/]*)/([^/]*)$ /?category_name=$1&locations=$2 [L]      I'm not even sure that adding to `.htaccess` directly is correct or will work - can anyone let me know if this is a non-starter or how I go about this?


A question about .htaccess

I'm redeveloping a site for a client. Their current site is written in .asp. I've rebuilt in WordPress as they need a CMS. We're repointing the DNS to our hosting environment. My question is - I need to set up an .htaccess file (I think this is the best way) to redirect all the old URLs to their new equivalent. Some of the URL structures have changed so it's not just a case of changing .asp > .php. Soo... where should I upload the .htaccess file - does this need to go in the root directory OR does it need to go in my wp-theme folder? Thanks


Relevanssi show only 1 result

Search works correct, but show only one result Why is that? How can I change it? I'm using also Dave's WordPress Live Search which show me many results (for example 10), but in search result page I can see only link and little bit of content for 1 page only. This is my search page:               <?php get_header(); ?>
Search Results For "<?php echo wp_specialchars($s, 1); ?>"

         <?php if (function_exists('relevanssi_the_excerpt')) { relevanssi_the_excerpt(); }; ?>
     <?php get_footer(); ?>      How to display more results?


Custom Function for Portfolio Archive Template With Conditonal Tag

Can't work out which conditional tag to use to add a page title to the portfolio archive page which uses custom posts types. This doesn't work:               if( is_archive('portfolio') )     echo '
Add Your Page Title Here
';     };      // Here's the code which generates the portfolio post type and archive               add_action( 'init', 'executive_portfolio_post_type' );     function executive_portfolio_post_type() {     register_post_type( 'portfolio',         array(             'labels' => array(                 'name' => __( 'Portfolio', 'executive' ),                 'singular_name' => __( 'Portfolio', 'executive' ),             ),             'exclude_from_search' => true,             'has_archive' => true,             'hierarchical' => true,             'menu_icon' => get_stylesheet_directory_uri() . '/images/icons     /portfolio.png',             'public' => true,             'rewrite' => array( 'slug' => 'portfolio' ),             'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'page-attributes', 'genesis-seo' ),         )     );      } // Or maybe its something which needs to added in the portfolio archive template               function executive_portfolio_grid() {     if ( has_post_thumbnail() ){         echo '
';         echo '';         echo get_the_post_thumbnail($thumbnail->ID, 'portfolio' );         echo '';         echo '
';     }      }


Any known bugs that could cause disappearance of the wp_users table?

I administer a number of WordPress-powered web sites. One of these sites is new, and has been running untouched since it was set up a month ago. Today, I tried to log in, but was unable to do so - all my login attempts were rejected. After some investigation, I found out that the `wp_users` table was missing. All other tables were present, and the blog was fully functional. None of the entries in the database, nor any of the files suggest that there has been any kind of hacking going on. I'm due for vacation tomorrow, and this leaves a bit of a worry as I'm the only person taking care of these sites. I've altered all the passwords, of course, and I might do a reinstall of the code base, but I'd like to know whether there is any common bug that could have caused this? The WP version running is 3.4.1. Noteworthy installed plugins include WP Super cache, All in one SEO pack, and User Photo.


OOP - add_action

I'm making a simple theme framework for personal use and I'm try to set up various options in a class. Basically, I want to use add_action within my class but the function doesn't seem to be firing (but neither am I getting any errors). I've searched for an answer to this but can't find anything that helped. What am I doing wrong here?               <?php          class Theme {          private $settings;          public function __construct($settings)     {         $this->settings = $settings;         add_action('after_setup_theme', array(&$this, 'boco_set_permalink_structure'));     }          /*     | --------------------------------------------------------------------     | Set Permalink Structure     | --------------------------------------------------------------------     |     | Changes the Wordpress permalink structure.     |     */          public function boco_set_permalink_structure()     {         echo 'working...';              global $wp_rewrite;              if ($this->settings['change-permalink-structure']):             $wp_rewrite->set_permalink_structure($this->settings['permalink-structure']);             flush_rewrite_rules();         endif;     }          }      I'm instantiating the object like so:               $theme = new Theme($settings);      If I call the boco_set_permalink_structure method manually it works just fine. It just seems that add_action isn't actually doing anything. Thanks in advance for any help. EDIT: As requested in the comments: The object is instantiated from a file which is included into the functions.php file. $settings is setup as follows:               $settings['change-permalink-structure'] = true;     $settings['permalink-structure'] = '/%postname%/';     $settings['enable-post-thumbnails'] = true;


Nonces and Cache

It's clear that form submissions and AJAX requests, especially sensible ones, need "nonces" to avoid certain exploits. However, with heavy use of caching systems it becomes harder to generate them and output fresh nonces instead of cached ones. To solve the problem I thought about creating an AJAX function that returns a fresh nonce, to be requested before a form is submitted. This nonce will be then appended to the form as a hidden field. Do you think it's a safe approach? PHP function to return a fresh nonce:               function create_nonce() {         return wp_create_nonce('my-nonce');     }          add_action('wp_ajax_create_nonce', 'create_nonce');     add_action('wp_ajax_nopriv_create_nonce', 'create_nonce');      Submit the form ( **request()** is a custom function I've created to easily make ajax requests):               $('form').on('submit', function(e){         e.preventDefault();         var $form = $(this);              request('create_nonce', function(nonce){              // Append the fresh nonce to the form              $form.append('<input type="hidden" name="nonce" value="'+nonce+'">');                   // Proceed with the form submission...         });     });


Adding a class to the body_class function

Basically I've applied this way to show certain colors on pages like search.php or a list on home. What it does is it reads a variable that gets a field from WP, if that field is equal to a certain number then it adds a class name which in CSS has a color Now the field on a single page is there, though whenever I add the 'if system' that I applied on the other pages it doesn't add the class in the body on header.php. Now this works correctly on other pages(Not globally but individually) but not here for some reason. On the header.php:               <?php         //Body class         if($mem_id == 1)          { $class =  'color1';    }         if($mem_id == 2)          { $class =  'color2';    }                  if($mem_id == 3)          { $class =  'color3';    }         if($mem_id == 4)          { $class =  'color4';    }         if($mem_id == 5)          { $class =  'color5';    }         if($mem_id == 6)          { $class =  'color6';    }         if($mem_id == 7)          { $class =  'color7';    }         if($mem_id == 8)          { $class =  'color8';    }         if($mem_id == 9)          { $class =  'color9';    }     ?>     <body <?php body_class($class); ?>>      In other pages: `$mem_id = get_field('memtype_id');`


Bootstrap Dropdown Menu unresponsive in mobile

I have built a responsive website using Bootstrap Theme the menu is working fine in desktop, but if I tap the menu button in mobile devices, more often unresponsive and the transition is delay. Any help would be appreciated. Thanks. to access the site user: user pass: user123


Get ID of first image attached to a post

I'm looking to find a solution that enables me to get the ID of the first image attached to a post in the loop. I'm currently using this;               $size = 'post-thumbnail'; // Define image_size to be used     $args = array(         'post_type'        => 'attachment',         'post_mime_type'   => 'image',         'post_parent'      => $post->ID     );     $images = get_posts($args);     $attachment_id = $images[0]->ID;     $i = wp_get_attachment_image_src($attachment_id, $size);          if (has_post_thumbnail()) { // Check if post thumbnail is present first         the_post_thumbnail($size);     } else { // If no post thumbnail is present, echo first image in post         echo '<img src="'.$i[0].'" alt=""/>';     }      Which works fine if it's on a single post, but doesn't work correctly in a loop of posts (It only gets the ID on 1 post as oppose to all of them). I've googled around and every function I've found seems to have the same issue, it only gets the ID for one post. Can anyone help me out? This needs to be a function and NOT a plugin.


Using a Plugin to Show/Hide Content after Header?

Using a plugin,I am looking a way to Show/Hide all Content after Headers are sent. If I have an authenticated user then show the content other wise redirect the user to authenticate first. I want to use Facebook PHP SDK to authenticate the user. My questions are   1. Using which Hook or Action I can put a check whether User is authenticated or Not.   2. If user is authenticated, continue with WordPress Loop to show Content else Redirect to Facebook for Authentication. A rough pseudo code is > After header if Facebook user Continue WordPress Loop else Redirect


Add field to user meta table in database when link is clicked

I am working on function that enables registered users on my site to bookmark posts. I have searched for plugins but none seemed to do the job properly. I have a page where users can see their info like name, email, password and so on. I want a list of posts they have bookmarked. This should be done by clicking on a link in the post, which then saves the url or a link to the post in the database. The code for getting the url of the post:               function curPageURL() {     $pageURL = 'http';      if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}       $pageURL .= "://";      if ($_SERVER["SERVER_PORT"] != "80") {      $pageURL .=           $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];      } else {       $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];      }      return $pageURL;      }      Now i have the url in a variable. But how i can store this url in a field for the current user? I was thinking about inserting a field in user table. But I'm not quite sure how and if this is the best way to go about.


Pasting this PHP breaks my page. Why?

I tried a few echo commands, and they return properly. **Breaking Statement**               <?php      $gallery_ids = $wpdb->get_results(     "SELECT gid FROM ".$wpdb->prefix."ngg_gallery ORDER BY gid ASC", ARRAY_A);     ?>      This causes anything after this statement not to show up, consequentially breaking the page. If I do things like this :               <?php     $custom_query = new WP_Query( 'posts_per_page=3&cat=1' );     if ( $custom_query->have_posts() ) : while ( $custom_query->have_posts() ) : $custom_query->the_post(); ?>
<?php the_title(); ?>

Posted on: <?php the_time('F j, Y') ?>
     <?php the_excerpt(); ?>
      It works fine. So I know it can take complicated PHP statements. I'm curious why my previous statement would break..


$wpdb sql help. Select post id and post meta value based on 2 other post_meta values

I am trying to select post ids and a post meta value based on the value of 2 other post meta values and from a custom post type. Here is a screen shot of my post meta table. https://www.evernote.com/shard/s40/sh/99a4c115-48bb-46c4-81ef-0df3ccd48862/3f9e2d56e7bb5db54a64782b9860ab4b/deep/0/wp_13_postmeta%20@local_wp_multisite_%20(localhost).png I need the `_days` meta_key value based on the values of the `_start_date` and `_end_date` values. I also would like to return the post id's. UPDATE: I think I got it. It is not in wordpress form but that is the easy part. If anyone can improve on this please add to it. Thanks                SELECT     key1.ID,     key1.post_title,     days.meta_value AS days     FROM     wp_13_posts key1     INNER JOIN wp_13_postmeta days ON days.post_id = key1.ID     AND days.meta_key = '_days'     INNER JOIN wp_13_postmeta startdate ON startdate.post_id = key1.ID     AND startdate.meta_key = '_start_date'     INNER JOIN wp_13_postmeta enddate ON enddate.post_id = key1.ID     AND enddate.meta_key = '_end_date'     WHERE     days.meta_key = '_days'     AND startdate.meta_value <= '1385769600'     AND enddate.meta_value >= '1383264000'     AND key1.post_type = 'mbe_enrollments'


Redirect returning users to a certain page?

Is there a way to redirect users returning to the site who are already logged in? Assuming something like:               function returning_redirect()     {        //code here     }          add_action('auth_cookie_valid', 'returning_redirect');      But I can't seem to get any variation of that to work. Thanks!


Newsletter, mailingList and contact management

I think it's a good question, and my research don't come to a FINAL answer, so i turn to you WordPress community. here is the question I have about 300 email that i like to take from entourage to a catalog (contact database) WordPress seem fit to do that. After having a nice interface to get the first name, last name, telephone, email, company, etc in the database to manage contact in WordPress much like a CRM for the person on the road and in the office to get hold to that info anywhere Then i like to get those person in the database to get a nice mailing newsletter each month in there inbox. Use the WordPress post to get the thing together, and hit a button, the post #123 send to 300 email, and get some stat on how many have open the email and so on... So, WordPress is a nice platform to do that, but i will need a plugin(s) to do that... and listing in the plugins database of WordPress plugin dont help me What i need, is THE best one to do that, cheep and efficiently... so you guys, have real world experience with that... what plusin do that ? thanks in advance - i have found that comparison link, but it just add more option, and no real answer : http://winkpress.com/newsletter/subscribe/


Actions, functions and conditionals

When developing themes and plugins it is sometimes neccesary to add some functionality to some hook using conditional statements. Example:               function my_custom_function() {         if( is_home()) {            <---what should the function do--->         }     }           add_action( 'some_hook', 'my_custom_function' );      To my understanding, whenever any other condition exists (`is_home` return false), the content of the function is not executed, however the function is executed, although it is "empty". This means that an empty function is passed to the hook. This is the way that all examples are shown in the codex using conditional tags. I do understand that this is safe to do so, and it should not have any significant impact on load times (if there is any impact on load time at all). I have been thinking, the same piece of code, as per example, can be written as follow               if( is_home()) {        function my_custom_function() {          <---what the function should do--->        }            add_action( 'some_hook', 'my_custom_funtion' );          }      This will completely skip everything if `is_home` returns false. I don't mind using any of these two methods. But what I want to know, because of the first example been extensively used, are there any coding standard that states that this is the correct method to use, or is this rather the prevered way according to wordpress developers, or just personal preference.


3rd Party Login in wordpress

I have two sites. One on wordpress and one non wordpress site. Now, I have used the header and footer from my non-wordpress site. What i want is that if user logs in on my non-wordpress site then he may use the same email and name to comment on my wordpress site. I get the user info from the non-wordpress site of the user via a CURL request. The main problem I have is how to use user's email and name to post comment. I tried using this:               global $current_user;     $current_user->user_email = $body->user->email;     $current_user->user_firstname = $body->user->name;      Here $body has the email and name of user logged in from my non-wordpress site. How can i do this?


What are WooCommerce starter themes?

I've done created a lot of Wordpress themes and plugins, but I haven't done much with the Wordpress WooCommerce plugin from WooThemes. If someone asked me what general theme they should work with to learn about themes, I would suggest one of Wordpress' defaults, like `TwentyFourteen` However, for someone who is creating an online store with Worpdress / WooCommerce I would not know where to tell them to start.   1. What themes are available as a starting point for working with WooCommerce?   2. What other resources are available for getting started?


post_type is ignored by WP_Query when 'tag' argument is included

I've created a function to call in a page template, inside of which is the following query:               $custom_news = new WP_Query(array(          'post_type' => array('post', 'resource', 'job'),          'posts_per_page' => 5,          'tag' => 'justice',          'orderby' => 'post_date',          'order' => 'DESC',          )     );      The problem is that the 'resource' and 'job' CPTs are not being included in the query, even though they have been registered with `'taxonomies' => 'post_tag'`. Here is the generated SQL: > >     [request] => SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts INNER > JOIN wp_term_relationships ON (wp_posts.ID = > wp_term_relationships.object_id) WHERE 1=1 AND ( > wp_term_relationships.term_taxonomy_id IN (13) ) AND wp_posts.post_type IN > (‘post’, ‘portfolio’) AND (wp_posts.post_status = ‘publish’ OR > wp_posts.post_author = 1 AND wp_posts.post_status = ‘private’) GROUP BY > wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 5 >   The only CPTs included in the query are 'post' and 'portfolio' (which is a CPT that comes with the theme I'm using). However, if I remove the `'tag' => 'justice'` argument, the post type argument is "seen" by the query, and the following SQL is generated: > >     [request] => SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts WHERE > 1=1 AND wp_posts.post_type IN (‘post’, ‘resource’, ‘job’) AND > (wp_posts.post_status = ‘publish’ OR wp_posts.post_author = 1 AND > wp_posts.post_status = ‘private’) ORDER BY wp_posts.post_date DESC LIMIT 0, > 5 >   I should also mention that I've tried it with the `'tag__in'` and `tax_query` arguments to no avail. Could anyone illuminate why this might be? It could be I'm missing something very basic, and if so, forgive me. Thanks, matt


https website comment form posts to 127.0.0.1

I am working on a "https" website. There is a strange problem. Whenever I post comment at any of the posts, next page after clicking the "Post Comment" button is with the url 127.0.0.1, which thereby opens my localhost server. If I comment at url starting with "http" (in the the same website), it posts the comment successfully and loads the same webpage. Any ideas?


adding google event tracking to links in posts

I am trying to add outbound link tracking for links within my posts. But only for links that do not have an img as a child. My code is below but does not add my class to any links in my posts:               jQuery(document).ready(function(){         //outbound post links         //var outbound_post_name = jQuery(this).find('h2.title').text();         var post_link = jQuery('.post .entry').find('a');             if( jQuery(post_link).has('img') ){                 //do not add class or tracking if the link has an img             }             else{                 jQuery(post_link).addClass('outbound-link');                 jQuery(post_link).click(function(){                     _gaq.push(['_trackEvent', 'Outbound Link', 'Click', outbound_post_name + 'Post Link', '', false]);                 });             }     });      I also need to get the post title for my label but am unsure of how to get it set as "outbound_post_name". If I remove the "if" statement all links get the class "outbound-link" What am I missing? Thanks!


Current post in AJAX call is always zero

I have a custom post type named event and a button to load more timeline. I need to arange current timeline item to the left or right depending on his current_post from WP_query object. Ex:               if (current_post % 2 == 0) {     go to the left     } else {     go to the right     }      For the first 3 timeline items that are loaded on page load the position is correct, but when i make the AJAX call everytime the current_post is 0. Here is my query:               $args = array(                     'post_type' => 'timeline',                     'order' => 'ASC',                     'posts_per_page' => (int)$data['posts_per_page'],                     'offset' => (int)$data['offset'],                     'suppress_filters' => true                 );             $the_query = new WP_Query($args);      Is there something that I can change to get the correct position of the post? UPDATE To be more clear i will put my entire code here. AJAX function:               $(".download-resume").on("click", function() {             var $this = $(this);             var posts_per_page = parseInt($this.data("show"));             var currentPage = parseInt($this.data("current"));             var offset = currentPage * posts_per_page;                  var data = {                 action : "timeline_load",                 offset : offset,                 posts_per_page : posts_per_page             };                  var last_item = $('.resume-holder:last');             $.post(options.ajax_url, data, function(resp) {                 if(resp.success == false) {                     $this.text(resp.data.msg).removeAttr('href');                 } else {                     if(resp.data) {                         $this.text(resp.data.msg).removeAttr('href');                     } else {     //                    alert(resp);                         last_item.after(resp);                         $('.resume-slider').flexslider({                             animation: "slide",                             slideDirection: "horizontal",                             slideshow: false,                             slideshowSpeed: 3500,                             animationDuration: 500,                             directionNav: true,                             controlNav: false,                         });                         $this.data("current", currentPage + 1);                         $('html, body').animate({                             scrollTop: $this.offset().top                         }, 1200);                     }                 }             });                  return false;         });      and this is my php function:               global $post;                  $data = filter_var_array($_POST, FILTER_SANITIZE_SPECIAL_CHARS);                  if ($data['action'] == "timeline_load") {                 $post = null;                      $args = array(                     'post_type' => 'timeline',                     'order' => 'ASC',                     'posts_per_page' => (int)$data['posts_per_page'],                     'offset' => (int)$data['offset'],                     'suppress_filters' => true                 );                 $the_query = new WP_Query($args);                      if ($the_query->have_posts()) :                          while ($the_query->have_posts()) : $the_query->the_post();                         $icon = get_post_meta($post->ID, 'timeline_icon', true);                         $year = get_post_meta($post->ID, 'timeline_year', true);     //                    var_dump($the_query->current_post);                         if (($the_query->current_post) % 2 == 0) : ?>

<?php echo $year; ?>

<?php the_title(); ?>

<i class="fa <?php echo $icon; ?>">

                                         <?php                                         $featured_image = array();                                         $featured_image[] = get_the_post_thumbnail($post->ID);                                         if (class_exists('Dynamic_Featured_Image')) {                                             global $dynamic_featured_image;                                             $featured_images = $dynamic_featured_image->get_featured_images($post->ID);                                                  if (!is_null($featured_images)) {                                                 foreach ($featured_images as $image) {                                                     $featured_image[] = $image['full'];                                                 }                                             }                                         }                                         $count = count($featured_image);                                         if ($count > 1) :                                             ?>

                                                     <?php                                                     $featured_image = get_the_post_thumbnail($post->ID, array(560, 324, 'class' => ' respimg'));                                                     echo '
' . $featured_image . '
';                                                     if (class_exists('Dynamic_Featured_Image')) {                                                         global $dynamic_featured_image;                                                         $featured_images = $dynamic_featured_image->get_featured_images($post->ID);                                                              if (!is_null($featured_images)) {                                                             foreach ($featured_images as $image) {                                                                 echo '

';                                                             }                                                         }                                                     }                                                     ?>

                                         <?php else : ?>                                             <?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID, array(560, 325, 'class' => ' respimg')), 'single-post-thumbnail'); ?>                                             <a class="image-popup" href="<?php echo $image[0]; ?>" title="">                                                                                <?php echo get_the_post_thumbnail($post->ID, array(560, 325, 'class' => ' respimg')); ?>                                                                                <?php endif; ?>                                         <?php the_content(); ?>

                         <?php else : ?>

<?php echo $year; ?>

<?php the_title(); ?>

<i class="fa <?php echo $icon; ?>">

                                         <?php                                         $featured_image = array();                                         $featured_image[] = get_the_post_thumbnail($post->ID);                                         if (class_exists('Dynamic_Featured_Image')) {                                             global $dynamic_featured_image;                                             $featured_images = $dynamic_featured_image->get_featured_images($post->ID);                                                  if (!is_null($featured_images)) {                                                 foreach ($featured_images as $image) {                                                     $featured_image[] = $image['full'];                                                 }                                             }                                         }                                         $count = count($featured_image);                                         if ($count > 1) :                                             ?>

                                                     <?php                                                     $featured_image = get_the_post_thumbnail($post->ID, array(541, 313, 'class' => ' respimg'));                                                     echo '
' . $featured_image . '
';                                                     if (class_exists('Dynamic_Featured_Image')) {                                                         global $dynamic_featured_image;                                                         $featured_images = $dynamic_featured_image->get_featured_images($post->ID);                                                              if (!is_null($featured_images)) {                                                             foreach ($featured_images as $image) {                                                                 echo '

';                                                             }                                                         }                                                     }                                                     ?>

                                         <?php else : ?>                                             <?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID, array(560, 325, 'class' => ' respimg')), 'single-post-thumbnail'); ?>                                             <a class="image-popup" href="<?php echo $image[0]; ?>" title="">                                                                                <?php echo get_the_post_thumbnail($post->ID, array(541, 313, 'class' => ' respimg')); ?>                                                                                <?php endif; ?>                                              <?php the_content(); ?>

                         <?php endif;                     endwhile;                     wp_reset_query();                 else :                     wp_send_json_success(array("msg" => "No more results to load"));                 endif;             } else {                 wp_send_json_error(array("msg" => "An error was occured"));             }                  die();


get_template_part() doesn't work

I use get_template_part() function to get theme options page content like this:               function setup_theme_admin_menus() {         add_theme_page( "Theme Options", "Theme Options", "read", "theme_options", "theme_options" );     }     function theme_options() {         get_template_part("content","options");     }      And it seems to work perfect when I use it on my localhost but when I relocated it online it stopped rendering desired HTML. When I use something like:               function theme_options() {         echo "Hello World!";     }      It works as expected both online and locally. No idea why it is happening.


How to detect /category and /tag base pages?

In a theme I'm building, I have this structure for detecting what type of page something is. However, if I visit mydomain.com/category/ or mydomain.com/tag/, all I get is the "nothing found" message I have in the have_posts()'s else statement. Is there a way to detect when these links are visited and display something other than what's in the final else statement?               if(is_category()):        echo '
title here
';     elseif(is_tag()):        echo '
title here
';     elseif(is_author():        echo '
title here
';     elseif(is_archive()):        echo '
title here
';     endif;          if(have_posts()):          //the loop     else:         echo '
Nothing Found
';     endif;


How to include one class/instance without using global variables

I would like to add http://mobiledetect.net/ class to my template. Which is the best approach to dynamically use this class in every part(s) of my template? For the moment I just loaded the class in functions.php like this                   function devicecontrol() {         require_once '_/inc/md/Mobile_Detect.php';     }     add_action('wp_loaded', 'devicecontrol', '1');      but to use it, I must first create an instance in every page-template               $detect = new Mobile_Detect;      I know global variables are not a good solution, which is then the best approach to include such classes?


Use an anchor link to open an iframe inside a Wordpress page

My Question: How do you make an anchor link to an offsite webpage that when clicked opens up the offsite webpage as an iframe that is inside a new Wordpress page where the Wordpress header and footer remain but the iframed webpage shows where the content would normally be? For Example: You have a wordpress page with a series of offsite links. Each link goes to a registration page. The registration page is hosted by a 3rd party website.               ____ get_header() ____         Logo.png          ____ get_the_content();          Which class do you want to register for?              Click here to register for Class A (link to 3rd party offsite webpage)         Click here to register for Class B (link to 3rd party offsite webpage)          ____ Wordpress Footer ____         get_footer();      When 'Click here to register for Class B' is clicked, A new Wordpress page is opened like so.               ____ get_header() ____         Logo.png          ____ 3rd party webpage                      Please fill out this registration form to continue.                  Name:              Credit Card #:                   ____ Wordpress Footer ____         get_footer();      Possible Approach: Is this way overkill...   * create a new, theme page template thst pulls in the header and footer. Then in the content area, parse out the the 3rd party webpage url from the the 3rd party link and use that link in an iframe where the post/page content would normally show.   * in Wordpress add a page and assign the new template. permalink: ../reg-page   * in the page that has the list of 3rd part links, build the anchor like so:              Click here to register for Class B        * in the theme page template:              // I know this is not legal code          /**     * Template Name: iframe fullwidth      */          get_header()

          get_footer()


Custom Taxonomy Not Saving in Front End Post

I am trying to create a front end posting form that will allow users to create a post when schools are closed. I have 4 custom taxonomies closed_schools, study_open, safe_arrival, hour_delay. each has the same list of 30 or so schools. Once the post is submitted I want to display the schools that are closed, opened, delayed etc. If I build the post in the back end it works, and shows everything like I intend. If I post from the front end none of the categories show up, So I know there is something wrong with how I am storing the taxonomies but I have tried many forums and techniques but no luck. Any help would be super appreciated, thanks.               if(isset($_POST['submit'])){         $title =  $_POST['title'];         $description = $_POST['description'];         $category = $_POST['cat'];         $tags = $_POST['post_tags'];         $terms = $_POST['terms'];          $error_msg = array();     if($title == ''){         $error_msg[] = 'Please select an area and/or region.';     }     if($description == ''){         $error_msg[] = 'Please write a description for the closure and/or delay.';     }     if($category == '-1'){         $error_msg[] = 'Please identify the reason for the closure and/or delay.';     }     else if( !$error_msg && 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) &&  $_POST['action'] == "new_post"){         $new_post = array(         'post_title'    =>  $title,         'post_content'  =>  $description,         'post_category' =>  array($_POST['cat']),  // Usable for custom taxonomies too         'tags_input'    =>  array($tags),         'tax_input' => array(terms),         'post_status'   =>  'publish',           // Choose: publish, preview, future, draft, etc.         'post_type' =>  'post',  //'post',page' or use a custom post type if you want to     );          //SAVE THE POST     $pid = wp_insert_post($new_post);          //SET OUR TAGS UP PROPERLY     wp_set_post_tags($pid, $_POST['post_tags']);          //SET OUR POST TERMS, CUSTOM TAXONOMIES     wp_set_post_terms($pid, $_POST['terms'], 'closed_schools', 'safe_open', 'safe_arrival', 'hour_delay', true);          //REDIRECT TO THE NEW POST ON SAVEs     $link = get_permalink( $pid );     wp_redirect( $link );     //POST THE POST     do_action('wp_insert_post', 'wp_insert_post');     }          }      My Form Istelf               <form id="new_post" name="new_post" method="post" action="" class="wpcf7-form front-end-form" enctype="multipart/form-data">              <fieldset name="name">             Area and/or Region:                          <select name="title" id="title">                 <option value="">-Please select an area and/or region-</option>             </select>         </fieldset>                       <fieldset class="category">             Reason For closure and/or delay:             <?php wp_dropdown_categories(array('hide_empty' => 0, 'name' => 'cat', 'orderby' => 'name', 'selected' => $category->parent, 'hierarchical' => true, 'show_option_none' => __('Select an area and/or region'))); ?>         </fieldset>                        <fieldset>          Closed Schools:          <?php             $closed_schools = get_terms('closed_schools', 'orderby=id&hide_empty=0');             $counter = 0;             foreach ($closed_schools as $close) {             $counter++;             $option = 'slug.'">'.$close->name.'';             $option .= '<input type="checkbox" name="terms[]" id="'.$close->slug.'" value="'.$close->slug.'">';             echo $option;            }                         ?>       </fieldset>       <fieldset>           Open for Study Only:           <?php             $study_only = get_terms('study_open', 'orderby=id&hide_empty=0');             $counter = 0;             foreach ($study_only as $study) {                 $counter++;                 $option = 'slug.'">'.$study->name.'';             $option .= '<input type="checkbox" name="terms[]" id="'.$study->slug.'" value="'.$study->slug.'">';             echo $option;             }         ?>        </fieldset>        <fieldset>            Open for Safe Arrivals Only:            <?php             $safe_arrival = get_terms('safe_arrival', 'orderby=id&hide_empty=0');             $counter = 0;             foreach ($safe_arrival as $safe) {                 $counter++;                 $option = 'slug.'">'.$safe->name.'';                 $option .= '<input type="checkbox" name="terms[]" id="'.$safe->slug.'" value="'.$safe->slug.'">';                 echo $option;             }             ?>          </fieldset>          <fieldset>               2 Hour Delay:               <?php                 $hour_delay = get_terms('hour_delay', 'orderby=id&hide_empty=0');             $counter = 0;             foreach ($hour_delay as $delay) {                 $counter++;                 $option = 'slug.'">'.$delay->name.'';                 $option .= '<input type="checkbox" name="terms[]" id="'.$delay->slug.'" value="'.$delay->slug.'">';                 echo $option;             }             ?>         </fieldset>                   <fieldset class="content">             Description and Notes:             <textarea id="description" tabindex="15" name="description" cols="80" rows="10"></textarea>             </fieldset>                  <fieldset class="submit">                 <button type="submit" value="Submit Cancellation/Closure" name="submit" tabindex="40" id="submit">Submit Cancellation/Closure</button>                              </fieldset>             <input type="hidden" name="action" value="new_post" />             <?php wp_nonce_field( 'new-post' ); ?>       </form>


Meta Tags by Meta Box

I have successfully added custom meta tags to metaboxes on my pages. The issue I am having is when the metabox has no data it is still showing in the html. This is the code I have got, does anyone have any ideas on how to not show this?                   <!-- Google Meta Tags -->     <meta name="citation_title" content="<?php if(get_post_meta($post->ID, "vw_citation_title", true) !='' ) echo get_post_meta($post->ID, "vw_citation_title", true);?>">     <meta name="citation_author" content="<?php if(get_post_meta($post->ID, "vw_citation_author", true) !='' ) echo get_post_meta($post->ID, "vw_citation_author", true);?>">     <meta name="citation_author" content="<?php if(get_post_meta($post->ID, "vw_citation_author_1", true) !='' ) echo get_post_meta($post->ID, "vw_citation_author_1", true);?>">     <meta name="citation_author" content="<?php if(get_post_meta($post->ID, "vw_citation_author_2", true) !='' ) echo get_post_meta($post->ID, "vw_citation_author_2", true);?>">     <meta name="citation_author" content="<?php if(get_post_meta($post->ID, "vw_citation_author_3", true) !='' ) echo get_post_meta($post->ID, "vw_citation_author_3", true);?>">     <meta name="citation_author" content="<?php if(get_post_meta($post->ID, "vw_citation_author_4", true) !='' ) echo get_post_meta($post->ID, "vw_citation_author_4", true);?>">     <meta name="citation_author" content="<?php if(get_post_meta($post->ID, "vw_citation_author_5", true) !='' ) echo get_post_meta($post->ID, "vw_citation_author_5", true);?>">     <meta name="citation_author" content="<?php if(get_post_meta($post->ID, "vw_citation_author_6", true) !='' ) echo get_post_meta($post->ID, "vw_citation_author_6", true);?>">     <meta name="citation_author" content="<?php if(get_post_meta($post->ID, "vw_citation_author_7", true) !='' ) echo get_post_meta($post->ID, "vw_citation_author_7", true);?>">     <meta name="citation_author" content="<?php if(get_post_meta($post->ID, "vw_citation_author_8", true) !='' ) echo get_post_meta($post->ID, "vw_citation_author_8", true);?>">     <meta name="citation_author" content="<?php if(get_post_meta($post->ID, "vw_citation_author_9", true) !='' ) echo get_post_meta($post->ID, "vw_citation_author_9", true);?>">     <meta name="citation_publication_date" content="<?php if(get_post_meta($post->ID, "vw_citation_publication_date", true) !='' ) echo get_post_meta($post->ID, "vw_citation_publication_date", true);?>">     <meta name="citation_journal_title" content="<?php if(get_post_meta($post->ID, "vw_citation_journal_title", true) !='' ) echo get_post_meta($post->ID, "vw_citation_journal_title", true);?>">     <meta name="citation_volume" content="<?php if(get_post_meta($post->ID, "vw_citation_volume", true) !='' ) echo get_post_meta($post->ID, "vw_citation_volume", true);?>">     <meta name="citation_issue" content="<?php if(get_post_meta($post->ID, "vw_citation_issue", true) !='' ) echo get_post_meta($post->ID, "vw_citation_issue", true);?>">     <meta name="citation_firstpage" content="<?php if(get_post_meta($post->ID, "vw_citation_first_page", true) !='' ) echo get_post_meta($post->ID, "vw_citation_first_page", true);?>">     <meta name="citation_lastpage" content="<?php if(get_post_meta($post->ID, "vw_citation_last_page", true) !='' ) echo get_post_meta($post->ID, "vw_citation_last_page", true);?>">     <meta name="citation_pdf_url" content="<?php if(get_post_meta($post->ID, "vw_citation_pdf_url", true) !='' ) echo get_post_meta($post->ID, "vw_citation_pdf_url", true);?>">


how to call ajax on frontend of wordpress

In my plugin folder I have two file 1. hello-ajax.php 2. myajax.js and by shortcode I add this form on frontend               <form id="theForm" method="post">      <input id="name" name="name" value = "name" type="text" />      <input name="action" type="hidden" value="the_ajax_hook" />  <!-- this puts the action the_ajax_hook into the serialized form -->      <input id="submit_button" value = "Click This" type="button" onClick="submit_me();" />      </form>      <div id="response_area">      This is where we\'ll get the response      </div>      In plugin file I added js file as:               wp_enqueue_script( 'my-ajax-handle', plugin_dir_url( __FILE__ ) . 'myajax.js', array( 'jquery' ) );      wp_localize_script( 'my-ajax-handle', 'the_ajax_script', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );      // THE AJAX ADD ACTIONS      add_action( 'wp_ajax_the_ajax_hook', 'the_action_function' );      add_action( 'wp_ajax_nopriv_the_ajax_hook', 'the_action_function' ); // need this to serve non logged in users      // THE FUNCTION      function the_action_function(){      /* this area is very simple but being serverside it affords the possibility of retreiving data from the server and passing it back to the javascript function */      $name = $_POST['name'];      echo"Hello World, " . $name;// this is passed back to the javascript function      die();// wordpress may print out a spurious zero without this - can be particularly bad if using json      }      // ADD EG A FORM TO THE PAGE      So form is displaying at front end but in console Uncaught ReferenceError: submit_me is not defined               submit_me() is defined in myajax.js file as:          function submit_me(){     //alert(a);     jQuery.post(the_ajax_script.ajaxurl, jQuery("#theForm").serialize()     ,     function(response_from_the_action_function){     jQuery("#response_area").html(response_from_the_action_function);     }     );     }      But this function is not working, and as far i know there is some problem in ajax call, so suggest me what did I wrong and how to make it work....Thanks


Using Singleton in wordpress themes/plugins

i am creating a wrapper class for wordpress settings API to generate theme options page. i used singleton design pattern to avoid multiple instance. is it the right place to use the pattern ? because wrapper class acts like a helper here so i dont think multiple instances are required. And when i am extending the wrapper class can i inherit the singleton in child class as well? child class is basically for custom fields(text,checkbox,etc). thanks.


API integration with WordPress

I'm trying to integrate a 3rd party API with WordPress. I fear this is above my head. I was this code but I'm not exactly sure how to make is work in WordPress. Is it possible?               $ch = curl_init();          curl_setopt($ch, CURLOPT_URL, 'https://xxx');     curl_setopt($ch, CURLOPT_POST, 7);     curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array(         'auth_token' => 'xxxxxx',         'list_id' => 'xxxxx,         'name' => 'Office',         'campaign_id' => 'xxxxx',     )));     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);          $result = curl_exec($ch);          curl_close($ch);


Enqueueing Scripts on a Custom Top-level Menu Page

I've created a menu page using the following function:               add_menu_page(     'Nonpareil options',     'Nonpareil options',         'administrator',         'nonpareil_theme_options',       'nonpareil_theme_display'        );      Now I want to load a js file only on this page. I'm trying to do so properly by enqueueing it only on my new page:               function nonpareil_options_js_enqueue($hook_suffix) {         if( 'nonpareil_theme_options' != $hook_suffix )         return;         wp_enqueue_script( 'nonpareil-options', get_template_directory_uri().'/js/nonpareil-options.js', array('jquery') );     }            add_action( 'admin_enqueue_scripts', 'nonpareil_options_js_enqueue' );      The script is not being enqueued. I think the issue is probably that $hook_suffix != "nonpareil_theme_options" on my new page, but in that case I have no idea what to put instead. What's wrong here? Thank you!


Multisite, turn off "create new site"

If someone enters the wrong URL to my wordpress multisite, they get the option to create another site in the network. Why does this happen, and how do I turn it off?


Open everything in new tab

I have a blog and there in category section I have a list of categories like story,poem etc. Now in the list of stories, I want that when someone clicks on continue reading, it should open the post in a new tab. How can I do it by default so that I don't have to do it for each post?


How to list tags from custom post type attachments?

So I am trying to list out all the tags created for images uploaded within my custom post type only. I added in a snippet of code to my themes functions.php file to enable media categories and tags:               function wptp_add_tags_to_attachments() {         register_taxonomy_for_object_type( 'post_tag', 'attachment' );     }     add_action( 'init' , 'wptp_add_tags_to_attachments' );      I am using the following code within my template file to generate a list of tags from my custom post type... but hopefully some fresh eyes can show me what I need to do to it to just show the tags I have generated on my images that are uploaded within this custom post type:

all.
             <?php                 query_posts(array( 'post_type'=> 'work', 'taxonomy' => 'type', 'term' => 'case-study' ));                 if ( have_posts() ) : while ( have_posts() ) : the_post();                     $custom_post_tags = get_the_tags();                 if ( $custom_post_tags ) {                     foreach( $custom_post_tags as $tag ) {                         $tags_arr[] = $tag -> name;                     }                 }                 endwhile; endif;                 if( $tags_arr ) {                     $uniq_tags_arr = array_unique( $tags_arr );                  foreach( $uniq_tags_arr as $tag ) {                      // LIST ALL THE TAGS FOR DESIRED POST TYPE                      $sanitizeTag =  sanitize_title($tag);                      $tag_link = get_terms('name', $tag, 'post_tag');                      $tag_class = preg_replace('/[^A-Za-z0-9-]+/', '_', html_entity_decode($tag)); // This strips our sepcial characers and spaces, then replaces them with an underscore                      //echo '
term_id).'">' .$tag. '.
';                      echo '
' .$tag. '.
';                      }                  }              ?>
      Any help would be appreciated.. thanks!


Taxonomies in URL

I have a custom post type and two custom taxonomies associated with it. One is locations and the other is activities. How can I form the permalinks in the following format? http://mysite.com/usa/diving Therefore the first one would be the location taxonomy and second would be the activity taxonomy?


Show recent posts in single-post page

I'm trying to show recent custom posts in `single-events.php` I can make it work by using `get_posts` what I don't know how to do is exclude the post that is active so if I'm on 'Event 1' just now using the code below it will show 'Event 1' in the 'Recent Events' section. How do I get around this?               <?php          $args = array(      'post_type' => 'events',      );          $myposts = get_posts( $args );     foreach ( $myposts as $post ) : setup_postdata( $post ); ?>       /* EDIT */ I was missing this: `'exclude' => $post->ID`


Guest Author - How to modify my custom function code if the guest author URL will follow a particular pattern/format?

Based on code the awesome G.M. provided in an earlier question (Use Custom Fields to Create Guest Author Link), I now have a custom function that uses custom fields to support guest authors. The code changes the post author to display the guest author name and changes the author link to the guest author URL of my choosing. This is the code I've added to my theme's function.php file to support guest authors:               //Guest Author Handling - Uses custom fields for guest author name and URL. Changes the guest author name display and changes the author link to guest author URL of your choosing     add_filter( 'get_the_author_user_url', 'guest_author_url' );      add_filter( 'the_author', 'guest_author_link' );      add_filter( 'get_the_author_display_name', 'guest_author_name' );          function guest_author_url($url) {       global $post;       $guest_url = get_post_meta( $post->ID, 'guest-url', true );       if ( filter_var($guest_url, FILTER_VALIDATE_URL) ) {         return $guest_url;       } elseif ( get_post_meta( $post->ID, 'guest-author', true ) ) {         return '#';       }       return $url;     }          function guest_author_link($name) {       global $post;       $guest_url = get_post_meta( $post->ID, 'guest-url', true );       $guest_name = get_post_meta( $post->ID, 'guest-author', true );       if ( $guest_name && filter_var($guest_url, FILTER_VALIDATE_URL) ) {         return '' . $guest_name . '';       } elseif( $guest_name ) {         return $guest_name;       }       return $name;     }          function guest_author_name( $name ) {       global $post;       $guest_name = get_post_meta( $post->ID, 'guest-author', true );       if ( $guest_name ) return $guest_name;       return $name;     }      After playing with this, it occurred to me that it's possible to simplfy the guest author URL entry. The URL for my guest authors will always be formatted as follows:               http://yoursite.com/author/[AuthorName]      Since the URL will always follow this same pattern, what I need to know is how would I modify G.M.'s code so that I only need to enter the [AuthorName] in the custom field for the guest authors URL? I hope this makes sense...


How to undo deregister script and use local versions?

The WordPress theme I am using deregisters the jQuery and jQuery UI libraries and registers google-hosted versions instead of the libraries from wp- includes. Here is the code in `functions.   UPDATE:               function w3t_add_scripts() {         $options = get_option('lollipop');         global $data; //get theme options              wp_enqueue_script('jquery');             wp_enqueue_script('jquery-ui');              // Site wide js         wp_enqueue_script('modernizr', get_template_directory_uri() . '/js/modernizr.min.js');         wp_enqueue_script('customscript', get_template_directory_uri() . '/js/customscript.js');              //Slider         if($options['w3t_featured_slider'] == '1') {         //  if(is_front_page() || is_page()) {                 wp_enqueue_script('cslider', get_template_directory_uri() . '/js/jquery.cslider.js');         //  }         }              //Lightbox         if($options['w3t_lightbox'] == '1') {             wp_enqueue_script('prettyPhoto', get_template_directory_uri() . '/js/jquery.prettyPhoto.js');         }     }     add_action('wp_enqueue_scripts','w3t_add_scripts');      That's how the entire function looks like now. i did what you suggested, but it's not loading the jquery or jquer-ui files


How to Use Checkbox in Custom Option Page Using The Setting API

Can you please let me know how I can add a checkbox to Setting API in creating Custom Options Page? I am using the following code to add a txt box which is working perfectly but I am totally confused how to add chechbox to the setting API and options. I just tried ti update the input type to checkbox but I am not sure what to put in Value besides when I save the form the check box still appears unchecked!                add_settings_field('the_option_label',                         'Display Paragraph:',                          array($this,'the_option_label_setting'),                          __FILE__,                          'hte_main_section');           public function the_option_label_setting()         {            echo "<input name='My_Theme_Options[the_option_label]' type='text' value='{$this->options['the_option_label']}'/>";         }      Thanks


Add multiple Visual Editors for Custom Post Type

I'm designing a site that will be part of a WP-Network; we have been told we cannot install plugins. I have a custom post type, which I have added in `functions.php` of the child- theme I am writing. In addition to the built-in editor that is available as part of the Edit Post, I would like to add a further two visual editors - I believe from 3.3, the widget is called `wp_editor`. Is it possible to add these without the use of metaboxes? I have already used WPAlchemy as per this article, but I didn't like that it wasn't possible to switch from Visual to Text, and the fact that the editor appeared inside another box. I have also seen this question on WPA which appears to be asking the same question, but the answer also uses WPAlchemy. I have seen how to use the `wp_editor` on front-end pages, but not how to add them to the back end edit pages for specific post types. Thanks.


Run php function after html click after page refresh

I'm trying to create a table of custom type posts in the admin section, in my plugin's settings page. The part I'm having trouble with is allowing user's to delete a custom post through my table. What I have so far is               <?php         if (isset($_GET['remove_now'])){//.$post_id         custom_post_removal_func ($_GET['remove_now']);         header('Location: '.$_SERVER['PHP_SELF']);              die();              }     ?>
         <?php echo $the_title?>	         <?php echo $post_start?>	         <?php echo $run_time ?>	         <a href='./admin.php?page=plugin_settings_page&remove_now=<?php echo $custom_post_id?>'>Remove Now
      When I click on the "remove now" link it takes me to a blank page and doesn't run the custom_post_removal_func function. thanks


How to export and import plugin data through WordPress tools option

I have a plugin which doesn't have import/export option in WordPress tools http://wordpress.org/plugins/color-manager/ How can I add this functionality?


Inserting image into post content - Front End

This is the php I have for a form which creates a post with thumbnail. I want to know how to add the uploaded image to the post content as well. Tried a few things, but they didn't work.                if(isset($_POST['new_post']) == '1') {                  $post_title = $_POST['post_title'];             $post_category = $_POST['cat'];             $filename = $_POST['attach'];                 $new_post = array(               'ID' => '',               'post_author' => $current_user->ID,                'post_category' => array($post_category),               'post_title' => $post_title,               'post_status' => 'draft'             );                  $post_id = wp_insert_post($new_post);             $post = get_post($post_id);             $new_post = $post->ID;               if (!function_exists('wp_generate_attachment_metadata')){                 require_once(ABSPATH . "wp-admin" . '/includes/image.php');                 require_once(ABSPATH . "wp-admin" . '/includes/file.php');                 require_once(ABSPATH . "wp-admin" . '/includes/media.php');                 }                       if ($_FILES) {                 foreach ($_FILES as $file => $array) {                     if ($_FILES[$file]['error'] !== UPLOAD_ERR_OK) {                         return "upload error : " . $_FILES[$file]['error'];                     }                     $attach_id = media_handle_upload( $file, $new_post );                 }                    }                      if ($attach_id > 0){                      //and if you want to set that image as Post  then use:                 update_post_meta($new_post,'_thumbnail_id',$attach_id);                 }          }


Checking for existing title in custom db query not working

I want to check if the title exists before the `wp_insert_post()` is triggered. However, the condition seems not to work as expected:               if( $wpdb->get_row("SELECT * FROM wp_posts WHERE post_title = '" . trim($titles_arr[$i]) . "' AND post_type=post", 'ARRAY_A') ) {       // title do exist       // don't save          } else {            // ...perform save code          }      And it saves always no matter if it exists. The funny part is that if the existing title i my db is e.g.: `The best title in the world` and slug `the-best-title-in-the-world` and for example one thing from the `trim($titles_arr[0])` (I am looping the array via foreach loop) array than the slug of that post that shouldn't be saved in the first place is called `the-best-title-in-the-world-2` and if I run my scirpt again it became `the-best-title-in-the-world-3` etc.


Blank Pages with # URL & Google

I'm using some blank pages that have a title only and a URL set to '#' for my navigation. (So, that the item appears in the dropdown menu, but when it's clicked a page doesn't open). Do I need to make sure that Google doesn't try to index these pages? I don't want to be penalized by Google. Should it be a concern? Thank you!


How to order posts by descending comment count on taxonomy page?

This lists the posts in my custom taxonomy template page:               <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>      How can I order those posts by comment count?


Example for use tinymce in wordpress 3.5.1?

I'm search the topic about how to use tinymce in wordpress 3.5.1 and i not found. I'm writing plugin and i have textarea that i want to add timymce into What should i do to add tinymce into suppose that i have textarea like this               <textarea class="focus_des" name="focus_des" id="focus_des" ></textarea>


Using custom post type parent as slug

I'm currently using the plugin 'Types Custom Post Type' to create custom post types (I know it's pretty easily done through `functions.php` but I was feeling a bit lazy!). Basically, I'm looking to have the following format for pages: `/wellbean-cottage/` - the main page for a house `/wellbean-cottage/things-to-do/` - a child page with information about the house I thought the best option would be to create a different post type for these sub-pages, but unfortunately it doesn't seem to add the house slug beforehand. Does anyone have any idea how it can be set up to work like this? Thank you in advance!


How To Update Premium Plugins I made

> **Possible Duplicate:**   >  Updates for a private plugin?    I am trying to find a way to update my premium plugins for WP. My current needs are that:     * the system I use must allow for multiple plugins (although if it only allows for one plugin I can modify it to make it work for several.   * the system I use should protect the URL of the source file   * the system I use should be easy to update and **must work** I do not want my code on Github (for obvious reasons as they are premium plugins).


Copying over taxonomy structure from one CPT to another

I have a CPT called adverts and it has 2 taxonomies - category and location. The problem is that there are about 100 entries in location taxonomy and I need to copy the same structure to another CPT - businesses. Doing everything manually will take forever. Are there any solutions for that? P.S. Taxonomy structure includes parent and children hierarchy P.P.S. I checked the DB structure and due to its design it is hard to find all relations and taxonomies there as they are in various tables. Maybe there some kind of a plugin?


How do I place content on archive pages but not on main page?

I would like to place content in a sidebar of my blog articles when they are viewed in the archive, but not show this content when the blog articles are shown on the main page of my site. Can this be done?


Multiple permalinks

My blog uses the `/?p=378` permalink structure for some years. This isn't very helpful with Google Analytics, and I would like to change it to the `YEAR/MONTH/DAY/post-title` structure. Is there a way to do this without losing backward compatability, so that old link will work?


How to get the post id (of the parent custom custom type) in a loop inside a widget?

Below there is a widget with a Wordpress loop inside. It works as expected. The only problem is this part:               'post_parent' => $post->ID,      The widget is not getting the `post->ID` of the parent of the current `topic` custom post type (with is another custom post type called `forum`). It does work when I place the loop in a template file. This:               <?php $current_post_id = $post->ID; ?>
<?php echo $current_post_id; ?>
      Outputs a post id (the forum custom post type which is the parent of the topic custom post type).               /**      * Most voted topics widget      */     class MostVotedTopics extends WP_Widget {         /** constructor */         function MostVotedTopics() {             parent::WP_Widget(false, $name = 'Most Voted Topics');         }              /** @see WP_Widget::widget */         function widget($args, $instance) {             extract( $args );             $title = apply_filters('widget_title', $instance['title']);             ?>               <?php echo $before_widget; ?>                   <?php if ( $title )                         echo $before_title . $title . $after_title; ?>                          <?php // Display the top topics of current forum                         $args = array(                             'post_type' => 'topic',                             'posts_per_page' => '3',                             'post_parent' => $post->ID,                             'gdsr_sort' => 'thumbs',                             'gdsr_ftvmin' => '1',                             'gdsr_order' => 'desc',                             'order' => 'DESC'                         );                     ?>                      <?php query_posts( $args ); ?>                         <?php while ( have_posts() ) : the_post(); ?>

                          <?php $current_post_id = $post->ID; ?>
<?php echo $current_post_id; ?>

<a href="<?php bbp_topic_permalink(); ?>" title="<?php bbp_topic_title(); ?>"><?php bbp_topic_title(); ?>
                                     <?php printf( __( 'Started by: %1$s', 'bbpress' ), bbp_get_topic_author_link( array( 'size' => '14' ) ) ); ?>                  <?php echo get_avatar(get_the_author_meta('user_email'), 64); ?>                      <?php the_author_meta('nicename'); ?>
Last modified on the: <?php the_modified_date(); ?>. by: <?php the_modified_author();?>

Time last modified: <?php the_modified_time(); ?>
             <?php echo time_ago(); ?>

<?php wp_gdsr_render_article_thumbs(); ?>
                                              <?php preg_match( '!
(.*)
!si' , wp_gdsr_render_article_thumbs(0, false, "", 0, "", false) , $n );                                         $thumbs_number = strip_tags( $n[1] ); ?>                                              <?php if ( $thumbs_number == 1 || $thumbs_number == -1 ) : ?>                                             <?php _e( 'vote' ); ?>                                         <?php else : ?>                                             <?php _e( 'votes' ); ?>                                         <?php endif; ?>

<?php bbp_topic_reply_count(); ?>
                                         <?php if ( bbp_get_topic_reply_count() == 1 ) : ?>                                             <?php _e( 'reply' ); ?>                                         <?php else : ?>                                             <?php _e( 'replies' ); ?>                                         <?php endif; ?>

<?php bbp_topic_freshness_link(); ?>
                                                                                <?php bbp_author_link( array( 'post_id' => bbp_get_topic_last_active_id(), 'size' => 14 ) ); ?>
                          <?php $most_voted[] = get_the_ID(); // get the id of the most voted post ?>
                         <?php endwhile; ?>                 <?php wp_reset_query(); ?>                 <?php print_r($most_voted); ?>                        <?php echo $after_widget; ?>             <?php         }              /** @see WP_Widget::update */         function update($new_instance, $old_instance) {         $instance = $old_instance;         $instance['title'] = strip_tags($new_instance['title']);             return $instance;         }              /** @see WP_Widget::form */         function form($instance) {             $title = esc_attr($instance['title']);             ?>
<label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" />
             <?php         }          } // class FooWidget          // register FooWidget widget     add_action('widgets_init', create_function('', 'return register_widget("MostVotedTopics");'));      Any suggestion to fix this?


programmatically adding categories to custom taxonomy

wp_create_category() adds new categories to the 'content' taxonomy associated with the post type... Simple question really neither wp_create_category() or wp_insert_category() allows configuration for taxonomy type... so how can I can do it?


populate array with posts

I want to generate an array of custom post types to add it to a options array. I'm doing this to show a checkbox group populated with custom post type. I have this array:               'options' => array (           'one' => array (               'label' => 'Option One',               'value' => 'one'           ),           'two' => array (               'label' => 'Option Two',               'value' => 'two'           ),           'three' => array (               'label' => 'Option Three',               'value' => 'three'           ),           'four' => array (               'label' => 'Option Four',               'value' => 'four'           )       )      How can i replace this with a custom post type? i'm trying this:               function get_sponsors()     {         $args = array(         'numberposts' => -1,         'post_type' => 'movies'         );              $my_movies = get_posts( $args, ARRAY_A );              return $my_movies;     }      I'm using the code in this article: Reusable Custom Meta Boxes Part 2


Remove "Content" and "Discussion" from Right Now Dashboard Widget

How do I hide "Content" and "Discussion" element in the "Right Now" dashboard widget? Here's a screenshot: ![right now dashboard widget](http://i.stack.imgur.com/EtPQT.png)


Why does this loop only work on the homepage?

I've been trying to figure this out all day now. Consider the following code below:

<?php            wp_reset_query();              if(have_posts()) :                 while (have_posts()) :                   the_post();                  if(is_sticky()) : ?>
<a rel="bookmark" href="<?php the_permalink() ?>"><?php echo the_post_thumbnail('full'); ?>
<?php the_title(); ?>

                  <?php endif;                endwhile;               else: ?>
Sorry, no posts matched your criteria.
              <?php endif; ?>

      The loop above doesn't work on the site's pages (e.g: page 2/3/4) or 404.php, but works perfectly fine on page 1 (the index.php). Why is that and how do I fix this?


Custom post type navigation - 404 on page 2

I have a custom post type `portfolio` and now I'm trying to enable navigation for the template where 10 portfolio items are shown. I'm using the following code to query the posts:               if ( get_query_var('paged') )          { $paged = get_query_var('paged'); }     elseif ( get_query_var('page') )          { $paged = get_query_var('page'); }     else          { $paged = 1; }     $posts_per_page = get_option('posts_per_page');          $offset = ( $posts_per_page * $paged ) - $posts_per_page;          query_posts(array('paged'=>$paged, 'posts_per_page'=> $posts_per_page, 'post_type'=>'portfolio', 'offset' => $offset));      The current link structure is as follows:               domain.com/portfolio //main portfolio page, showing 10 portfolio items     domain.com/portfolio/item //shows a single portfolio item     domain.com/portfolio/page/2 //should show the next set portfolio items, but shows a 404 error instead.      I'm assuming the problem is that when you visit `domain.com/portfolio/page/2` that WordPress assumes that `page` is a portfolio item, so it looks for that specific portfolio item rather than showing the next portfolio page. How could I solve this issue? I'd rather not change the link structure for easier browsing. I do not want to use a plugin like `WP Page Navi`, so this is not a duplicate with Pagination not working with custom loop


Archive page for custom post type not working

I use a plugin called CPT-onomies to create Custom Post Types. I created a post type called "case", and set "Has Archive Page" to true, but when i try to view a single case, i just get 404'd. Same thing also happens if i try to view the actual archive, eg. "site.com/case" and not "site.com/case/case-item". Here's a screenshot of my settings: http://i.imgur.com/6rJgdhS.png I've tried disabling/enablind it, no success. I also tried changing permalink structure of the whole site (from settings -> permalinks) because sometimes that doesn't update. Have i missed something in the settings or is this a bug in the plugin? I've gone through it several times and i can't find anything that would prevent it from working. I have a template file called `single.php` that should be used. I also tried `single-case.php` but that didn't make any difference. # Solution I found a solution here: http://gabrieleromanato.name/wordpress-fix- the-404-error-on-custom-post-types/


get_all_category_ids for bookmark

I was wondering how to create a list of categories name and ids for Wordpress Bookmarks such as `get_all_category_ids` for post. I tried using the `get_bookmarks`, but the category does not appear in it. **Update** : Based on advice from @Mridul-Aggarwal, I wrote code that might be useful:               <?php         $tautan=get_terms('link_category');//get links category object         $html="
\r\n";//Init              /*Looping*/         foreach($tautan as $isi) {             $nama=$isi->name;             $id=$isi->term_taxonomy_id;             $html.="\t
$id - $nama
";         };         $html.="
\r\n";              /*Output*/         echo $html;     ?>


Wordpress admin right sidebar isn't working

I don't what happened but few times ago its working and now i don't what i did so it stops working, I want its quick fix, Currently when we're adding new post it looks like that screenshot : ![enter image description here](http://i.stack.imgur.com/JOI0t.png) Column is already 2 and nothing changed when we use 1 column, I want its right sidebar.


Load .txt file for login_message in wp-login.php

How do I load the contents of a text file - or any other file, like .php - and use the test for the `login_message` hook that prints a message above the `#login` box in wp-login.php? _(BTW, this is in a child theme, if it makes a difference.)_               function custom_login_message() {          $message = get_bloginfo('stylesheet_directory')."/tos.txt";     return $message;     }     add_filter('login_message', 'custom_login_message');      Right now, the function above prints out the URL of the file, not the text in the file, i.e.: ![enter image description here](http://i.stack.imgur.com/xb3QP.png)


How to re-arrange the MENU of "Allure Real Estate Theme for Placester" wordpress theme?

I am using "Allure Real Estate Theme for Placester" wordpress theme, I tried the below three methods but no positive result in realtypointusa.com   1. I tried in Dashborad-> Appearance-> Menus and re-arranging but it didn't worked. I got a blank white screen as output on pages.   2. Rearranged the below code, (As its a html code with embedded PHP, it not being rendered here properly. I tried posting it as an image but new users are not allowed so please click on the below link to look on the snippet or code.) CLICK HERE TO SEE THE CODE USED TO RENDER THE MENU BAR Finally, this option I am very well aware that the 'page order' in wordpress is used for webmaster convenience and it cannot impact menu ordering on the menubar of website but I still tried it to look out for a change but it didn't worked not re-arrangement happened. **HOW TO REARRANGE THE MENU IN "Allure Real Estate Theme for Placester" WORDPRESS THEME?**


How to keep WP from recompressing Full Size images

I have noticed that WP does have the bad habit of recompressing Full Size images during uploads. I mean, it does make sense creating several smaller versions of each uploaded image, applying a default 90% JPEG quality setting, but why compressing twice also the Full Size images, as they are fine just as they are? My problem is that usually 90% of the large JPEGs I'm uploading through WP are usually set to a 50-75% quality to decrease their size, so when WP re-compress them it causes a further loss in quality and their size is being bloated between 100-200%. Is there any way to keep WP from changing the size and quality of Full Size JPEGs?