How to structure WordPress plugin to display data from API

I am creating a plugin that connects to a remote API that has car listings and displays the data that's returned in that call. The plugin essentially does not need to interact with the WordPress database at all. I already know I can use things like `wp_remote_get`, `file_get_contents` and `file_get_contents` to retrieve that data. My problem is that I'm not sure if I should be creating a plugin for this or just shortcodes or page-templates or what. I want the urls to look like               example.com/cars/ //Cars listing results     example.com/cars/2 //Page 2 of Cars listing results     example.com/cars/?doors=4&engine=v8 //Search parameters for Cars listing results     example.com/car/1234 //Car info page 1234 is the car_id      I was thinking I could create pages in WordPress called `cars` and `car` and then create custom shortcodes that would hook into some functions I build to interact with the API, but for some reason that doesn't seem like the best idea to me. Can anyone recommend a better structure for setting this up?


Load scripts only for selected template

Is there a built in function to load scripts only for particular template? At them moment I am doing like so:               if (is_page('portfolio') || is_page('gallery')){          wp_register_script('jScrollpane', get_bloginfo('stylesheet_directory') . '/js/jquery.jscrollpane.min.js');     wp_enqueue_script('jScrollpane');     }      and it works as long as I call the pages "portfolio" and "gallery". I would like to have it more reusable, how can I achieve that? Thank you in advance


How to include php-generated javascript?

I've looked around and have found no great solution so far: I would like to add customized javascript from a widget using `wp_enqueue_script`, but Wordpress seems to be limiting scope to the javascript file I load in, as my javascript file says: > Uncaught TypeError: Object [object Object] has no method 'photogallery' Here is the output I would like to load in, as if it were its own script via `wp_enqueue_script`:               <script type = "text/javascript">                 (function ($) {                     "use strict";                     $(function () {                         var $gallery = $("#gallery").photogallery(                                 "a",                                 {                                     thumbs: <?php echo setBool($instance["hasThumbs"]); ?>,                                     history: <?php echo setBool($instance["historyEnabled"]); ?>,                                     time: <?php echo ($instance["transitionTime"] * 1000); ?>,                                     autoplay: <?php echo setBool($instance["autoplayEnabled"]); ?>,                                     loop: <?php echo setBool($instance["isLooped"]); ?>,                                     counter: <?php echo setBool($instance["hasCounter"]); ?>,                                     zoomable: <?php echo setBool($instance["zoomable"]); ?>,                                     hideFlash: <?php echo setBool($instance["hideFlash"]); ?>                                 }                             );                     });                 }(jQuery));             </script>      I know that manually coding the default values in to another js file, and using `enqueue_script` will work fine, but how do I do this properly, with custom widget values, and not load the required js file twice? I am not interested in complex ajax requests unless it is my only option, as mentioned here. Thanks in advance.


How to code arrays in other language which requires UTF-8

I´m changing a code to Rusian but the Admin panel get freeze, I need to deactive a plugin to access again the admin panel; there is no problem on front end. the lines I´m changing is   `   $listing_types = array('Продажа', 'Аренда', 'передача', 'аукцион');` which is   `$listing_types = array ('For Sale', 'Rent', 'transfer', 'auction'); ` I´ve done this for spanish   `$Listing_types = array ('Venta', 'Renta', 'transferencia', 'subasta'); `   But the spanish language is like english if I don't use special charset.


WP_Query tax_query - Show results if child has parent X

I've made a custom search which includes a 3 tier custom taxonomy that looks like this: continent \- country \- - state The search is formatting in the above way. Here is my problem: Example data: Taxonomy name = 'locations'. Custom post type = 'firms'.               America [term_id = 1]     - United States [term_id = 2]     - - Idaho [term_id = 3]     - - New York [term_id = 4]     - - Wisconsin [term_id = 5]      So how would I go about returning results for all firms with a 'locations' taxonomy PARENT of ID = 2 (United States)? Let's say the user selects United States in the dropdown. There will be no results because for the 'firms' custom post type, the 'locations' taxonomy selected is always drilled down as far as possible to the state level. So for example a firm with 'locations' set as New York would not show up when a user searches for 'United states', because their 'locations' taxonomy ID is 4 (state level) and NOT 2 (country level). Hope this makes sense... I was thinking of perhaps storing country level and continent level in post_meta and conditionally adding a meta query on the search page if the selection is not state level. Any ideas? I think this is quite an interesting problem :-) Thanks


Simple Custom Metabox Not Saving

I'm not quite sure why but I've been playing around with all kinds of different solutions but none seem to work. I've traded `update_post_meta` with `add_post_meta` and even broke it up into 3 conditionals to see if it was adding, updating, or deleting but nothing seems to work. The problem is that it won't actually save and show the data on update. I know that '_desc' is set since it does show data when I `die()` (right before the update). Suggestions on how I can figure out why it's not updating?               /** Add the Meta Box **/     function add_custom_meta_box() {         global $meta_box;         add_meta_box(             'short-desc', // $id             'Short Description', // $title              'show_custom_meta_box', // $callback             'post', // $page             'side', // $context             'high'); // $priority     }     add_action('add_meta_boxes', 'add_custom_meta_box');          /** The Callback **/     function show_custom_meta_box() {         global $post;         // Use nonce for verification         echo '<input type="hidden" name="shortdesc_meta_box_nonce" value="'.wp_create_nonce(basename(__FILE__)).'" />';              // get value of this field if it exists for this post         $meta = get_post_custom($post->ID);              // Begin the field table         echo '

';                  echo 'Enter A Short Description:                 <input type="text" name="_desc" id="short-desc" value="'.$meta['_desc'].'" size="30" />';              echo '

'; // end table     }           /** Save the Data **/     function save_custom_meta($post) {         // verify nonce         if (!wp_verify_nonce($_POST['shortdesc_meta_box_nonce'], basename(__FILE__)))              return $post->ID;         // check autosave         if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)             return $post->ID;         // check permissions         if (!current_user_can('edit_post', $post->ID))             return $post->ID;              //echo $_POST['_desc'];         //die();              if(isset($_POST['_desc']))             update_post_meta($post->ID, '_desc', strip_tags($_POST['_desc']));     }     add_action('save_post', 'save_custom_meta', 1, 2);


Custom post type missing custom fields

The theme I purchased came without custom fields in the post/product editor. It uses a custom post type in its own admin php file. I've managed to add custom fields by pulling the following code out of wordpress core metabox.php file however I'm unsure how to get it to work. Its missing the area where the custom field values should go.

     <?php     $metadata = has_meta($post->ID);     list_meta($metadata);     meta_form(); ?>


Custom Post Type post ordering not working

I'm having a problem with entries for a custom post type not being ordered as expected inside a custom query:
Related projects
                      <?php                          $rp_args = array(                             'post_type' => 'work',                             'post_status' => 'publish',                             'orderby' => 'title',                             'order' => 'ASC',                             );                               $related_projects = new WP_Query($rp_args);                 ?>
                     <?php                      if($related_projects->have_posts()):                     while ($related_projects->have_posts()) : $related_projects->the_post();                 ?>
<a href="<?php the_permalink();?>"><?php the_title();?>
                 <?php                    endwhile;                    endif;                 ?>
      It's supposed to just simply pull out a custom post type and order it by name - but the ordering isn't working and I'm not sure why not. It's simply listing the posts in the order they appear in the WP admin. Any thoughts on why my ordering isn't kicking in? It finds the correct post type and number of posts I specify - just the ordering doesn't seem to work.


Plugin or shortcode for ISBN number?

I have a Woocommerce site with a catalogue of books. Each book has an ISBN (or EAN) number entered in a custom field. I need to do two things with the ISBN, and I don't want to have to manually enter code for each product:   1. I need to link to the Google books preview (at the moment I do this manually by adding another custom field with this script (only the ISBN changes from product to product) `<script type="text/javascript" src="http://books.google.com/books/previewlib.js" </script> <script type="text/javascript"> GBS_insertPreviewButtonPopup('ISBN:978-1-920590-37-6'); </script>`   2. I need to link to the products for sale via a number of other online shops, with my affiliate ID followed by the ISBN number, for example `http://etrader.kalahari.net/referral.asp?linkid=5&partnerid=5710&ISBN=978-1-920590-37-6` Can anyone tell me whether I need to create a plugin or use shortcode to achieve this?


How can I query for all children posts regardless of parent

How can I get all children posts regardless of parent. If you require more info: > The setup I have is like this: I have a custom post type "Project". I will > create top level pages as the "main" project page. Then I will have children > pages as something like a project blog. Mainly for WIP posts. > > I will have a Portfolio page that shows all completed projects, and a "WIP" > page showing all WIP posts regardless of project. How can I do this


Filter posts by author selected in page

I've inherited a Wordpress project, and my client has a new feature request. For a "portfolio" page template, they want to be able to select an author, which I want to add to the `$args` in my `WP_Query()`. I have no idea where in Wordpress or in my theme-file I would be able to add this option to the page editor... Can anyone set me off in the right direction? Codex isn't helping much.


Which hooks is this? add_action('wp',

I have seen it here: `wp_schedule_event` Code snippet:                add_action( 'wp', 'prefix_setup_schedule' );      I couldn't find this hook anywhere in documentation, how does it work?


Problem with activate theme

I have download a wordpress theme from http://wordpress.org/extend/themes/citizen-kane When I am trying to activate it gives somthing like in the location`Dashboard->Appearence->Themes` **Broken Themes The following themes are installed but incomplete. Themes must have a stylesheet and a template. Name Description Citizen Kane The parent theme is missing. Please install the "bp-default" parent theme.`** Please help If any body have idea .I shall be very thanful to you all I am waiting for ur reply


WP Query Post Type with same Taxonomy name

This is what I have:   * Custom Post type "Books" with Taxononies/Categories "Genre" and "Author"   * Another Custom Post Type "Authors" which have all author pictures and bios. This is what I want to do:   * On the single "Book" page, have a sidebar with the books "Author" picture and bio. I know how to get the "Author" Taxonomy of a "Book" post, but the information I need is from the "Author" Custom Post Type with the same name. The only thing i can think of is that the slug for both would be the same (i.e. if the books author was "John Smith", the taxonomy would be "john-smith" and the post that I need to query from my "Authors" Custom Post Type would also be "john- smith"). I just don't know how to go about getting it or if there is another way of doing it. I think it should be something like this:                  $bookauthor = wp_get_post_terms($post->ID, 'author', array("fields" => "slug"));        $custom_query = new WP_Query(array(        'post_type' => 'authors',        'name' => $bookauthor      or this:                  $bookauthor = wp_get_post_terms($post->ID, 'author');        $bookauthorslug = $bookauthor[0]->slug;        $custom_query = new WP_Query(array(        'post_type' => 'author',        'name' => $bookauthorslug      But neither works.


How to add an xml-stylesheet link immediately after the 'open' xml tag on the rss2 feed?

In order to style my rss2 feed, I would like to add the following content after the "open" xml tag:               <?xml-stylesheet href="path/to/rss.xsl" type="text/xsl"?>      So, the start of the document would look like:               <?xml version="1.0" encoding="UTF-8"?>     <?xml-stylesheet href="path/to/rss.xsl" type="text/xsl"?>      It seems like none of the hooks listed in the documentation (ex = rss2_head) add content to the spot I need. Can this be done?


Can't access Admin section of Wordpress using MAMP

I have been developing a Wordpress site locally using MAMP, and I have run into an issue twice now where when I leave at night and come back, I can't access the admin page. I have debugging on, and there aren't any fatal errors. I can access the front-end of the site just fine, but I can't log into the admin page. All I get is a white screen like: ![enter image description here](http://i.stack.imgur.com/Bqeuv.png) Here is the front end: ![enter image description here](http://i.stack.imgur.com/YshdZ.png) As you can see the front end is working well, but I can't get into the admin section. I've tried to re-login and it just doesn't work. What could be causing this? The last time this happened, I had to reinstall the entire site. I really don't want to do this every day. I know that everything was working when I left, and I haven't made any changes today. It also looks like this happens with some frequency, as there is another user with a similar issue: Cannot access admin panel I tried all the suggestions on the linked question, but that didn't work.


warnings & errors after MAMP to live (hosteurope)

I get these warnings after getting live with my wordpress site from local to server.               Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'bones_register_sidebars' not found or invalid function name in /is/htdocs/wp1108989_5IDG6XP7VR/www/cgi-bin/website/wp-includes/plugin.php on line 403          Warning: Cannot modify header information - headers already sent by (output started at /is/htdocs/wp1108989_5IDG6XP7VR/www/cgi-bin/website/wp-includes/plugin.php:403) in /is/htdocs/wp1108989_5IDG6XP7VR/www/cgi-bin/website/wp-includes/pluggable.php on line 881      hoster is hosteurope. any one any ideas how to fix it?


Permalink /%category%/%postname%/ returns 404 on OSX

I'm on OSX 10.8.4 with a pretty standard installation of Wordpress 3.6.1 under the local OSX Apache/MySQL. If my permalinks are set to `/%category%/%postname%/` I get a 404... This is working on the live server which I think is running CentOS, so it's definitely something wrong on my machine. I don't have any custom post types. I am using the wp-no-category-base plugin, but removing that has no effect on the 404 problem. Same problem using default theme. `/%category%/%year%/%postname%/` works, as does `/%category%/%post_id%/%postname%/`, although: `/%category%/%postname%/%post_id%/` puts the ID on the end of the URL twice... Check out the config details I've got: My mod_rewrite is on in httpd.conf (`LoadModule rewrite_module libexec/apache2/mod_rewrite.so`) My .htaccess looks to be properly generated by Wordpress:               # BEGIN WordPress     <IfModule mod_rewrite.c>     RewriteEngine On     RewriteBase /     RewriteRule ^index\.php$ - [L]     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule . /index.php [L]     </IfModule>          # END WordPress      And my httpd-vhosts.conf has the correct AllowOverride All lines in it (check out the commented lines for other things I've tried!):               <VirtualHost *:80>         ServerName sitename.gareth.dev         DocumentRoot /Users/G/Sites/SiteName         DirectoryIndex index.html index.php              <Directory /Users/G/Sites/SiteName>                  Options Indexes FollowSymlinks             AllowOverride All                  # Options Indexes MultiViews SymLinksIfOwnerMatch             # AllowOverride Options FileInfo                  Order allow,deny             Allow from all         </Directory>     </VirtualHost>      Any help would be very gratefully appreciated!


I need to exclude from a query a category and a few custom taxonomies. Is this code right? This query don't exclude any post, the one with the category, or the custom taxonomy. What am I doing wrong?               <?php       $args = array(         'post_type' => 'post',         'tax_query' => array(             'relation' => 'OR',             array(                 'taxonomy' => 'ubicacion',                 'field' => 'slug',                 'terms' => array( 'ruperto-concha', 'estallido', 'vineta', 'vitrina', 'letrero', 'plenoempleo', 'primero' ),                         'operator' => 'NOT IN'             ),             array(                 'taxonomy' => 'category',                 'field' => 'slug',                 'terms' => array( 'las-informasiones' ),                 'operator' => 'NOT IN'             )         )      );      $query = new WP_Query( $args );      ?>       Note: i need to exclude post with that category, or with any of those custom taxonomies. Any of both conditions. Sorry for the bad english. UPDATE I intended to this code works               <?php           $args = array(             'post_type' => 'post',             'tax_query' => array(                     'taxonomy' => 'category',                     'field' => 'slug',                     'terms' => array( 'las-informasiones' ),                     'operator' => 'NOT IN'                   )          );          $query = new WP_Query( $args );          ?>       even this:               <?php           $args = array(             'post_type' => 'post',             'tax_query' => array(                     'taxonomy' => 'category__not_in',                     'field' => 'slug',                     'terms' => array( 'las-informasiones' ),                     )          );          $query = new WP_Query( $args );          ?>       and, don't. There is some problem in wp with wp-query and categories? Somebody knows? MOAR INFO That's my custom tax code. I've used an automatic generator.               function register_taxonomy_ubicacion() {              $labels = array(              'name' => _x( 'Ubicaciones', 'ubicacion' ),             'singular_name' => _x( 'Ubicación', 'ubicacion' ),             'search_items' => _x( 'Hurgar en ubicaciones', 'ubicacion' ),             'popular_items' => _x( ' Ubicaciones más usadas', 'ubicacion' ),             'all_items' => _x( 'Todos', 'ubicacion' ),             'parent_item' => _x( 'Parent Ubicación', 'ubicacion' ),             'parent_item_colon' => _x( 'Parent Ubicación:', 'ubicacion' ),             'edit_item' => _x( 'Editar', 'ubicacion' ),             'update_item' => _x( 'Actualizar Ubicación', 'ubicacion' ),             'add_new_item' => _x( 'Añadir Ubicación', 'ubicacion' ),             'new_item_name' => _x( 'Nueva Ubicación', 'ubicacion' ),             'separate_items_with_commas' => _x( 'separelas con comas', 'ubicacion' ),             'add_or_remove_items' => _x( 'Añadir o remover ubicación', 'ubicacion' ),             'choose_from_most_used' => _x( 'Escoger de las más usadas', 'ubicacion' ),             'menu_name' => _x( 'Ubicaciones', 'ubicacion' ),         );              $args = array(              'labels' => $labels,             'public' => true,             'show_in_nav_menus' => true,             'show_ui' => true,             'show_tagcloud' => false,             'show_admin_column' => true,             'hierarchical' => false,                  'rewrite' => true,             'query_var' => true         );              register_taxonomy( 'ubicacion', array('post'), $args );     }


How to handle shortcodes when using the JSON API

I'm wrangling a little logic problem: I'm making a single page WP theme which uses the JSON API for the content and Mustache style templates for the presentation... However, shortcodes? What would be the best way to handle these? For example: JSON result->template->DOM injection->trigger hijack for gallery/slideshow/whatever the shortcode is? The above method feels a bit dirty as I'd have to either keep firing a parser to process the shortcodes or else I'd have to use JQuery.live (seriously dirty). Can anyone think of a more elegant way of doing this?


How to access a taxonomy archive like site.com/taxonomy

I created a custom taxonomy called for example "cars", and inside of it I have several "categories", ex: Chevrolet, Audi, Ford, etc... The problem is that I found no way to make it possible to show all content that have the "cars" taxonomy by accessing site.com/taxonomy. I'd like to have an archive for at site.com/taxonomy exactly as happen when using custom post_type. **Complementing for better understanding.** If I access site.com/taxonomy/term it works. But site.com/taxonomy won't show all posts that have some term of that taxonomy. is there any solution for this? Thanks.


Custom SQL Query on Custom Post Type. Order by Taxonomy?

I've created a custom post type called `'publications'` and a custom taxonomy called `'topics'`. I'm also using the standard taxonomy of `'category'`. My Custom Query makes sure that it fetches ALL `'publications'` that are in the correct `'category'` but I'd like it to also `ORDER BY` the additional `'topics'` taxonomy. This custom query does fetch all the correct `'publications'` but I'm having no luck with the `ORDER BY` section:               $querystr = "         SELECT *          FROM $wpdb->posts         LEFT JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id)         LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)         LEFT JOIN $wpdb->terms ON ($wpdb->term_taxonomy.term_id = $wpdb->terms.term_id)         WHERE $wpdb->posts.post_type = 'publications'         AND $wpdb->terms.slug = %s         AND $wpdb->term_taxonomy.taxonomy = 'category'         ORDER BY $wpdb->term_taxonomy.taxonomy = 'topics' DESC     ";     $pageposts = $wpdb->get_results($wpdb->prepare($querystr, array($parent_post_slug)));      The `$parent_post_slug` is the `'category'` name. And it's fetching all the correct Posts. Just how would I order them by the taxonomy called `'topics'`? An example of the order I'd like: > Category Name = Fiction (This page is just showing the fiction publications)   >  Publication 1 = has custom taxonomy topic of Alligators   >  Publication 2 = has custom taxonomy topic of Alligators   >  Publication 3 = has custom taxonomy topic of Antelopes   >  Publication 4 = has custom taxonomy topic of Buffalos   >  Publication 5 = has custom taxonomy topic of Buffalos Any idea of what I should be using in the `ORDER BY` line to get this to work?


Sort categories by meta value

How can I make a list of categories with 4 last posts in each where every category is sorted by meta_value. For example, template without sorting by meta_value is http://pastebin.com/AeH6vx9b It displays parent categories only. Few days I am searching something related to categories extra fields but can't find something workable. This is my best search result. What I have to do with this? I don't understand it. Is it possible to do what I want?


I need to get this sub nav to show up on cat, sup-cat and post

This is some code that I have mixed together from around the web, what I am wanting it to do is show the sub-categories of what ever category it is in. It seems to work on category, and sub-categories but wont show in the post its self.               <?php     if (is_category()) {     ?>

         <?php         $this_category = get_category($cat);     if($this_category->category_parent){         $this_category = wp_list_categories('orderby=id&title_li=&child_of='.$this_category-        >category_parent."&echo=0");     }     else{     $this_category = wp_list_categories('orderby=id&title_li=&child_of='.$this_category-            >cat_ID."&echo=0");     }     if ($this_category) {          echo "
". $this_category . "
";          echo "

";     }}                else {     ?>
     <h2 title="<?php bloginfo( 'description', 'display' ); ?>"><?php bloginfo( 'description' ); ?>

     <?php     }          ?>


Hook into admin post list page

So I want to create a custom admin interface for the post and page lists. I want it to be a split view with a list of posts and some data on the left, and a full editable preview of the post on the right. I'm having a hard time finding the right place to hook in to accomplish this. What hooks are available for these pages? ![enter image description here](http://i.stack.imgur.com/aHgMw.png) I essentially want to hook into these screens to edit the output of them. All I'm looking for is a hook that will pass in all the information on this page, and allow me to output my own HTML and CSS. I plan on making this list 50% of the screen, and when you click on one of the items, it uses ajax to pull down the post content and display it in a preview window on the right side of the screen. Think Mac mail app. All I'm looking for is the right hook. I think I've got it past that.


Showing the attachment for a page?

I have the following function, it displays the attachments of a post, however it shows the full size, how can i show a limited number of attachments and also a smaller version like a thumbnail.               function page_thumbnails() {     $argsThumb = array(         'order'          => 'DESC',         'post_type'      => 'attachment',         'post_parent'    => $post->ID,         'post_mime_type' => 'image',         'post_status'    => null     );     $attachments = get_posts($argsThumb);     if ($attachments) {         foreach ($attachments as $attachment) {             apply_filters('the_title', $attachment->post_title);             echo '<img src="'.wp_get_attachment_url($attachment->ID, 'post-thumbnail', false, false).'" />';         }          }     }     add_shortcode('page-thumbs', 'page_thumbnails');


Shortcode with multiple variables

I'm trying to create a shortcode to insert the Pinterest button with variables manually in posts. This is the code I've arrived at after reading various posts and grabbing the code from Pinterest. I haven't tested it yet. I wondered whether someone would kindly check for any obvious errors or problems? Secondly, I wondered if in place of the 'url' variable the url / permalink of the post can be grabbed automatically? So this is the code I have. Any thoughts / comments?...               function mypinfunction( $atts ) {          extract( shortcode_atts( array(         'url' => ''         'img' => ''         'description' => ''     ), $atts ) );          return '     '          add_shortcode('skipspin', 'mypinfunction');      The short code to insert would be `[skipspin url="http://example.com" img="http://example.com/image.jpg" description="some words here"]`


Wordpress Loop - Style rows of posts differently

I am trying to adapt the Wordpress loop to style posts differently in rows that get infinitely smaller until all posts are displayed The concept here is to display posts in rows   * first row 1 post   * second row 2 posts   * third row 3 posts   * fourth row 4 posts   * fifth row 5 posts   * sixth row 6 posts   * seventh row 7 posts ...and onward until all posts have been retrieved. The below code is limited and does not do the above how would you adapt to make the below do the above? The below code is functional and can be seen here.               <?php if (have_posts()) : ?>     <?php $count = 0; ?>     <?php while (have_posts()) : the_post(); ?>     <?php $count++; ?>     <?php if ($count == 1) : ?>
<?php the_content(); ?>
     <?php elseif ($count == 2 || $count == 3) : ?>
<?php the_content(); ?>
     <?php elseif ($count == 4 || $count == 5 || $count == 6) : ?>
<?php the_content(); ?>
     <?php elseif ($count == 7 || $count == 8 || $count == 9 || $count == 10) : ?>
<?php the_content(); ?>
     <?php elseif ($count == 11 || $count == 12 || $count == 13 || $count == 14 || $count == 15 ) : ?>
<?php the_content(); ?>
     <?php elseif ($count >= 16 ) : ?>
<?php the_content(); ?>
     <?php endif; ?>     <?php endwhile; ?>      Any help is much appreciated! Kind Regards, Fred Shequine


Create a Meta Box in the Admin User Screen?

My client wants the New User admin page to be composed of a meta box.               add_meta_box( $id, $title, $callback, $post_type, $context, $priority, $callback_args );      But this seems to be for posts only (`$post_type`).   Is there an alternative for the User screen?


Can I Create a Static-Content Site With WordPress?

Hi I'm evaluating wordpress to implement a rather static website (http://www.eddaconsult.se) that now uses static html that I think could be advantageous to do with wordpress since it would make updates and administration easier. Do you agree with me that it's possible to implement these quite simple webpages with wordpress? I started a project to do this at http://eddaconsult.wordpress.com not getting very long since I didn't see how to upload a logo image etc but I'm sure that it can do all or most of what is required.


After having installed APC Object Cache Backend transients stopped working

My understanding is that once you enable the persistent object cache, your transients are no longer stored in `wp_options` but in the cache. Once I installed Mark Jaquith's APC Object Cache Backend, calls to `get_transient( $key )` no longer return the transient in question. Where should I look next? EDIT: One very important piece of evidence is that AS SOON as I renamed the `object-cache.php` file, everything started working again.


Choices for thumbnail image in a Facebook Link post

When I'm posting a link for a WordPress page or post on a Facebook Page wall (using the "Post a link" option), I want Facebook to offer up, as choices, (a) all images which are embedded in the linked page/post as well as (b) a set of default images (in case the page/post in question has no embedded images). What I've done is add (to wp_head) several candidate images in separate link rel="img_src" tags. The problem is that these link rel tags appear to override any images that are actually embedded in the page/post. Any advice would be appreciated.


Internal linking search box not working - WP 3.2

I'm developing on a local install of WP 3.2 and noticed that the search box inside the insert/edit link dialog is not working (Tiny MCE link button in the visual editor). Has anyone else experienced this / know what might be causing it? The search indicator just spins without returning any results when I type in keywords which I know to be good.


Move sticky posts down in main loop

Currently I am working for a site which runs on WordPress, and using twenty thirteen theme which already has a sticky post function built in and working reasonably well. But I do not like how a sticky post is always displayed on absolute top. I would rather be able to display the latest one or two or three posts, then the featured/sticky posts. How can I do this?


Multiple social buttons with a fast loading?

I have pages like this with a lot of social buttons. A lot means more than 50 buttons because each posts on that page has its own buttons. So maybe I'll make the page smaller, with less posts but this is not the main reason and not what I am looking for. I want to know how can I make the buttons faster..               Use XFBML? Iframe? HTML5?     How can I make all of them run from one script and not duplicate?     Do you recommend loading the rest of the buttons just when the user scrolls down?     Do you recommend using a service like AddThis or Sharrre?     How can I make all my JS load asynchronously?     Other tips?      Thanks!


Cannot use Network Admin (Dashboard) on Multi-site after 301 www redirect

I have recently added the 301 redirect non-WWW to WWW on .htaccess for my current running blog multisite (Wordpress blog resides under "mysite.com/home/" directory), they seem to work fine after all the changes in those 3 files below: **.HTACCESS**               # Redirect Non-WWW to WWW     RewriteEngine on     RewriteCond %{HTTP_HOST} ^mysite\.com\home     RewriteRule ^(.*)$ http://www.mysite.com/home/$1 [R=301,L]     # END Redirect Non-WWW to WWW          RewriteEngine On     RewriteBase /home/     RewriteRule ^index\.php$ - [L]          # uploaded files     RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]          # add a trailing slash to /wp-admin     RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]          RewriteCond %{REQUEST_FILENAME} -f [OR]     RewriteCond %{REQUEST_FILENAME} -d     RewriteRule ^ - [L]     RewriteRule  ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]     RewriteRule  ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]     RewriteRule . index.php [L]      **WP-CONFIG.PHP** Change From               define('DOMAIN_CURRENT_SITE', 'mysite.com');      Change To               define('DOMAIN_CURRENT_SITE', 'www.mysite.com');      **FUNCTIONS.PHP (OF THE MAIN THEME)** Change From               update_option('siteurl','http://mysite.com/home');     update_option('home','http://mysite.com/home');     global $oswcPostTypes;      Change To               update_option('siteurl','http://www.mysite.com/home');     update_option('home','http://www.mysite.com/home');     global $oswcPostTypes;      I could be able to view my sites as usual and log-in to each Site Dashboard **BUT CANNOT BE ABLE TO USE the network tab:** My Sites > Network Admin > Dashboard, Sites, Users. Is there anywhere else needed to change in order to be able to use the network tab on multisite without using any plugin or changes all the data in the database?


Extending site width according to the image size

The WordPress theme is for a comic reading site. Since image cannot be re sized because the text will be distorted, I need to extend the site width according to the image size in the post. Here is the URL: http://myreadingmanga.info/wordpress/?p=1578 **Image re size should not be done, but site expansion should be. Anyone can help with this?**


Getting a custom post type image using 'get_post_custom'

I am trying to echo the image src of an image I have uploaded for my custom post type outside of the while loop. I have used the following:               $custom_fields = get_post_custom($_GET['id']);      I can easily now use this code to get, for example the phone number:               echo $custom_fields['telephone'][0]; // e.g. returns 0800 555 222       However, when I try to get an image using the same code, all I get back is a number.               echo $custom_fields['logo'][0]; // e.g. returns 247      Doing a var_dump of $custom_fields, it seems as though I cannot load this data outside the loop using this function. Does anybody know what I'm supposed to do here without having to do a loop?


Add category to custom post type automatically, using category slug

I'm using this excellent function to automatically add a category to my custom post type "Videos" on publish, if there's no category already chosen. This works great:               function add_video_category_automatically($post_ID) {         global $wpdb;         if(!has_term('','category',$post_ID)){             $cat = array(394);             wp_set_object_terms($post_ID, $cat, 'category');         }     }     add_action('publish_videos', 'add_video_category_automatically');      But, I'd really like to get the category ID via the slug, so that I don't have to change it manually when I'm testing on localhost vs the live site (which may have a different ID for that category as localhost and the live site aren't in sync). I've tried a number of options but all of them result in a category of "394" being assigned to new posts, rather than "Videos". Here's my latest attempt. Can you tell me where I'm going wrong?               function add_video_category_automatically($post_ID) {         global $wpdb;         if(!has_term('','category',$post_ID)){             $category = get_term_by( 'slug', 'videos', 'category' );             $cat = array($category->term_id);             wp_set_object_terms($post_ID, $cat, 'category');         }     }     add_action('publish_videos', 'add_video_category_automatically');      Thank you!


Review site custom post type structure

I build a review site with Wordpress. I created a custom post type called "Reviews", inside this, theres two taxonomy, one called "Genres" and one called "Types". Inside the Genres, i have a couple of subcategory, action, comedy, drama etc... and inside the Types, i have 2 subcategory: Movies and TV Shows I want to create a navigation on my homepage like this:   * Movies      * Action     * Comedy     * Drama   * Tv Show      * Action     * Comedy     * Drama And of course, if i click on the Tv Shows/Action, i only want to display all of the reviews inside the Tv Shows category which has an Action genre, and only the TV show, not the movies. What is the easiest solution to do this?


featured image metabox MU

I have a MU install, the admin for my main site (site.com) shows the Featured Image Meta Box, but the admin for the subsites (site.com/blog1) the F.I.M.B. is not shown or available in the screen options tab.. The sites run the same theme and with the same settings. The sites both run a (the same) child theme, and the `add_theme_support('post-thumbnails');` is defined in the Parent theme (framework). It's like the `add_theme_support('post-thumbnails');` only has effect on the main site in my network.. is this a known problem, or should I start to dig for bugs in mu setup?


What is the difference between user_description and description?

In the codex page for `the_author_meta`, the list of fields available for the function lists both `user_description` and `description`. What is the difference between the two?


Reverse ordered pagination on home page

Use on the blog reverse pagination. The question arose. How to make a home page is not the first? Need to break the link `Home` = `First page` and make a connection `Home` = `Last page`. Home should be the last. For example on a blog with 20 pages: Opening the site at `httр://www.example.com` I get to the home page. And this the same page at the address `httр://www.example.com/page/1/` I want to do the opposite: `httр://www.example.com` opens page 20 (`httр://www.example.com = httр://www.example.com/page/20/` ). For example like this http://izismile.com. Home is the last, not the first.


Right way to update widget on dynamic new input field

I have code to add an input field dynamicly in my theme. I have testd it, as a metabox and it works. But, not in a widget. First add and update, that codes work, but when I refresh page or try to add more field and update it again, the oldest field will be replaced with a new one, whats wrong with my code?                   <?php     /**      * Adds TMD_Radio_Player.      */     class TMD_Radio_Player extends WP_Widget {              /**          * Register widget with WordPress.          */         function __construct() {             parent::__construct(                 'tmd_radio_player', // Base ID                 __('TMD Radio Player', 'text_domain'), // Name                 array( 'description' => __( 'Menampilkan radio player', 'text_domain' ), ) // Args             );         }              /**          * Front-end display of widget.          *          * @see WP_Widget::widget()          *          * @param array $args     Widget arguments.          * @param array $instance Saved values from database.          */         public function widget( $args, $instance ) {                  $title = apply_filters( 'widget-title', $instance['title'] );                  echo $args['before_widget'];                  if ( ! empty( $title ) )                 echo $args['before_title'] . $title . $args['after_title'];                  $stream_sources = isset( $instance['stream_sources'] ) ? $instance['stream_sources'] : array();                  // Your code here                  echo $args['after_widget'];         }              /**          * Back-end widget form.          *          * @see WP_Widget::form()          *          * @param array $instance Previously saved values from database.          */         public function form( $instance ) {             if ( isset( $instance[ 'title' ] ) ) {                 $title = $instance[ 'title' ];             }             else {                 $title = __( 'Radio Player', 'text_domain' );             };                  ?>
                 <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Judul:' ); ?>                  <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>">
                  <?php              $stream_sources = isset( $instance['stream_sources'] ) ? $instance['stream_sources'] : array();             $counter = 0;              if ( is_array( $stream_sources ) ) { ?>                 <?php foreach ( $stream_sources as $source ) {                     if ( isset( $source['title'] ) ) { ?>
                          <?php echo $counter; ?>                                                  <input class="widefat" type="text" id="<?php echo $this->get_field_id('stream_sources'); ?>[$counter][title]" name="<?php echo $this->get_field_name('stream_sources');?>[$counter][title]" value="<?php echo esc_attr( $source['title'] ); ?>">                                                       <input class="widefat" type="text" id="<?php echo $this->get_field_id('stream_sources'); ?>[$counter][url]" name="<?php echo $this->get_field_name('stream_sources');?>[$counter][url]" value="<?php echo esc_attr( $source['url'] ); ?>">                              <?php _e( 'Hapus', 'textdomain' ); ?>
                     <?php }                     $counter += 1;                 }             } ?>                  <span id="<?php echo $this->get_field_id( 'field_clone' );?>">
             <span class="<?php echo $this->get_field_id( 'add_field' );?> button button-primary button-large"><?php _e('Tambah Audio'); ?>
                               <?php          }              /**          * Sanitize widget form values as they are saved.          *          * @see WP_Widget::update()          *          * @param array $new_instance Values just sent to be saved.          * @param array $old_instance Previously saved values from database.          *          * @return array Updated safe values to be saved.          */         public function update( $new_instance, $old_instance ) {             $instance = $old_instance;                  $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';                  $instance['stream_sources'] = isset( $new_instance['stream_sources'] ) ? $new_instance['stream_sources'] : array();                  return $instance;         }          } // class TMD_Radio_Player          // register TMD_Radio_Player widget     function register_tmd_radio_player() {         register_widget( 'TMD_Radio_Player' );     }     add_action( 'widgets_init', 'register_tmd_radio_player' );


Custom Stylesheet instead of Inline CSS for Wordpress Customizer API Overrides

I've looked at Wordpress Customizer API and it looks to be able to achieve what I'm looking for; allowing the developer to set aside as many dynamic styles which can later be configured by the Wordpress admin. However, the recommended mechanism for injecting the styles is really not cool. All guides I've read online and from Wordpress recommend they be added inline to the Head of the document. With the popularity of such documents flooding the net I was unable to find a definitive guide on how to add these codes neatly to a stylesheet! Can get theme mod() be called from a PHP stylesheet? Sorry please bear with me as I'm just weeks into PHP and Wordpress documentation. Any suggestions would be nice I'm sure there are many developers who would not accept inline CSS.


WordPress 2.8.5 & 'Responsive Twenty Ten' - error

So, According to the WordPress theme download page; the theme 'Twenty Ten' and it's child theme/plugin 'Responsive Twenty Ten' are compatible with 2.8+ _I'm stuck with using 2.8.5 at work, I don't have an answer to why - but am._ I've uploaded both the plugin and the base theme manually - and was stoked to begin implementation of the graphical mock-up when;               Fatal error: Call to undefined function home_url() in /data/24/1/0/139/1815302/user/1967139/htdocs/wp-content/themes/twentyten 3/header.php on line 63      Anyone have any suggestions as to what causes this error and how to fix it? * * * Thanks for your response Chip; but I'm a little confused with your advice - Your advising me to edit the _header.php_ , but then your saying it will create more errors, so that's not really an option then? But your last suggestion seems like a good idea; how do I revert the theme to the old version? Is this something your suggesting I do in the code or is there a place I can download the old version? _**Edit:_** On the download WP page for the 'Responsive Child theme/plug in' it says it's WordPress 2.8+ compatible - the base version I downloaded didn't specify it's compatibility so it may very well be an updated version not compatible with 2.8 - though I feel like I've seen that theme for years, so hopefully I can find an older version and get it going with the child theme. -cheers!


Accessing the Posts page Content

I have a Posts page set in settings->reading - posts page is set to a page called "notes" How can I access the title, content & featured image of the page? WP seems to want to access the first post instead of the page.


boostrap on wp-admin backend via plugin installation

how can i add and use the twitter bootstrap to my wp-admin backend by a plugin installation approach? i plan to create multiple custom plugins and i just want to add bootstrap as a global style instead of using it per plugin this is my code, it doesnt seem to work.               <?php          /*      * Plugin Name: bootstrap      * Plugin URI: http://#/      * Description: add boostrap      * Author: some guy      * Author URI: http://#/      * Version: 0.1.0      */               function theme_name_scripts() {         wp_enqueue_style( 'style-name', get_stylesheet_uri() . '/custom/css/bootstrap.css');     }          add_action( 'wp_enqueue_scripts', 'theme_name_scripts' );          ?>


Exclude All Posts Which Do Not Have A Tag Assigned

Basically I have regular Category Listings that include posts WITH tags and posts WITHOUT tags. I need to modify the loop so that it ONLY includes posts which have one or more tags assigned to them. Is there a way do this? Thanks


use custom field value as post category in loop

I have a page template and at the bottom, I want a loop of posts based on a custom field value - store_name This is what I have:               <?php         global $wp_query;         $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;         query_posts(array('posts_per_page' => '10','paged'=>$paged,'category_name'=>'<?php echo get_post_meta($post->ID, 'store_name', true); ?>'));                     ?>      But of course that doesn't work because I know my syntax is incorrect with the nested php statement, but how do I fix it?


Posts not showing with custom categorybase and subcategories

Edit: Fixed. I had an error in my permlink structure. I have a problem with individual posts not showing with their URL. I have set a custom category base in Permlinks called 'story'. I have a blogpost category called 'chapters', which has a subcategory 'chapter-1'. Both category pages show fine, but when I want to go to the post (I have to, because I'm using the read more link) I get a 404 error, it can not find the post. The post does show on the category pages, but the actual link, which wordpress creates as: site.com/story/chapters/chapter-1/post-name/ doesn't work. It looks good to me, that's how I want the URL structure to be. What can I be doing wrong?


How to change background image from Wordpress Gallery

I am building a custom theme for a client in Wordpress: She wants the background to change when you click on a gallery thumbnail in a post. It must be a solution, that doesn't involve any coding on her end. >   * create new gallery in a post >   * » user clicks thumbnail >   * » swaps background image >   * » clicks another thumbnail >   * » changes background image again > Any help is much appreciated.


Add class to last 3 posts in loop

I have this code so far, which adds the classes first, second, and third to every first, second and third post in the loop. It also adds a class to the first 3 posts in the loop. But how can I make it so that it adds another class to the final 3 posts?               if (have_posts()) :      while (have_posts()) :          the_post();         $classes = array('themeview');         $classes[] = $style_classes[$counter % 3];         if ($counter < 3) $classes[] = 'top';         $class = sprintf('class="%s"', implode(' ', $classes));         $counter++     ?>     <li <?php echo $class?>>      Thanks!


wordpress post pagination with image buttons?

I'm trying to make a post pagination like this: `button left image | 1 2 3 4 5 |button right image` but I can't get it work. I've tried: `<?php wp_link_pages('before=<p>&after=</p>&next_or_number=number&pagelink= %'); ?>` But how to add images to the left an right as buttons? thx! AD


Multiple users editting widgets

I have just completed a website using WordPress as a CMS, the site has 6 people administering the content and in the couple of days before launch all 6 were updating the content. We found that if multiple people were editing/creating widgets at the same time this would save over and some of the widgets were deleted. I'm assuming this is because widgets are stored in a serialized array when the user is pressing save its adding an array which doesn't contain the widget the another user is editing. Obviously this can be a bit frustrating for the users so I was wondering if anyone else has had this problem and if there was a way to only allow one user to edit widgets at a time?


Will anyone buy a premium plugin that's available at GitHub?

I'm developing a WordPress plugin. I'd like to charge somewhat for it, because I'd like to be developing related things, for a living. I also want to make it easy for people to e.g. contribute patches and bug fixes. So I'm thinking about hosting the source code at GitHub. Does anyone host the source code for a premium plugin, or theme, at e.g. GitHub? Do people actually pay for that plugin?   Or do people share the link to the GitHub repo, and download via GitHub? Please note: I don't mind if some people download the source code without paying. But if everyone does that, and no one pays, then that'd be problematic, perhaps I'd have to get a "real" job. What if there was a _compilation and build step_ , so you could not use the source code directly. Then perhaps _most_ people would buy the plugin? So they'd get a downloadable .zip file that they understand how to use? (Instead of unusable source code.) (A _compilation step_? PHP? What? Well, I like Coffeescript better than Javascript. There's a compilation step from Coffeescript to Javascript: you'd need to open a shell and run `make dist` or something, and that would compile the Coffeescript code and build a .zip file.)


MAMP.app & .htaccess - Can't override after config

For whatever reason I can't seem to get my .htaccess file to work correctly on a local Wordpress install. What I'm trying to achieve is to have the themes assets paths rewritten as such:                RewriteRule ^img/(.*)$ wp-content/themes/cashed/img/$1 [L]      The current location to my images folder is:                wp-content/themes/cashed/img      and I'd like to change it to be                img/      I've read a few posts about having to configure MAMP to allow for .htaccess files and I feel like I've configured them correctly. I've edited the file: applications/MAMP/conf/apache/httpd.conf to have the following rules:                <Directory />          Options All          AllowOverride All          Order allow,deny          Allow from all       </Directory>      I've also restarted MAMP.app as well as my machine many times and for whatever reason I feel that MAMP is ignoring this .htaccess file which is stored in the root directory of my WP install. Any ideas?


Custom Post Types, URL rewrite on multiple CPTs

Re: Custom post types, taxonomies, and permalinks by @TheDeadMechanic The solution above works perfectly, and rewrite is great, but can you advise on how to rewrite for more than one custom post type with its own taxonomy? the code below works for taxonomy product cat under products, but adding another CPT with taxonomy gives 404 as it not included below, how can the code below be amended to cater for more than one CPT and taxonomy?               function filter_post_type_link($link, $post)      { if ($post->post_type != 'product_listing') return $link;               if ($cats = get_the_terms($post->ID, 'product_cat'))         $link = str_replace('%product_cat%', array_pop($cats)->slug, $link);     return $link;      } add_filter('post_type_link', 'filter_post_type_link', 10, 2); thanks in advance


Pagination/404 I believe wp is getting a page ahead of itself

My site is using the Faceted Search Widget upon reaching an archive page. The widget works fine provided you stay on the initial archive page, but if I try using it on the second page of the archive it works only if there are 8 or more entries to return, third page only if there are 16+. It almost seems as though when wp is figuring out what page it's on it's one ahead of itself. Here is a pastebin of my archive page. Any thoughts as to why this is happening/how to fix it? Pastebin with the faceted-search-widget


Strange behavior with pagination on custom query

I already have a knot in my brain and searched here and on the web, but I can't find any solution. I build a Custom Post Type with some Taxonomies and create a page template to get some of the posts of this CPT with this code               <?php         $object_query = array(             'paged' => get_query_var('paged'),             'post_type' => 'my_custom_post_type',             'post_status' => 'publish',             'posts_per_page' => 5             'tax_query' => array(                 'relation' => 'AND',                 array(                     'taxonomy'  => 'my_first_taxonomy',                     'field'     => 'slug',                     'terms'     => 'my_term'                 ),                 array(                     'taxonomy'  => 'my_second_taxonomy',                     'field'     => 'slug',                     'terms'     => 'my_term'                 )             )         );         $custom_query = new WP_Query( $object_query );         // Pagination fix         global $wp_query;         $original_query = $wp_query;         $wp_query = null;         $wp_query = $custom_query;         if ( $custom_query->have_posts() ) :             while ( $custom_query->have_posts() ) : $custom_query->the_post();                 the_title();             endwhile;         endif;         $big = 999999999; // need an unlikely integer         echo paginate_links( array(             'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),             'format' => '?paged=%#%',             'current' => max( 1, get_query_var('paged') ),             'total' => $custom_query->max_num_pages         ) );         // Reset query         $wp_query = null;         $wp_query = $original_query;         wp_reset_query();     ?>      So far so good - I got a list with 5 posts and the pagination shows (it's correct because there are 15 posts matching my query): " 1 2 3 Next » " Switching to the second page - either by clicking the number 2 or the Next- link - shows me the second page with another list of 5 post. The same for the third page. ## The problem Some posts are shown on page 1 and 2 and some posts are not listed anyway. The post listing on each page looks like this: **Page 1**   Post 3   Post 4   _Post 5_   _Post 6_   _Post 7_   **Page 2**   _Post 5_   _Post 6_   _Post 7_   Post 11   Post 12   **Page 3**   Post 9   Post 10   Post 13   Post 14   Post 15   The posts 5, 6 and 7 are on page one and two and the posts 1, 2 and 8 are missing. For a check if all posts listed correctly I changed               'posts_per_page' => -1      and get a correct list of all 15 posts - no duplicates and no missing posts. So I'm assuming my query works correct but something went wrong with the pagination (or the CPT). Therefore I started a testing on the standard post_type 'post' (without the tax_query parameter) and got a correct pagination. I can't figure out what's going wrong with my custom query on the CPT. Any help or advices are welcome. Thanks


Is there a way to make this kind of loop shorter and nicer?

Here is my loop code, i want to call **different page templates** for **different pages**. Please notice that this is a **one-page-layout**.               <?php $args = array( 'post_type' => 'page' );?>  <!-- get only pages -->          <?php query_posts($args); ?>          <?php while (have_posts()) : the_post(); ?>  <!-- loop with pages starts -->          <?php $id = get_the_ID(); ?>  <!-- get post/pageID -->           <?php   if ($id == 5) : include( get_stylesheet_directory() . '/page_special.php' );                  else: include( get_stylesheet_directory() . '/page_all.php' );                  endif;      ?>       Would it be possible to change the `if ($id == 5)` with `is_page` or sth like that?


Plugin De/Activation Not Firing On MultiSite install

I have a very rudimentary plugin in development, but at the point of needing to enable the `register_activation_hook()` and `register_deactivation_hook()` I have stalled. I am getting zero output from `error_log('it ran')` debugging statements. This plugin is going to be run on a multisite install (so I am developing it on a multisite install). I need to create a custom table for the business logic of the work, but until I can get this hook happy I am getting nowhere. Interestingly, if I **Network Activate** this same plugin, the site locks me out with a " _You do not have permission to access this page._ " message. I have to clear the `wp_sitemeta` option: `active_network_plugins` to get back on the site again. I'm praying someone hears a bell ringing with this description and ca straighten me out quickly.


RSS feed not displaying excerpt text?

I am attempting to fix my RSS feed and have implemented the following code below in my `functions.php`. How do I go about getting the excerpt text to display in this RSS feed? The following code seems to be working as the featured image is now showing up in my feed (for example at: example.com/feed).               #----------------------------------------------------------------------------------------     # Customize RSS Feed     #----------------------------------------------------------------------------------------          function featuredtoRSS($content) {         global $post;         if (has_post_thumbnail($post->ID)) {             $content = get_the_post_thumbnail($post->ID,'thumbnail') . get_the_excerpt($post->ID);         }         return $content;     }          add_filter('the_excerpt_rss', 'featuredtoRSS');     add_filter('the_content_


How to find out which template the HTML content comes from?

At my page, I want to change the text "next" and "previous" at the bottom of the page, but I can't figure out which PHP template it derives from. I tried searching the classes that was connected to the object, but without luck. Is there any developer tool or plugin, that could be of any help?


Random Category with Recent Post Title and Thumbnail

This code below works perfect to pull the title of five random categories, the issue is for each random category I want the latest post title and thumbnail but where and how do I add the post query?               <?php     //display random sorted list of terms in a given taxonomy     $counter = 0;     $max = 5; //number of categories to display     $taxonomy = 'category';     $terms = get_terms($taxonomy);     shuffle ($terms);     //echo 'shuffled';     if ($terms) {     foreach($terms as $term) {         $counter++;         if ($counter <= $max) {         echo '
term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $term->name ) . '" ' . '>' . $term->name.'
 ';         }     }     }     ?>


do_action( 'init' ) in wp-settings.php breaks my website. All plugins and themes disabled

As the title says, do_action( 'init' ) in wp-settings.php breaks my website. All plugins and themes have been disabled. Basically if I comment out line 308 which is simply `do_action( 'init' );` then the site works fine, but if I enable that line, I see just a white page, no HTML in the source at all. I've disabled all plugins and themes. How do I continue troubleshooting from here? UPDATE: The problem is due to a bad cron job, the output of my list of cronjobs is here:               FUNCTION                        ARGUMENTS               SHEDULE TIME (H)     wp_scheduled_auto_draft_delete  array ( )               Once Daily  24     wp_scheduled_delete             array ( )               Once Daily  24     publish_future_post             array ( 0 => 43169, )   not-set     wp_version_check                array ( )               Twice Daily 12     wp_update_plugins               array ( )               Twice Daily 12     wp_update_themes                array ( )               Twice Daily 12     do_pings                        array ( )               not-set     sm_build_cron                   array ( )               not-set      The function sm_build_cron is from the plugin google-sitemap-generator and the function referenced it:   Action:               //WP Cron hook     add_action('sm_build_cron', array('GoogleSitemapGeneratorLoader', 'CallBuildSitemap'),1,0);      Function:               function CallBuildSitemap() {           if(GoogleSitemapGeneratorLoader::LoadPlugin()) {               $gs = &GoogleSitemapGenerator::GetInstance();               $gs->BuildSitemap();         }     }


Display custom post function ONLY if it has a value

How do I get the following code to insert a link only if the custom function has a value?               <a href="<?php echo esc_html( get_post_meta( get_the_ID(), 'game_review_link', true ) ); ?>"><div class="rating-<?php echo esc_html( get_post_meta( get_the_ID(), 'game_rating', true ) ); ?>"><?php echo esc_html( get_post_meta( get_the_ID(), 'game_rating', true ) ); ?>
	      Basically I'm trying to link a review score to a review but if a review hasn't been written I don't want a link to appear. Thanks in advance.


woocommerce download post-types\writepanels limits?

How can I change these codes so that the download limits are set and no one can change them on the add product side? Or hide them, so no one can see them?               // Download Limit     woocommerce_wp_text_input( array(          'id' => '_download_limit',          'label' => __( 'Download Limit', 'woocommerce' ),          'placeholder' => __( 'Unlimited', 'woocommerce' ),          'description' => __( 'Leave blank for unlimited re-downloads.', 'woocommerce' ),          'type' => 'number',          'custom_attributes' => array(             'step'  => '1',             'min'   => '0'         )      ));          // Expirey     woocommerce_wp_text_input( array(          'id' => '_download_expiry',          'label' => __( 'Download Expiry', 'woocommerce' ),          'placeholder' => __( 'Never', 'woocommerce' ),          'description' => __( 'Enter the number of days before a download link expires, or leave blank.', 'woocommerce' ),          'type' => 'number',          'custom_attributes' => array(             'step'  => '1',             'min'   => '0'         )      ));          do_action( 'woocommerce_product_options_downloads' );          echo '</div>';


How to Generate html tags using shortcodes?

I am using a widget and adding this:

[acf field="testimonial" ]     [acf field="name" ]

[acf field="testimonial_2" ]     [acf field="name2" ]

      The issue is that I am getting empty tags when there are NO testimonials, and thus some styling is being picked up in the empty tags. I've messed around with some css/jquery, but I am thinking it's probably better to actually generate the html tags as well but I am not sure how to go about that. Is there a way to generate tags using shortcodes? I wouldn't know how to do this but I was thinking an if statement in loop, get_field(); would work too? Any ideas are appreciated.


Open a single linked image with popup/modal

on my wordpress blog I have some text and a word is a link to an image. At the actual state of things, when the link is clicked the image is shown by itself, outside of my website. I would like that the image opens on a popup/modal layer over the website itself instead. The image has an absolute url now, but I could place it on the wordpress gallery, if it helps to solve the issue. I have tried NextGen gallery, but so far I was unable to find a way to link a single image with popup/modal to a linked word inside a paragraph. How can I solve my issue? thanks a lot for the answers.


How to group navigation items in the admin panel

I have more than 50 custom post types which I have created using the Pods plugin. The problem is that the left navigation of the admin panel looks really busy and messy and it takes a lot of time for me to get to the needed CPT. Lots of the CPTs are related to each other, so it would be much cleaner if I created top-level navigation items that includes multiple CPTs. I've looked for any plugin that does this and I didn't find anything. Can you please recommend a plugin that does this, or if there is a way to use WordPress hooks to code this functionality? Please keep in mind that the default navigation of WordPress consists of two levels, and I need them to be 3. The default state is that the second level is a menu that appears when you hover over the parent item. And when they are 3 levels in the updated version, the 3rd level also will need to be a menu that appears when you hover over the 2nd level menu item. The 1st level in the 3 levels menu doesn't need to be hyperlinked.


Filtering all posts AND sticky posts through meta_query

I have a filter that filters posts from the main loop depending on a user role (handled externally) The meta data is entered when adding a post/page. This is the filter - it works for filtering posts from the main page loops and the search pages but **sticky posts** are ignored and will show regardless of user role. Are these not included in the main_query?               add_filter( 'pre_get_posts', 'hide_private_posts' );          function hide_private_posts( $query ) {          $loggedInArray  = array(                       'key' => 'smartPrivate',                       'value' => 'smartPrivate_loggedIn',                       'compare' => '!='                 );     $mentorArray    = array(                       'key' => 'smartPrivate',                       'value' => 'smartPrivate_loggedInMentors',                       'compare' => '!='                 );          // If user isn't logged in, hide all private posts / pages     if( !is_user_logged_in() ) {              if ( $query->is_main_query() || $query->is_feed() ) {                  $query->set( 'meta_query', array(                      $loggedInArray,                 $mentorArray                  ));         }          // If user is logged in but a learner, show logged in posts / pages     } else if( is_user_sso_role( array('learner') ) ) {              if ( $query->is_main_query() || $query->is_feed() ) {                  $query->set( 'meta_query', array(                      $mentorArray                  ));         }          }          return $query;     }


"paged" in WP_Query returns 0 posts

If i don't supply a `paged` value (get the first page), it works. But when i try to get the next page by doing `paged => 2` it doesn't find anything even though there are plenty of posts to get. That's the first page showing the first ten posts. It works fine. If you scroll to the bottom and open the "Ladda fler" link in a new tab (otherwise it will ajax it), it doesn't find anything. At the top of the page you see the arguments i pass to WP_Query, for debugging purposes. As you can see, on page two i also pass `paged => 2` which returns nothing. Is there something more i need to supply? Am i missing something?


Same Loop on Multiple Pages

I have my main loop (loop-entry.php) pulling to my index page which is my homepage on this site: http://snippetmagazine.com/ when I tried to copy that loop and create (loop-blog.php) and included it on this page: http://snippetmagazine.com/blog with a custom page template nothing will pull. Here is the page template for the "inner page"               <?php     /**      * @package WordPress      * @subpackage portabellopixie Theme      * Template Name: Blog      */     ?>     <?php get_header(); ?>     <?php if (have_posts()) : ?>
         <?php get_template_part( 'loop', 'blog') ?>
     <?php get_sidebar(); ?>     <?php pagination(); ?>     <img src="<?php bloginfo('template_directory'); ?>/images/sew.png" alt="" /><img src="<?php bloginfo('template_directory'); ?>/images/classes.png" alt="" /><img src="<?php bloginfo('template_directory'); ?>/images/start_art.png" alt="" />     <?php endif; ?>     <?php get_footer(); ?>      My loop for both pages looks like this:               <?php     //design for pages     if ( get_post_type() == 'page') { ?>              <div class="loop-entry clearfix <?php if($count =='2') { echo 'remove-margin'; } ?>">
<a href="<?php the_permalink(' ') ?>" title="<?php the_title(); ?>"><?php the_title(); ?>
             <?php the_excerpt(); ?>
          <?php } else { ?>     <div class="loop-entry clearfix <?php if($count =='2') { echo 'remove-margin'; } ?>">              <?php if ( has_post_thumbnail() ) {  ?>
                 <a href="<?php the_permalink(' ') ?>" title="<?php the_title(); ?>"><?php the_post_thumbnail('post-image'); ?>
         <?php } ?>
<a href="<?php the_permalink(' ') ?>" title="<?php the_title(); ?>"><?php the_title(); ?>

             <?php _e('Posted On','portabellopixie'); ?> <?php the_time('j'); ?> <?php the_time('M'); ?>, <?php the_time('Y'); ?> - <?php comments_popup_link('0 Comments', '1 Comment', '% Comments'); ?>
             <?php the_excerpt(''); ?>
          <?php } ?>                    <?php if($count =='2') { echo '

'; $count=0; } endwhile; ?>


Wordpress gallery image link gives 404 when not logged in

I'm attempting to use the default Wordpress gallery (from the post editor '`Add Media`' then '`Create Gallery`'). When logged in as an admin and clicking an image in the gallery on the resulting blog page will correctly link to the attachment page for the clicked image. However when logged out, clicking an image in the gallery will result in a 404. The URL is the same in both cases (something like `<my_wordpress_site>.com?attachment_id=2408`) What could be causing this, and is there a way this could be fixed, so the attachment url loads correctly when logged out?


get menu id using its name

I have a menu name `Social Network`. I want to get the menus ID. I tried the following, but didn't succeed.                 global $wpdb;     $menu_slug = 'social-network';     $menu_id = $wpdb->get_results(         "         SELECT TERM_ID         FROM $wpdb->wp_terms         WHERE name = ".$menu_slug."         "     );     echo $menu_id;


Wordpress built in custom fields don't validate or sanitize? Is there a way to fix this?

I'm surprised to see that when creating post meta using the default/built in custom fields on the post editor page it allows you to enter tags like:               <a>,<script>,etc.       I then realized you can also enter:               <script> </script>       into the post content box. Is there a way to hook into the validation and make it so that script can't be entered? Am I wrong in thinking that a hacker with access to the backend could use the fields to get malicious script to the database? I guess I'm just a bit confused because when using the settings api ( or even creating custom metaboxes ) there's so much emphasis put onto proper validation/escaping. Yet, on post pages you can enter whatever you want? Thanks!


Do plugin files have to follow a specific convention to be "picked up" by WordPress?

I developed a plugin using the normal convention of naming the main plugin file after the plugin folder (i.e. `prefix-someplugin` for the folder and `prefix-someplugin.php` for the file). However, I saw some plugins that use the following structure:               prefix-someplugin      - plugin-loader.php // This file just loads src/prefix-someplugin.php      - /src         - prefix-someplugin.php      Obviously, if they used such structure, it means that it works. The issue is that I'm not sure **how** it works, hence my question. How does WP know which file to load as the main plugin file? I would have assumed that it looked for a file named after a folder, just adding `.php` as an extension, but it seems I was wrong. Does WPjust scan `wp-content/plugins` for folders, and loads all the files it finds in them, or does it follow a different logic? Thanks in advance for the answers.


Query "Category A" + 1 post from "Category B" - how?

It's pretty easy to query posts from one category but what if I need also one single post from another category?               $query = new WP_Query( 'cat=4' );      I'm looking for something like this:               $query = new WP_Query( array( 'cat' => 4, 'post__in' => array( 20 ) ) );      But the above code will not return anything because there are not posts with an ID of 20 in category 4. I'm wondering if anyone has any idea how this could be done.


Failing to load my script files in wordpress! i can't figure out what i'm doing wrong

i have customized my .html as a custom wp theme. i have these scripts in my header.php:               <script type='text/javascript' src="scripts/jquery-1.8.2.js"></script>     <script type='text/javascript' src='scripts/jquery.easing.1.3.js'></script>     <script type='text/javascript' src='scripts/jquery.hoverIntent.minified.js'></script>      <script type='text/javascript' src='scripts/diapo.js'></script>     <script type="text/javascript" src="scripts/scripts.js"></script>          <!--[if !IE]><!--><script type='text/javascript' src='scripts/jquery.mobile-1.0rc2.customized.min.js'></script><!--<![endif]-->          <!-- html5.js for IE less than 9 -->     <!--[if lt IE 9]>     <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>     <![endif]-->      I am really new in all these wp customization stuff and i am struggling through dozens of tutorials by great minds out there sharing their knowledge. after a quite long search before posting here, i see that the right way including these files is registering and queuing them inside my functions.php file. so, my "functions.php" has this:               function load_javascript_files() {          //Register the script like this for a theme:     wp_register_script('easing', get_template_directory_uri() . 'http://gsgd.co.uk/sandbox/jquery/easing/jquery.easing.1.3.js', array('jquery'), '1.3', true);     wp_register_script('hoverIntent', get_template_directory_uri() . '/js/jquery.hoverIntent.minified.js', array('jquery'), true);     wp_register_script('jquery-mob-custom', get_template_directory_uri() . '/js/jquery.mobile-1.0rc2.customized.min.js', array(jquery), true);     wp_register_script('home-page-slideshow', get_template_directory_uri() . '/js/diapo.js', array('jquery'), true);     wp_register_script('custom-script', get_template_directory_uri() . '/js/custom-script.js', array('jquery'), '1.0', true);               wp_enqueue_script('easing');     wp_enqueue_script('hoverIntent');     wp_enqueue_script('custom-script');          global $is_IE;          if ( $is_IE ) {     wp_enqueue_script('jquery-mob-custom');     }          if(is_front_page()) {         wp_enqueue_script('home-page-slideshow');     }     }     add_action('wp_enqueue_scripts', 'load_javascript_files');          ?>      Any help of understanding what i am doing wrong here is really appreciated


Having WordPress control only certain pages with .htaccess?

Building a site that we want the home page controlled by it (main page will be the main blog page as well as the site home); it should also control a couple other pages such as the contact us page and the about us page. However, we don't want it to control any of the other pages. Seems easy enough, but problem is wouldn't wordpress' rewrite code in the `.htaccess` file take control of all pages in the root of the site? We want to control the other pages ourselves via .htaccess and currently use this rewrite code in our .htaccess file..               RewriteEngine On     Options +FollowSymlinks     RewriteBase /     RewriteRule ^browse/([0-9]+)/[a-zA-Z-]+/? browse.php?sport_id=$1     RewriteRule ^browse/([0-9]+)/([0-9]+)/[a-zA-Z0-9-]+/? browse.php?sport_id=$1&year_id=$2&type=set     RewriteRule ^set/([0-9]+)/[a-zA-Z-]+/[a-zA-Z0-9.-]+/([a-z_]+)/? set.php?set_id=$1&type=$2      However if we moved the site to WordPress how can we continue to make use of this without WordPress overriding it? Additionally, even if we were able to overwrite it, I'm concerned about the code being wiped if WordPress regenerates it's .htaccess file for some reason. Is it possible to do what we want to do? Only thing I can think of is storing WordPress in a sub-directory but then doing some rewrite code that rewrites people that go to certain pages such as the home page of the site to the sub- directory where WP is installed?


Custom header shows two or three or more images

Is there is a way to make the custom header to show more than one image in a random show without duplicate images. I tried something like this:               <?php $header_image = get_header_image();         if ( ! empty( $header_image ) ) : ?>             <a href="<?php echo esc_url( home_url( '/' ) ); ?>">

<img src="<?php echo esc_url( $header_image ); ?>" class="header-image" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="" />

<img src="<?php echo esc_url( $header_image ); ?>" class="header-image" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="" />

                          <?php endif; ?>      But dose not work - Any advice please? Want something like this in the latest wordpress Version 3.5.1 ![enter image description here](http://i.stack.imgur.com/CkuXi.jpg) and want to make every image change with random without duplicate


Duplicate homepage to show posts from 1 category

I'm trying to accomplish the following: I wan't to display all posts from a certain category on a page that has the same layout as the homepage of the actual blog. I found the following online to display posts for the category `<?php $recent = new WP_Query("cat=797&showposts=30"); while($recent->have_posts()) : $recent->the_post();?>` but I don't know a) should I just take my index.php and edit the loop to the above b) where should I place this new file? in the root of my WP install or in the themes folder? EDIT 1: My homepage is a regular "archive" showing the latest posts for any category The current loop starts with                   <?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>            <?php global $ar_ID; global $post; $ar_ID[] = $post->ID; ?>      Entire index.php is here


How can i call the facebook #hashtag images on my site

Can Any one tell me the way for facebook #hashtag images to get on my site site is in wordpress I am getting image from instagram which are posted there with # tag like #test then all the images with this tag i am geting but i want to know any plugin or core api code by which i able to get the all images which added the # tag #test on my site


Toolbar/topbar missing on homepage only?

My theme seems to have the `<?php wp_footer() ?>` and `<?php wp_head() ?>`, yet it's still not showing on the homepage of my site. However, it is visible on all other pages and posts.


sweet custom dashboard link customize

I am using the sweet custom dashboard plugin. When I go to the dashboard then it shows this `example.com/wp-admin/index.php?page=custom-dashboard` type of link. But I want to show `example.com/wp-admin/dashboard`, or I want to change it somehow. How could I do that? `sweet-custom-dashboard.php` code:               // plugin folder url     if(!defined('RC_SCD_PLUGIN_URL')) {         define('RC_SCD_PLUGIN_URL', plugin_dir_url( __FILE__ ));     }          /*     |--------------------------------------------------------------------------     | MAIN CLASS     |--------------------------------------------------------------------------     */          class rc_sweet_custom_dashboard {              /*--------------------------------------------*          * Constructor          *--------------------------------------------*/              /**          * Initializes the plugin by setting localization, filters, and administration functions.          */         function __construct() {                  add_action('admin_menu', array( &$this,'rc_scd_register_menu') );             add_action('load-index.php', array( &$this,'rc_scd_redirect_dashboard') );              } // end constructor              function rc_scd_redirect_dashboard() {                  if( is_admin() ) {                 $screen = get_current_screen();                      if( $screen->base == 'dashboard' ) {                          wp_redirect( admin_url( 'index.php?page=custom-dashboard' ) );                      }             }              }                        function rc_scd_register_menu() {             add_dashboard_page( 'Projukti Chowa Dashboard', 'Projukti Chowa Dashboard', 'read', 'custom-dashboard', array( &$this,'rc_scd_create_dashboard') );         }              function rc_scd_create_dashboard() {             include_once( 'custom_dashboard.php'  );         }               }          // instantiate plugin's class     $GLOBALS['sweet_custom_dashboard'] = new rc_sweet_custom_dashboard();          ?>


Only show div on homepage/blog index in wordpress/php

I have a wordpress site. I have a div that I only want to appear on the homepage (in the header). What type of php if statement do i need... In other words: only show .... in the header of the main blog index page. Problem is the header itself is loaded in every page. Thanks!


Posts 2 Posts plugin: best way to change connection field value?

I have started to use posts-to-posts plugin by scribu, and now I need to change vaues for connection fields. Particularly, I've created 'person' and 'piece', connection 'role' in between and defined possible values for role as 'composer', 'conductor' -- but now I think that I need rather 'author', not 'composer'. Please, how to do that? I could experiment with phpmyadmin, but I wouldn't like to loose anything in progress. Thanks!


do more action after wordprss login successfully

I have a simple requirement, after user login set the login user session and then redirect to another page. Yes, I found some similar page from here is-there-a-hook-that-runs-after-a- user-logs-in As the post said, what I need to do is like this:               function set_blog_session(){         $_SESSION['blogger'] = get_current_user_id();         wp_redirect("http://www.google.com");//just for test     }     add_action('wp_login', 'set_blog_session');      But I got nothing. First, `get_current-user_id()` always returns `0`.   Second, **no redirect at all**. Whats going wrong?


how to change automatic placing of social plugins below content?

I'm wondering if it possible to change the automatic place below the_content() function; this is becuase I`m displaying custom information fields, but activating the social plugins which have not it´s own implementation code, the social bar or facebook commnents appears between the content and the custom fields, so important values are below the social content :/ can be created another hook to point the content of plugins? :) probably I have to modify the plugin Simple Facebook Comments


Show one same template for two category

I want to show `gallery.php` template for category. I am currently using `category-15.php` and `category-19.php` technique. I want to redirect category 15 and 19 to `gallery.php` instead (one template for two category). And I want to use a simpler technique. It can be by using `functions.php`. How can i do it?


Can't pass variable in wordpress wpdb->get_results

I wanna pass a variable, but always get the error message > Invalid argument supplied for foreach()... Here is my code:               function second($taxonomies)     {         global $wpdb;         $result = $wpdb->get_results( "SELECT * FROM tblTest WHERE manufacturer = $d", $taxonomies);         foreach ($result as $pointer) {         $id = $pointer->id;         $car = $pointer->car;         $price = $pointer->price;         echo $id." ".$car." ".$price."<br />";         }       }      And how can I pass the result to another drop down? Thanks in advance!


Multiple templates for single custom post type

Does anybody know of a way to modify the wordpress template process so that a single custom post type can be displayed on two separate templates based on the value of a custom field. For example I have a single Custom Post Type called "plans" It is using the single-plans.php and archive-plans.php files as templates by default. What I would like to do is use this bit of code to filter out some of the results within my loop.               <?php //Filter the results based on the presence of $var        $var = get_post_meta($post->ID, 'my_custom_field', true);         if($var !== '') { ?>           THE LOOP         <?php } ?>      This works fine but i need create two separate templates where I can test for separate $var so I can have two menu items that each call on a separate version of the template and get a unique set of results from my single CPT Thanks, Eric


How to remove screen options and help links in the admin area?

I would like to remove screen options and help links in my admin area. How to remove that thing?. This is what i want to be removed. ![enter image description here](http://i.stack.imgur.com/hR9ik.png) Thanks.


A plugin popularity data inside "install new plugin"

Where i can find a plug-in that can show in wordpress "/wp-admin/plugin- install.php" the download count of each plug-in?


Why is my content missing from homepage?

On my website http://filmblurb.org, all the posts and everything on my home page are missing. Can you anybody tell me how to fix this? Thanks! (If it helps, I'm using Wordpress 3.2.1.)


adding plugin settings link upon activation

Here I want to have upon activation of my wordpress plugins activation Before Activation               Activate | Edit | Delete      After Activation               Settings | Edit | Delete      How can this be done in code to add this Menu


Efficiency on displaying random authors based on large database

I'm trying to display a list of 5 authors **randomly**. Here are some solutions I had found: http://stackoverflow.com/questions/5502609/get-authors-randomly http://wordpress.stackexchange.com/a/91326/1044 I'm currently using the former solution except that I use `WP_User_Query` like so:               $args  = array(         'role' => 'subscriber'     );     $wp_user_query = new WP_User_Query($args);     $authors = $wp_user_query->get_results();          // Shuffle list to get random results     shuffle($authors);      However, to my _amateurish_ understanding, this **will fetch the whole list of users**. So I'm just wondering if I had around **2000-5000 users (or more)** , will this affect **page load** drastically? how can I make this more efficient? **UPDATE:** Also would `array_rand()` be a more efficient method compare to `shuffle()`?


How to Wrote Simple Calculations by Using Custom Fields in Loop?

I am building a website with whole bunch of custom fields and need to implement several custom fields that will auto calculate values by using values from other custom fields. All files which I need to use in these calculation are in loop, so I would love to use hooks in functions.php. Can somebody give me few examples on how to wrote filters with some simple calculations so I could continue writing filters for different problems I need to solve, like: * * * **Example 1: Sum 2 Numbers**               Custom Field 1: product_price     Custom Field 2: addon_price     Custom Field 3: price_total      **Formula:**               price_total = product_price + addon_price      * * * **Example 2: Add commision on price**               Custom Field 1: product_price     Custom Field 2: tax_commision - [%]     Custom Field 3: price_total      **Formula:**               price_total = product_price + ( tax_commision / 100 ) * product_price


Can I dynamically create duplicate fields with the Settings API?

I'm not sure that my title accurately explains what I'm trying to do, but it's the best way I could think of to explain what I'm attempting to do. I'm writing my first Wordpress plugin, and while it's been a huge learning experience so far, I've found myself stuck. Basically, the plugin adds a shortcode, `[routes_and_schedules_accordion]` that generates a jQuery accordion that's a more fleshed-out version of this:

Route 1 - Market Street

           Current Schedule

      After a **lot** of reading, I've created an options page with the Settings API that lets me change the name of the route and the URL to its schedule (we're a small bus agency):               <?php $options = get_option('routes_and_schedules_accordion_settings') ?>

<?php echo $options['route_name'] ?>

           <a href="<?php echo $options['route_current_schedule_url'] ?>">Current Schedule

      What I'm really struggling with is making it so that new routes can be added. The goal is for the options page to have a way of adding and removing routes, and for the shortcode to spit out something like this:               <?php $options = get_option('routes_and_schedules_accordion_settings') ?>

<?php echo $options['route1_name'] ?>

           <a href="<?php echo $options['route1_current_schedule_url'] ?>">Current Schedule

<?php echo $options['route2_name'] ?>

           <a href="<?php echo $options['route2_current_schedule_url'] ?>">Current Schedule

      I guess I could just make new fields each time the number of routes changes and update the plugin every single time, but that would be a lot of work, and I know that there has to be better way. If someone could point me in the right direction, I would greatly appreciate it!


attachments with tags and get_posts

having problems with filtering a posts attachments by tag... It worked fine until i added the tag__in arg (and other variations of it).               $vidArgs = array(                                 'tag__in' =>5,                                 'post_type' => 'attachment',                                 'post_parent' => $post->ID,                                 'post_mime_type'=>'video/quicktime',                                 'posts_per_page'=>20                             );          $videos = get_posts($vidArgs);          foreach ($videos as $vid) { ///....      pointers / advice appreciated! **UPDATES** it is odd. It just doesn't work with media tags! Added _testtag_ to a post and it comes up. There must be a way to get attachments by tags? Otherwise what's the point? The functionality is in wp admin from the Media Tags pane...               $argsc = array(         /* 'tag' => 'commercials,testtag',  */         'tag__in' => array(5,11),         'post_type'=>array('post','page','attachment'),         'post_status'=>'any',         /* 'post_parent'=>$post->ID, */         'posts_per_page'=>20     );          $the_queryB = get_posts( $argsc);          echo count($the_queryB).", <pre>";     print_r($the_queryB);


Listing of all site options in dashboard

I know that I can visit `/wp-admin/options.php` on a single install (or on a sub-site on a multisite install), and it will give me a formatted list of all of the options in the site's `{prefix}opitions` database table. How can I achieve a similar list in the network dashboard for the `{prefix}sitemeta` table?


Custom wp_query - I'm getting 'all' post, not the specific post in the query

Get all post from today, that are of post type 'product' and are in the taxonomy of 'productType' as 'Indica' and in the taxonomy of 'locationCity' as 'Los Angeles' -- However, I get 'all' the post with no regards to the query params of the custom taxonomies.               // args     $today = getdate();          $indicaArgs = array(              'post_type' => 'product',             'productType' => 'Indica',              'locationCity' => 'Los Angeles',             'posts_per_page' => -1,              'post_status' => 'publish',             'date_query' => array(                                 array(                                     'year'  => $today["year"],                                     'month' => $today["mon"],                                     'day'   => $today["mday"],                                 ),                               )     );     // The Query     $query1 = new WP_Query($indicaArgs);


Only loads on the contact template page

In the footer i load the Google maps api. But only on the contact page, i used the google maps api. Now i want to make code. That the google maps api is only load in the contact template pages. How can i make that. This is the script tag in the footer.                <script type="text/javascript" src="//maps.google.com/maps/api/js?v=3&sensor=false"></script>      That script tag. Must only load in the template contact page. Thank for helping


Check user's role and store in variable

I am using **custom user roles** which I create and assign by using a plugin. I was wondering how I could retrieve the user's role and store it in a PHP variable. What I am trying to achieve is something like this: Let's say I created 3 custom user roles: `role_apple`, `role_banana` and `role_carrot`               if ( 'role_apple' === $user_role ) {         echo 'User is an apple';     }     elseif ( 'role_banana' === $user_role ) {         echo 'User is a bannana';     }      How this can be achieved?


Programmatically change post templates?

> **Possible Duplicate:**   >  Wordpress - Programmatically change post templates? I need to change the template on several hundred pages on my site. Does anyone know if there is a command to do it programmatically? See the following code snippet; I'd like to replace my comment inside the loop with a function that will change the template of the current page:               query = new WP_Query($args);     while ( $query->have_posts() ) : $the_query->the_post();       if ( has_tag('tag-slug') )       {          /* CHANGE TEMPLATE OF $post */       }     endwhile;     wp_reset_postdata();


Is it possible to move wordpress out of webroot?

Is there a way to put the wordpress out of webroot dir, and just leave a entry index.php to the webroot?


Using $themename Variables

Is it a bad idea to set your themename and shortname as variables to be used in the various functions of a theme? Example:               $themename = mytheme;     $shortname = mth;          /**      * Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.      */     function toolbox_page_menu_args($args) {         // some code     }     add_filter( 'wp_page_menu_args', $themename . '_page_menu_args' );


Contact Form in sidebar

I have a Contact Form 7 form as a page on my site. I'd like to place the contact form on the sidebar. How can I do this?