title: is_archive() returns false on the archives page

text: I've followed the official documentation to create my archives page: http://codex.wordpress.org/Creating_an_Archive_Index It works fine exept that "is_archive() returns false when I'm viewing this page. Any idea ?


title: PhotoPress Gallery plugin cannot retrieve my photos after overriding the gallery output

text: I am using PhotoPress Gallery plugin and PhotoPress taxonomy by padams to create a gallery using terms and keywords on my Stock Photo site. It's working well until I decide to override the Gallery output of wordpress for additional functions and stylings. Now, it doesn't retrieve the photos and I need to actually attach them on the page. But this is kind of troublesome because I would keep on adding photos on this pages like a normal stock photography site would do that is why I use the PhotoPress Gallery plugin together with the PhotoPress Taxonomy for easier uploads. The output code that I use comes from this site I think it has something to do with the extract code:               extract(shortcode_atts(array(         'orderby' => 'menu_order ASC, ID ASC',         'include' => '',         'id' => $post->ID,         'itemtag' => 'dl',         'icontag' => 'dt',         'captiontag' => 'dd',         'columns' => 3,         'size' => 'medium',         'link' => 'file'     ), $atts));      and the query:               $args = array(         'post_type' => 'attachment',         'post_status' => 'inherit',         'post_mime_type' => 'image',         'orderby' => $orderby     );      What could I change in this query to make it the photos appear? Here's a sample shortcode that works before overriding the gallery `[gallery taxonomy="photos_collection" term="stock-photo" columns="6" size="thumbnail" itemtag="li" icontag="th"]`


title: How can i add validation to this login form with out it redirecting to the wp-login.php page

text: Im using the code as posted on the website below, to create a hard coded login form. http://www.wprecipes.com/add-a-login-form-on-your-wordpress-theme What would be the best way of incorperating some validation with this or using the default wordpress error messages? the whole point in hard coding the form is that the user isnt taken away from the content to the default wp-login.php page throughout the login process. Regards, Tom Kiddle


title: how to put a custom field value in variable

text: function zh_get_invoice_round_off_number()          {             global $post;             return get_post_meta($post->ID, 'invoice_round_off_number', true);         }              function zh_invoice_round_off_number()          {             echo zh_get_invoice_round_off_number();         }


title: Where to save common libraries?

text: I have a multiple-site WordPress install. I have decided to centralize as many of my libraries as possible into one spot, for obvious organizational reasons, and in order to reduce bloating. Many of those libraries can be used both in plugins and themes. My first idea is to create a ' ** _myLibs_** ' (or other name) directory inside **_wp-content_** where I would save all those libraries. Anybody has a better idea? Would there be any reasons NOT to do this?


title: How can I show the Jetpack Subscriptions form in a page?

text: In the Jetpack plugin, the subscriptions module can be included in your blog by following these instructions: > To use the Subscriptions widget, go to Appearance → Widgets. Drag the widget > labeled “Blog Subscriptions (Jetpack)” into one of your sidebars and > configure away. I am interested in including the subscriptions form on a Page within my site, in the main section of the page. Is there some sort of shortcode or other way that I can easily include the subscriptions form within my page content? Or to do this, would I need to define a new sidebar, put the subscriptions widget in the sidebar, and them make a custom template that includes this new sidebar within this page (quite a cumbersome exercise)?


title: How to display all the categories a post is in

text: How do I display all of the categories that a post is in, in sentence format. eg. cars, boats, aircraft, bicycles.


title: Wordpress comment pagination : newest comments on first page

text: I use Wordpress commment pagination as follows:   * paginated comments   * comments displayed with the newest comments at the top of each page   * 50 comments on each page   * first page displayed by default The problem is that I am trying to achieve YouTube like comments such as - newest comments on first page, first page being displayed by default, then older comments in order on page 2, 3 etc The problem is that Wordpress comments are structured in such way,that I cannot achieve this by changing the "Discussion" settings. I have tried different options, such as extending the Walker's paged_walk() function, or to reverse the comments, or even pulling the comments with a MySQL query and using paginate_link() - but can't seem to be able to achieve this type of comments hierarchy. Any advice is appreciated, thank you! **Solution:** I have found a solution as follows:   * into functions.php I have inserted a custom function that sorts the comments by date (newest comments first) by using an associative array sorting as can be seen here   * into the Wordpress settings I changed the following at Settings -> Discussion _Comments should be displayed with the comments at the top of each page_ So now my comments are being displayed newest first (at top) with page numbering starting from 1. The only issue that I see, is that when posting a comment the user is redirected for some reason to the last page of comments.


title: Javascript Helpers

text: Are there any WordPress specific Javascript functions that could be used as helpers when writing custom code? I am thinking specifically of one that would pull back the base URL of your install, but any helper functions built into WordPress would be nice to know.


title: Give Friend Post Management

text: On my site you can create a post for someone who is your friend in site. How do I give permission to my friend to also manage that post as well as me?


title: insert an html tag using php plugin

text: I wanted to create a new `<div>` on top of the `<div id="wpwrap">` in **adminheader.php** and a closing tag below the `</body>` on **adminfooter.php** should i just go create a new div manually? or use a plugin to insert those html tags. thanks.


title: Limitless amount of posts in custom archive page

text: I want to get rid of pagination completely on my custom archive, I want everything on 1 page. How can I do this? Currently I'm getting my posts with:               <?php query_posts($query_string . '&orderby=title&order=ASC'); ?>     <?php if (have_posts()) : while (have_posts()) : the_post(); ?>      The codex pages on query_posts and pagination don't seem much help, they're just telling me how to limit it but not saying how I can get rid of the limit. I've used the bones starter theme so I don't know if that affects the default behaviour.


title: How to add content at the end of posts?

text: I am trying to add custom fields at the end of posts. I succeeded showing the custom content using the below mentioned code. But the main post's content was replaced. :               function custom_content_filter_the_content( ) {        the_field("field1");     }     add_filter( 'the_content', 'custom_content_filter_the_content' );      So I want to try this as in below mentioned example:               function custom_content_filter_the_content( $content ) {         $custom_content = 'some_content_appears_here';         $custom_content .= $content;         return $custom_content;     }     add_filter( 'the_content', 'custom_content_filter_the_content' );      Want to replace `'some_content_appears_here'` with `<span class="custom_fds"><?php if( function_exists('the_field') ) the_field('field1'); ?></span>`. Could any tell me how to use the `<?php the_field() ?>` with in functions.php to add custom fields(created with Advanced custom fields) at the end of the post content(that is easy when we use in templates but not in funcitons.php) ? **Update** : @G.M 's code helps me to achieve what I want. Here is the final code:               function custom_content_filter_the_content( $content ) {         if ( function_exists('get_field') ) {           $content .= '' . get_field('field1') . '';           $content .= '' . get_field('field2') . '';                   }         return $content;     }     add_filter( 'the_content', 'custom_content_filter_the_content' );      Thanks to @G.M. I have a few questions related to the custom content.   * I am displaying multiple fields in the single function. Is that ok?   * Instead of the end or beginning of the post, is there a way to choose a position for custom content any place with in `the_content` ? For example, if I use any plugins for social sharing, they display the content at the same place, I want to change positions of these two types of custom content.


title: Inconsistent title for posts

text: I remember, I had edited some part of my theme for optimizing the title values. Currently in google I see this. Whereas when I open a post, the site name is not appended to the post title. I looked at the `header.php` of my theme and found the following line:               <title><?php seotitles(); ?></title>      I am using "All in one SEO" plugin and have set the title and description of each post manually and when I do so, I don't append the site name in the post name. How can I bring what I see in google and what the user sees in sync with each other?


title: Display the current post author and his url in the post header

text: I'm making some changes in my theme. I want that when they visit a Post the header should contain the post author and his URL. right now I'm using this:               echo ''.get_userdata($posts[0]->post_author)->data->display_name.';      the auhtor's display name is working correctly, but the link is going like               www.mysite.com/?auhtor=0      instead of this (for example)               www.mysite.com/?auhtor=36      so this is the code in the header               Display name      instead of this:               Display name      by the way: I'm doing this outside a loop.


title: wp_get_object_terms(): count relative to passed IDs?

text: I know when you `wp_get_object_terms()` you get a "count" member variable for each term object returned, but that "count" is what's in the `$wpdb->term_taxonomy` table in the database, it's not relative to the IDs you pass in as the first parameter. How do I get that number, though? Example, something like:               $query = new WP_Query(array('post_type' => 'foo', 'numberposts' => 20));     $ids = wp_list_pluck($query->posts, 'ID');     $terms = wp_get_object_terms($ids, 'multi_post_type_tax');      So I want the count returned to be relevant to the query, meaning the count I get is only for the passed in post IDs. Each term object returned from the tax "multi_post_type_tax" may have a count of 400 because it applies to other post types that aren't in my query, but since I passed in specific IDs, I want that count to apply to that query, meaning a count > 20 wouldn't make any sense at all (and most likely for a particular term, it'd be less than 20, I can't see every post in a post type having the same term usually). It seems like that would work but the returned value from `wp_get_object_terms` has unique objects.


title: Defined function gives undefined function error.. is a custom function

text: OK so I'm making a theme here at work and I'm sectioning off all functions that aren't add_action or the like. I'm using them through-out for different things. They are stored in a file called 'theme_functions.php' So far I have like 7 functions in there, they're all running perfectly fine. I added another and when I try to use in anywhere, it gives me `Fatal error: Call to undefined function myFunction() in /Users/mycomputer/PHP/MY_SITE/wp-content/themes/MY_THEME/page-home.php on line 15` I asked PHP if the filed existed and it tells me YES `echo file_exists(plugin_dir_path(__FILE__)."_include/inc/theme_functions.php") ? "YES" : "NO";` I am including like so: `require_once plugin_dir_path(__FILE__)."_include/inc/theme_functions.php";` I know it's not scope because other functions work. My code is clean and I made sure my syntax was on point... So I'm resorting to asking here because I have absolutely NO clue what is going on. CODE:               function myFunction($termName, $postsPerPage=10){       $category = get_term_by( 'name', $termName, 'category' )->term_id;       $posts = array();            $post_args = array(         'posts_per_page' => $postsPerPage,         'category' => $category,         'orderby' => 'post_date',         'order' => 'DESC' );       $p = get_posts($post_args);            foreach ($p as $i => $post) {         $img = get_primary_image($post->ID, '300'); // this is another non-wp function within the same file that WORKS         $title = $post->post_title;         $link = get_permalink($post->ID);              $excerpt = substr($post->post_excerpt, 0, 90)."...";         $x = array(           'img' => $img,           'title' => $title,           'excerpt' => $excerpt,           'link' => $link         );         array_push($posts, $x);       }       return array_chunk($posts, 2);     }      If anyone can point me in the right direction, I will love you forever and ever (restrictions may apply).


title: Change link to other post to shortlink in the editor

text: Curently if we use the insert link dialog to insert a link to another post, WordPress always use the permalink of that post. The problem is when we change permalink structure, that link will be broken. I'd like to ask if there is a way to change the link from permalink to shortlink like `?p=123` to make it work in any circumstance. Thanks.


title: How to modify/ customise NextGen Gallery's templates?

text: I would like to customise the "Image browser" template in particular. I'm trying to make clicking on an image redirects to the next image in a gallery, just like how Facebook image browser works.   (This is not a cosmetic change with CSS - CSS change is not what I mean by customising the tempaltes) I can always edit `/wp-content/plugins/nextgen-gallery/view/imagebrowser.php` but it's a hack and it's not upgradable when next version of NextGen Gallery is out. Is there anyway I can overwrite the template imagebrowser.php in my theme?


title: Prevent plugin from deleting important directories

text: I want to allow users to upload custom files to specific plugin directory. The problem is, obviously, that WP removes everything upon plugin version update. I think that the `upgrader_pre_install` and `upgrader_post_install` hooks may be useful, but unfortunately so far I wasn't able to find any info to help me. In your opinion, can these hooks be used to retain a directory and if so, how? Should I simply copy the directory elsewhere, like the uploads folder, and copy it back with `upgrader_post_install`? What would be the best practice? Thanks


title: Why have <?php and ?> on every line

text: I've seen this convention pretty much everywhere, and, at times, it comes close to driving me nuts:               <?php //The loop ?>     <?php while ( have_posts() ) : the_post(); ?>         <?php the_content(); ?>     <?php endwhile; // end of the loop. ?>      Where the `<?php` and closing `?>` are on every single line, even if there is no intervening HTML code. **My question is: Why?** Why include all these extra tags? To me, it seems this convention adds a significant amount of clutter to code, is annoying to follow in the first place, and adds that many more places to accidentally leave out an opening or closing tag. **NOTE** This is code pulled from the Twenty-Twelve theme, the example given by WordPress.


title: Move posts to top of WP_Query if in certain Taxonomy?

text: I'm trying to figure out the best way to promote certain (custom) posts to the top of my Wordpress loop. I can't use sticky posts because they are all in a custom post type.. I was thinking of using a taxonomy to do this, however I'm not sure if it will work, I am thinking I may need 2 loops?


title: Custom Query based on custom field of a single post

text:
I have posts which have a custom field date in the format yyyy-mm-dd. What Im trying to do is list all the posts for a specific year on the side of a single page based on the year in the custom field of this post and separated into months. So for example if the post has a custom field date of 1990 then I want to list all posts from 1990 on the side of the page and sorted into months. I have to use this custom field date and cannot use the Wordpress internal date function. Below I extracted just the year from the custom field date for the query and it returns all the links to the posts from the year the single post custom field is dated. This query appears on the side of the single post page template outside of the single post loop. Im trying to figure out how I can now sort these posts into months? So January followed by all the post links for this month, February and so on...               <?php      $histyear = substr (get_post_meta($post->ID, "historic-date", true),0,4);      $querystr = "     SELECT $wpdb->posts.*      FROM $wpdb->posts, $wpdb->postmeta     WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id      AND $wpdb->postmeta.meta_key = 'historic-date'      AND $wpdb->postmeta.meta_value = $histyear      AND $wpdb->posts.post_status = 'publish'      AND $wpdb->posts.post_type = 'post'     ORDER BY $wpdb->postmeta.meta_key = 'historic-date' DESC      ";           $pageposts = $wpdb->get_results($querystr, OBJECT);           ?>           <?php if ($pageposts): ?>      <?php global $post; ?>      <?php foreach ($pageposts as $post): ?>      <?php setup_postdata($post); ?>           <div class="post" id="post-<?php the_ID(); ?>">
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">      <?php the_title(); ?>

      <?php endforeach; ?>      <?php else : ?>


title: Stop `update_post_meta` from working each time page refreshes?

text: So my code I have here including `update_post_meta` makes it work when clicking a button I have although what I fail to find out is how I can prevent `update_post_meta` from working on each page refresh/visit because I have this button on a certain page. This is the code:                   <form action="" method="post">             <input type="submit" value="Test" id="submit">             <?php             $post = array(                 'post_title'   => $column1,                 'post_status'  => 'draft',                 'post_type'    => 'bedrijf'             );                  $thisid = wp_insert_post ( $post, true);             if(!isset($_POST['submit'])){                 if ( is_wp_error($thisid) ) {                     return get_error_codes();                 }             }else{                 wp_insert_post($thisid);                 update_post_meta( $thisid, 'field_1223ewedwd3123', $column2);                  }             ?>               </form>


title: SQL query to get posts from multiple categories but not in a category

text: I need to get the last posts' ID and the post_tile within categories 1 and 2, and exclude those within category 3. It must be SQL, because if I use WP_Query it retrieves too much info and I only need the ID and post_title. The following query works fine getting posts from the 2 categories, but if I try excluding the third one, it doesn't work:               select distinct p.ID, p.post_title                 from wp_posts p,                  wp_terms t, wp_term_taxonomy tt, wp_term_relationships tr,                 wp_terms t2, wp_term_taxonomy tt2, wp_term_relationships tr2                      where p.id = tr.object_id                 and t.term_id = tt.term_id                 and tr.term_taxonomy_id = tt.term_taxonomy_id                      and p.id = tr2.object_id                 and t2.term_id = tt2.term_id                 and tr2.term_taxonomy_id = tt2.term_taxonomy_id                      and (tt.taxonomy = 'category' and tt.term_id = t.term_id and t.term_id = 15)                 and (tt2.taxonomy = 'category' and tt2.term_id = t2.term_id and t2.term_id = 5)                 ORDER BY p.ID DESC                 LIMIT 0, 60      Any help? Thanks in advance :)


title: Pretty URLs and custom post types

text: I've read the posts on WP SA on rewrites and custom post types, but I can't figure out why my search for 2 different post types isn't working. I'd like my URLS to become `example.com/search/events/searchtem` and `example.com/search/artists/searchterm`. I have a CPT called 'events' and one called 'artists'. My custom permalink structure is set to `/%postname%/`. My search forms:               <form class="search-form" action="<?php echo home_url('/events/'); ?>" method="get">     <input id="s" name="s" type="text" class="span4" />     <input class="search-button" type="submit" value="Zoek" tabindex="-1" />     </form>          <form class="search-form" action="<?php echo home_url('/artists/'); ?>" method="get">     <input id="s" name="s" type="text" class="span4" />     <input class="search-button" type="submit" value="Zoek" tabindex="-1" />     </form>      If I search, the URLs become `example.com/events/?s=searchterm` and `example.com/artists/?s=searchterm` but the return a 404. This is weird, because putting `?s=` behind any URL turns it into a query right? These are the results with the nice-search functions (see below) disabled or enabled (no difference). If I change `<?php echo home_url('/events/'); ?>` to `<?php echo home_url('/'); ?>` and add `<input type="hidden" name="post_type" value="events" />` with nice-search (see below) disabled everything works as expected (URL becomes `example.com/?post_type=events&s=searchterm`). With nice-search enabled, the results become example.com/search/searchterm (so it does rewrite) and it does take me to my search results page but it searches everything instead of just one post type. The functions from nice-search (I'm using the roots theme) which consists of two parts:               function roots_nice_search_redirect() {       global $wp_rewrite;       if (!isset($wp_rewrite) || !is_object($wp_rewrite) || !$wp_rewrite->using_permalinks()) {         return;       }            $search_base = $wp_rewrite->search_base;       if (is_search() && !is_admin() && strpos($_SERVER['REQUEST_URI'], "/{$search_base}/") === false) {         wp_redirect(home_url("/{$search_base}/" . urlencode(get_query_var('s'))));         exit();       }     }      if (current_theme_supports('nice-search')) {       add_action('template_redirect', 'roots_nice_search_redirect');     }      and               function roots_request_filter($query_vars) {       if (isset($_GET['s']) && empty($_GET['s'])) {         $query_vars['s'] = ' ';       }            return $query_vars;     }      add_filter('request', 'roots_request_filter');      After reading the posts, I think I need to alter my rewrite function but I don't really know how to... Also, I'd like to use `<?php echo home_url('/events/'); ?>` instead of `<input type="hidden" name="post_type" value="events" />` if possible and I don't use pagination.


title: how to move <img> from content and place them elsewhere on a page template?

text: An existing website have many images placed within the content of pages. I'd like to redesign the template, separating the display of text and images. How could i do that?


title: BBPress Search results in Wordpress search

text: I want to display in Wordpress search results page - 10 or less found results from BBPress (plugin) forums. I know that BBPress use custom post types (forum, topic, reply) but I don't know how to do it. I try with WP Query, but it didn't show nothing. I don't want to override BBPress search page and functions, I just want to show some results in Wordpress search page. Is this possible? Thank you all in advance. Here is the query I try:               <?php          // The Query         $the_query = new WP_Query( array (             'post_type' => array('topic', 'reply'),             'posts_per_page' => 10,             's'=> $s         ));              // The Loop         if ( $the_query->have_posts() ) {             while ( $the_query->have_posts() ) { $the_query->the_post();                 echo '<li>' . get_the_title() . '</li>';             }         } else {         // no posts found         }         /* Restore original Post Data */         wp_reset_postdata();     ?>


title: How to change blog category, author URL in wordpress

text: I have create a WordPress page with slug blog. I can easily access the blog par with `/blog`. Now what I want is to add `blog/` in front of all the urls in my blog, like `blog/category/first`, blog/author/pramod.. I have try this by changing category base and author base but it gives me page not found error. Please let me know is there any other way to do this. Asked same question on SO but no reply


title: How show post only from after custom date

text: I have custom post type. In this custom post type I have custom field with date in format: 23/09/2012 How to show only posts, which currently date is before date from these custom field? Sory for my english. Tom


title: wp_enqueue_script : how to change loading order of scripts?

text: I would like to know how to list all scripts loaded on a page, ranked by order and change this order.


title: How to make wp-login.php not accessible

text: I've successfully made wp-admin not accessible (redirected to 404 page) here is the codes in my function file:               add_filter('site_url', 'wpadmin_filter', 10, 3);          function wpadmin_filter( $url, $path, $orig_scheme ) {         $old = array( "/(wp-admin)/");         $admin_dir = WP_ADMIN_DIR;         $new = array($admin_dir);         return preg_replace( $old, $new, $url, 1);     }               function redirect_wp_admin(){         $redirect_to = $_SERVER['REQUEST_URI'];         if(count($_REQUEST)> 0 && array_key_exists('redirect_to', $_REQUEST)){             $redirect_to = $_REQUEST['redirect_to'];             $check_wp_admin = stristr($redirect_to, 'wp-admin');             if($check_wp_admin){                 wp_safe_redirect( '404.php' );             }         }     }       and the htaccess:               RewriteRule ^controlpanel/(.*) wp-admin/$1?%{QUERY_STRING} [L]      Now the confusing part is I have no idea how to do the same thing for wp- login.php. the changing from "wp-login.php" to "access" works but when wp- login.php typed, it is still accessible here's the code in the function file:               add_filter('site_url',  'wplogin_filter', 10, 3);          function wplogin_filter( $url, $path, $orig_scheme )     {      $old  = array( "/(wp-login\.php)/");      $new  = array( "access");      return preg_replace( $old, $new, $url, 1);     }      htaccess file:               RewriteRule ^access$ wp-login.php      So, my question is what to do to make wp-login.php not accessible (either redirected to 404 page or anything)? Any answers are very appreciated :) Thank you very much in advance


title: Set templates for custom post types

text: I am using Weaver II Pro theme 1.3.8 with WordPress 3.5.2 The theme is very flexible and provides many templates. On individual pages, I can even choose which template to use, which is cool and handy. Is there a way to assign a particular template for a particular custom post type, e.g. no sidebars for bbPress forum pages, or no sidebars for time.ly All-in-One-Event-Calendar, etc?


title: Site returns a 500 Internal server error

text: I have a serious problem with my WordPress theme. When I try to log in from Firefox, I will be logged in successfully but after that I try to log in with chrome or IE then I get 500 Internal server error. What am i doing wrong? I tried error reporting E_ALL, debug to true but no success. ![enter image description here](http://i.stack.imgur.com/3rJVd.png)


title: Wordpress Query based on random taxonomy

text:
I am banging my head to get this solved, would appreciate if any one can help _**The scenario is,_**   * I have a WordPress site related to books.   * I have a custom taxonomy named "History Books" sluged as "history_books". under this particular taxonomy, I have many history books(terms).   * under my /assets/images/books folder, I have all the images related to specific booked (terms) i.e terms_hsb1.jpg _**What I want is,_**   * I need to run a RANDOM query based on my custom taxonomy " history_books", which should return a randomly selected term.   * Then I need to show the related image for that specific term.   * Total count of that terms   * A direct link to the term archive page. _**In Second Step,_**   * I want to show five post related to that specific term. I was trying many combinations, but nothing worked. Lately, I tried this code                           <?php                  $sugarquery = new WP_Query();                 $sugarquery->query( array( 'taxonomy' => 'history_books', 'orderby' => 'rand', 'showposts' => 1 ) );                 while( $sugarquery ->have_posts() ) : $sugarquery ->the_post();                 ?>                 <a href="<?php the_permalink(); ?>"><?php the_title(); ?>                      <?php                 $product_terms = wp_get_object_terms('history_books');                 if(!empty($product_terms)){                 if(!is_wp_error( $product_terms )){                 echo '
';                 foreach($product_terms as $term){                 echo '
slug, 'history_books').'">'.$term->name.'
';                  }                 echo '
';                 }                 }                      endwhile; ?>          I does query from specific tax, and returns one random post, but after that nothing happens. Please help me, what is the better way to get this done? BR


title: Automatically post to Google+ on new post

text: Is there a way to automatically post to Google+ whenever there is a blog post on WordPress? I found very conflicting information if that is possible or not. Ideally this should be free of course.


title: Wordpress Custom Rewrite Rule

text: I have a custom page template to use for a wordpress page. I am trying to setup a custom rewrite rule but without success. I have a page at blog/book-page/, the display of this page depends on the book id, hence I want url like blog/book-page/book-id/ to read the book id. In my functions php I have included the below function from Wordpress Codex:               add_rewrite_rule('^book-page/([^/]*)/?','index.php?page_id=11&book_id=$matches[1]','top');      But when I access http://xyz.com/book-page/123/, it keeps on redirecting me to http://xyz.com/book-page/ I refreshed the rewrite rules by saving the permalinks in the dashboard. Unable to solve by looking at similar questions at: Custom rewrite rule is not picked by Wordpress and Need help creating custom rewrite rule Any suggestions, Thanks in advance.


title: Custom field in a shortcode?

text:
I cannot get the image from one of my fields into a shortcode.   (it works with `get_the_post_thumbnail($post->ID, 'thumbnail')` but I need the value from the field `udstiller logo`.               function logo_shortcode( $atts ) {         extract( shortcode_atts( array(             'limit' => '50',             'orderby' => 'name',         ), $atts ) );         // Creating custom query to fetch the project type custom post.         $loop = new WP_Query(array('post_type' => 'udstillere', 'posts_per_page' => $limit, 'orderby' => $orderby));         $output = '
';         // Looping through the posts and building the HTML structure.         if($loop){             while ($loop->have_posts()){                  $loop->the_post();                  $output .= '
ID,'wpcf-udstiller-logo',true).'"/>
';                  }         }         else             $output = 'Sorry, No projects yet. Come back Soon.';         // Now we are returning the HTML code back to the place from where the shortcode was called.         return $output;         $output = '
';     }     add_shortcode("Logo", "logo_shortcode");


title: How to get Poster (thumbnail) Image of Video

text: I'm getting all videos using the function below and it's working fine. Now I want to get the videos Poster Image (Thumbnail Image) from that video. How can I get the video Image as thumbnail? I've also tried to get thumbnail by this function but It's not working                   $page_id = 659;          $page_data = get_page( $page_id );               if (has_post_thumbnail( $page_data->ID ) ){ ?>         <?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $page_data->ID ), 'single-post-thumbnail' ); ?>         <img src="<?php echo $image[0]; ?>" width="200" height="212" />         <?php }?>      I'm getting all videos by this function                   $args = array                 (                     'post_type' => 'attachment',                     'post_mime_type' => 'video',                     'order' => 'DESC',                     'orderby' => 'post_date',                     'posts_per_page'  => -1                 );                 $videoFiles = get_posts($args);                  foreach ($videoFiles as $file) {         }      My post object:               WP_Post Object     (         [ID] => 670         [post_author] => 1         [post_date] => 2013-06-26 10:55:51         [post_date_gmt] => 2013-06-26 10:55:51         [post_content] => Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries,         [post_title] => Strike Back         [post_excerpt] => Composer         [post_status] => inherit         [comment_status] => open         [ping_status] => open         [post_password] =>          [post_name] => columbia4x3         [to_ping] =>          [pinged] =>          [post_modified] => 2013-06-26 10:55:51         [post_modified_gmt] => 2013-06-26 10:55:51         [post_content_filtered] =>          [post_parent] => 0         [guid] => http://host.com/wp-content/uploads/2013/06/Columbia4x3.mov         [menu_order] => 0         [post_type] => attachment         [post_mime_type] => video/quicktime         [comment_count] => 0         [filter] => raw     )


title: Creating Pages within a secure folder outside the normal wordpress folder

text: I have a members site where the members material is in a folder in root called secure. Access is controlled by a separate billing company and protected by strongbox. I m re designing the site using wordpress and have set up wordpress in a folder called mywp. I would like to make update pages that are only available in the secure folder once members have logged in but cannot find any clear instructions on how to do this. Any suggestions or solutions are appreciated.


title: Viewing statistics on self hosted site from Android WordPress app

text: I did / do have a WordPress hosted blog (with statistics working fine). I've now set-up a self hosted blog and have paid for an off-site redirect from WordPress to my new blog. That all works fine. If I log onto my self hosted admin page I can see the sites statistics, but I'm asked to log in again, this is odd, but I do get to see the statistics. However, when I'm using the WordPress for Android (1.3.7) application and I log onto my self hosted site I see no statistics unless I go to the year view. This seems to then show me the statistics from the WordPress site, but not my self hosted site. How can I fix this?


title: admin-ajax.php vs .load() in WordPress

text: I'm developing a theme and I want to ajaxify each internal link in my theme. Uptill now, i've used `admin-ajax.php` method successfully for these actions ... 1: Load More Posts for Blog with Ajax 2: Open Single Blog Post with Ajax And i've used seperate .js scripts and ajax callback function for each of the above action. But the issue is if i want to ajaxify whole of my wordpress theme i'll have to code many such scripts and callback functions for each internal link e.g author page, search page, default page template, custom page template ... etc. Now, i want to ask ... 1: Is it the only way to ajaxify your whole site or if there is any better way? Cannot we use `.load()` method with less usage of code? (as in `.load()` method we only have to specify the URL to load irrespective of the fact that which page we are loading) 2: Why `admin-ajax.php` method is preferred vs `.load()` method?


title: Disallowing Users of a Custom Role from Deleting or Adding Administrators?

text: _( **Moderator's note:** The original title was "Custom User Role Restrictions")_ A project I am working on requires me to create two new user roles - one for the owner of the website and the other for agents of the company. With the website owner user role I was just looking for a way to restrict users in this group from modifying core site settings while having access to modify all other settings. The code below seems to work perfectly for everything other than the user management area. I did want users of this group to be able to add/modify website users BUT where I am running into a problem is that users of this group currently have the ability to create users in the _"Administrator"_ category and they are also able to deleting existing _"Administrators"_. What I am looking for is a way to modify the code below so that such users can NOT delete or modify a user account which is set as _"Administrator"_ and restrict the user from being able to create a new Administrator account. Does anyone know how this can be done?               // CREATE CUSTOM - SITE OWNER - USER ROLE WITH CUSTOM CAPABILITIES     if (!get_role('website_owner')) {       //let's use the editor as the base capabilities       $caps = get_role('editor')->capabilities;        $caps = array_merge( $caps, array(         'install_plugins'               => false,         'activate_plugins'              => false,         'update_plugins'                => false,         'delete_plugins'                => false,         'list_users'                    => true,         'add_users'                     => true,         'create_users'                  => true,         'edit_users'                    => true,         'delete_users'                  => true,         'remove_users'                  => true,         'unfiltered_upload'             => true,         'install_themes'                => false,         'update_themes'                 => false,         'delete_themes'                 => false,         'switch_themes'                 => false,         'edit_theme_options'            => true,         'manage_options'                => false,         'import'                        => false,         'update_core'                   => false,         'edit_dashboard'                => false,         'gravityforms_view_entries'     => true,         'gravityforms_edit_entries'     => true,         'gravityforms_delete_entries'   => true,         'gravityforms_export_entries'   => true,         'gravityforms_view_entry_notes' => true,         'gravityforms_edit_entry_notes' => true,         'gravityforms_feed'             => true,       )); //adding new capabilities.       // Ref: http://codex.wordpress.org/Roles_and_Capabilities#Capability_vs._Role_Table       add_role( 'website_owner', 'Website Owner', $caps );     }


title: Removing container from wp_nav_menu not working

text:
I'm converting this html menu to wordpress:

Home

About

      i use:               wp_nav_menu(array(      'menu'=>'mainmenu' ,      'container'       => false,       'link_before'     => '',      'link_after'      => '',      'theme_location'  => 'primary')      );      but the html i get is:

Home

About

      If i use a custom menu then i get:

Home

About

      but if i don't use a custom menu 'container'=>false doesn't work Any solution?


title: How do I display Youtube/Vimeo video ID on custom post type when user enters it in custom meta box?

text:
I have created a 2x shortcodes that displays a youtube video and vimeo video when the user enters the videos id in it, for example: [youtube id=""] [vimeo id=""]. Instead of entering this in my post I am trying to create a custom meta box that the user can enter the id in and then this is displayed. So far I have been able to create a plugin to display the meta box but I'm not sure how to get it to save the youtube/vimeo ID and display the video. Will I need 2x different meta boxes? One that the user can enter the youtube video ID in and the other where the vimeo ID can be entered and then this is displayed on the front end? The code I have for the meta box is:               add_action( 'add_meta_boxes', 'cd_meta_box_add' );     function cd_meta_box_add()     {         add_meta_box( 'my-meta-box-id', 'Enter Video ID', 'cd_meta_box_cb', 'videos', 'normal', 'high' );     }          function cd_meta_box_cb( $post )     {         $video_type = get_post_meta($post->ID,'my_video_type',true);         $video_id = get_post_meta($post->ID,'my_meta_box_text',true);         wp_nonce_field( 'my_meta_box_nonce', 'meta_box_nonce' );              ?>
             Select video type:                           <select name="my_video_type" id="my_video_type">                   <option <?php echo ($video_type == 'youtube') ? "selected='selected'" : "" ;?> value="youtube">Youtube</option>                 <option <?php echo ($video_type == 'vimeo') ? "selected='selected'" : "" ;?> value="vimeo">Vimeo</option>             </select>

             Youtube/Vimeo ID:             <input type="text" name="my_meta_box_text" id="my_meta_box_text" value="<?php echo $video_id; ?>" />
                        <?php        }               add_action( 'save_post', 'cd_meta_box_save' );     function cd_meta_box_save( $post_id )     {         // Bail if we're doing an auto save         if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;              // if our nonce isn't there, or we can't verify it, bail         if( !isset( $_POST['meta_box_nonce'] ) || !wp_verify_nonce( $_POST['meta_box_nonce'], 'my_meta_box_nonce' ) ) return;              // if our current user can't edit this post, bail         if( !current_user_can( 'edit_post' ) ) return;              // now we can actually save the data         $allowed = array(              'a' => array( // on allow a tags                 'href' => array() // and those anchords can only have href attribute             )         );              // Probably a good idea to make sure your data is set         if( isset( $_POST['my_meta_box_text'] ) )             update_post_meta( $post_id, 'my_meta_box_text', wp_kses( $_POST['my_meta_box_text'], $allowed ) );               }     ?>      In single.php I need to run a query to display the video based on what the user enters in the meta box. My code for that is:               <?php global $post; ?>     <?php                                       if(get_post_meta($post->ID,'my_video_type',true) == "youtube"){                                 $youtube_id = get_post_meta($post->ID,'my_meta_box_text',true);                                      }                                 if(get_post_meta($post->ID,'my_video_type',true) == "vimeo"){                                     $vimeo_id = get_post_meta($post->ID,'my_meta_box_text',true);                                    }                                 ?>      However this does not display anything. I have been pulling my hair out to get this sorted. If anyone can help it will be greatly appreciated. Thanks in advance.


title: How to forbid users to change their first, last and screen names?

text: I'm using Wordpress 3.1. I need to forbid users to change their first, last and screen names in their profile, but admin must still have this possibility. How can I do that?


Is there any free (or cheap) software that can be used for testing WordPress functionality? I would like to create some test scripts and then them against my self-hosted WordPress installation.


title: How to prevent redirect to 'About' after core upgrade?

text: In `wp-admin/includes/update-core.php` we find the following line:               add_action( '_core_updated_successfully', '_redirect_to_about_wordpress' );      I want to remove this action, so I created a mu plugin with the following content:               <?php # -*- coding: utf-8 -*-     add_action( '_core_updated_successfully', 't5_no_redirect_after_update', 0 );          function t5_no_redirect_after_update()     {         remove_action( '_core_updated_successfully', '_redirect_to_about_wordpress' );     }      It does … nothing. I am still redirected. Tested with single site and multi site installations. I guess I miss something obvious, as usual. :)   How to do it better? ## Update Based on Brady’s answer I build a very minimal version:               <?php # -*- coding: utf-8 -*-     /* Plugin Name: T5 No redirect after core upgrade. */     add_action( '_core_updated_successfully', 't5_no_redirect_after_update', 0 );          function t5_no_redirect_after_update()     {         show_message( __('WordPress updated successfully') );              // Include admin-footer.php and exit         include(ABSPATH . 'wp-admin/admin-footer.php');              exit;     }      Now we see the success message and no other action is called. You can download the plugin on GitHub. Use it as regular plugin or as MU plugin.


title: paginate_links() on page (shortcode output)

text:
On a standard WordPress page, I have a `WP Query` that runs through a post type I created. Along with that query, I am using paginate_links() to generate pagination. While the standard (no permalinks) seems to work fine - when enabling any permalink combination, the subsequent pagination pages do not load. Here is what I have so far:               $post_args = array(         'post_type' => 'galleries',         'paged'     => get_query_var('paged'),         'post_type' => 'galleries'     );          $posts_query = new WP_Query($post_args);     $i = 0; // count     $total_items = $posts_query->post_count; // total profiles     $number_columns = $galleries_options['columns']; // number of columns     if ($posts_query->have_posts() ) {         echo '
';         while ($posts_query->have_posts() && ($i < $total_items)) { ?>             <?php $posts_query->the_post(); if ($i % $number_columns == 0) echo ($i > 0 ? '

' : '
'); ?>             <div class="<?php echo 'width'.intval(100 / $number_columns); ?> <?php if ($i % $number_columns == 0) echo 'first-item'; ?>">                 <?php                     galleries_list(get_the_ID());                 ?>
         <?php $i++;         }         echo '
';         echo '
';              $total_pages = $posts_query->max_num_pages;         $big = 999999999; // need an unlikely integer          if ($total_pages > 1){               $current_page = max(1, get_query_var('paged'));               echo '';               echo paginate_links(array(                   'base'      => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),                 'format'    => '?paged=%#%',                   'current'   => $current_page,                   'total'     => $total_pages,                   'prev_text' => 'Prev',                   'next_text' => 'Next'               ));               echo '';           }           }      The default URL is `?page_id=60&paged=2` which works/loads fine - yet `galleries/page/2/` does not. Anyone have any suggestions? I'm using the exact same thing for taxonomy pagination... so I'm a bit confused on why this isn't working. Thanks!


title: How to add GET variable after script url?

text: So, I've registered and enqueued my script. `http://mysite.com/wp-content/plugins/my-plugin/script.js?ver=3.6` But how do I add a GET variable on the script src url? `http://mysite.com/wp-content/plugins/my- plugin/script.js?ver=3.6&myVar=whatever` Any help appreciated.


title: Post title not output correctly

text: I am trying to set up titles of posts with WordPress SEO, however my title gets output like this: My post name There is no separator and site name. Here's the code in the theme:                 <title><?php wp_title(''); ?></title>      In the WordPress SEO settings, under Post Types > Posts I have the following setting for titles: %%title%% %%page%% %%sep%% %%sitename%%


title: add youtube thumbnail in index and single.php add video

text: I crating custom wordpress themes for video related website, client can embed youtube video, in index.php only show thumbnail image and title of video then when click thumbnail it goes to single.php & show the video, Plase any one help me, I try Video Thumbnails it not work me.


title: Rendering of custom walker menu function not working properly

text:
I have a custom function for my nav walker menu that adds custom php/html to it, which can be seen below. It renders a twitter bootstrap dropdown menu that I would like to put my login form in.                   function add_login_logout_link($items, $args) {             if ( is_user_logged_in() ) {                 $items .= '

' . __('Log out', NOVALANG) . '
';             } else {                 $items .= '

Skapa konto

                         ' . __('Log in', NOVALANG) . '

' . get_template_part('login') . '

Jag har glömt lösenordet

';         }         return $items;         }         add_filter('wp_nav_menu_items', 'add_login_logout_link', 10, 4);      The problem here is the rendering of the custom login form using get_template_part('login'), which shows up in the top of the page where it really should not be as far as I can see.

      It's empty! And the login form shows up in the header. I have that code in a separate php-file, but I don't think that is the problem because I have tried rendering it using other code in a custom function in the functions.php-file. Anyone who can point me in the right direction?


title: Localized Date Format for Custom Field

text: I'm using a custom field, formatted with "dd-mm-yyyy". I would like to use it with the Date Format defined in the Dashboard settings. It seems alright in English with               get_option('date_format');      Or manually in French with               setlocale(LC_ALL, 'fr_FR');     $date_local = strftime("%d-%m-%Y",$date->format('U'));      But is there a way to use the localized date format of wordpress? I can't find how to give the date as an argument to               the_date()


title: wp_mail - using a custom field value for $to

text: I'm trying to pass a custom field value to my functions.php file. I want to replace: $to = get_bloginfo( 'admin_email' ); to something along the lines of: $to = get_custom_field('sendto', TRUE); So the user will have a recipients field on their post (custom post type) that they can add email addresses to, then when the post is published, those users will receive the notification as well. Thank You for any help.


title: Interface for logged-in users to upload/download files

text: I am setting up a site for a non-profit that would like to have a 'members' area where certain users can swap files for meetings, events, etc. They essentially need a simple interface where they can upload/download files --one that is removed from the WordPress admin area. Some info:   * They would be uploading mostly text documents, so I am not worried about a high-capacity solution. The server I have for the website would definitely be able to handle the load    * There are about 30 members    * A secretary would look after the creation/removal of members    * It would be nice to be able to embed it into the site using some sort of plugin, but I am not against using a 3rd-party service either The only solutions that are looking good so far are Dropbox Teams or Box.com Business, but they seem quite extreme for this organization's needs. I also came across Wuala. I've never heard of it before, but the prices are much cheaper than the alternatives. Does anybody have experience with this kind of problem? :) Thanks a lot!


title: Copyright: Get first and last date of post type

text: I was searching for the easiest/fastest way to get the accurate date range for copyright notices in the footer. The copyright notice shouldn't only contain the year, but as well take month and day into account and consider the post type. So a custom post type of "Event" could have a different copyright date range than a blog "post" post type.


title: WordPress Images | How to get the cropped image?

text: I have the URL of an image (full size). During the upload it already generates a smaller version (I added this in functions). How can I get this cropped version when I have the full size URL? The Image is not in a post so I can't use `post-thumbanil()`. The image is in a slider on the Homepage.


title: "Error parsing the WSDL file:" Web service plugin in Wordpress

text: I am new at using Wordpress and using this plugin guide (WordPress Web Service Plugin) to activate the plugin to use over Web Service in Wordpress. After followed the procedures, an error showed up, even when I tried on _localhost_. It showed like this, not like in the instruction.. :( ![WSDL Fail, shouldn't be like this](http://i.stack.imgur.com/7keRw.png) Maybe someone could try it since it's easy to follow, but somehow different in result.


title: How can I stop WordPress from catching URL's for static pages that I save on my server

text: I posted a question about whether it's possible to add a Page in WordPress without headers and footers. Here's that question: Add a Page without header and menus? So how can I create a static page with none of the WordPress stuff that appears on all the other pages of my WordPress site, and add html at that url? How would I do that?


title: Add a Page without header and menus?

text: Is it possible to add a Page in WordPress, so that none of the header or the menus of the site appears on that page? And also so that the stuff in sidebars that's on the rest of the site doesn't appear. And the stuff at the bottom of the page (there's a 'Leave a reply' form on the other pages.) So on this site: http://richardclunan.com/ don't want any of the header handwriting or the 'hey there' / 'portfolio' / 'need copywriting' / 'etc' menu items to appear on one particular page, nor the side-bar sign-up box, nor the 'leave a reply' form. But I want all that stuff to appear on all other pages.


title: Can't iterate through 2 levels of categories

text: I purchased a Wordpress theme, for a restaurant. The theme uses Posts for each (food)menu entry, and Categories to segment the menu into sections. The theme is built for 1 level hierarchies. e.g:               >Menu     >>>Breakfast     >>>Lunch     >>>Dinner      However, the restaurant I am working for has a more complex menu:               >Menu     >>>Breakfast     >>>>>>Food     >>>>>>Sides     >>>>>>Drinks     >>>Lunch     >>>>>>Small     >>>>>>Large     >>>>>>Sides      Here is the original index.php Here is my modified index.php, which attempts to iterate first within the 1st level of categories (e.g. Breakfast, Lunch...), and then through all 2nd level categories (e.g. Breakfast > Food, Breakfast > Sides...). In both, $menuCat refers to the "Menu" parent category. This is the live site, using a child theme, and the new index.php. It manages to find the "Lunch" category, but not the "Breakfast" category, and it doesn't output the subcategories. I receive a PHP exception: > Warning: Illegal offset type in isset or empty in /.../wp- > includes/taxonomy.php on line 1236 Here is taxonomy.php from line 1234:               if ( $parent ) {         $hierarchy = _get_term_hierarchy($taxonomies[0]);         if ( !isset($hierarchy[$parent]) )             return $empty_array;     }      So, it seems the $hierarchy of the parent is not not set. I don't know what this means.


title: typeerror this.getdoc(...) is undefined wordpress

text: I have face this issue after upgrade WordPress 3.0 to 3.5.1 . Can anyone guide me how can I fix it. My all tinymce editor stop working after upgrade.


title: Pagination working locally but not on live site

text: I have a loop on my single.php page like this:-               <?php if (have_posts()) : ?>              <?php $paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1; ?>              <?php $this_post = $post->ID; query_posts( array('meta_key' => 'epicredrank', 'orderby' => 'meta_value_num', 'order' => 'DESC' , 'paged' => $paged, 'category__in' =>  wp_get_post_categories( $post->ID ), 'post__not_in' => array($this_post),  ) ); ?>                             <?php while ( have_posts() ) : the_post() ?>                             <?php if ( has_post_format( 'video' )) {                      get_template_part( 'video-post' );                 } elseif ( has_post_format( 'image' )) {                     get_template_part( 'image-post' );                 } else {                    get_template_part( 'standard-post' );                 }                  ?>                   <?php endwhile;?>              <?php endif; ?>      This works on my local installation to paginate posts on single.php but not on the live server and I can't work out why. Have tried saving permalinks etc... EDIT:- If I use the permalink structure 'default' it works just fine, but it fails on pretty permalinks.


title: Pass PHP variable to javascript

text: Is there any possibility to pass some PHP variables in javascript so I can use them later? Only in `single.php`.   I heard about `wp_enqueue_scripts` but with that it is neccesary to declare a path to a JS file, but I don`t need one.


title: How to display Multi Checkbos select Custom Field on the post?

text: i have create a Custom Post Type calle "Places". I have created a Custom Field with Field Type "Multi CheckBox" Option Title "Type of Pub" Option values "Sports, Rock, Biker, Beer, Live Band, Restro, Gastro, Irish, Karaoke Bar" Field Title "Type of Pub" Field name "typeofpub" When i Add New Places, Type of Pub with Values with checkbox shows up on edit page. I selected all the values (Sports, Rock......) How do i call the metadata to display is custom field on a post.


title: Index template and Home page

text: Sorry if this seems silly but I am new to WP. I realise that Index template is the most important file. Is it ok to have Index as your "home" page, and can you just assign the Index template to the home page when setting it up in the back-end?


title: Is there a widget that can display a certain Custom Post Type Terms?

text: I am looking for a widget that a user can choose a Custom POst Type Term from a list. As an example I have a Custom Post Type called events and it has multiple categories. I want the user to be able to choose to show only posts from a certain category. Does anyone know of one or know how I can make this please?


title: User Signup in Multisite - Need Plugin or Advice

text: I'm trying to make some modifications to a wordpress multisite and i could use some help from someone more experienced. I want to restrict the acces to my blogs unless the user has an account. In detail : i have a series of blogs, each one with an admin/autor. If a user wants to read posts from a blog, he should first go on the main site, to wp-signup.php and create an account. I'm planning on creating a plugin, active on all subsites. Is this possible? if yes, could someone give me some directions - wich hooks, filters and functions i would need ? Thank you!


title: Global searchin multisite but only with one subsite

text: I have a multisite set up with currently 2 subsites. Is it possible to have a search box that searches the main site and just one subsite?


title: How do I apply a template to my single posts?

text: (I am using a child theme of twenty-ten) For most of my pages I like to use the single column template. I noticed that (after I updated to 3.14) my single posts were using the default template (which has a sidebar for widgets). How do I get rid of this? I could style the sidebar away but is there a way to tell WP to apply the single-column template for my single-posts? Note that the main blog page applies the single-column template to it, so this is only happening when I bring up individual posts.


title: Creating an "admin only" meta box with WPAlchemy. Getting a fatal error on front-end when using current_user_can

text: I'm trying to create an "admin only" meta box using WPAlchemy. The box for example may contain a "feature post" check box and other functionality. How can I show this meta box for only the admin, yet have it work properly? I'm currently using the following code below, but I receive a "Fatal error: Call to a member function the_meta() on a non-object" when trying to echo the value of whatever is inside on the front-end. Everything works as intended if I don't use current_user_can and works also if I'm logged in as admin and viewing the front-end.               if (current_user_can('administrator')) {     $custom_admin_mb = new WPAlchemy_MetaBox(array(         'id' => '_custom_admin_meta',         'title' => 'Admin only',         'template' => TEMPLATEPATH . '/custom/admin_meta.php',     ));      }


title: How to modify the comments to be displayed in a post?

text:
I would like to know how to modify the way wordpress displays the comments in a page. The requirement at hand is to display a certain number of comments in the comments list and while the the user scrolls to the bottom of the comments list (not on the page), a new set of comments will be appended to the comments list (if there are more comments to be displayed). I have the following code to call the comments to be displayed:               <?php     require_once("../../../wp-config.php");          $page = $_GET['cpage'];     if(isset($page))     {         echo loadComments($page);                               }          function loadComments($page=1)     {         global $wpdb;                 $number=5;             $result='';              // get comments from WordPress database          $numRows = $wpdb->get_var("SELECT COUNT(*)                                 FROM $wpdb->comments                                  WHERE comment_approved = '1'                                      AND NOT (comment_type = 'pingback' OR comment_type = 'trackback')");                          if ($numRows > $number)         {                 $nav=1;                 $pages=ceil($numRows/$number);         }         else {             $nav=0;             $pages=0;         }              $getnumber=$number*$page;              // get comments from WordPress database          $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments                                          WHERE comment_approved = '1'                                              AND NOT (comment_type = 'pingback' OR comment_type = 'trackback')                                         ORDER BY comment_date_gmt ASC                                          LIMIT $getnumber");                   $comments=array_slice($comments, $getnumber-$number, $number);                   if ( $comments )         {             $count=1;                  // display comments one by one             foreach ($comments as $comment)             {                   if ($page <= $pages)                 {                     $result.= '
comment_ID.'" class="leftcolumn">

'.                             '

'.$comment->comment_content.'

'.                             '

'.                             '

'.'

'.                             '
comment_ID.'">'.'
'.                             ''.$comment->comment_author.'

'.                             ''.mysql2date('j-n-Y',$comment->comment_date).''.                             '

'.                             '

';                                     $count++;                           }                else                {                 $result = '';                }             }         }            return $result;     }          ?>      and this is the ajax call to append a new set of comments:               function updatestatus(){         //Show number of loaded items         var totalItems=$('.commentlist li div.commenttext').length;         $('#status').text('Loaded '+totalItems+' Items');     }          function scrollalert(){         var scrolltop=$('.commentlist').attr('scrollTop');         var scrollheight=$('.commentlist').attr('scrollHeight'); //825         var windowheight=$('.commentlist').attr('clientHeight'); //600         var scrolloffset=20;         //alert(scrolltop);         if(scrolltop >= (scrollheight - (windowheight + scrolloffset)))         {             //fetch new items             if (count > 0 )             {                 count++;                 $('#status').text('Loading more items...');                 $.get('/wp-content/themes/twentyten/commentloader.php?cpage='+count, '', function(newitems){                                if (newitems != '')                     {                         $('.commentlist').append(newitems);                         updatestatus();                                         }                        else                     {                            // prevent from appending content                         count = -1;                     }                 });            }            else            {                 $('#status').text('No more items to load...');            }         }            setTimeout('scrollalert();', 1500);     }      I tried adding the two files inside the themes folder and adding a reference to header.php for js file. This works but I have to set paging on for the comments and hide the navigation. If you could provide a better way to achieve (may be create a plugin?) I will greatly appreciate it. I am new to WordPress and will be delighted if you'll lead me to the right direction. Thanks, RNorbe


title: Sticky Posts & Posts Per Page

text: I notice that sticky posts will disregard the `posts_per_page` param? Like I have a query like               $q = new WP_Query(array( 'posts_per_page' => 4, ... ));      If there are 3 sticky posts, I will get 6 posts? (its abit strange tho why 6 not 7 (4+3)) I dont want to ignore sticky posts. How can I force the posts per page limit? eg, I have 10 sticky, I still get only 4 posts. One way I can think of is a counter that counts to 4 and exit the loop. But there isnt a WP way? This appears to be more of a bug to me?


title: Can I specify template to use with the_permalink?

text: Can I specify a template to use with the_permalink()? Why I need this: when they click a link from a certain page, I want to show that user a different template (extra content) on the linked page.


title: pages won't show on front page using loop or pre_get_posts

text:
I changed up my theme to work what I think is the "proper" way. After reading in the codex and seeing things on this site. I started from scratch. loaded the 2012 theme. Made two pages. Home and blog. I set the homepage to have the default 2012 front-page.php template. then in the settings->reading I set static front page to home and posts page to blog. I know the posts will be pulled from the index.php so in that file, I put the custom loop to pull from the blog category and in my front-page.php file I put a custom loop to get pages.                $args = array(         'post_type' => 'page'      );            $page_query = new WP_Query( $args );            if ( $page_query->have_posts() ) : while ( $page_query->have_posts() ) :   $page_query->the_post();       $template = get_post_meta( $post->ID, '_wp_page_template', true );       // If the page doesn't have any template assigned - display the default page template         if ( $template == 'default') { ?>
<?php the_title();?>
                 <?php the_content(); ?>         <?php   }  else {             include( $template );         }         endwhile;        endif;      This loop was working just fine in other versions of this theme but for some reason, set up the way it is now which is suppose to be the right way, it's not working. I also tried using pre_get_posts to display pages on the front- page. ?>


title: send bulk emails without timeout

text: I am developing a plugin that sends emails out to users. I am having difficulty in finding the most performance enhanced way to send these emails out and prevent a server timeout. In other words, I would like my plugin to scale, so if someone that uses it on a site with a hundred thousand users, my plugin will still work. Perhaps there is a way to execute each email or two as a separate script that gets executed one after another? Some help/insight on this would be appreciated. Thanks


title: Set default text for the editor in new posts

text: I was wondering, is it possible to set default text to appear inside "text" part of the wysiwyg located on Create post page? So every time you click add new post that text would be there waiting for you?


title: Register a widget area when a theme option has been saved?

text: Is it possible to register a widget area and sidebars when an option has been selected and saved in a theme options panel? I am using a framework called redux but am not too sure if this can be accomplished as I am unsure on whether there is a hook that would be available to register the widget area / menu.


title: How to find what index page a post is on?

text: Here is a simple example of what I am wanting to figure out. Say I have WordPress set to show 5 posts per page. And say I there is a post 17 posts back chronologically. The formula would be 17 / 5 = 3.4. Round up 3.4 to a whole page of 4 and that post 17 posts back is on the 4th index page. Now... How to do this programmatically... The number of posts on each index page is determined by the `get_option( 'posts_per_page' );` option. If all I have is the post's id, how do I figure out how many posts back it is chronologically? My head first went to `WP_Query`, but it is not a suitable option. The blog this is for has thousands of posts and it runs out of memory before I can get anywhere to determine where the post is at. Does anyone have an clever suggestions?


title: Why did installing wordpress in url root jack up underlying WP sites?

text: I have a server (w2008 with iis7.5) and domain with a lot of different WP installs. > All of the following represent WP installations. > >   * x.com/stuff >   * x.com/programs/recent >   * x.com/programs/asia >   * x.com/sandbox/1 >   * x.com/sandbox/2 >   * x.com/requests > I have been redirecting x.com to y.com for some time now - with only the WP subsites in use but would like to take off the redirect and start using the root url. However when I install WP (fresh 3.8.1) in the root (inetpub/wwwroot) it basically breaks every website that I have. I was having various issues, from the site not coming up, to permalinks not working, to not being able to get theme files. I tried taking out the web.config files on each install and those not coming up came up but of course the permalinks weren't working. What are the steps I need to do to get the root working without killing the rest of the WP installs? On one of the older WP installs that only works with the default permalink and when I set it to default in WP admin it changes the web.config to the follow:               <?xml version="1.0" encoding="UTF-8"?>     <configuration>       <system.webServer>         <rewrite>           <rules/>         </rewrite>       </system.webServer>     </configuration>      When I change the same site to year/month/name in the WP admin it sets the web.config to this:               <?xml version="1.0" encoding="UTF-8"?>     <configuration>       <system.webServer>         <rewrite>           <rules>                 <rule name="wordpress" patternSyntax="Wildcard">                     <match url="*"/>                         <conditions>                             <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>                             <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>                         </conditions>                     <action type="Rewrite" url="index.php"/>                 </rule></rules>         </rewrite>       </system.webServer>     </configuration>      This totally messes up the site (doing this used to work). The site looks like it doesn't have css or correct paths plus any link needing the rewrite doesn't work. **Also note that I do change the name of the rule so it doesn't conflict with other wordpress sites. So this one is wordpress_22 - I just copied what WP actually creates.** However on a WP install from last week - on same server just one directory over using year/month/postname I get a web.config:               <?xml version="1.0" encoding="UTF-8"?>     <configuration>       <system.webServer>         <rewrite>           <rules>                 <rule name="wordpress" patternSyntax="Wildcard">                     <match url="*"/>                         <conditions>                             <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>                             <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>                         </conditions>                     <action type="Rewrite" url="index.php"/>                 </rule></rules>         </rewrite>       </system.webServer>     </configuration>      This site works perfectly fine. I can change the permalinks whatever way and they all work... riddle me that.


title: Show post categories

text: I'm trying to show post categories for some breadcrumbs. At the moment, I have this:               the_category(' / ', 'multiple');      But for some reason, it is stating the parent category twice (I only want `parent > child`):               FASHION / DAILY FASHION CANDY / FASHION      It should really be:               FASHION / DAILY FASHION CANDY      Would anyone know why it's doing this, and how to change it?


title: Dashboard - get status and position of metaboxes and pass them to ajax method

text: I'm wondering if it's possible to get status and position of metaboxes added to a dashboard-like page. The main page of my plugin has several metaboxes laying in a two-columns page and a "table of content" box on top (with internal links, like a wikipedia page). However, since you can order/hide/reveal a metabox, the TOC box should be updated accordingly via an ajax method. Is it possible to trigger a method like that, passing all parameters i need to accomplish the ordering (position and status of all metaboxes)? tnx in advance, Gabriele


title: Add text to Text Widget using Javascript

text: Wordpress has a Text Widget (at least the theme I'm using does, and I think they all do?) In this widget I can add text or HTML. If I add HTML I can include JavaScript. This works fine (I'm hosting my own site). I want to add some text to the Widget using a script. However; document.write("Whatever") writes the text onto the actual web page. What command do I use to write text into the Text Widget only. Many thanks for any help!


title: Custom field in external Javascript

text: How do I use a custom filed value in an external javascript? I'd like to use a custom field already stored for a post that is an url in an external javascript               <script type='text/javascript' src='http://www.my-website.com/wp-content/themes/mytheme/js/scripts.js'></script>      in order to open a new window               onclick="window.open('MY_CUSTOM_FIELD_VALUE');"      I tried to add               global $post; $cf = get_post_meta( $post->ID, 'my_custom_field', true );      but it doesn't work. Thanks for your help.


title: Custom post type or just use custom fields

text: I am turning a restaurants website into a wordpress website to allow for the customer to take over content changes. The restaurant has a menu that has categories like Baskets with different types. For instance under the Basket type there is Fish which has a Title, Description, and Price. So what I want to do is to be able to have the customer create or delete Menu categories and have the ability to create,delete, update menu types. Then the entire menu is shown on one page. You can view the page at www.tailfinstogo.com/menu.html.


title: Custom Post Type for displaying products in a database table

text: I have a WordPress project that I'm using as a CMS. ~~I also have a database with some products in it that I'd like to display on the site (gallery or portfolio maybe?)~~ I have a custom post type for Products that I want to be editable in the wordpress admin (along with the rest of the content). ~~I know I have to do a custom post type (which I'm reading up on, probably will use Simple Fields plugin) but I'm not seeing a way to pull these values from a database.~~ Products will have ProductName, URL, Category, and Type. I would want to list and add/edit/delete these in the word press admin side of course. Any advice will be greatly appreciated. Thank you all! EDIT: I've created the Custom Post Type for `Products`. Now each `Product` can have a `Category`, `Subcategory`, and `Type`, which I'm assuming will also need their own Custom Post Type if they are to be manageable right? The layout for the products will be roughly: `ProductName`, `Type`, `Category`, `SubCategory`, `Document Name`, `Document URL`. Remember the `Category`, `SubCategory`, `Type` will need to be manageable and editable so I guess they will need to be custom post types as well. Thinking about this some more, could I use the built-in categories for MY custom post type categories and have the subcategories as children of the main categories? That might be the easier way out on that end. But how would I map a custom post type of `ProductType` to my custom post type of `Product`? Here is my product custom post type:                   /*  CUSTOM POST TYPE AREA FOR PRODUCTS   */     add_action( 'init', 'create_product_post_type' );          function create_product_post_type()      {         $labels = array(             'name' => _x('Products', 'post type general name'),             'singular_name' => _x('Product', 'post type singular name'),             'add_new' => _x('Add New', 'products'),             'add_new_item' => __('Add New Product'),             'edit_item' => __('Edit Product'),             'new_item' => __('New Product'),             'view_item' => __('View Product'),             'search_item' => __('Search Products'),             'not_found' => __('No products found'),             'not_found_in_trash' => __('No products found in Trash'),             'parent_item_colon' => '',             'menu_name' => 'Products'                        );              $args = array(             'label' => __('Products'),             'labels' => $labels,             'public' => true,             'can_export' => true,             'show_ui' => true,             '_builtin' => false,             'capability_type' => 'post',             'menu_icon' => get_bloginfo('template_url').'/functions/images/product.png',             'hierarchial' => false,                 //'rewrite' => array( "slug" => "events" ),             'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' ),             'show_in_nav_menus' => true                  );                  register_post_type( 'tf_events', $args);         }