title: How to create custom tables in WordPress using my own plugin?

text: I am new in WordPress plugin development. This is my core PHP and HTML code **create-table.html**                 <form method="post" action="function.php">         <input type="text" name="table_name">         <input type="submit" name="create">         </form>      **function.php**               if(isset($_POST['create'])     {     $table-name=$_POST['table_name'];          //create table query     header("location: add_table_attribute.php");     }      I want to use this same process in my WordPress plugin development. Please any one help me. Thanks in advance.


title: Inserting large amounts of data into a custom table during plugin install

text: I am working on a WordPress plugin that creates several new tables into the database. It also loads some default data into the tables from CSV files. Most of these are small and loading the data works fine. One, however, is a zip code database meant to be loaded with just over 43,000 rows of data. The first time I tried to do exactly what I did for the tables with significantly smaller amounts of data to be inserted. WordPress responded with, "Plugin could not be activated because it triggered a fatal error." After checking the database I saw that it got through just over 1,000 zip codes before it stopped. So I took the first 1,500 lines from that CSV and broke it into 2 CSV files (750 lines each). I used the code below to loop through loading the two CSV files to test if I could just do this in what would be an incredibly slow solution, but at least something that worked. It turned out that it was still only able to get through 1099 zip codes before stopping. Does anyone have a solution for inserting very large amounts of data into a table from a WordPress plugin? Thanks in advance to anyone who tries to help me here. Here is an example line from the zips CSV:               %1%;%00544%;%NY%;%HOLTSVILLE%;%-73.047623%;%40.813296%;%0%      Here is the create table function:               function zip_table_create() {          global $wpdb;     $table_name = $wpdb->prefix . "zip";          $sql = "CREATE TABLE $table_name (          `zip_id` bigint(20) NOT NULL AUTO_INCREMENT,          `zip` char(5) DEFAULT NULL,          `state` char(2) NOT NULL DEFAULT '',          `name` char(40) DEFAULT NULL,          `lng` double NOT NULL DEFAULT '0',          `lat` double NOT NULL DEFAULT '0',          `population` int(10) unsigned NOT NULL DEFAULT '0',          PRIMARY KEY (`zip_id`)          );";          dbDelta($sql);          // Check to see if any records are stored in table     // If not, load default data from CSV     $zip = $wpdb->get_row("SELECT * FROM $table_name WHERE zip_id = 1");     if ($zip == null) {         for ($z=1; $z<3; $z++)         {             $csvpath = plugin_dir_path(__FILE__);             $csvpath = $csvpath."csv/zips".$z.".csv";                  $csv_array = csv2array($csvpath, ";", "%");                  for ($x=0; $x < count($csv_array); $x++) {                 $wpdb->insert(                      $table_name,                      array(                           'zip_id' => $csv_array[$x][0],                         'zip' => $csv_array[$x][1],                         'state' => $csv_array[$x][2],                         'name' => $csv_array[$x][3],                         'lng' => $csv_array[$x][4],                         'lat' => $csv_array[$x][5],                         'population' => $csv_array[$x][6]                     )                 );             }         }     }          }      Here is the csv2array function called in the create function:               function csv2array($file, $delimiter, $enclosure) {     if (($handle = fopen($file, "r")) !== FALSE) {          $i = 0;          while (($lineArray = fgetcsv($handle, 4000, $delimiter, $enclosure)) !== FALSE) {              for ($j=0; $j<count($lineArray); $j++) {              $data2DArray[$i][$j] = $lineArray[$j];              }              $i++;          }          fclose($handle);      }      return $data2DArray;     }


title: wp-login returns blocked

text: I'm working on a site where i let users sign-up and login from the front-end. But a random problem is making my head spin. On some occasions the users can't log in. After typing username and password the page just returns "Blocked" in the upper left corner. The url to mu site: http://www.karsten-tietje.dk/bolig The site is still in test phase, so I have created several users from my computer (ip) and I don't know if thats coursing the problem. But it has also happened on other computers. This is a huge problem for me as i can't locate the problem. And to make things more complicated it doesn't happen all the time. it seems rather random. I'm using s2members plugin and turned off the bruteforce option. Any suggestions on how to fix this problem?


title: Installing plugins and using complex folder structure with child theme in WordPress

text: I'm creating a new WP website based on a template, and I've created the child theme for this template. It is working without any problem. I understand the basics for a child theme as adding my `style.css`, `function.php`, etc. I need to get a better understanding on the following points:   * For plugins installation, will I install it using the child theme, or install in the parent theme? And will it be in `/wp-content/plugins` or do I need to create another folder and add some function to it to make it work.   * If I have a file inside more than one folder in the parent theme (example `/parenttheme/includes/php/anotherfolder/example.php`) and I want to modify the `example.php` file, do I need to create and match all this structure in the child theme only?, or do I need to add more function to make it work.


title: App Development for facebook

text: I would like to know how to connect between wp and Facebook. Is there any way to connect both of them and I can easily use Fb Api in WordPress?


title: Get published posts and pages?

text: I'm working on a plugin to use gettext in posts and pages content. I'm trying to get all published posts and pages in order scan them for translatable strings, but I cannot figure out how to do it. This is what I'm trying:               $pages = $wpdb->query('SELECT * FROM wp_posts WHERE post_status = "publish"');     foreach ( $pages as $post ) {         print_r($post);     }


title: Categories from front-end, checkbox selection doesn't work

text:
I'm using the plugin Post from site, which sets up a WP front end writer. I changed some line of code because I need to select categories with checkboxes and not with a multiple select (as it was originally in the plugin). Unfortunately it doesn't work: there is a checkbox in the front end writer, now, but checking boxes just does nothing: the post is saved without categories. Here's the code which handles the taxonomy selection:               public function get_taxonomy_list( $taxonomy ){         $terms = get_terms($taxonomy, array(             'hide_empty' => 0         ));         if (!$terms || empty($terms)) return '';         //preg_match_all('/\s*<input class="(\S*)" value="(\S*)" type="checkbox">(.*)<\/input>\s*/', $terms, $matches, PREG_SET_ORDER);         $out = apply_filters( 'pfs_taxonomy_label', "Seleziona i corsi", $taxonomy );         foreach ($terms as $term){             if (is_taxonomy_hierarchical($taxonomy))                 $out .= "<input class='{$term->term_taxonomy_id}' type='checkbox' value='{$term->term_taxonomy_id}' name='{$term->term_taxonomy_id}' /> {$term->name}
";             else                 $out .= "<input class='{$term->term_taxonomy_id}' type='checkbox' value='{$term->name}' name='{$term->name}' /> {$term->name}";         }         $out .= "
\n";         return apply_filters("pfs_{$taxonomy}_list",$out);     }      and here's the code which saves the post and the taxonomy (which I didn't change):               $postarr['tax_input'] = (array_key_exists('terms',$pfs_data)) ? $pfs_data['terms'] : array();     $post_id = wp_insert_post($postarr);


title: Multiple Domains Same Install Different Static Pages

text: I have my main domain `domain.co.nz` with a static homepage of `home` but I also have a url that is great for SEO purposes and what I am trying to do is work out how I can have my `seoDomain.co.nz` point to a specific static page with the related information but the rest of the site remains `domain.co.nz`


title: Get page content using slug

text: I'm trying to get page content when I only know the slug string. Is there a function for this, or an easy way to do this or is this a case of doing it via SQL? Thanks very much


title: How to create multiple sidebar areas with a forloop and register_sidebars?

text:
Im trying to create like, 8 sidebar areas using an array of page templates (like date, archive, tag ect) and then looping through the array, creating a sidebar for each value. I thought this should work, but it only creates a sidebar for the last value in the array:               $widget_areas = array('single','index','category','archive','tag','taxonomy','author','date','search','attachment');     foreach($widget_areas as $area){                   register_sidebar(              array(             'name' => __( $area. ' Widgets' ),             'id' => 'index',             'description' => __( 'Widgets in this area will appear on the ' . $area ),             'before_widget' =>'
',             'before_title' => '
',             'after_title' => '
',             'after_widget' => '
'         )         );          }      The only sidebar it's creating is for the "attachment" template. What gives? Shouldnt register_sidebar run for each value in that array, creating a ton of sidebars? If I hardcode each section with register_sidebar that works, but I really dont want to repeat a bunch of code


title: Add rel to all images in a post

text: I want to add a `rel` to all images in a post. I am trying following filter but it will wrap only the images which are in the gallery. It does not wrap the images which are added individually without the gallery. How can I add the `rel` to all images in the gallery or without the gallery?               function add_rel($link) {         return str_replace('<a href', '<a rel="lightbox" href', $link);     }     add_filter( 'wp_get_attachment_link', 'add_rel');


title: Show single post then all posts (with pagination)

text: On my `single.php` I would like to show the single post then list all the posts with a pagination. I use the following code:               <?php while ( have_posts() ) : the_post(); ?>     <!-- Show single post -->     <?php endwhile; ?>          <?php $page = (get_query_var('paged')) ? get_query_var('paged') : 1;     $all_posts_query = new WP_Query( array('posts_per_page' => 12, 'paged' => $page));     while($all_posts_query->have_posts()) : $all_posts_query->the_post(); ?>     <!-- Show all the posts -->     <?php endwhile; wp_reset_postdata(); ?>          <?php next_posts_link('older', '', 'yes'); ?>      As result I can see the single post then the first 12 posts and that all, no pager... Thanks a lot for your time.


title: non-hierarchical custom taxonomy using checkboxes on edit-screen -> saving issue

text:
I registered a non-hierarchical custom taxonomy ('property_features'). There is a checkbox for every terms of this tax in a custom meta box on the edit- screen. All terms are displayed and all terms wich are attached to the post are checked correctly. So far so good... ... but when I check one of the unchecked boxes and hit save wordpress creates a new term. **EXAMPLE:** _code of unchecked checkbox I want to see checked after saving_
                <input value="11" name="tax_input[property_features][]" id="in-property_features-11" type="checkbox"> Term-Name
      _code of resulting checkobx:_
                <input value="55" name="tax_input[property_features][]" id="in-property_features-55" checked="checked" type="checkbox"> 11
      _code I use to create the checkboxes:_               function display_property_features_meta_box($post) {              $tax_name = 'property_features';         $taxonomy = get_taxonomy($tax_name);         $args     = array(             'descendants_and_self'  => 0,             'selected_cats'         => false,             'popular_cats'          => false,             'walker'                => null,             'taxonomy'              => $tax_name,         );              ?>         <div class="tagsdiv" id="tagsdiv-<?php echo $tax_name; ?>">                       <?php if ( current_user_can($taxonomy->cap->assign_terms) ) : ?>
                      <?php                 ?>                 <ul id="<?php echo $tax_name; ?>checklist" data-wp-lists="list:<?php echo $tax_name?>" class="tagschecklist form-no-clear">                     <?php wp_terms_checklist($post->ID, $args ) ?>

             <?php endif; ?>
         <?php     }      When I change to > 'hierarchical' => true in the register_taxonomy args everything works fine.


title: How can i display a jquery slide on front page

text: Hy, I integrate a jquery slide on front page, the problem apear when i install Next Gen Galley on the website. The Slide Stop Working, there is a conflict i think. I have 2 header index-header.php - the header of index page Slide                                    header.php - it is use on every page of the site. here i have `<?php wp_head(); ?>` How can i make it work. How can i load the slide without interfering the Next Gen Galley jquery


title: Problems with text alignment (justify)

text:
When clicking justify button to justify text inside the editor I get the following:
Lorem ipsum
      But when saved and viewed live, I get this:
Lorem ipsum
      Source:
              <?php if (have_posts()) : while (have_posts()) : the_post(); ?>                      <?php                       $desc= str_ireplace('"', '', trim(get_the_content()));                                       ?>                       <?php echo wpautop( $desc ); ?>

                         <?php the_post_thumbnail(); ?>
              <?php endwhile; endif; ?>       Any ideas what might be causing this? **Wordpress 4.0**


title: PHP in Wordpress?

text: I'm stuck with a question. How far can I go with php with wordpress? If good it's of course not the same as using a server+db and a .php file to script everything you can imagine, but how far can I go with Wordpress? For example you have your standard while's etc. but then you have inserting, what if I want to insert something like this in a field in wordpress? Would this even be possible or something related to things like `substr`?                   $firstletter = $row['Name'];         $firstletter2 = substr($firstletter, 0,1);              $return .= '<li data letter="'.$firstletter2.'" >';          }        return friendly ($firstletter2);


title: Including files in Child Themes

text: Twenty Thirteen uses the following in functions.php: `require( get_template_directory() . '/inc/custom-header.php' );`. When I copy /inc/custom-header.php to twentythirteen-child, it isn't replaced. I can't use `require()` because two copies will be included. How this should be handled?


title: Add category selection to custom post type (plugin)

text: I picked up someone's old project at the company I work at. They created a plugin to add courses to the website (including dates, location etc), but they didn't add the possibility to select a category for the course. I want to add this function, which I tried by looking at their other code and copy/pasting it and adapting it so it fits my needs. It does show up on the right side of the page, but whatever I do, it never remembers the category. ![Category selection showing](http://i.stack.imgur.com/qEX9k.png) I also adapted the "POST" function lower in the file, but I guess I'm still missing a piece of code that actually activates the category-selection, as it is also not showing up in the overview of all courses: ![No category displayed](http://i.stack.imgur.com/I3zXp.png) The previous developer worked with `add_meta_box` to create the boxes on the side. I created the following:               add_meta_box(             'course_category_box',          // Unique ID              esc_html__( 'Category', 'Category Box' ),       // Title             'render_course_category_box',       // Callback function             'course',                   // Admin page (or post type)             'side',                 // Context             'default'                   // Priority         );      Which I called upon by using               <?php         function render_course_category_box( $object, $box ) {                  wp_nonce_field( basename( __FILE__ ), 'course_category_box_nonce' ); ?>         <p>              <?php wp_dropdown_categories( $args ); ?>          </p>     <?php } ?>      And also added it to the `save_course_meta_boxes` function.               if ( !isset( $_POST['course_category_box_nonce'] ) || !wp_verify_nonce( $_POST['course_category_box_nonce'], basename( __FILE__ ) ) )             return $post_id;      Now, I'm probably doing something that is way too complicated, as Wordpress often has a much easier way to add functions like these. I hope it's clear enough what my problem is. If not, don't hesitate to ask for more info!


title: .htaccess and virtual host configuration for WP in its own directory

text: I've been taking a look at the _modern WP development approaches_ using Composer and so on, for example Bedrock or WordPress-Skeleton. I'd like to adapt these approaches ad create my own WP boilerplate, so I ended up with a project structure like this:               my_project      |      \--app  <-- custom wp-content folder      |   |        |   \--mu-plugins      |   \--plugins      |   \--themes      |      \--vendor  <-- folder for composer packages      |   |      |   \...      |      \--wp  <-- WordPress core folder      |   |      |   \...      |      |--composer.json      |--composer.lock      |--index.php      |--wp-config-local.php      |--wp-config.php      Everything works fine so far, but the problem is that I have to set **my_project** as the web root folder, so that an user can go to _http:/my- project/vendor_ , for example, and see all my vendor packages, which I think it's not good... So, is there any way to set some _.htaccess_ file or configure the _virtual host_ in such a way that I can use that folder structure but do not allow anybody to access all those files and folders that are not absolutely necessary for the site...


title: Fatal error: Call to a member function update() on a non-object in my resturant plugin file restaurants.php

text: when ever i click on publish or save button in custom post type in wordpress it will shows above error. I am using single database (i.e, gls) but that database share data both sites. The problem is when ever I update any restaurant post, after click publish or save draft button it give the above error. plz help me... here is my code               function save_restaurant()     {          //start function save         global $wpdb;         global $gldb;         global $post;              $glpost=get_post($post->ID);              if($post->post_type == 'page') { return; }         else if($post->post_type == 'post') { return; }              if($post->post_type == 'restaurant')             {   //start post type check                           $restaurant = $wpdb->get_row( "SELECT * FROM  `wp_restaurant` WHERE `post_id`='".$post->ID."'" );                 if($restaurant->post_id==$post->ID)                 { // post is exist or not                          if($_POST['gl']==1 && $restaurant->gl_postid!=0)                     { // chec for gl exit  page and gl id exit =1       !0                                    $gldb->update('wp_posts', array(                               //elements                             ),                          array( 'ID' => $restaurant->gl_postid ),                          array(                              //element                             ),                          array( '%d' )                         );                               $wpdb->update('wp_restaurant', array(                                   ),                          array( 'post_ID' => $post->ID ),                          array(                              //elements                         ),                          array( '%d' ) );                     }// end check for gl exit  page and gl id exit =1       !0                      else if($_POST['gl']==1 && $restaurant->gl_postid==0)                     {// check for gl exit  page and gl id exit =0       !0                               $gldb->insert('wp_posts', array(                              //elements                             ),                          array(                              //elements                             )                         );                          $last = $gldb->get_row("SHOW TABLE STATUS LIKE 'wp_posts'");                         $glid  = $last->Auto_increment-1;                         $wpdb->update('wp_restaurant', array(                             //elements                         ),                          array( 'post_ID' => $post->ID ),                          array(                              //elements                             ) ,                          array( '%d' )                         );                     }// ending check for gl exit  page and gl id s                     else if($_POST['gl']==0 && $restaurant->gl_postid!=0)                     {// check for gl exit  page and gl id exit =0       !0                               $gldb->update('wp_posts', array(                              //elements                             ),                          array( 'ID' => $restaurant->gl_postid ),                          array(                              //elements                             ),                          array( '%d' )                         );                               $wpdb->update('wp_restaurant', array(                             //elements                         ),                          array( 'post_ID' => $post->ID ),                          array(                              //elements                         ),                          array( '%d' ) );                     }// ending check for gl exit  page and gl id exit =0        !0                      else                     {// check for gl exit  page and gl id exit else case                         $wpdb->update('wp_restaurant', array(                             //elements                         ),                          array( 'post_ID' => $post->ID ),                          array(                              //elements                         ),                          array( '%d' ) );                     }// ending check for gl exit  page and gl id exit else case                 } // ending post exist or not                 else                 { // else case post exist                          if( $_POST['gl']==1)                     { // check for gl==1                         $gldb->insert('wp_posts', array(                              //elements                                  ),                          array(                              //elements                              )                         );                      $last = $gldb->get_row("SHOW TABLE STATUS LIKE 'wp_posts'");                     $glid  = $last->Auto_increment-1;                     $wpdb->insert('wp_restaurant',                          array(                             //elements                              ),                          array(                              //elements                             )                         );                      }// ending check for gl==1                     else                     { // checki gl else                         $wpdb->insert('wp_restaurant',                          array(                             //elements                         ),                          array(                              //elements                             )                         );                      }// checki gl else                 }// ending else for post exist             }// ending else case post type check     }//ending function save


title: Preexisting login to change to logout link in sub menu

text: I am using twenty twelve with a child theme. I have a link in my primary nav menu where I have an link for “My Account” which has a sub menu with a “Login/Register” link that redirects to a modified wp-login.php. Is it possible for me to turn the “Login/Register” link into a “Logout” link when a user is logged in? If it is possible, would you know how I could accomplish this, or point me in the right direction? Everything I've found online is adding a login/logout link to the primary menu. I would like to leave the menu intact since the "My Account" sub menu will have more links added to it. I'm not sure if this is relevant but, I created the sub menu using Wordpress menus and created a custom link to redirect it to wp-login.php Thank you


title: Update post counts (published, draft, unattached) in admin interface

text: I am working on a multi-user WordPress setup and have made it so a particular type of user can only see and interact with posts, images, pages etc that they have authored. The code to make this happen looks like this:               add_filter('pre_get_posts', 'current_author_posts');          function current_author_posts($query) {              if ($query->is_admin && current_user_can('artist')) {             global $user_ID;             $query->set('author', $user_ID);         }              return $query;     }      This works well within the admin interface but leaves all of the post counts displaying incorrectly: ![image that shows incorrect post counts within WordPress](http://i.stack.imgur.com/EJyUv.png) Are you aware of any filters or hooks to manipulate these figures and be correct across posts, pages, media and custom post types? Many thanks.


title: Warning: Cannot modify header information (with a twist)

text: Warning: Cannot modify header information - headers already sent by (output     started at /home/ezekiel/public_html/boxsponsive/wp-     content/themes/BoxSponsive-Portfolio/class.wp-less-styles.php:3) in     /home/ezekiel/public_html/boxsponsive/wp-includes/pluggable.php on line 934      So, I'm sure that you've all seen this error before for one reason or another. However, the problem is a bit different this time. I've gotten rid of extra lines, made sure the file's encoding is right, basically, I've tried the usual fixes. There are no plugins on this site. The code that seems to be causing the problem is here: http://pastebin.com/3TSDWhTS I've used this code with no issues (on other servers) before, but I don't really know PHP... Can anyone spot the problem? P.S. Telling me to remove lines at the top isn't working. Need other ideas... **Update:** I feel like an idiot. There was a different file with the same bug (extra line), and that's why the error didn't go away. Rookie mistake, really.


title: Automatic add record after refreshing page

text: I have on page only this code:                get_header();              global $title;         global $wpdb;         global $current_user;                   if ( 0 == $current_user->ID ) {         } else { }          include_once('home-sidebar.php');       get_footer();       I would like to automatically add a record after refreshing the page.


title: should i use GLOB_ONLYDIR to hook add-ons for wordpress plugin

text: I am adding the ability to add add-on to my plugin. Right now i am using:               foreach(glob(GMW_PATH .'/plugins/*', GLOB_ONLYDIR) as $dir) {          include_once $dir . '/connect.php';       }       The function loop trough all the folders inside the "plugins" folder in my plugin and includes the connect.php file that is inside each of those folders (each add-on folder include the connect.php file). This is the first time i am using GLOB_ONLYDIR and i am not sure about its performance. Is it a good idea to use the above or should i create each add-on as a stand alone plugin, which they actually are, but add the a ability to just activate them from the plugins page? Thank you.


title: Free Wordpress Hosting with Custom Themes?

text: Is there any place that has free hosting for wordpress and allows custom themes? I have seen a bunch that offer free hosting but none that seem to allow custom themes. I guess I should add a Little more about why I want it to be free I just want to throw up a site for a couple days to fool around with the theme get some feedback. Not a permanent hosting solution. So if this doesnt exist that is alright but I am aware of the pros and cons of free v paid hosting. It doesnt have to be a "wordpress host" either just a good place that I can setup a wordpress install in an hr and test for 3 days and tear down.


title: Masking logout URL

text: The primary goal is to hide that the site is driven by wordpress. I've got the login part all locked up, but the logout URL still has those blasted `wp` delineators that give away it's a wordpress site. Is there a way to somehow mask this URL? Perhaps by a conjunction of custom redirect where the client-side link goes to `www.site.com/logout/` but something in `functions.php` rebuilds the actual logout link? I've tried variations of `wp_logout_url('$index.php')` but this only redirects. I've also tried               add_filter( 'wp_logout_url', 'cusotm_logout' );     function cusotm_logout()      {         // set your URL here         return 'http://www.site.com/logout/';     }      Not only does this last one not work, it also appends `title=` to the end of the URL. I'm not sure if the logout doesn't work because of that or if the function itself is the wrong approach entirely. I only use plugins if I absolutely have to. Looking for a self-managed solution... without needing to `mod_rewrite` if at all possible.


title: Allow users of my plugin to define their own shortcode rather than use mine?

text: I'm creating my first plugin. So far everything is great, but my shortcode is something like this `[BIMS]` and that acronym might not be easy to remember, or appeal to everyone. I'd like to include an option to have them input their own replacement shortcode. What is the proper code to allow them to use their own shortcode text yet bring up my function?


title: Broken? WP_Query and "attachment" as a post type

text: I have a gallery attached to a page. On that page, I'm running the following query:               $events_gallery = new WP_Query( // Start a new query for our videos     array(         'post_parent' => $post->ID, // Get data from the current post         'post_type' => 'attachment', // Only bring back attachments         'post_mime_type' => 'image', // Only bring back attachments that are images         'posts_per_page' => '3', // Show us the first three results         'status' => 'inherit', // Inherit the status of the parent post          'orderby' => 'rand', // Order the attachments randomly           )     );      I've experimented quite a few ways and, for some reason, I can't get attachments to return. Am I missing something obvious here? **Update*** Thanks to Wok for pointing me in the right direction. It turns out I was using "status" instead of "post_status". The codex had used "status" as the example in its in-context explanation of the "attachment" post type. I updated the codex to reference "post_status" instead. The correct code is as follows:               $events_gallery = new WP_Query( // Start a new query for our videos     array(         'post_parent' => $post->ID, // Get data from the current post         'post_type' => 'attachment', // Only bring back attachments         'post_mime_type' => 'image', // Only bring back attachments that are images         'posts_per_page' => '3', // Show us the first result         'post_status' => 'inherit', // Attachments default to "inherit", rather than published. Use "inherit" or "all".          'orderby' => 'rand', // Order the attachments randomly           )     );


title: Add a custom field when adding / editing a page / post in admin panel

text: I create a new theme and I the page / post is divided to:   * Title   * Slogan   * Content I want to add a slogan field in the admin panel, where the user adds or edits a post or page. After I will use in update_option function.. just the part of adding this is the problem. I think there is a function or filter which does it but I don't know which. Thank you.


title: Append argument not working in the wp_get_recent_posts function

text: I want to append some WP posts to the normal search function but when I run the wp_get_recent_posts function (with the append and the posts IDs in an array) I dont get the posts I wanted to append in the results, am I doing something wrong?               $include = array(1, 2);          $args = array(             'showposts' => 10,              'tag_id' => '123',             'post_status' => 'publish',             'exclude' => $current_id,             'orderby' => 'post_date',             'append' => $include,         );              $entries = wp_get_recent_posts($args, 'ARRAY_A');      If I remove the tag_id argument then the posts I want to append are included in the results, seems that WP also filters the appended posts with the other arguments, is there any workaround?


title: Uploading and inserting an image using a custom option panel like in the Twenty Ten theme?

text:
Twenty Ten gives the option to change the background image of the header. Where is the code involved in this feature? (uploading the picture and adding the picture). I would like to mimic this feature to archive the following: Upload a custom logo and upload various images (maybe 10) into a slider. So `front-page.php` would look like this: Custom Logo:

      Custom images for slider:

      **EDIT: I realised that the theme uses this: add_custom_image_header(). Does Wordpress have a similar function to add other type of custom images (like logo, feature image, etc...) ?** (The simpler way I found was this, but I think it has a bug. In order for the image to appear, I have to upload it twice).


title: creating a left-side sidebar in word press

text: I would like to know how to create a side bar on the left-side.I have a site containing a sidebar in the right side.I need a sidebar in the left side too. Please help me.


title: How to link PHP pages not included in menu?

text: I'm developing a plugin which has basically four pages in menu, each page contains a form that the action value should link to another page (not included in menu). My questions are: how do I link the form to that another page properly? There's some way to include another pages in '/wp-admin/' folder that is not included on menu? I tried in many ways that I've found on another topics and in another plugins. But I still don't get it.


title: Posts Overlap and Not in Column Format - How to Append Masonry + Infinite Scroll (no plugin)

text: Using Wordpress, I have manually installed Masonry and paulirish's Infinite Scroll code. Masonry works and Infinite Scroll works, but having issues with them together when the next posts load. I have the issue of new posts loading in a single column (not masonry style) behind all the first set of posts. It's the same issue of as the question here, but I'm not using Jetpack. The solution provided in the above question said to "append" the newly loaded masonry posts, but I'm not sure how to apply the code in my given situation. Here is a similar code provided as a solution for non Wordpress sites, but again I don't know how to apply it to make it work. I've tried both, but think my selectors for the code are wrong? Not sure. Once I figure this all out, I think I'll put together a complete tutorial for people like me who are more front-end developers. Here is the script I'm using for loading Masonry and Infinite Scroll:               /**      * Add Masonry Libraries      */     if (! function_exists('slug_scripts_masonry') ) :     if ( ! is_admin() ) :     function slug_scripts_masonry() {         wp_enqueue_script('masonry');         wp_enqueue_style('masonry’, get_template_directory_uri().'/css/’);     }     add_action( 'wp_enqueue_scripts', 'slug_scripts_masonry' );     endif; //! is_admin()     endif; //! slug_scripts_masonry exists               /**      * Initialize Masonry Javascript       */     if ( ! function_exists( 'slug_masonry_init' )) :     function slug_masonry_init() { ?>     <script>         //set the container that Masonry will be inside of in a var         var container = document.querySelector('#masonry-loop');         //create empty var msnry         var msnry;         // initialize Masonry after all images have loaded         imagesLoaded( container, function() {             msnry = new Masonry( container, {                 itemSelector: '.masonry-entry'             });     });     </script>     <?php }     //add to wp_footer     add_action( 'wp_footer', 'slug_masonry_init' );     endif; // ! slug_masonry_init exists                                        /**      * Load Javascript for Infinte Scroll      */     function custom_theme_js(){         wp_register_script( 'infinite_scroll',  get_template_directory_uri() . '/js/jquery.infinitescroll.min.js', array('jquery'),null,true );         if( ! is_page_template( 'archive' ) ) {             wp_enqueue_script('infinite_scroll');         }     }     add_action('wp_enqueue_scripts', 'custom_theme_js');               /**      * Infinite Scroll      */     function custom_infinite_scroll_js() {         if( ! is_page_template( 'archive' ) ) { ?>         <script>         var infinite_scroll = {             loading: {                 img: "<?php echo get_template_directory_uri(); ?>/images/ajax-loader.gif",                 msgText: "<?php _e( 'Loading the next set of posts...', 'custom' ); ?>",                 finishedMsg: "<?php _e( 'All posts loaded.', 'custom' ); ?>"             },             "nextSelector":".navigation .nav-next a",             "navSelector":".navigation",             "itemSelector":"article",             "contentSelector":"#masonry-loop"         };         jQuery( infinite_scroll.contentSelector ).infinitescroll( infinite_scroll );         </script>         <?php         }     }     add_action( 'wp_footer', 'custom_infinite_scroll_js',100 );      Any assistance or guidance would be greatly appreciated! Thank you for your time.


title: How can I allow people to 'subscribe' to categories?

text: I would like for people to be able to subscribe to categories and tags, somewhat like Pinterest or Quora where you have to follow a minimum number of categories. After doing a plugin search, I can't seem to find anything that's been previously developed. Is there anything you can recommend? Ultimately this will be used send people email updates when new items are posted in a specific category / tag, and, as well, they will optionally be able to set their home page content to show only these content from "followed" categories when logged in. Thanks!


title: How to add a shortcode button to the TinyMCE editor?

text: How to make any plugin icon in wordpress post? The code I want to insert in plugin code and will appear in post bar [wp-admin/post.php]. Like this image: ![enter image description here](http://i.stack.imgur.com/0Qy8r.jpg) Output: If I click the icon it automatically writes `[plugin]` to the post content like this: ![enter image description here](http://i.stack.imgur.com/ECf2J.jpg)


title: Blog post not showing title

text: When on my main site NewMediaNook.wordpress.com, one particular post does not show a title (see image below). When I am on just that one post, the title appears, and all other titles appear when on the main site...but that one does not show up. All browsers look the same, regardless of login status. Can I just add it in with code?? (I just don't want to risk extra code to junk it up or potentially show the title twice in some random spots). Sorry, I'm new at WordPress, so I'm not sure what other information is needed. But all help is appreciated! ![enter image description here](http://i.stack.imgur.com/IMMSi.jpg)


title: How to restrict access to wp-content, wp-includes and all sub-folders

text: after searching I didn't find an answer still confused of how do I hide the   -> wp-content   --> uploads   --> themes   --> plugins   -> wp-includes in browser. What I want is when viewer browse some like this: http://www.mysite.ext/wp-content they will see an error: **You don't have permission to access this page**.   Other said that just upload index.html or index.php with .htaccess in the folder you want to hide. But what if I have many subfolder inside wp-content I will do that every folder manually? Or there is a way either in _cpanel_ , or in _.htaccess_ ? Suggestion please, thanks.


title: Offset Loop by 1 , Limit next loop to 1 (Most Recent) Post

text: I have a loop that I would like to Offset by 1 so the most recent post is not displayed, and another loop where I only want 1 item which would be the most recent post. These are the loops I tried: for both: Offset Loop: `<?php query_posts('offset=1'); if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>` and Most Recent Post Loop: `<?php query_posts('posts_per_page=1'); if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>` The page doesnt load for me when I tried this, any ideas?


title: how do I get rid of the links and all the links related menu items on the admin ui?

text: Since I won't be using the built-in links feature of wordpress, I see no reason in keeping its related menu items on the admin ui causing nothing but clutter. How do I do that?


title: Overriding default calendar to show posts from a category

text: I'm trying to modify the default WP calendar (get_calendar()) so that it shows posts from a specific category and then use that as a shortcode. Here's what I've done: Copied across the get_calendar() function from the core (from wp-includes) into my child theme's functions.php file. In order to make it an 'independent' calendar, I changed the name of the get_calendar() function to osu_get_calendar() and have successfully hardcoded the calendar into my template using osu_get_calendar(); Now I'm trying to get my hands a bit dirtier and do the following: 1) Restrict the posts shown in the calendar to a specific category (while maintaining the previous and next navigation so visitors can search through those posts by month) 2) Make it into a shortcode so my client can essentially embed a calendar with posts from a category they choose at the bottom of their posts. I'm stuck on 1) at the moment as it looks like I need to modify the SQL queries so that it pulls posts from a specific category. Looking at the code below from the get_calendar() function, how would I filter the posts pulled from the database so that they are from a specific category? There are other SQL queries in there, but hopefully someone can help me with this one for now:               $previous = $wpdb->get_row("SELECT DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year             FROM $wpdb->posts             WHERE post_date < '$thisyear-$thismonth-01'             AND post_type = 'post' AND post_status = 'publish'                 ORDER BY post_date DESC                 LIMIT 1");         $next = $wpdb->get_row("SELECT  DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year             FROM $wpdb->posts             WHERE post_date >   '$thisyear-$thismonth-01'             AND MONTH( post_date ) != MONTH( '$thisyear-$thismonth-01' )             AND post_type = 'post' AND post_status = 'publish'                 ORDER   BY post_date ASC                 LIMIT 1");      Thanks, osu


title: select box not checked and is not saved

text:
I needed to assign categories to post from frontend and found this fantastic thread here on this site, which generates a form at frontend with selectboxes. The plugin automatically appends the form after the content and works like charm.               <?php      /*     Plugin Name: WPSE Crowded Cats     Plugin URI: http://wordpress.stackexchange.com/questions/43419/how-do-i-create-a-way-for-users-to-assign-categories-to-a-post-from-the-frontend     Description: Allow visitors to change categories of posts. Ready to use with custom taxonomies and post types.      Version: 0.1     Author: WPSE     Author URI: http://wordpress.stackexchange.com/users/2110/maugly     License: GPL2     */          add_action('plugins_loaded','wpse_init_crowd_cats_class');     function wpse_init_crowd_cats_class(){         new WPSECrowdCatsClass();     }          class WPSECrowdCatsClass {          function __construct() {             // APPEND THE FORM AUTOMATICALLY TO EVERY POST             add_filter( 'the_content', array( $this,'append_form' ) );                  // TEMPLATE ACTION TAG TO BE USED IN THEME             // Usage: do_action('wpse_crowd_cats_form');             // Usage: do_action('wpse_crowd_cats_form', $post_id, $taxonomy );             add_action( 'wpse_crowd_cats_form', array( $this,'wpse_crowd_cats_form' ), 10, 2 );                  // FORM PROCESSING             add_action( 'template_redirect', array( $this,'process_request' ) );         }              function process_request(){             // check submission             if ( ! isset($_POST['crowd-cat-radio']) || ! is_array($_POST['crowd-cat-radio']) )                 return;                  //TODO: check nonce             // sanitize and check the input             $suggested_terms = array_map( 'absint', $_POST['crowd-cat-radio'] );             $post_id = absint( $_POST['crowd-cats-pid'] );             $tax = $_POST['crowd-cats-tax'];             if ( ! taxonomy_exists($tax) )                 return;                  // Allow only existing terms. Not sure if this is needed.             $args = array( 'hide_empty' => false );             $args = apply_filters( 'mcc_allowed_terms_args', $args, $post_id, $tax );             $args['fields'] = 'ids';             $allowed_terms = get_terms( $tax, $args );             foreach ( $suggested_terms as $key => $term_id )                 if ( ! in_array( $term_id, $allowed_terms ) )                     unset( $suggested_terms[$key] );                  // Add terms to taxonomy             $affected_terms = wp_set_object_terms( $post_id, $suggested_terms, $tax, false );             update_term_cache($affected_terms);             return $affected_terms;         }              function get_form( $post_id=null, $tax='category' ) {             if ( is_null($post_id) || ! taxonomy_exists($tax) )                 return false;                  $args = array( 'hide_empty' => false );             $args = apply_filters( 'mcc_get_terms_args', $args, $post_id, $tax );             $all_terms = get_terms( $tax, $args );                  if ( ! $all_terms )                 return false;                  $post_terms = wp_get_object_terms( $post_id, $tax, array( 'fields' => 'ids' ) );             $permalink = get_permalink( $post_id );             $out = "<form id='crowd-cats' action='$permalink' method='POST' >
";                  foreach ( $all_terms as $t ) :                 $checked = in_array( $t->term_id, $post_terms) ? 'checked' : '';                 $out .= "
                             <input type='checkbox' id='crowd-cat-$t->term_id' name='crowd-cat-radio[]' value='$t->term_id' $checked />                              term_id' >".esc_attr($t->name)."
";             endforeach;                  $out .= "
                     <input type='submit' value='Submit' name='crowd-cats-submit'/>                     <input type='hidden' value='".esc_attr($tax)."' name='crowd-cats-tax'/>                     <input type='hidden' value='$post_id' name='crowd-cats-pid'/>";                  //TODO: set nonce             $out .= "</form>";             return $out;         }              function append_form($content){             global $post;             if ( 'post' != $post->post_type )                 return $content;                  $form = $this->get_form( $post->ID );             if ( ! $form )                 return $content;                  return "$content \n $form";         }              function wpse_crowd_cats_form( $post_id=null, $taxonomy='category' ) {             if ( is_null($post_id) ) {                 global $post;                 $post_id = $post->ID;             }             echo $this->get_form( $post_id, $taxonomy );         }     } // end of class                     However I did not want the form to appear right after the content but after a few other important divs i have, after the content. So I used the following action tag ( mentioned in code as commented out lines) to use it in the template single.php. Doing so the form appeared in the desired place.               <?php do_action('wpse_crowd_cats_form'); ?>      The issue is it does not remains selected on submit neither the option gets saved. Please suggest me a solution.


title: Hijack site url on sub domain for translation

text: Ok, i have complicated issuse (i think)... i created a site that has 3 languages   without any plugin since none meet my needs.... **i create 2 sub domains named:**   * he.example.com   * en.example.com they both lead to the same site. **When the he.example.com loads:**   i want to change all the links inside the page according   to the **specific** sub-domain... for example my menus, recent posts   and all the other link on pages. **Reason:**   that way i can control which meta boxes, texts and stuff are being loaded   on the site and thus creating a translated sites without needing any plugin   (tested 3 so far - none of them answer my requirments)... **question:**   how can i "hijack" the site url the page uses when loads and change the   output accoring to the current sub-domain?


title: Custom classes for attachments

text: I'm trying to create a custom field in ATTACHMENT DETAILS section. I want to add in this field multiply words separated by space which will be than added as a classes to particular images. This is the solution I've found so far. It adds custom field but it doesn't add a class to images. What is wrong here?               function add_attachment_classes_field( $form_fields, $post ) {     $field_value = get_post_meta( $post->ID, 'classes', true );       $form_fields['classes'] = array(         'value' => $field_value ? $field_value : '',         'label' => __( 'Classes' ),         'helps' => __( 'Add class seperated by space' )       );      return $form_fields;     }     add_filter( 'attachment_fields_to_edit', 'add_attachment_classes_field', 10, 2 );          function save_attachment_classes( $attachment_id ) {       if ( isset( $_REQUEST['attachments'][$attachment_id]['classes'] ) ) {        $classes = $_REQUEST['attachments'][$attachment_id]['classes'];        update_post_meta( $attachment_id, 'classes', $classes );       }     }     add_action( 'edit_attachment', 'save_attachment_classes' );


title: wp-config.php file and code injection

text: It looks like several my sites on BlueHost got code injection in the wp- config.php file. Injected code itself looks like Any clue where it comes from? BH malware scan doesn't recognize that code so they are not able to detect where it started. Thanks


title: Save JSON object attributes to custom metabox

text: Case: I use a imagepicker.js script to create a image picker for my custom meta box. But this doesn't work for WP 3.6 anymore, So i'm trying to create a image picker metabox with the new media uploader. I got it to work with a JSON object, but how can I save these attributes from the JSON object to the metabox? jQuery image picker:               jQuery(function(jQuery) {              // Uploading files         var file_frame;         var wp_media_post_id = wp.media.model.settings.post.id; // Store the old id         var set_to_post_id = 5; // Set this              formfield = jQuery(this).siblings('.custom_upload_image');         preview = jQuery(this).siblings('.custom_preview_image');              jQuery('.custom_upload_image_button').live('click', function( event ){                  event.preventDefault();                  // If the media frame already exists, reopen it.             if ( file_frame ) {                 // Set the post ID to what we want                 file_frame.uploader.uploader.param( 'post_id', set_to_post_id );                 // Open frame                 file_frame.open();                 return;             } else {                 // Set the wp.media post id so the uploader grabs the ID we want when initialised                 wp.media.model.settings.post.id = set_to_post_id;             }                  // Create the media frame.             file_frame = wp.media.frames.file_frame = wp.media({                 title: jQuery( this ).data( 'uploader_title' ),                 button: {                     text: jQuery( this ).data( 'uploader_button_text' ),                 },                 multiple: false  // Set to true to allow multiple files to be selected             });                  // When an image is selected, run a callback.             file_frame.on( 'select', function() {                 // We set multiple to false so only get one image from the uploader                 attachment = file_frame.state().get('selection').first().toJSON();                          // Do something with attachment.id and/or attachment.url here                     console.log(attachment.url);                     console.log(attachment.id);                          imgurl = attachment.url;                     id = attachment.id;                     formfield.val(id);                     preview.attr('src', imgurl);                          // Restore the main post ID                 wp.media.model.settings.post.id = wp_media_post_id;             });                  // Finally, open the modal             file_frame.open();         });              // Restore the main ID when the add media button is pressed         jQuery('a.add_media').on('click', function() {             wp.media.model.settings.post.id = wp_media_post_id;         });          });      And my guess is that there has to be something added to this:               // Save data from meta box         function save($post_id) {             // verify nonce             if (!wp_verify_nonce($_POST['mytheme_meta_box_nonce'], basename(__FILE__))) {                 return $post_id;             }                  // check autosave             if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {                 return $post_id;             }                  // check permissions             if ('page' == $_POST['post_type']) {                 if (!current_user_can('edit_page', $post_id)) {                     return $post_id;                 }             } elseif (!current_user_can('edit_post', $post_id)) {                 return $post_id;             }                  foreach ($this->_meta_box['fields'] as $field) {                 $old = get_post_meta($post_id, $field['id'], true);                 $new = $_POST[$field['id']];                      if ($new && $new != $old) {                     update_post_meta($post_id, $field['id'], $new);                 } elseif ('' == $new && $old) {                     delete_post_meta($post_id, $field['id'], $old);                 }                 elseif ($new == '') {                     delete_post_meta($post_id, $field['id'], $old);                 }             }         }


title: image in new embedded player

text: Wordpress now has its own embedded media player as of 3.6 and it works good but Icant seem to find out how to add an image in the video itself, like when the player first loads all I have is a black box with the play button, is there a shortcode, plugin or something that allows me to add the photo of my choice in each video?


title: Hook for saving an image after editing

text: Is there any hook which is triggered when an image is edited (crop/re-size whatever)? I need to send an email notification to an admin user when an image will be edited (crop/re-size whatever). I need to get media/attachment id as well which have to be sent in email. I need your advice.


title: list of attachments: wp_get_attachment_link works, wp_get_attachment_image does not

text:
On single.php theme template file, I'm displaying the post's list of attachments.               global $post;     $args = array(         'post_type' => 'attachment',         'numberposts' => null,         'post_status' => null,         'post_parent' => $o_ID     );     $attachments = get_posts($args);     if ($attachments) {         echo '
';         foreach ($attachments as $attachment) {             //echo apply_filters('the_title', $attachment->post_title);             echo '
';             echo wp_get_attachment_link($attachment->ID, 'thumbnail', 0, 0, 'Download');             echo wp_get_attachment_image($attachment->ID, 'thumbnail',false);             echo '
';         }         echo '
';     }      Weird, `wp_get_attachment_link`works correctly (echoes the attachment's media link), `wp_get_attachment_image`does not: it echoes nothing at all. What am i doing wrong?


title: How to move meta information in TwentyTwelve's single post template?

text: How can I move a single post's meta data to it's headline? I tried `single.php` and `content_page.php`, but could not find it. I am using the recent Wordpress 3.5.1 with the standard theme _TwentyTwelve_. See the screenshot (sorry, it's in German) for clarification: ![Screenshot of a single post](http://i.stack.imgur.com/zjPSw.png)


title: Category checkbox list tree changes when editing a post

text: I'm setting up the categories for my website and I have them like so: ![Original categories order](http://i.stack.imgur.com/st50L.jpg) That's it, I have children of the same name but they are not interchangeable. If that bugs you just think that they have different names. Then I go to a post and I want to add categories to it and now the tree is completely gone and the categories order is completely messed up: ![categories inside post](http://i.stack.imgur.com/5BBSI.jpg) Why is this happening? It's not always like this, sometimes the tree shows up nicely but that behaviour is not consistent. I have seen this happening countless times on other blogs and so far I've just ignored this behaviour because I (or the web admin) could identify which category is child of which parent but this is not the case because some names are repeating. Anyway even if my categories may not be the best practise, maybe for the end user is not transparent that one category is child of another one if the tree is broken like that, right? EDIT: This is only happening when editing a post, when I add a new one everything is fine and dandy: ![enter image description here](http://i.stack.imgur.com/L1c08.jpg)


title: Output dropdown results into Woocommerce Order details

text: How do I correctly get the data from a drop down (select) output into the Woocommerce Order Details section of the admin? When I do this, I get an output for all my text box questions, but nothing for the select (dropdown).               $this->address_formats = apply_filters('woocommerce_localisation_address_formats',  array(             'default' => "{question}\n"          function get_address_fields( $country, $type = 'billing_' ) {     $locale     = $this->get_country_locale();          $fields = array(             'question' => array(         'label'       => __('Question?', 'woocommerce'),         'placeholder' => _x('', 'placeholder', 'woocommerce'),         'required'    => yes,         'clear'       => yes,         'type'        => 'select',         'option'     => array(             'yes' => __('yes', 'woocommerce' ),             'no' => __('no', 'woocommerce' )     )),          );      When I do this I do not get any data output in the Order details of Woocommerce               $options[] = array(         'question' => array(             'label'       => __('Question?', 'woocommerce'),             'placeholder' => _x('', 'placeholder', 'woocommerce'),             'required'    => yes,             'clear'       => yes,             'type'        => 'select',             'options' => $test_array         )));               $test_array = array(             'no' => __('yes', 'woocommerce' ),             'yes' => __('no', 'woocommerce' )      );


title: Show the content of Admin menu to a page

text: I have created a new page and want to show the content of a Admin Menu in that new page. How can I do it?


title: Why can't I see my attachment page information for an image?

text: I'm following a course where the tutor uploads an image to his media library. He adds attachment information. He then creates a new post and includes the image. When he clicks through, he gets the image with his attachment info below it. I however do not. I click through and I just get the image by itself. I'm sorry, I may be missing something obvious but I'm not sure what that is at this stage.


title: Is this a bad approach to add conditional comments to wp_head?

text: Why people say this is a bad approach to add conditional comments to wp_head? For example:               function add_ie_html5_shim () {         echo '<!--[if lt IE 9]>';         echo '<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>';         echo '<![endif]-->';     }          if ($GLOBALS['is_IE']) {         add_action('wp_head', 'add_ie_html5_shim');     }      especially using the `$GLOBALS[]` inside if condition and outside a function.. Is it a BAD approach.. If yes WHY???


title: How to dequeue a stylesheet by src, not handle?

text: I'm trying to develop a Wordpress plugin that will dequeue/deregister _Font Awesome_ stylesheets added to a theme by certain plugins that users may install, if the theme already make use of _Font Awesome_. In other words: if an administrator uses a theme that has **Font Awesome** font-awesome.css (or font-awesome.min.css) and he uses 2 plugins that make use of _Font Awesome_ too, the administrator will ended up with 3 font-awesome.css (or font-awesome.min.css) stylesheets loaded. Is there a way to check if the _Font Awesome_ stylesheet is already loaded by the theme and if so, automatically dequeue/deregister all plugins _Font Awesome_ stylesheets, before the theme enqueue it? The solution I have in mind is something like this (pseudo code):               add_action( 'wp_enqueue_scripts', 'no_more_fontawesome', 999 );     function no_more_fontawesome() {         if ( src_contain ('font-awesome.css') || src_contain('font-awesome.min.css') ) {             wp_dequeue_style( that has font-awesome.css or font-awesome.min.css in src);         }      A solution might be a regex check in src for the expressions _font- awesome.css_ and _font-awesome.min.css_ but how to achieve this? Any help will be greatly appreciated!


title: Custom Post Type: Event - Display Upcoming Events for Next 30 Days

text:
I need to display the upcoming events for next 30 Days and sort the same based on custom date field. Below is the code I am using right now but not got any success in hiding old Events and restricting events to 30 Days.               <?php          $todayDate = date('d F, Y');         $futureDate = strtotime ( '+30 days' , strtotime ( $todayDate ) ) ;         $futureDate = date ( 'd F, Y' , $futureDate );         $eventsOpt = array(                      'post_type' => 'ptype_events',             'posts_per_page' => -1,             'meta_key' => 'ptype_event_date',             'meta_compare' => '>=',             //'meta_value' => $todayDate,             'orderby' => 'meta_value',             'order' => 'ASC',         );         $events_query = new WP_Query($eventsOpt);     ?>
       <?php while ($events_query->have_posts()) : $events_query->the_post();                  $date = get_post_meta($post->ID, 'ptype_event_date', true);             ?>

           <?php the_title()?>
         Date: <?php echo $date ?>
       <?php endwhile; ?>       <?php wp_reset_query() ?>
      Note: Date saved in database is in this format date('d F, Y') and I cannot change it to timestamp while saving because creating meta-fields using a plugin. Please help me out. Regards


title: Using add_sub_menu to put into Appearance Section

text: I am working on a new plugin, and want to add my plugin menu to the Themes/Appearances section.               add_submenu_page('themes.php','Widget Area Manager','administrator','widget_area_manager','wm_area_manager_admin');      However the menu get's added to the setting's section of the dashboard. What am I doing wrong?


title: Access denied error when logged in as admin

text: What are the possible causes for getting the "You do not have sufficient permissions to access this page." message when logged in as admin? I've done a lot of searching and found a lot of possible solutions, but in my case they haven't worked. In my case I've taken a copy of a database off our staging site (close enough to having the same code) and placed it on dev, done the usual steps of changing values in the options table, gone to the lengths of disabling all plugins (through the database, even to the point of renaming the plugins folder). It was a multisite install at one stage (but this should have been cleaned up). I can log in, but get the access denied when I try and go to the dashboard page.


title: How to get rid of the home link in nav menu?

text: I am using the following code for my navigation structure. Currently it shows a home link in the navigation. Why does this show? and how would I get rid of it by changing this code.               <?php wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location'=> 'primary' ) ); ?>


title: How do I do this?: If custom post type exists, echo it, else do not

text:
I'm creating the search page for my wordpress site. The problem I'm having is that most of my articles have custom post types that display a featured image. The problem is that some do not. I am trying to figure out how I can tell my loop to include the custom post type if it exists but to ignore that section of code if it does not exist. Here's my code:
              <?php              if(function_exists('wp_paginate')) {                 wp_paginate();             }          ?>          <?php if (have_posts()) : ?>              <?php while (have_posts()) : the_post(); ?>                  <div <?php post_class() ?> id="archives">
<a href="<?php the_permalink() ?>"><?php the_title(); ?>
                      // HERE'S THE STUFF THAT IS OPTIONAL                          <a href="<?php the_permalink(); ?>"><img src="<?php bloginfo(url); ?><?php echo get_post_meta($post->ID, 'featured-image-large', true); ?>" title="<?php echo get_post_meta($post->ID, 'featured-image-title', true); ?>" />                      // END OPTIONAL STUFF                          <?php the_excerpt(); ?>                     <a href="<?php the_permalink(); ?>" class="button-blue">Continue Reading
              <?php endwhile; ?>              <?php              if(function_exists('wp_paginate')) {                 wp_paginate();             }          ?>          <?php else : ?>
No posts found.
          <?php endif; ?>
      You can see the test site search results here: http://testserver1.staceylanehosting.net/?s=jesus The first two results are pages that do not have images associated with them. The rest are posts. But there are posts that do not have images as well and I would like the if else statement to work for those too. EDIT: @andrewkthx: Your answer wasn't exactly correct but it did lead me to find the correct answer so thank you for posting. :) The correct method is:               <?php if ( get_post_meta($post->ID, 'featured-image-large', true) ) : ?>              <a href="<?php the_permalink(); ?>"><img src="<?php bloginfo(url); ?><?php echo get_post_meta($post->ID, 'featured-image-large', true); ?>" title="<?php echo get_post_meta($post->ID, 'featured-image-title', true); ?>" />          <?php endif; ?>


title: No My Sites link after installing Multisite

text: I have just setup a fresh Centos server onto which I have installed the latest version of Wordpress. I then enabled multisite and went through and changed my .htaccess and wp-config as shown. I then logged out and back in again but there is not any My Sites menu at the top on the dashboard. I have tried clearing my cache and on several different browser so I am pretty certain that it is a server issue. This is the relevant part from wp-config:               /* Multisite */     define('WP_ALLOW_MULTISITE', true);     define('MULTISITE', true);     define('SUBDOMAIN_INSTALL', false);     define('DOMAIN_CURRENT_SITE', 'test.site.com');     define('PATH_CURRENT_SITE', '/');     define('SITE_ID_CURRENT_SITE', 1);     define('BLOG_ID_CURRENT_SITE', 1);      And this is the .htaccess               RewriteEngine On     RewriteBase /     RewriteRule ^index\.php$ - [L]          # add a trailing slash to /wp-admin     RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]          RewriteCond %{REQUEST_FILENAME} -f [OR]     RewriteCond %{REQUEST_FILENAME} -d     RewriteRule ^ - [L]     RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]     RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]     RewriteRule . index.php [L]      Can anyone see any issues or suggest where I might look next?


title: Get posts that have custom post type value

text: I have a custom post type called Authors where you can choose an author for that post (authors don't have user account so I went down the custom post type route). ![author select](http://i.stack.imgur.com/YbZWN.png) I am building an "author profile" page (outside of the loop) and I want to get all posts that this author has been chosen against. I've written this function to attempt to get these posts when passing the post ID of the author:               function authorPosts($authorID)     {         $args = array(             'post_type'     => 'post',             'post_status'   => 'publish',             'meta_key'      => 'author',             'meta_value'    => $authorID         );              $getPosts = new WP_Query($args);         $posts = FALSE;              foreach($getPosts->posts as $post)         {             $posts[] = array(                 'ID'            => $post->ID,                 'image'         => $this->getFeaturedImageUrl($post->ID, 'medium'),                 'post_title'    => $post->post_title,                 'post_name'     => $post->post_name             );             }         return $posts;     }      This just seems to return all of my posts. When passing 13118 (author ID) This is the meta data for a test post showing it has "Alex Crooks" assigned to it (post ID 13118). Is it because it's being stored as json instead of a string? Is there a way to query a meta value when it's stored as json? ![post meta](http://i.stack.imgur.com/0Ci3v.png)


title: Is there a syntax highlighting plugin for HTML View?

text: > **Possible Duplicate:**   >  Syntax highlighting for post/page editor I've googled this already to no avail, all I'm finding are syntax highlighting plugins to post actual code to the front-end of your blog (ie.. a post called "Hey check out this code snippet") I'm talking about when you edit a POST or PAGE, is there some kind of editor that replaces just the plain textarea of HTML view. Also note: I'm not talking about Appearance > Editor... just inside the page or post html view. I REALLY like what Shopify.com has... its extremely nice, it would be nice to have that inside wordpress.


title: next_post_link and previous_post_link order not working properly

text:
Very strange problem, i have uploaded lots of photos and made posts for each of them so i have them in order 1 to 120. I have used `next_post_link` and `previous_post_link` in my loop eg.               <?php if ( have_posts() ) : while ( have_posts() ) : the_post();  ?>

<?php previous_post_link('%link','←'); ?>

<?php next_post_link('%link','→'); ?>
                          <?php the_content(); ?>

              <?php endwhile; endif; ?>      But when i go to post 01, which should have a link to 02 i get a link back to 44 then 39 then 70 then nothing! Very strange order, they are all in the same month and year so should just go back and forth fine. I'm very confused, anyone else had this problem


title: Wordpress: PHP code rendering in the wrong place

text:
I'm trying to insert a php code for a post-rating on wordpress. It used to work out of the echo normally and in-place. Now, using this code, instead of the rating showing up after "User Rating:" it renders completely out of the 'anime-info' div and show up above it. The code is " . the_ratings() . " The full code should be: but " . if(function_exists('the_ratings')) { the_ratings() } . " didn't work so I had to change it. Here's the full code. Basically, if the category ID assigned to the current post is 4, it shows this text and an image. If it's not, it renders only a image. Any suggestions? This is the plugin I'm using http://wordpress.org/extend/plugins/wp- postratings/ Thanks!                   <?php foreach((get_the_category()) as $category)                 { if($category->cat_ID = 4){ echo "

                         Anime Title: ".get_post_meta( $post->ID, 'anime_title', true )."
                         Creator: ".get_post_meta( $post->ID, 'anime_creator', true )."
                         Genres: ".the_tags()."
                         Studio: ".get_post_meta( $post->ID, 'anime_studio', true )."
                         First aired at: ".get_post_meta( $post->ID, 'anime_firstaired', true )."
                         # of Episodes: ".get_post_meta( $post->ID, 'anime_episodes', true )."
                         Official Website: ".get_post_meta( $post->ID, 'anime_website', true )."
                         Anime ii Rating: ".get_post_meta( $post->ID, 'anime_revrating', true )."

                         User Rating:" .  the_ratings() . "

                            img src='".get_bloginfo( 'template_directory' )."/timthumb.php?src=".get_post_meta( $post->ID, 'image_value', true )."&w=225&h=246&zc=1' />

";                      }else{ echo "
ID, 'image_value', true )."&w=529&h=253&zc=1' />
";                                         }                                     }                             ?>


title: How do I assign a custom post to all terms in a custom taxonomy?

text: I'm building a database of cities as a part of a "location" taxonomy. In order for the terms to render, as far as I've found, they need to have some type of content associated with them. My work-around is to create a "placeholder" post, assign it to the respective terms, then move it to the trash. So, first, if you have any suggestions for a _better_ way to get the terms to display _without_ yet having content associated with them, please let me know! Otherwise, what's the best way to bulk assign terms to a custom post?


title: Why isn't my multiple orderby working?

text: I have a custom category page with the following query:               $args = array(          'cat'  => $portfolioCategories,           'posts_per_page'     => $itemsPerPage,          'orderby'            => 'menu_order date',           'order'              => 'DESC',           'paged'              => $paged        );        query_posts( $args );      So `'orderby' => 'menu_order'` works just fine. `'orderby' => 'date'` works just fine. But `'orderby' => 'menu_order date'` does not work - I get some weird completely random order. What have I done wrong? PS: Yes, I have enabled page attributes (ie, menu order) for posts in my functions file   PPS: I get the same results whether I use `query_posts($args)` or `new WP_Query($args)` EDIT: The SQL generated looks like this:               SELECT SQL_CALC_FOUND_ROWS  wp_rk2ukj_posts.ID        FROM wp_rk2ukj_posts       INNER JOIN wp_rk2ukj_term_relationships ON (wp_rk2ukj_posts.ID = wp_rk2ukj_term_relationships.object_id)       WHERE 1=1          AND ( wp_rk2ukj_term_relationships.term_taxonomy_id IN (89,93,94,95,96,106) )         AND wp_rk2ukj_posts.post_type = 'post'         AND (wp_rk2ukj_posts.post_status = 'publish' OR wp_rk2ukj_posts.post_status = 'private')       GROUP BY wp_rk2ukj_posts.ID      ORDER BY wp_rk2ukj_posts.menu_order,wp_rk2ukj_posts.post_date DESC      LIMIT 0, 9


title: How to check if an email was sent from or originated from a specific plugin?

text: How to check if an email was sent from or originated from a specific plugin. E.g. I have an SMTP plugin which sends all mail via SMTP however I would like to determine in the SMTP plugin. If an email originated from plugin x then the SMTP plugin would assign different "from" and "reply-to" headers as oppose to if it originated from plugin y


title: Dealing with a library that depends on jQuery

text: I am about to use the pikachoose.com library with wordpress. However, this library references jQuery, and uses the short form (using $). In WordPress documentation, it states that the short form should not be used, and instead I should use the long form to use jQuery functinality and to prevent conflict. My problem is the library/object I am downloading is written in the short form. So how can I use it with WordPress. The documentation in WordPress states I should wrap it like this:               jQuery(document).ready(function($) {         // Inside of this function, $() will work as an alias for jQuery()         // and other libraries also using $ will not be accessible under this shortcut     });      or like this:               (function($) {         // Inside of this function, $() will work as an alias for jQuery()         // and other libraries also using $ will not be accessible under this shortcut     })(jQuery);      however, it is not clear on how to include the external file. Please explain with an example. Thanks.


title: How to retrieve text only from wp_content() not from wp_excerpt()?

text: I'm currently developing a website with WordPress 3.5 and I need to retrieve **Post Text (Only text, not include images)** at **Archive Page**. I can retrieve it with `wp_excerpt()` method without any problems. But the main problem for me is that I can't get the exact text layout. `wp_excerpt()` method returns text which ignores all extra spaces and line breaks. What should I do? I think I will get **Only Post Text with Exact Layout** if I can retrieve from `wp_content()` method. Thanks in advance for your help!


title: Advice and plugins against Malware

text: I´m starting with WordPress and would like to make sure my blog stays Malware free. I´ve seen that there are quite a few things to do to insure that. Personnally I´d like to keep it easy and still be protected. Is a plugin like Better WP Security good? but it can create some compatibility issues with some plugins Or I was thinking of using something like Sitelock that I´ve seen with some hosts. Or should I use both? What would be your advice? Thanks a lot for that.


title: Remove default subpages from Custom Post Menu

text: I am creating a Custom Post Type using `register_post_type`. After running the function a new menu item appears in the Admin Panel. Under this item there are menu items for `new_item` and `all_items`. Is there a way to get read of the these two options considering that I created a custom page to manage these posts.


title: How to make my plugin insert text into a custom div?

text:
I'm making my first plugin, and after following a couple of tutorials, have managed to make a custom admin page, that allows the editing of the custom text I'd like to have inserted homepage. It currently posts whatever custom text has been saved in the settings page, but to the end of every _post_ not on the homepage ( which I understand to be `is_home()` or `is_front_page()`). Now I want it to insert the text that is saved in the plugins settings page to be inserted into a `<div>` tag that's already in my websites html, so it will basically be underneath the navigation bar, inside the header. The custom div id is `<div id="inner-category">` I just don't know and can't find anywhere, what the syntax would be to get the text to be inserted inside a `<div>` already within my website. Any help is massively appreciated! Here's the code snippet that inserts the text into every post:               add_filter('the_content', 'insert_content_here');          function insert_content_here ($content) {         if ( is_single() ) {             $content .= '

This is bloody annoying!
</div' . "";         }     }      The above code is what I have for my plugin and the code below is where the `<div id="inner-category">` is housed: `<div id="category-name"> <div id="category-inner"> <p>MY CUSTOM CONTENT HERE</p>`


title: Can I set my WP_Query to be a Main Query?

text: When I create a `WP_Query` it's automatically considered a "secondary query", but what if I replace my main query with a WP_Query? Can I set my WP_Query to be considered a "Main Query"? The reason I say this is because I need to use `pre_get_posts` to do some filtering. My current logic looks like this:               if(isset($query->query_vars['post_type']) && $query->query_vars['post_type'] == 'my_post_type')      The problem with the above logic is that I have 2 queries in the same template of the same post type but only one of them is my core query, the query I want to label as "Main Query" so I can use a conditional such as `$query->is_main_query()` to differentiate the two and filter accordingly.


title: Best way to style first post differently?

text:
I am building a custom (child) theme and I want to style the first post of my loop in a different way than the others (bigger image, different position of some stuff). Which is the best way of doing it? My "problem" is that my theme has support for different post types and the style would vary depending on the type of content, so I want to avoid repeating code as much as possible (i.e. using a function). As I am a bit more used to OOP, my ideal scenario would be passing a variable to the view and check it in the loop of each content-type (that way I can re- use most of the code from the TwentyEleven templates). From what I know, that is not possible (please correct me if I am wrong). For now, what I do is this:               function electric_index_loop($readMore = 0) {          $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;     $args = array(         //Excluimos los "miniposts" (citas, estados, enlaces...) del listado         'tax_query' => array(             array(                 'taxonomy' => 'post_format',                 'field' => 'slug',                 'terms' => array('post-format-aside', 'post-format-link',                     'post-format-status', 'post-format-quote'),                 'operator' => 'NOT IN'             )         ),         'posts_per_page' => 5,         'paged' => $paged     );          // The Query     query_posts($args);          // The Loop     if (have_posts()) {         $post_count = 0;         global $more;         $more = $readMore; // 0 fuerza que se muestre sólo el "excerpt", 1 fuerza que se muestre todo el contenido         twentyeleven_content_nav('nav-above');         while (have_posts()) {             the_post();             if ($post_count == 0) {                 get_template_part('highlight', get_post_format());             } else {                 get_template_part('content', get_post_format());             }             $post_count++;         }     } else {         ?>

<?php _e('Nothing Found', 'twentyeleven'); ?>

<?php _e('Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.', 'twentyeleven'); ?>
                 <?php get_search_form(); ?>

         <?php     }     wp_reset_query();}      As you see, I check the counter in the loop that I create in the function and ,if the current post is the first, I load a different template ("highlight"). I'd have to create different templates for the different types of content (which, in some cases sucks, because I can get all I need in some cases with just a CSS class). Well, is there a better way of doing these? Perhaps a hook or something? Thanks in advance!


title: How to transfer changes from test environment to live site?

text: As with most other software it's safer to try new plugins, configuration options or template changes in a separate testing environment, see e.g. WordPress local development environment. Most questions and answers I've seen about this is the simpler case: doing the _initial_ development locally and then deploy everything to the live site. That is easy. However, what if I need to test some change in the middle of site's life cycle? I guess the steps should be:   1. **Replicate** a current state of the site to the testing environment   2. **Test** the changes in the testing environment   3. When done, **merge the changes back** to live I know how to do 1+2 but am not sure about 3. This steps breaks down to 2 parts:   1. Files   2. Database Again, 1 is easy so for example template updates are easily migrated from test to live. But 2 is tricky. Copying test db to live is not always possible (there might have been content changes in the meantime etc.), comparing schemas is also not a trivial task, theoretically there could be a plugin that would help with test <-> live synchronization but I'm not sure if it exists. How do you people deal with this? Any tips & tricks or procedures?


title: How to create a archive template for custom post type

text:
I've created a custom post type using _Custom Post Type UI_ and _Advanced Custom Fields_ plugins. The name of my custom post type is `article`. I want to have a page which lists all the articles in a table format with the links to respective article. To achieve it, I've created a page and applying a custom template to it:               <?php             $args = array('post_type' => 'article');        $article_posts = new WP_Query($args);             if($article_posts->have_posts()) :      ?>
             <?php while($article_posts->have_posts()) : $article_posts->the_post(); ?>
                  <?php the_title() // <-- Here I want to have a link ?>	                  <?php the_field('published_in'); ?>	                  <?php the_field('article_author'); ?>	                  <?php the_field('published_date'); ?>
             <?php endwhile; ?>
          <?php             else:      ?>                Oops, there are no posts.          <?php        endif;     ?>      **Question 1:** I don't know how to get link to each article : I mean like `the_title()` which gives me title of the article is there `the_link()` which gives me link of that page? **Question 2:** Now assuming I got the link, when user clicks that link he'll be taken to that article page with my custom `single-article.php` but how to display content of that requested article?


title: add data-attribute to all images inside the_content()

text: I wonder if it's possible to add a filter to all images inside `the_content()` to create the following image pattern for all images …               <img class="digest" src="smallest-file.jpg" data-fullsrc="largest-file.jpg" alt="something"/>      So I'd like to add a `class="digest"` to the img tag. Additionally the `src` attribute of the image should always link to the smallest-file wordpress creates and a `data-fullsrc` that links to the largest file of the image. Any idea or approach on how to do this? I'd really appreciate your help with this as I'm completely helpless right now.


title: Using several add_action with parameters inside a class

text: I'm creating a theme framework and using a class to initiate all basic function of the theme (adding theme support, menus, etc). I've got stuck when I tried to enqueue the scripts and styles though: I'm using `add_action( 'init', array(&$this, 'EnqueueScrits'), 10, 1);` and `do_action( 'init', $enqueued );` to call method with the $enqueued param. That's working fine, however when I try to use the same technique in order to add `wp_enqueue_style` the $param are getting mixed up (the $param for scripts are also used for styles). My solution then was to create a chain reaction to the first add_action like so: but then nothing happens and the action is not called at all (it seems like that anyway). Does anyone knows a better solution for this or what am I missing? EDIT: Here's the full code. My class:               class Nomade     {              public function __construct($menus, $features, $enqueued, $styled)         {                  // Define base constants             define('THEME_FRAMEWORK', 'nomade');             define('NOMADE_VERSION', '1.0');                  // Define directories             define('NOMADE_DIR', get_template_directory());             define('NOMADE_LIB_DIR', get_template_directory() . '/library');                  $this->AddThemeSupport($features);             $this->MenuBuilder($menus);                  // Add support for WordPress features             add_action('after_setup_theme', array(__CLASS__, 'MenuBuilder'));             add_action( 'after_setup_theme', array(__CLASS__, 'AddThemeSupport'));             add_action( 'init', array(&$this, 'EnqueueScrits'), 10, 1);                  do_action( 'init', $enqueued );              }              public function AddThemeSupport($features)         {                  if(is_array($features))             {                      foreach ($features as $feature) {                          add_theme_support($feature);                      }                  }              }              public function MenuBuilder($menus)         {                  if (is_array($menus)) {                      foreach ($menus as $location => $name) {                          register_nav_menus(array(                              $location => $name                          ));                      }                  }              }              public function EnqueueScrits($enqueued)         {                  if (is_array($enqueued)) {                      foreach ($enqueued as $value) {                          wp_enqueue_script( $value["name"], $value["location"], array("jquery"), $value["version"], true );                      }                  }              }          }      And here how I instantiate the object (in a separate file):               <?php          // Depedencies: menu registrer and builder     include('application.class.php');          // Set menus     $menus = array( 'main_menu' => 'Main Menu', 'footer_menu' => 'Footer Menu', 'side_menu' => 'Sidebar Menu' );          // Set theme features     $features = array( 'menus', 'custom-background', 'custom-header', 'post-thumbnail' );          // Register scripts array     $register = array( 'scripts' => 'NOMADE_DIR' . '/js/scripts.js' );          // Enqueue scripts array     $enqueued = array(           array("name" => "general", "location" => get_template_directory_uri() . '/js/general.js', "version" => 1)     );          $styled = array(         array("name" => "main", "location" => "lac1", "version" => 2, "media" => "all")     );          // Instantiate Nomade (main application)     $Nomade = new Nomade($menus, $features, $enqueued, $styled);      Thanks for the help in advance


title: How To Display Value from Theme Options Field in Front End Template?

text: I put this code into my functions.php https://gist.github.com/corvannoorloos/4703066 and it work nice. Now I want to display value from **Sample Select Options** filed in some front-end templates. How can I do that? I tried get_option               <?php echo get_option( 'sample_select_options', true); ?>      but it return number 1 no matter what is selected.


title: Load Next Posts With AJAX not working with custom post type

text:
I am using this plugin to load in my next posts with AJAX. I have implemented it into my site and it is showing the load more posts button however once you click on the 'load more posts' button it then says there is nothing to load. Below is my code:                   // Add code to index pages.     if( !is_singular() ) {           // Queue JS and CSS         wp_enqueue_script(             'pbd-alp-load-posts',             plugin_dir_url( __FILE__ ) . 'js/load-posts.js',             array('jquery'),             '1.0',             true         );              wp_enqueue_style(             'pbd-alp-style',             plugin_dir_url( __FILE__ ) . 'css/style.css',             false,             '1.0',             'all'         );                        // What page are we on? And what is the pages limit?         $max = $wp_query->max_num_pages;         $paged = ( get_query_var('paged') > 1 ) ? get_query_var('paged') : 1;              // Add some parameters for the JS.         wp_localize_script(             'pbd-alp-load-posts',             'pbd_alp',             array(                 'startPage' => $paged,                 'maxPages' => $max,                 'nextLink' => next_posts($max, false)             )         );     }      I am trying to do this on a custom post and I think the problem may be where it says is_singular. I tried updating this to the following:               if( !is_post_type_archive($work) )      But when i change it to this it not longer detects the plugin and goes back to the standard pagination. Here is the jQuery as well:               jQuery(document).ready(function($) {          // The number of the next page to load (/page/x/).     var pageNum = parseInt(pbd_alp.startPage) + 1;          // The maximum number of pages the current query can return.     var max = parseInt(pbd_alp.maxPages);          // The link of the next page of posts.     var nextLink = pbd_alp.nextLink;          /**      * Replace the traditional navigation with our own,      * but only if there is at least one page of new posts to load.      */     if(pageNum <= max) {         // Insert the "More Posts" link.         $('#postContent')             .append('

')             .append('
Load More Posts
');              // Remove the traditional navigation.         $('.navigation').remove();     }               /**      * Load new posts when the link is clicked.      */     $('#pbd-alp-load-posts a').click(function() {              // Are there more posts to load?         if(pageNum <= max) {                  // Show that we're working.             $(this).text('Loading posts...');                  $('.pbd-alp-placeholder-'+ pageNum).load(nextLink + ' .post',                 function() {                     // Update page number and nextLink.                     pageNum++;                     nextLink = nextLink.replace(/\/page\/[0-9]?/, '/page/'+ pageNum);                          // Add a new placeholder, for when user clicks again.                     $('#pbd-alp-load-posts')                         .before('

')                          // Update the button message.                     if(pageNum <= max) {                         $('#pbd-alp-load-posts a').text('Load More Posts');                     } else {                         $('#pbd-alp-load-posts a').text('No more posts to load.');                     }                 }             );         } else {             $('#pbd-alp-load-posts a').append('.');         }                 return false;     });     });      * * * Update: This is what I get after a var dump:               array(61) { ["post_type"]=> string(4) "work" ["error"]=> string(0) "" ["m"]=> string(0) "" ["p"]=> int(0) ["post_parent"]=> string(0) "" ["subpost"]=> string(0) "" ["subpost_id"]=> string(0) "" ["attachment"]=> string(0) "" ["attachment_id"]=> int(0) ["name"]=> string(0) "" ["static"]=> string(0) "" ["pagename"]=> string(0) "" ["page_id"]=> int(0) ["second"]=> string(0) "" ["minute"]=> string(0) "" ["hour"]=> string(0) "" ["day"]=> int(0) ["monthnum"]=> int(0) ["year"]=> int(0) ["w"]=> int(0) ["category_name"]=> string(0) "" ["tag"]=> string(0) "" ["cat"]=> string(0) "" ["tag_id"]=> string(0) "" ["author"]=> string(0) "" ["author_name"]=> string(0) "" ["feed"]=> string(0) "" ["tb"]=> string(0) "" ["paged"]=> int(0) ["comments_popup"]=> string(0) "" ["meta_key"]=> string(0) "" ["meta_value"]=> string(0) "" ["preview"]=> string(0) "" ["s"]=> string(0) "" ["sentence"]=> string(0) "" ["fields"]=> string(0) "" ["menu_order"]=> string(0) "" ["category__in"]=> array(0) { } ["category__not_in"]=> array(0) { } ["category__and"]=> array(0) { } ["post__in"]=> array(0) { } ["post__not_in"]=> array(0) { } ["tag__in"]=> array(0) { } ["tag__not_in"]=> array(0) { } ["tag__and"]=> array(0) { } ["tag_slug__in"]=> array(0) { } ["tag_slug__and"]=> array(0) { } ["post_parent__in"]=> array(0) { } ["post_parent__not_in"]=> array(0) { } ["author__in"]=> array(0) { } ["author__not_in"]=> array(0) { } ["ignore_sticky_posts"]=> bool(false) ["suppress_filters"]=> bool(false) ["cache_results"]=> bool(true) ["update_post_term_cache"]=> bool(true) ["update_post_meta_cache"]=> bool(true) ["posts_per_page"]=> int(2) ["nopaging"]=> bool(false) ["comments_per_page"]=> string(2) "50" ["no_found_rows"]=> bool(false) ["order"]=> string(4) "DESC" }       Var dump immediately after wp_query               array(61) { ["post_type"]=> string(4) "work" ["error"]=> string(0) "" ["m"]=> string(0) "" ["p"]=> int(0) ["post_parent"]=> string(0) "" ["subpost"]=> string(0) "" ["subpost_id"]=> string(0) "" ["attachment"]=> string(0) "" ["attachment_id"]=> int(0) ["name"]=> string(0) "" ["static"]=> string(0) "" ["pagename"]=> string(0) "" ["page_id"]=> int(0) ["second"]=> string(0) "" ["minute"]=> string(0) "" ["hour"]=> string(0) "" ["day"]=> int(0) ["monthnum"]=> int(0) ["year"]=> int(0) ["w"]=> int(0) ["category_name"]=> string(0) "" ["tag"]=> string(0) "" ["cat"]=> string(0) "" ["tag_id"]=> string(0) "" ["author"]=> string(0) "" ["author_name"]=> string(0) "" ["feed"]=> string(0) "" ["tb"]=> string(0) "" ["paged"]=> int(0) ["comments_popup"]=> string(0) "" ["meta_key"]=> string(0) "" ["meta_value"]=> string(0) "" ["preview"]=> string(0) "" ["s"]=> string(0) "" ["sentence"]=> string(0) "" ["fields"]=> string(0) "" ["menu_order"]=> string(0) "" ["category__in"]=> array(0) { } ["category__not_in"]=> array(0) { } ["category__and"]=> array(0) { } ["post__in"]=> array(0) { } ["post__not_in"]=> array(0) { } ["tag__in"]=> array(0) { } ["tag__not_in"]=> array(0) { } ["tag__and"]=> array(0) { } ["tag_slug__in"]=> array(0) { } ["tag_slug__and"]=> array(0) { } ["post_parent__in"]=> array(0) { } ["post_parent__not_in"]=> array(0) { } ["author__in"]=> array(0) { } ["author__not_in"]=> array(0) { } ["ignore_sticky_posts"]=> bool(false) ["suppress_filters"]=> bool(false) ["cache_results"]=> bool(true) ["update_post_term_cache"]=> bool(true) ["update_post_meta_cache"]=> bool(true) ["posts_per_page"]=> int(2) ["nopaging"]=> bool(false) ["comments_per_page"]=> string(2) "50" ["no_found_rows"]=> bool(false) ["order"]=> string(4) "DESC" }