title: shortcode for recent custom type post

text:
I'm not a coder so I may have done some "coding" crimes, apologies. I've bought a theme who has shortcodes for last posts but not for last "custom post type". So I tried to create last "custom post type" function modifying the Last post function provided. Last post funtion:               function get_custom_posts( $params ) {     extract( shortcode_atts( array (         'number' => '1',         'excerpt' => 290,         'readmore' => 'no',         'readmoretext' => 'Read more'     ), $params ) );          //$latest_posts = get_posts( 'category=0&numberposts=' . $number . '&suppress_filters=false');     OLD     $latest_posts = query_posts( 'cat=0&posts_per_page=' . $number );     wp_reset_query();          $result = '
';     $count = count($latest_posts);     foreach ($latest_posts as $key => $latest_post) {       $author = get_the_author_meta('nickname', $latest_post->post_author );       $post_link = get_permalink( $latest_post->ID );       $date = mysql2date(get_option('date_format'), $latest_post->post_date);       $category = get_the_category_list( ', ', $parents = '', $latest_post->ID );            $result .= '

';       // POST THUMBNAIL       if (get_the_post_thumbnail( $latest_post->ID, 'thumbnail' )) {           $result .= '
';           $result .= '';           $result .= get_the_post_thumbnail( $latest_post->ID, 'thumbnail' );           $result .= '';           $result .= '
';       }            // POST BODY       $result .= '
';       $result .= '

' . $latest_post->post_title . '

';       if ( $latest_post->post_excerpt ) {           $result .= '
' . $latest_post->post_excerpt . '
';       }       else {           $limit = $excerpt;           $my_text = substr($latest_post->post_content, 0, $limit);           $pos = strrpos($my_text, " ");           $my_post_text = substr($my_text, 0, ($pos ? $pos : -1)) . "...";           $read = "";       if($readmore == 'yes'){         $read = ' '.$readmoretext.'';       }           $result .= '
' . strip_tags($my_post_text) . $read . '
';           //$result .= '
' . substr_replace( $latest_post['0']->post_content, '...', 350 ) . '
';       }            $result .= '
';            if ($count - 1 != $key)       $result .= do_shortcode('[rule]');            $result .= '

';     }     $result .= '
';          return $result;     }     add_shortcode( "get_posts", "get_custom_posts" );      Then I tried to modify it like this, (my custom post type is ait-dir-item):               function get_custom_items( $params ) {     extract( shortcode_atts( array (         'number' => '1',         'excerpt' => 290,         'readmore' => 'no',         'readmoretext' => 'Read more'     ), $params ) );          //$latest_posts = get_posts( 'category=0&numberposts=' . $number . '&suppress_filters=false');     OLD     $latest_items = WP_query( 'post_type' = 'ait-dir-item', 'cat=0&posts_per_page=' . $number );     wp_reset_query();          $result = '
';     $count = count($latest_items);     foreach ($latest_items as $key => $latest_item) {       $author = get_the_author_meta('nickname', $latest_item->post_author );       $post_link = get_permalink( $latest_item->ID );       $date = mysql2date(get_option('date_format'), $latest_item->post_date);       $category = get_the_category_list( ', ', $parents = '', $latest_item->ID );            $result .= '

';       // POST THUMBNAIL       if (get_the_post_thumbnail( $latest_item->ID, 'thumbnail' )) {           $result .= '
';           $result .= '';           $result .= get_the_post_thumbnail( $latest_post->ID, 'thumbnail' );           $result .= '';           $result .= '
';       }            // POST BODY       $result .= '
';       $result .= '

' . $latest_item->post_title . '

';       if ( $latest_item->post_excerpt ) {           $result .= '
' . $latest_item->post_excerpt . '
';       }       else {           $limit = $excerpt;           $my_text = substr($latest_item->post_content, 0, $limit);           $pos = strrpos($my_text, " ");           $my_post_text = substr($my_text, 0, ($pos ? $pos : -1)) . "...";           $read = "";       if($readmore == 'yes'){         $read = ' '.$readmoretext.'';       }           $result .= '
' . strip_tags($my_post_text) . $read . '
';           //$result .= '
' . substr_replace( $latest_item['0']->post_content, '...', 350 ) . '
';       }            $result .= '
';            if ($count - 1 != $key)       $result .= do_shortcode('[rule]');            $result .= '

';     }     $result .= '
';          return $result;     }     add_shortcode( "get_items", "get_custom_items" );      Of course, this function doesn't work... Can someone help me? I want to modify this function instead of installing a plugin because I want to use the same classes so I will have the same design for both shortcodes. Thanks in advance!


title: Custom user registration shortcode - redirect header issue

text: I've created a custom shortcode that calls a function which will produce a registration page. Registration works. No issue here. The issue I am having is to log the user in after a successful registration. I understand the reason I am getting `header already sent error` is because the shortcode is loaded after the header information. What is the best way to redirect or log the user in within a shortcode `add_action( 'user_register', array($this,'auto_login_new_user'), 10);`               function auto_login_new_user( $user_id ) {         // exit($user_id);         wp_set_current_user($user_id);         wp_set_auth_cookie($user_id);              wp_redirect( home_url() );         exit;     }


title: How can I add an author-box below a post?

text: I would like to have a box below each blogpost with information about the author. These screenshots are examples for what I would like to have: ![enter image description here](http://i.stack.imgur.com/6JSPR.png) * * * ![enter image description here](http://i.stack.imgur.com/xYJmP.png) * * * **Links that could help** : I've found these links so far:   * Author Templates     * wp_list_authors I would prefer a plugin (or widget, I don't know the difference), but if nothing like that existed, I would have to adjust **single.php** to my needs, wouldn't I? What would happen, if the theme (Modern Style) got updated? **Related question** : How to add author details in the post sidebar? This is not the same question, as I would like to get the box below the post. But if this is not easily possible: Where should I save the given code?


title: bbPress plugin - How do I add a forum description?

text: This might be a total dummy question, but I have no idea where to enter the forum description with bbpress. I see it on plenty of other bbPress-powered forums, and the plugin is inserting `<div class="bbp-forum- description"></div>` into my table of entries, but when I create or edit a forum, I don't see a field to enter this information. Is this normal or is something strange going on with my bbPress forum?


title: How to create a plugin page that shows XML?

text: I'm looking for the best way to create a plugin page that displays XML. It needs to be:   * Front facing to the public   * Valid XML that removes all the admin hub-bub and allows me to change the header info   * Doesn't display in the side menu


title: Adding custom class names to anchor in wp_list_pages

text:
I've the following navigation: (example)

Wat is het

Hoe werkt het?

Resultaten?

OncoNavigator?

Ziekenhuizen?

      Can I add custom classes to a anchor element inside `Wp_list_pages`? because the current `wp_list_page` doesn't use a class attribute inside a anchor element. I want to add a unique class to each anchor element. For final result, I want to make a tab based horizontal dropdown menu. I looked for couple of WordPress dropdown menu plugins but there wasn't anything out there that fulfill my wishes.


title: How to force unlink on attached/inserted images?

text: When users insert an image into the content, WordPress automatically wraps the image in a hyperlink that, when clicked, creates an "attachment" page showing only the image inside the theme. Can I insert a code in my theme that tells WP not to create this link?


title: Custom post and category template pagination problem

text:
I have a category template which holds a query to custom post with a category. The strange thing is when the pagination loads it displays how many pages we have. But when I click on the second page of the pagination it gives me a 404 page. If I make the query only to fetch the custom post or to fetch the category it works fine. After I have refresh the query with the test for the custom post and the category it works fine. Here is the code of the category template:

     <?php     $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;     $args = array(         'posts_per_page' => 6,         'post_type' =>  'awards-pub',         'cat'=>6,         'paged' => $paged,         'order'=>'DESC'     );     $wp_query = new WP_Query( $args );     //wp_query->query('showposts=5'.'&paged='.$paged);     $i=1;     while ( $wp_query->have_posts() )     {         $wp_query->the_post();         ?>     <article class="article-first-vision <?= ($i==2)?'mar':'' ?>" >       <?php if ( has_post_thumbnail()) { ?>       <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">       <?php the_post_thumbnail('menu-pub'); ?>              <?php     }; ?>
         <?php the_title(); ?>

         <?= truncateHtml(get_the_content()); ?>
       <a href="<?php the_permalink(); ?>" style="bottom:0; right:0;" class="pa"><img src="<?php bloginfo('template_url') ?>/img/link-articles.png">
     <?php     if($i==3){$i=0;}     $i++;     }     ?>

     <?php         get_template_part('pagination');     ?>

     <?php         wp_reset_query();     ?>      And this is the pagination:               global $wp_query;     $big = 999999999;     echo paginate_links(array(         'base' => str_replace($big, '%#%', get_pagenum_link($big)),         'format' => '?paged=%#%',         'current' => max(1, get_query_var('paged')),         'total' => $wp_query->max_num_pages,         'prev_next'    => True,         'prev_text'    => __('«'),         'next_text'    => __('»'),     ));      And this is the custom post:                register_post_type('awards-pub', // Register Custom Post Type         array(         'labels' => array(             'name' => __('Awards', 'awardspub'), // Rename these to suit             'singular_name' => __('Awards Post', 'awardspub'),             'add_new' => __('Add Awards', 'awardspub'),             'add_new_item' => __('Add Awards  Post', 'awardspub'),             'edit' => __('Edit', 'awardspub'),             'edit_item' => __('Edit Awards Post', 'awardspub'),             'new_item' => __('New Awards Post', 'awardspub'),             'view' => __('View Awards Post', 'awardspub'),             'view_item' => __('View Awards Post', 'awardspub'),             'search_items' => __('Search Awards Post', 'awardspub'),             'not_found' => __('No Awards Posts found', 'awardspub'),             'not_found_in_trash' => __('No Awards Posts found in Trash', 'awardspub')         ),         'public' => true,         'hierarchical' => true, // Allows your posts to behave like Hierarchy Pages         'has_archive' => true,         'supports' => array(             'title',             'editor',             'excerpt',             'comments',             'thumbnail'         ), // Go to Dashboard Custom HTML5 Blank post for supports         'can_export' => true, // Allows export in Tools > Export         'taxonomies' => array(             'post_tag',             'category'         ) // Add Category and Post Tags support     ));      And to add the category to the custom post:               register_taxonomy_for_object_type('category', 'awards-pub');     register_taxonomy_for_object_type('post_tag', 'awards-pub');


title: query posts and split meta information into separate div's

text:
I'm trying to replicate the functionality of the content showcase/slider seen here: http://stylewatch.stelladot.com/ From what I see in the HTML, it appears that there's 2 divs, one with the post images and one with the post titles. I'd like to use something like `wp_list_pages` to return the 4 most recent posts and put them in the slider, but I'm not quite sure how to do it. It seems that they're in separate div's - how would I query the posts and split the set of images from the set of post names? I guess I could make 2 queries and have one query images while the other queries titles but it seems that isn't the most efficient way to do so. EDIT: Adding sample desired markup - the content of `media-0` and `title-0` should be from the same post.

text

text


title: How do i migrate a Multi site to individual site?

text: I have a client who built a site on a sub site of a Multi site network Can this be migrated to a new domain and independant wordpress site?


title: How to add "Template" option in page attributes panel?

text: I am new in WordPress. In my theme, I do not have "Template" option in 'Page Attributes panel'. I want to add this option. I tried to solve this problem from the following post. But It did not work for me. I am using "WordPress 3.6". Adding a Template to the Page Attributes Panel for both Posts and Pages? I already made a new template file(sunrise.php), which contains -               /*     Template Name: Sunrise     */      And, I added the php code in my function.php file, from the above link. But, I did not find the template selecting option in my "Page Attributes" panel. Below, I have added an image of my new page present condition. Thanks, in advance.


title: How is WP_Query parsed to determine which template to request?

text: I noticed that when I changed the WP_Query to ask for a certain category, the page served was `category.php`. So I'm guessing there's a block of code somewhere that decides which template to serve based on keys in the query. Where is it?


title: Check if tag, category or author on archive.php

text: i'm making a wordpress theme and want to use a single archive.php page in order to present posts under a specific author, a category or tag. Now, i'm doing it like :                if (is_author())       {            }            if (is_category())       {            }            if (is_tag())       {            }      I know i can divide this in more templates, but i don't want to repeat myself and i generally prefer to do it in a single php file. So, my question is : How can i get either the category, tag or author in each of these ifs ? It seems that for the author i can use something like :               $author = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author));      and for the category :               get_query_var( 'cat');      But is this indeed the way to do it ? What is a safe way to get that information independent of permalinks ?


title: Including inline Custom Fields info with add_filter in functions.php

text:
I have a function set up to place some standard text in each post for a Custom Post Type. However, within that standard text I want to pull some unique text from a few custom fields. Not sure what is wrong with my code:               function default_content($content) {       global $post;       if ($post->post_type == 'my-custom-post-type') {         $content .= '
Custom Field Text here: <?php echo get_post_meta( get_the_ID(), \'custom-field-1\', true )

<a href="http://myblog.com/?checkout=<?php echo get_post_meta( get_the_ID(), \'custom-field-2\', true )">Link 01
';       }       return $content;     }     add_filter('the_content', 'default_content', 0);


title: Wordpress postboxes On Tabbed Views and Hiding Registered Pages

text: Firstly here is a YouTube of me explaining my problem... https://www.youtube.com/watch?v=Nenu1stzLRw I want to be able to use postboxes on tabbed pages. Usually tabbed pages are called views to avoid confusion with actual admin registered pages. I have around 5 plugin pages and each has a tab menu. I cannot use postboxes full ability on them because each tab/view shares the same settings registered for the WP admin page they are on. So one page, multiple views. Wordpress does not appear to have a parameter to create settings per tab/view as it relies on the "page" variable in the URL which is always for a registered page. So I've went ahead and registered all of my views. Around 30 and I want to hide 25 of them say. The 5 left will show menus allowing access to the rest of my plugins admin pages. That is my attempt at a solution but it does not work. This is the function that prevents postboxes being used properly on tabbed views...               function wp_ajax_meta_box_order() {     check_ajax_referer( 'meta-box-order' );     $order = isset( $_POST['order'] ) ? (array) $_POST['order'] : false;     $page_columns = isset( $_POST['page_columns'] ) ? $_POST['page_columns'] : 'auto';          if ( $page_columns != 'auto' )         $page_columns = (int) $page_columns;          $page = isset( $_POST['page'] ) ? $_POST['page'] : '';          if ( $page != sanitize_key( $page ) )         wp_die( 0 );          if ( ! $user = wp_get_current_user() )         wp_die( -1 );          if ( $order )         update_user_option($user->ID, "meta-box-order_$page", $order, true);          if ( $page_columns )         update_user_option($user->ID, "screen_layout_$page", $page_columns, true);          wp_die( 1 );      TablePress See the TablePress plugin for an example of what I DO NOT want my plugin to do. I want the tab menu but I do not want the tabs to be reflected in the main plugin menus and vice-versa. This plugin is great coding standards and makes perfect use of the WP core but I'm trying to improve on it. If I could do it the TablePress plugin could have a single page.


title: Posting an XML request using HTTP API

text: I'm trying to work with an API that expects an XML string in the body of the post. Additionally, the docs for the API specify: > Please post with mime-type text/xml with the XML in the body of the post I want to use the WordPress HTTP API to make this work, but I'm running into some problems. So far I have code like the following that seems to be failing.               $url = 'https://www.testurl.com';     $xml = <<<TESTED XML HERE>>>;     $response = wp_remote_post(          $url,          array(             'method' => 'POST',             'timeout' => 45,             'redirection' => 5,             'httpversion' => '1.0',             'headers' => array(                 'mime-type' => 'text/xml'             ),             'body' => array('xml' => $xml),             'sslverify' => false         )     );      My question is, am I properly setting the mime-type and am I sending the XML in the right place? It's surprisingly tough to find examples of the WordPress HTTP API utilizing XML requests.


title: comments_popup_link without echo?

text: I would like to just get the HTML that comments_popup_link generates, and echo it later on. I don't see the comments_popup_link has an `$echo` parameter, and I don't see a get_comments_popup_link function, like there is get_the_ID, that _returns_ HTML istead of displaying it. I'm using WordPress 3.1.2 What can I do?


title: Current Post/Page Ancestor, CSS

text: LINK: http://themeforward.com/demo2 Checkout my menu. Hover over Features > Shortcodes > Typography. Notice how when you put your mouse over typography the background of Shortcodes turns to the darker red? **How do I get the background to turn to the darker gray (#EEE) instead while on the third level of the menu without changing the parent menu link colors (Home, Templates, Features, Portfolio, Blog)?** Here is the part of my CSS creating this:               /*** DEMO SKIN ***/     .sf-menu {         float:          left;         z-index: 900     }     .sf-menu a, .sf-menu a:visited  { /* visited pseudo selector so IE6 applies text colour*/         color:          #FFF;         padding:        10px;         text-decoration:none     }     .sf-menu li {         margin-right:35px;         z-index: 900     }     .sf-menu li li {         z-index: 900;         background:#FAFAFA     }     .sf-menu li li li {         background:     #FAFAFA;         z-index: 900     }     .sf-menu li:hover, .sf-menu li.sfHover,     .sf-menu li a:focus, .sf-menu li a:hover, .sf-menu li a:active {         outline:        0;         background: #AF1D21     }          .sf-menu .current-post-ancestor a, .sf-menu .current-menu parent a, .sf-menu .current-page-ancestor a, .sf-menf .current-category-ancestor a, .sf-menu .active_category a, .sf-menu .current-menu-item a { color:#1a1a1a }               ul .sub-menu { }     ul li .sub-menu a { color:#262626!important }     ul li .sub-menu a:hover { background:#EEE!important }


title: Use Wordpress engine for user registration and management

text: I am building a web app and would like to use the Wordpress Engine only for Authentication and User Management. Is there any good tutorials out there on how I can connect only the back end of wordpress to my simple app?


title: Check if post has image

text:
I'm displaying a list of posts and I want to indicate if the posts have images. I'm using this code to check if a post has an image.               <?php              $attachments = get_children(array(             'post_type' => 'attachment',             'post_mime_type' => 'image',             'post_parent' => $post->ID         ));              echo count($attachments);              if(count($attachments) > 0) {              echo 'image';         }else{           echo 'No image';         }          ?>      Some of the posts have images but it echo's 'No image' Is there a better way to check if a post has an image.                 <?php get_header(); ?>
                  <?php                 $allideas_args  = array(                     'post_type' => 'post',                     'order' => 'ASC',                     'orderby' => 'date',                     'posts_per_page' => 10,                 );                      $allideas_loop = new WP_Query($allideas_args);                      if($allideas_loop->have_posts()):                     while($allideas_loop->have_posts()):                         $allideas_loop->the_post();                  ?>
                      <a href="<?php echo get_permalink($post->ID); ?>">
                         <?php                                  $attachments = get_children(array(                                 'post_type' => 'attachment',                                 'post_mime_type' => 'image',                                 'post_parent' => $post->ID                             ));                                  echo count($attachments);                                  if(count($attachments) > 0) {                                  echo 'image';                             }else{                                 echo ' No image';                             }                              ?>

<?php the_title(); ?>

by
                          <?php the_excerpt(); ?>
                    <?php                 endwhile;                 endif;             ?>                  <?php wp_reset_postdata(); ?>
              <?php get_footer(); ?>


title: why does installer/update screens not progress on some webhosts?

text: I have 20+ WP sites installed for clients on different web hotels. All WP- installs are updated to run latest versions of everything. On some of my sites, the update- and install screens work as expected when I update or install a theme/plugin, the page updates and ends displaying the sucess/finished message. On some of my sites however, these screens always just show the first line like "downloading package" (or something like that, you get the point), but then they never progress. It seems however that everything always gets installed updated as it should. Even when I do a batch update of more plugins. It seems to be a hosting issue, as it's the same for all sites on the same host. Does anyone have a hint at what it might be in the server configuration that is preventing these screens from updating on the progress?


title: offload media to external services

text: Does anyone know a way (plugins or similar) to offload media (images mostly) in wordpress to an external service? like flicker, or imageshak? I think that offloading images from the wordpress installation increase significantly the mante the maintainability of your site, and not mentioning the speeding up of the backupping process! One sad note is that many themes need the images on the same server to create thumbnails for post previews, while I thinks a better approach would be to create temporary made up files of the images. thanks!


title: wp enqueue style on specific page templates

text: I am in the process of a theme, I would like to add landing pages using page- templates. I cannot find anywhere that shows how to enqueue style or js for specific page templates. Any suggestions. Ex. Landing Page 1 - landing-page- template-one.php will need very different style and js than the blog or homepage.


title: Allow admin to determine the order of queries?

text:
I have a custom query that I created to display the team members of a company, but my client has asked whether they can have control over the order in which each team member is displayed. Is this possible? At the moment, the default display is to order by date, but it would be great if you could actually control the order of custom post types in a query, within the admin area. `<?php while ($teamFeed->have_posts() ) : $teamFeed->the_post(); ?>
  <?php if (has_post_thumbnail( $post->ID )): ?> <?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' ); ?> <img src="<?php bloginfo('template_directory'); ?>/thumbs.php?src=<?php echo $image[0]; ?>&w=95&h=107&zc=1" alt="<?php the_title(); ?>" />
 <?php the_title(); ?>
 <?php meta('position'); ?>
 <?php endif; ?>
<?php the_title(); ?>
 <?php the_content(); ?>
 <?php endwhile; ?>` Thanks


title: Find attached images for one post type

text: I would like to query for images attached to ALL posts of certain custom post type (e.g. 'gallery'). I can't see a way to do this by using only WP_Query. The workaround would be to query for all posts of a custom post type, then get the attachments and stuff everything together. But i don't think that this would be a good solution, because you end up doing multiple queries for something that should be done in one. Please help =)


title: Add "Post Options" for new wordpress post

text: How i can add "Post Options" section under wysiwyg editor? **Like this**


title: Display the number of unseen comments on a page since the user last visit

text: The community is private and it has several pages /wordpress /design /etc . When users go to those pages the only thing they can do is to comment. Now, what I am trying to do, Idk if possible, but if it is I need some directions/hints on what too search for. http://jsfiddle.net/melbourne/uPqBe/4/ Instead of those numbers I want to display like the title says, the number of lastest comments since the current user visited those pages. I thought of using localStorage/cookies but then if the user decides to login from somewhere else, that won't do the job, in others words I dont have a clue on where to go from here. Any suggestions would really be appreciated.


title: Disabling automatic teasers

text:
I have a custom theme that displays the excerpt:                   $data = get_the_excerpt();         if ($data) echo "
$data
";      if nothing is entered in the excerpt field in the post editor, Wordpress will automatically use the auto-generated teaser. I would like to get rid of this behaviour. Is there any way to do so? At the moment, I have to entere a space into the excerpt field of every post to prevent the automatic teaser from showing.


title: This Wordpress plugin isn't creating links correctly

text: To get my PHP and Wordpress skills, I've been trying to code a small plugin a day. Today's project was to create a plugin that searched over every word in my posts, checked if http://reddit.com/r/$word was a valid link, and added the link to the word if it was. The plugin works correctly for the first post.               "**trees**" links to **http://reddit.com/r/trees**          "**php**" links to **http://reddit.com/r/php**      However, for every other post, the $word variable does not change.               "**trees**" links to **http://reddit.com/r/$word**          "**php**" links to **http://reddit.com/r/$word**      I've been scratching my head for the past hour trying to get this plugin to work. Here's the code:               add_filter('the_content', 'subreddit_replacer');          function subreddit_replacer($content) {                 global $id;       $post_id = get_post($id);       $post_content = $post_id -> post_content;       //delete_post_meta($id, 'jordan'); die;       $derp = get_post_meta($id, 'jordan');            if (empty($derp)) {       $words = preg_split('@[\W]+@',$post_content);       $derp = array();       foreach ($words as $word) {              $link = "http://reddit.com/r/$word";         $x = get_headers($link);         $wordf = ($x[6] == 'HTTP/1.0 200 OK') ? '' . $word . '' : $word;         $derp[] = $wordf;            }         add_post_meta($id, 'jordan', $derp, 1);       }            $derp = is_array($derp[0]) ? $derp[0]: $derp;            return implode($derp, " ");          }      Any guesses on what this problem could be?


title: Insert into post button missing on custom post type

text: I have just purchased a theme called **HQ Photography** from themeforest which has a custom post type called `gallery`. I can add images from my hard drive no problem - but if I click the media tab and select an image the 'Insert into post button' is missing I found a site which suggested I needed to add a custom filter to functions.php               add_filter('get_media_item_args', 'force_send_to_post');           function force_send_to_post($vars) {          $vars['send'] = true; // 'send' as in "Send to Editor"          return($vars);      }      This brings the button back but the button then does nothing. Does anyone one know what could be wrong? **UPDATE:** It seams the above function does work! - **however** only for images that are 'unattached' - once an image has been 'attached' the insert into post does nothing Can you attach images to multiple posts?


title: wpdb result arrray inside an array

text: I am trying to run a database query as below:               $id = $_GET['id'];     $query = 'select * from ';     $query .= $wpdb->get_blog_prefix() . 'fxdescription ';     $query .= 'where id= '.$id;     $currency = $wpdb->get_results( $wpdb->prepare( $query ), ARRAY_A );      The result of doing print_r($currency) is as below:               Array (      [0] => Array ( [id] => 1 [code] => EUR [name] => Euro [description] => [format] => direct )      )      The question is - is the above result normal, as the result is an array inside an array, and to access the data I have to use `$currency['0']['code']`, in place of `$currency['code']`?


title: How to make custom dashboard widget to display alert in front-end?

text: I need to make a widget to display any alert in front end The widget is in dashboard section on backend and any user can use yet. The content of the widget in dashboard is:   * Welcome message   * On/off (with checkbox or select option) to display alert section in the front end   * Green/red selector in backend to display in the front-end with any message, for example: If red color "Stop!" else green color "Go!"   * Textarea for any message to display under the red/green area in the front end   * Finally submit button. Any idea?


title: How do I list categories and the common categories for posts beneath those categories?

text: I have four categories:   * 2013   * 2012   * 2011   * 2010 These categories contain posts that are also categorized   * Cat A   * Cat B   * Cat C So basically there's a bunch of posts that are categorized (2013, Cat A), (2013, Cat B), (2012, Cat A), (2012, Cat C), etc Without having to add Cat A, Cat B and Cat C as four sets of child categories under 2013, 2012, 2011 and 2010 is there a way that I can programmatically list those unique subcats with posts under each year so that they list as:   * 2013     * Cat A     * Cat B     * Cat C   * 2012     * Cat A     * Cat B     * Cat C   * 2011     * Cat A     * Cat B     * Cat C   * 2010     * Cat A     * Cat B     * Cat C AND have those subcats link to their respective category page?


title: Is there a default template file for child pages / subpages?

text: This seems like a very simple question. I'm looking for something like sub- page.php or page-child.php where I can do some different things on the child pages of my theme. They are different enough in design and content that I'm having to use a lot of php or the CSS .page-child class to do all the dirty work. I'm looking for a simpler method. One caveat - I would like this to happen automatically so I don't have to tell the client "make sure to always select the 'subpage' template when you create a subpage!" which is precarious..


title: How to use different domains for different blogs hosted in the same host in subdomains with .htaccess

text: ## Background i have a website running on wordpress and all its files are located in public_html of my host. Within it i created a sub domain "phantomomaga" and redirected an other domain to that sub domain to make it "www.phantomomaga.tk" instead of "phantomomaga.my-domain.com" for this i added some code to the .htaccess of my public_html as told here to make it like follow ## Code               # 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          #Fix missing trailing slash character on folders.     RewriteRule ^([^.?]+[^.?/])$ $1/ [R,L]          #www.phantomomaga.tk and phantomomaga.tk will map to the folder {root}/phantomomaga/     RewriteCond %{HTTP:Host} ^(?:www\.)?phantomomaga\.tk$     RewriteCond %{REQUEST_URI} !^/phantomomaga/     RewriteRule ^(.*) phantomomaga/$1 [NC,L,NS]      ## Problem Due to this edit i was able to achieve what i wanted but for some reason not known to me now the permalink of my subdomain is not working and i keep getting not found errors from my wordpress install that is in my root folder and if i remove               # 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       from the .htaccess the sub domain works perfectly but the root one messes up so i think the problem is with the .htaccess of either of root or sub domain and i cant figure out the solution even after i googled it so please help.


title: How can I query all users who registered today?

text: I'm trying to use `meta_query` to return all users that have registered today :               $args = array(         'meta_query' => array(             array(                 'key' => 'user_registered',                 'value' => date('Y-m-d'),                 'compare' => '=',                 'type' => 'DATE'             )         )     );          $query = new WP_User_Query( $args );     $users = $query->get_results();      This doesn't seem to work though. What am I missing ?


title: Member plugin - register approval, restrict downloads, members only pages

text: I've seen a few members plugins but was wondering if any of them can do a few things i need. 1) I need two different types of users. One is a standard user another is a Partner. The standard user needs to be able to register without any approval, but the Partners need to have the account approved to ensure they are actually a partner. 2) I have file upload fields on one of my custom post types. I need to only allow registered users to view the files. When someone who isn't logged in clicks on one of the files they get taken to the registration/login page, then when they login they get taken back to the page they were on. 3) Members only pages. There needs to be some pages that only user that are logged in can see and view. So the page isn't even visible in the menu unless the user is logged in. These pages will contain downloads as well for members only. There will be a couple of different sections for members only. Some only for Partners the rest for all members. Is there any plugin that can do this? Thanks


title: How to upload files straight to S3 without using local storage?

text: I'm looking for a WordPress plugin that would allow me to upload files straight to We are a development shop that actively co-creates CMS websites with clients. This means that we are often iterating sites that clients are using and uploading files to. In our projects, we store the database and code in a git repository which makes it easy to move code from production to local development. The problem with this process is that some of the files that clients upload are very large and we do not want to upload them to the repository, but we would still like to be able to access them as if we have them. So, I thought, instead of moving the files around we could just use a 3rd party that would host the files and we would just access them. I could use Amazon S3 with a backup plugin, but I would prefer to just upload to S3 through the admin interface. The second reason for wanting this plugin is that we hosts blogs that have 20-30GB of high resolution images. I would prefer to not keep these files on our server because server space is expensive. Its less expensive to use Amazon S3 to host the files. In conclusion, is there a plugin that allows to use the WordPress Media upload, but it will actually bypass the local storage and upload files straight to the server? Thank you in advance for your answers!


title: Markdown in WordPress 3.2?

text: I found the question Create posts using markdown? about using Markdown on WordPress, however the plugins referred to haven't all been upgraded to WordPress 3.0 or higher. Since I happen to be a bit pedantic about using updated plugin, what options are available to integrate Markdown for both editing and displaying on a WordPress 3.0 or higher setup?


title: Display all posts in a custom post type, grouped by a custom taxonomy

text: I’m working on a member page where I use a custom post type with a custom taxonomy. My custom post type is called “member” and my custom taxonomy is called “member_groups”. I want to list all the members but group them together into their respective groups. So to be clear, I’ve 35 members divided into 9 groups – so instead of making the same query nine times I want to do it once but group them together, so that Member1, Member4 and Member 11 is grouped together in one group, called “Marketing”. I’m using WP_Query to retrieve all posts under post type member. I’ve tried different attempts but with no successful result. Any help or suggestions would be much appreciated. Sincere   - Mestika


title: How to filter the edit comments admin page, show only current logged in author comments

text: > **Possible Duplicate:**   >  Filtering the Admin Comments List to Show Only Comments from the Current > User? I am trying to get the edit-comments admin page to only show comments for the logged in author. Comments left on their posts that is. It shows all comments but disables the logged in author from viewing/editing ones that are not his/hers. How can I get only the comments from his/her posts to show up? I looked through the edit-comments.php file but couldn't find anywhere to hook into or filter. Thanx in advance!


title: Create database on installation

text: I'm working on a custom wordpress plugin, but I can't seem to figure out how to create the database when installing the plugin. (Or when updating) When searching around this is what I came up with, but this doesn't seem to do anything.               function to_install() {         global $wpdb;         $sql = "CREATE TABLE to_issues (             id int(11) NOT NULL AUTO_INCREMENT,             name varchar(125) NOT NULL         );";              require_once(ABSPATH . 'wp-admin/includes/upgrade.php');         dbDelta($sql);         add_option('to_db_version', TO_VERSION);     }     function to_install_data() {         global $wpdb;         $welcome_name = "Hello";         $welcom_text = "Install successfull";     }     register_activation_hook(__FILE__, 'to_install');     register_activation_hook(__FILE__, 'to_install_data');      On a side note, when updating the plugin, will this reinstall all the tables? Or will wordpress handle this correctly?


title: How to put Login, Register and newsletter widget on the same page?

text: I would like to create a template file and put there a login code, register code and widget code. I can do it for a widget, but I do not know how to do such thing for login and register. Any advice how to accomplish that?


title: Change permalink for a single post type only

text: At present I'm using this permalink structure `/%category%/%postname%/`. There are some existing post type. I want to change permalink for image post type to `image/%post_id%/`, and don't want to affect other post type and their permalinks.


title: WP_query : meta_key with custom rule for specific value

text: I'm a bit stuck with a WP_Query code. Here it is :               $args = array(           'post_type' => 'post',           'meta_query'=> array(               'key' => 'karma',               'compare' => '>=',               'value' => 0,               'type' => 'numeric'),             'posts_per_page' => 9,             'meta_key' => 'karma',             'orderby' => 'meta_value_num',              'order' => 'DESC',             'post__not_in' => $dont_show_me         );      What I want to do : Show all posts with karma >= 0 (it works fine with this code). BUT if there are posts with karma = 100 only show 3 of them + the rest of posts. Examples : 9 posts with karma = 150, 133, 100, 100, 100, 100, 100, 33, 11. I want to show: 150, 133, 100, 100, 100, 33, 11. (Only 3 posts with karma = 100 are allowed). Do you have any idea how to achieve this? Maybe a `add_filter('posts_where');` ? UPDATE: Okay I got it working, based on @s_ha_dum answer. It's a bit tricky, but the result works ;)               $args = array(            // Check for 9 last posts with karma = 100            'post_type' => 'post',            'meta_query'=> array(               array(                   'key' => 'karma',                   'compare' => '=',                    'value' => 100,                   'type' => 'numeric'                )             ),            'posts_per_page' => 9,            'meta_key' => 'karma',            'orderby' => 'meta_value_num',             'order' => 'DESC',            'post__not_in' => $dont_show_me         );         $karma_qry = new WP_Query($args);              if (!empty($karma_qry->posts)) {             $i = 0;             foreach ($karma_qry->posts as $p) {                 $i++;                 // Check for more than 3 posts with karma = 100                 // Add them in the $dont_show_me array                  if($i > 3){                     $dont_show_me[] = $p->ID;                 }             }         }              // Setup the final query that excluded addional posts with karma = 100         $args['meta_query'][0]['compare'] = '>=';         $args['meta_query'][0]['value'] = 0;         $args['post__not_in'] = $dont_show_me;              $wp_query = new WP_Query($args);


title: if user has a certain role then display image

text: so close to figuring this out, or not I'm not to sure! Basically what I want to do is on the authors page (so outside the loop) if a user role is an editor I want to display a little badge (but just outputting their name and role at the mo) in their profile. I have: functions.php:               function get_user_role($id)     {         $user = new WP_User($id);         return array_shift($user->roles);     }      and author.php:               <?php     global $post;     $aid = $post->post_author;     if ($userlevel == '2') {     echo get_the_author_meta('user_nicename', $aid).' | '.get_user_role($aid);     }          ?>      But doesn't seem to work, any ideas?


title: Use Media upload in custom widget on wordpress 3.5

text:
I'm creating a small widget for wordpress 3.5 that allows you to upload images. The widget is loaded correctly by wordpress. When I add the widget to a sidebar upload button does not work. If I update the page of keeping my widget in the sidebar, button works and I can load and save the image correctly. To build the widget I was inspired by these links: http://stackoverflow.com/questions/13863087/wordpress-custom-widget-image- upload http://stackoverflow.com/questions/13847714/wordpress-3-5-custom-media-upload- for-your-theme-options/13901303#13901303 My widget Code:               <?php          add_action('widgets_init', 'ctUp_ads_widget');     function ctUp_ads_widget() {         register_widget( 'ctUp_ads' );     }          function ctUp_wdScript(){       wp_enqueue_media();       wp_enqueue_script('adsScript', get_template_directory_uri() . '/js/ads.js');     }     add_action('admin_enqueue_scripts', 'ctUp_wdScript');          class ctUp_ads extends WP_Widget{              function ctUp_ads() {             $widget_ops = array( 'classname' => 'ctUp-ads' );             $control_ops = array( 'width' => 250, 'height' => 350, 'id_base' => 'ctUp-ads-widget' );             $this->WP_Widget( 'ctUp-ads-widget',THEMENAME .' - Ads', $widget_ops, $control_ops );         }              public function widget($args, $instance){              extract( $args );            ?>         <img src="<?php echo esc_url($instance['image_uri']); ?>" />         <?php }              function update($new_instance, $old_instance) {             $instance = $old_instance;             $instance['text'] = strip_tags( $new_instance['text'] );             $instance['image_uri'] = strip_tags( $new_instance['image_uri'] );             return $instance;         }            public function form($instance){ ?>
           <label for="<?php echo $this->get_field_id('text'); ?>"><?php _e('Text', THEMENAME); ?>
           <input type="text" name="<?php echo $this->get_field_name('text'); ?>" id="<?php echo $this->get_field_id('text'); ?>" value="<?php echo $instance['text']; ?>" class="widefat" />

           <label for="<?php echo $this->get_field_id('image_uri'); ?>">Image
             <img class="custom_media_image" src="<?php if(!empty($instance['image_uri'])){echo $instance['image_uri'];} ?>" style="margin:0;padding:0;max-width:100px;float:left;display:inline-block" />             <input type="text" class="widefat custom_media_url" name="<?php echo $this->get_field_name('image_uri'); ?>" id="<?php echo $this->get_field_id('image_uri'); ?>" value="<?php echo $instance['image_uri']; ?>">             <?php _e('Upload', THEMENAME); ?>
         <?php       }               }      Js code:               jQuery(function($){         $('.custom_media_upload').click(function(e) {             e.preventDefault();             var custom_uploader = wp.media({                 title: 'Custom Title',                 button: {                     text: 'Custom Button Text',                 },                 multiple: false  // Set this to true to allow multiple files to be selected             })             .on('select', function() {                 var attachment = custom_uploader.state().get('selection').first().toJSON();                 $('.custom_media_image').attr('src', attachment.url);                 $('.custom_media_url').val(attachment.url);                 $('.custom_media_id').val(attachment.id);             })             .open();         });     });      Thanks in advance for help!


title: Using Advanced Custom Fields in a widget

text:
I've built a widget to show pages from a certain category in a dropdown menu. The page that's selected will show up on the homepage. This all works, except the Advanced Custom Fields (ACF) are all showing the same image. I think it's to do with $instance... The code I'm using is:
              <?php $attachment_id = get_field('main_image');         $size = "home-boxes";         $image = wp_get_attachment_image_src( $attachment_id, $size );         ?>              <a href="<?php echo get_permalink($instance['post_id']); ?>">         <img class="headline" width="<?php echo $image[1]; ?>" height="<?php echo $image[2]; ?>" src="<?php echo $image[0]; ?>" />

<?php the_field('sub_title'); ?>
      All the code works great on the individual pages - it's just when called by the widget that I get these issues. The title and permalink are using the normal Wordpress functions, and these work fine too. Are there any ACF users here that can shed some light on this? Thanks


title: Use a plugin to handle custom post types?

text: I've seen some tutorials showing how to create custom post types - the process seems straightforward enough. The issue I have with this is that the custom type information is part of the theme, and not handled by the WP core. So if the theme is switched for another, they custom type information is lost, and must be ported to the new theme. I've seen some plugins that handle the custom types for you. It seems to me that this is kept separate from the theme, and would thus be more portable, provided the plugin is kept activated. There would of course be a need for the theme to template and style the custom type, but it wouldn't have to maintain the type itself. Is it worthwhile to use a plugin for this purpose?


title: Preserve custom URL parameter on more pages

text: I created a custom URL parameter for sorting posts by their vote scores. I have a "most voted" link that sends a `?sort=most_voted` URL paramater and using a query posts filter I display posts with most votes. If for instance I want to display most voted posts in category 5, I'll need a URL like this `?cat=5&sort=most_votes` How do I preserve/attach the `sort` parameter in the URL when browsing categories (or even by tag name, search, etc)?


title: Programatically create multiple pages by passing in array of info

text: I'm trying to adapt Tom McFarlin's tutorial on programatically creating a page into a function that will create multiple pages by passing in an array of info. The page gets created in Wordpress, but the page information is all empty.


title: How can I paginate this?

text:
Been trying to use the pagination functions in wordpress with this code               <?php     $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;      $args = array( 'post_status' => 'pending', 'posts_per_page' => 3, 'paged'=>$paged);     $recent_posts = new WP_Query( $args );     ?>          <?php while ( $recent_posts->have_posts()) {     $recent_posts->the_post();     echo '

';     echo get_the_post_thumbnail($recent["ID"], 'thumbnail');     echo '
';     echo '
' . get_the_title() .'
';     echo '
' . get_the_excerpt(10) . '
';     echo '

Author: ' . get_the_author() . '

';     echo '
';      }      ?>     <?php posts_nav_link(); ?>     <?php next_posts_link('« Previous Entries') ?>     <?php previous_posts_link('Next Entries »') ?>      And yet each time I try I just can't seem to get it right, any help would be appreciated cheers. Result page here: http://streakingpirates.com/pending/ _excuse the random posts by my friend_ Solution found thanks to cale_b and the link he provided http://wordpress.stackexchange.com/a/120408/11704 needed to swap               <?php next_posts_link('« Previous Entries') ?>      for               <?php next_posts_link( 'Older Posts' , $custom_query->max_num_pages ); ?>      since apparently the previous pages link has some issues with custom loops


title: Activated plugin is stored as an object, rather than as a path

text: This seems like a very unusual behavior: Usually, when activating a plugin, a path to the plugin's main file (or bootstrap) is stored in the database under `options.active_plugins`. However, something in the following code is causing Wordpress to store the object itself, rather than a path to it, in the database. Here is the plugin's bootstrap file (`bootstrap.php`):               /**      * Plugin metadata      */          require_once( plugin_dir_path( __FILE__ ) . 'MyPlugin.php' );          $plugin = new MyPlugin();     $plugin->init();      After activation, the `active_plugins` option entry will look like this (retrieved using `get_option( 'active_plugins' )`:               Array {         [0] => (object) MyPlugin     }      When the expected result would be:               Array {         [0] => bootstrap.php     }


title: Limit image resolution on upload

text: I'm running into a problem where a particularly huge image is causing my VPS server to reboot because of memory issues. The configuration of this is out of my hands, it's sort of like the host's failsafe. I have a VPS with 300M memory, which I believe is sufficient for my WordPress installation, at least with day-to-day operations. The image I am uploading isn't particularly big in file size (~380 kb) and is mostly black with white letters. However, its resolution is 4583 * 4583. When I upload it through WordPress, I get an HTTP error in the upload window, and when I go check the live site, it's down for a couple of minutes. I was wondering if it's possible to detect an images resolution and prevent it from being uploaded. I'm clever enough to mess around a bit in an image processor, but some of my authors may not be savvy enough to process the image before they upload something as big as this. It would be even better if the limitation could be based on the images bits- per-pixel, but I have no idea what my server's limit is for this, so I guess an error message saying the image can't be uploaded because it's larger than, say, 2000 * 2000 is enough.


title: Turn off auto 301 on archive pages?

text: I'm currently using infinite-scroll. The scroll ends when it reaches a 404. For example it will look for   * category/cars/page/2    * category/cars/page/3    * etc until it hits a 404. The problem is that infinite scroll keeps on loading the first page of content because instead of a 404, I'm getting a 301. I also have yoast enabled. Any idea on how to fix this? pretty sure it's yoast although I'm not sure how to turn off the auto 301 setting.


title: Search Query that Includes Custom Table

text: I have a WordPress website that grabs product data from a custom table. I would like to be able to also search from fields in the custom table. Could someone provide a sample query of what this would look like? I cannot join the custom table to the posts table because the custom table has data that is not associated with any other database tables (unless I am misunderstanding joins). The end goal is to show all posts and custom table data that match the specified "s" variables data. Thanks! UPDATE Here is the requested table structure of the custom table: ![enter image description here](http://i.stack.imgur.com/0STC6.png) Just to clarify, I am trying to modify the WordPress search so that it searches the posts table using a like query. I also need it to return results that match from the custom table as well. I will need it to search the subarticle and Article fields of the custom table.


title: Add custom prefix to search URL

text: I am using Wordpress to manage a site with both a static page structure and a blog under /blog. I've updated my permalinks to use the custom structure `/blog/%postname%/` and all seems to be working well except that I'd like for my search results to be located under `/blog/search/search+terms`. Currently that URL returns a 404, but `/search/search_terms` works as expected. I know I could use a rewrite rule in Apache, but I'm wondering if there's a way to effect this change within Wordpress itself.


title: How can I call "preview post" from wp_remote_get with authentication?

text: I've got a plugin that needs to interogate the post preview (the contents of the rendered page that's presented when the user clicks "Preview Post". To attempt to obtain this input stream into a code variable, I'm using wp_remote_get like so:               $response =      wp_remote_retrieve_body(     wp_remote_get(     'http://localhost/mysite/test-post/?preview=true&preview_id=28&preview_nonce=640bc54ca4'));      $post->post_content = $response;      (I'm just replacing the post content with the results of the get for easy previewing during code testing). My problem is that since I'm not passing any authentication parameters in the wp_remote_get, the preview action fails. Is it possible to pass a parameter that authenticates the current user and returns the preview to the script?


title: Specified file failed upload test. wp_upload_handle

text: So I managed to write a peice of code that allows me to upload a zip file, im not even sure where it gets uploaded too, and I am doing it on my localhost with apache in control (www-data). the code is as follows:               public function upload_file(array $file){         add_filter('upload_mimes', array($this, accepted_mime_type));              if(wp_handle_upload($file, array('test_form' => false))){             var_dump(wp_handle_upload($file, array('test_form' => false)));         }else{             $this->error('Oops!', 'Something went wrong with the upload. Please try again.');         }            }      the error I get is: Specified file failed upload test Im not sure whats going on, this is localhost.


title: Development plugin to view and manage scheduled wordpress cron jobs?

text: Is there a plugin for wordpress that can help a user to view and manage the crons that are currently schdeuled in WordPress? I have looked into Core control but doesn't allow the user to manage the cron jobs.


title: How do I safely force get_theme_mod() to use a defined get_option("stylesheet") value?

text: In our development process we have several branches of the same theme for each developer. Theme branches live in different directory names, so when doing `get_theme_mod()`, `get_option("stylesheet")` can return different values, should we for some reason (customer demo) be forced to activate another theme branch besides "master". This makes us have to reconfigure menus, widgets, customizer mods etc etc. In our case, it's very rare that theme mods need to be different across branches, so I would like `get_theme_mod()` to always access the same mods array. The obvious solution seems to be making "`pre_option_stylesheet`" filter as a standard part of the theme codebase, but I am not sure if it may have any unintended side effects. Grepping around, looks like this option is almost exclusively used in a few places in `wp-includes/theme.php`. Q: Is "`pre_option_stylesheet`" filter the way to go here? Or can you think of something else?


title: get all posts from a custom post type

text: I'm trying to get all posts from a particular custom post type using the following code:               $auctions = get_posts(array('post_type' => 'auction'));     print_r($auctions);     echo '<select>';     foreach ($auctions as $auction) {         echo '<option value="' . $auction->ID . '">' . $auction->post_title . '</option>';     }     echo '</select>';      Although the print_r() call shows data, the foreach seems to ignore it and doesn't print anything. Any ideas? Any help would be appreciated print_r() output:               Array (         [0] => WP_Post Object (             [ID] => 36             [post_author] => 1             [post_date] =>    2013-05-19 10:58:45             [post_date_gmt] => 2013-05-19 08:58:45             [post_content] =>             [post_title] => My Title             [post_excerpt] =>             [post_status] => publish             [comment_status] => closed             [ping_status] => closed             [post_password] =>             [post_name] => my-title             [to_ping] =>             [pinged] =>             [post_modified] => 2013-05-24 09:55:53             [post_modified_gmt] => 2013-05-24 07:55:53             [post_content_filtered] =>             [post_parent] => 0             [guid] => http://domain.com/?post_type=auction&p=36             [menu_order] => 0             [post_type] => auction             [post_mime_type] =>             [comment_count] => 0             [filter] => raw         )        )


title: Multisite with a single, shared custom post type, while retaining site URL

text: Small multisite setup, two very different sites, both need to access an `event` custom post type. I don't want to duplicate posts (there are some plugins that "broadcast" a post to the network). `switch_to_blog(1)` will get me part way there, where `blog 1` is the "master" blog that contains the `event` data, as far as archive-style pages that list all the events. But my concern is that the URL/permalink of the event, when viewed from `blog 2` will point to `blog 1`, and following that permalink will then take the user to the other blog, confusing the user. Is there a solution (possibly using rewrite) that would allow an event post at `//blog1/events/event1` to appear as `//blog2/events/event1` when viewed from `blog 2`?


title: Ajax Dynamic Archives not showing correct results

text:
Im baffled on why this is not showing the correct results, when selecting the month alone and say 100 posts are on the site, only 3 show up, then if you select the category and month the proper show up. here is the archives template

Month
          <select id="month-choice">     <option val="no-choice"> — </option>     <?php wp_get_archives(array('type'    => 'monthly', 'format'  => 'option')); ?>     </select>

Category
          <?php wp_dropdown_categories('show_option_none= -- ');?>

      here is the archives getter               <?php          /*         Template Name: Archives Getter     */          $year = trim($_POST['digwp_y']);     $month = trim($_POST['digwp_m']);     $cat = trim($_POST['digwp_c']);     $querystring = "year=$year&monthnum=$month&cat=$cat&posts_per_page=-1";     query_posts($querystring);           ?>          <?php if (($year == '') && ($month == '') && ($cat == '-1')) { ?>

Please choose from above.

          <?php } else { ?>
         <?php                 if (have_posts()) : while (have_posts()) : the_post(); ?>
                     <img src="<?php echo get_post_meta($post->ID, 'PostThumb', true); ?>" alt="" style="width: 35px;" />	                     <a href='<?php the_permalink(); ?>'><?php the_title(); ?>	                     <?php comments_popup_link(' ', '1 Comment', '% Comments'); ?>	                     <?php the_date('m/j/Y'); ?>
         <?php              endwhile; else:                      echo "
Nothing found.
";                  endif;          ?>
      and finally the jquery code               jQuery(function($) {     $("#archive-wrapper").height($("#archive-pot").height());     $("#archive-browser select").change(function() {     $("#archive-pot")         .empty()         .html("
loading...
");          var dateArray = $("#month-choice").val().split("/");     var y = dateArray[3];     var m = dateArray[4];     var c = $("#cat").val();          $.ajax({         url: "/archive-getter/",         dataType: "html",         type: "POST",         data: ({             "digwp_y": y,             "digwp_m" : m,             "digwp_c" : c         }),         success: function(data) {             $("#archive-pot").html(data);             $("#archive-wrapper").animate({                 height: $("#archives-table tr").length * 50             });         }     });     });     });


title: How to receive notification of deprecated API elements and functions?

text: There is some way to get notifications when deprecated API elements are used in WordPress. How is it done? Put WordPress in debug mode (which also shows all other types of errors) or is there another method that shows only API related errors?


title: Custom Taxonomy type in nav menu

text: This might be a stupid question. But I really need the tip. I've created several custom taxonomies in "post" type and everything is perfect. I can insert each custom term i create in the main nav menu. but what i'm looking for any way that if i could all the terms under a taxonomy in a menu item. That is if i click on a menu item say "Services" which is a custom taxonomy consists of terms such as "service 1, service 2 service 3" etc the page open will show all the posts which are under all the terms of this taxonomy. I can add each terms in the menu list but i don't want them to be different. And again I can create another parent term of all those terms and assign it in the nav menu but i don't want it either. But I don't want it to be so tricky. Please any idea from the experts. Thanks in advanced.


title: Is it possible to us WP Core Maintenance Mode for short pause while a plugin runs?

text: I've written a plugin to manually (admin button push) delete several hundred posts that are created by another plugin. That other plugin creates posts based on an external API. I'm running into a situation where occasionally the API plugin is starting to creating new posts midway through the deletion. I'm wondering if there is a way to use WP's core maintenance mode for just a few seconds to pause everything else on the site from running while the delete runs? I've looked at update-core.php and update.php but it wasn't quite obvious to me what it was doing to initiate and terminate maintenance mode. I was kind of hoping there was a function to set maintenance mode and another to clear maintenance mode, but I'm not seeing it. Open to other ways to avoid this race condition as well.


title: grant a privilege for roles (for example editors) and higher

text: My wordpress theme has a custom post-type. Only editors (and higher) should be allowed to use this post type. I did this with:               function add_capability($role,$cap) {         $role_obj = get_role($role); // get the the role object         $role_obj -> add_cap($cap); // add $cap capability to this role object     }          function set_cpt() {         add_capability('editor', 'edit_cpt');         add_capability('editor', 'read_cpt');         add_capability('editor', 'delete_cpt');         add_capability('editor', 'edit_cpt');         add_capability('editor', 'edit_cpt');         add_capability('editor', 'publish_cpt');         add_capability('editor', 'read_cpt');     }     add_action('init', 'set_cpt');      ~~(I think) in Wordpress 3.1 this was enough - all editors **and higher** had the right to use the post-type.~~ Now ~~, in Wordpress 3.2~~ **only** editors have the right to use the post- type. Is there a way to grant privileges to role X and higher or would I have to mention every role? Thank you! [edit] actually I found out that this never worked before. But is there another way to do it?


title: Should I remove transients from the wp_options table?

text: I have been doing some cleaning up in the database of one of my WordPress installs, and I noticed that the `wp_options` table was about 2.1mb, and had 1200 rows. I've gotten it down to around 800 rows, and 1.2mb. However, there are a bunch of transients. Should I remove these? I know they don't autoload, so it probably isn't causing strain on the database. Most of the transients have formatting like the following:               _site_transient_browser_03df11ec4fda7630a5...     _site_transient_browser_065e09a1287aadfb4d...     _site_transient_timeout_browser_03df11ec4f...     _site_transient_timeout_browser_065e09a128...     _transient_feed_1a5f760f2e2b48827d4974a608...     _transient_feed_f8e8c12cc5c787789728d7481a...     _transient_feed_mod_e6460a14e5784b3ee64f91...     _transient_timeout_feed_1a5f760f2e2b48827d...      So, is it worth taking the time to remove these? Thanks for reading! Any thoughts are appreciated.


title: Custom Field returning Numerical Value for Image rather than URL

text:
I have been trying a way round my latest WordPress problem all morning and I feel now is the right time to shout and ask for help. I have been trying to create a people directory, I'm there except for the overall listing page which I have decided to be rows of 5 images followed by the persons name below each image, followed by another a row etc... Each persons page has a set of custom fields one of which is `name` and another is `mainimage` the idea being that with the following code I can pull the image along with the name from the child pages of `people` and display them all on the one page with the image and name linked to the permalinkof the specific child page.               <?php          // Get the page's children         $args = array( 'numberposts' => 100, 'child_of' => 35, 'post_type' => page, );         $children = get_pages( $args );          if (!empty($children)) {          echo '';         foreach($children as $child) {             // Get the 2 meta values from the child page             $main_image = get_post_meta($child->ID, 'main_image', true);              $name = get_post_meta($child->ID, 'name', true);                   // Display the meta values             echo '
';             echo $main_image;             echo '
';             echo $name;         }         echo '';     }           ?>       It works kind of, but I'm getting a number for the image as opposed something that outputs to an image. Upon checking the custom field I have found the image value is a number, looks to me like media ID. I need to either be able to interpret the ID within the people page as an image or a way to make sure actual urls are being put into the custom field values so I can use standard `img src` html to output the image. I am using Advanced Custom Fields to create the fieldsets for the people page as well as the individual person pages. Any help would be greatly appreciated as I have tried several variations of the code above but just cannot get the number to change in to the associated image.


title: When I re-save a post with [code] sections, the entities are double-escaped (> becomes > etc)

text: I've a hard time googling for this issue. On my blog, whenever I update an existing page, code sections are doubly escaped. I.e., on a recent page I have               find /V "QWERTYUIOPPO" < calc.exe:yourads.txt      and after a recent edit it has become:               find /V "QWERTYUIOPPO" < calc.exe:yourads.txt      When I save it once more, it will escape the entities once more:               find /V &quot;QWERTYUIOPPO&quot; &lt; calc.exe:yourads.txt      Etc. Needless to say this is nasty. For pages containing a lot of code this is a real bummer. Until now I just did some search and replace actions, but this can't stay forever. Does anybody recognize this issue? Here's an example page that illustrates this issue. Also in the screenshot for future reference (as I sure hope to solve the issue on my pages sometime soon). ![enter image description here](http://i.stack.imgur.com/X4qLL.png)


title: jQuery AJAX add json2 dependency?

text: I am working on a voting system in Wordpress with jQuery and AJAX. To make this voting system work I need jQuery in my theme. So wrote the code down in my functions.php. But for some reason my script doesn't do anything. Watch my full vote script here. So I started reading the codex, and found here to include jQuery for AJAX calls, you need the json2 dependency. Does anyone have experience with this, and can tell me how I need to include this, because jQuery is already registered in Wordpress, so do I need to register jQuery again and add the json2 dependency to this? I don't get it..               // Ajax Voting     wp_register_script( 'ajax-vote', get_template_directory_uri() . '/js/ajax-vote.js', array('jquery') );          $nonce = wp_create_nonce("vote_nonce");     $stn_vote_data = array(         'ajaxurl' => admin_url( 'admin-ajax.php'),         'nonce' => $nonce,     );     wp_localize_script( 'ajax-vote', 'stn_vote', $stn_vote_data );          function stn_script_enqueuer() {             wp_enqueue_script( 'jquery' );         wp_enqueue_script( 'ajax-vote' );          }     add_action( 'wp_enqueue_scripts', 'stn_script_enqueuer' );


title: How to add in title a date but with other color, like in iMDb titles?

text: Is there a way to add in title a date but with another color, like in iMDb titles? Like in this title (click on it): http://www.imdb.com/title/tt1606378/ **To be more clear,** see this picture **The result is this:**see this picture Thanks!


title: Way to hook into a sidebar call to replace it with a custom sidebar

text: I want to replace the `sidebar-2` in the twentyforteen theme with a custom sidebar based on a conditional statement for CPT. So if the page is showing a certain custom post type then show my custom sidebar, else just show the default sidebar. I want to do this without changing the theme or using a child theme (i.e. purely from a plugin). Here is what I have so far:               register_sidebar( array(         'name'         => __( 'Custom Sidebar' ),         'id'           => 'custom-sidebar',         'description'  => __( 'My Custom Sidebar' ),         ) );          add_action('get_header','change_dd_sidebar');     function change_dd_sidebar() {         if ( is_singular('my_cpt')) { // Check if we're on a single post for my CPT called "ips_due_diligence". Need another check for index pages too.            unregister_sidebar( 'sidebar-2' ); //remove the default right sidebar            dynamic_sidebar( 'custom-sidebar' ); //this doesn't replace the right sidebar - the content appears at the top of the page - no good...        }     }      Is there a way to hook into the call for `sidebar-2` and replace it with my own?


title: Migrating Markdown (from Drupal)

text: I'm in the process of migrating my blog from Drupal to Wordpress. I have made liberal use of Markdown in the original posts (and Geshi syntax highlighting). In see that the WP-Markdown plugin converts to (and from HTML) on save (and edit), so I now have a bunch of posts which appear with the Markdown 'on show'. Is there an API call which I can use to effectively do an 'edit and save' operation on each post to force the Markdown on Save plugin to operate on them all? Or alternatively, a different Markdown plugin I should try?


title: add logout button on admin side menu

text: I want to add a logout button on the side admin menu (because I disable the admin bar for the users). So I thought add_menu_page() is the way to do it, but how to add the link to the regarded function? Here is what i did:               add_action( 'admin_menu', 'my_logout_menu' );          function my_logout_menu() {     add_menu_page( 'Logout', 'Logout', 'read', 'logout', 'my_logout' );}          function my_logout() {     echo wp_logout_url( $redirect );}//here is I don't know what to do.      Am I using the correct approach? or there are other easier ways to do it?


title: Shortcode, Concatenating & Parse error: syntax error, unexpected T_FOREACH

text:
I'm learning how to write a shortcode. I'm getting this error: Parse error: syntax error, unexpected T_FOREACH . I'm having problems with concatenating it properly.               <?php     /*     Plugin Name:  My Plugin     Plugin URI: http://mysite.com     Description: This does blah     Version: 1.0     Author URI: http://www.mysite.com     */                         function csf_cap_databaseinfo() {         global $wpdb;                        $greeting = $wpdb->get_results($wpdb->prepare("SELECT * FROM wp_test;"));                $out = '

                  ID	                      Greeting
';                 $out .=  foreach ($greeting as $greet){ .'
' . echo $greet->id . '
' . } .'
';                   return $out;           }               add_shortcode('db-info', 'csf_cap_databaseinfo');     ?>      Any suggestion on how to fix this error? Thank you. -Laxmidi


title: How to create a new theme from scratch?

text: I'm new to WordPress. Which steps would I need to do, to get my new design implemented as a WordPress theme?


title: Akismet plugin is deleting spam despite preferences

text: Curiously, Akismet is deleting old spam comments after a period of time (I'm guessing within a week). This box is **NOT** checked: > Auto-delete spam submitted on posts more than a month old. I've sent a message to Akismet support more than a week ago but I've not yet received a reply. I do not want Akismet to delete anything. I do not check often enough to verify false positives so I want all comments saved indefinitely, even the spam. Does anyone know why it's deleting spam comments even though it's set not to? Does anyone know of a workaround?


title: CodeColorer: Allow Some Symbols in Java Language

text: I have a quick question about CodeColorer plugin. How can I allow less then (<) and greater then (>) signs in java code. I am asking this because they are used in Generics but they are being stripped away when I use lang = java, so I am forced to use lang = html for now. Any help is appreciated. Thanks for taking time to read this. **Update:** ok, the issue is resolved now. The thing was that anything resembling html, like , was stripped by WordPress for all roles less then admin. I added this code to make it work for contributor, $role = get_role( 'contributor' ); $role->add_cap( 'unfiltered_html' ); This resolved the issue.


title: Is there a way to enable bulk edit and quick edit on custom post types?

text: When viewing a list of all standard post or pages there are convient quick edit and bulk edit functions to edit author, template, status, dates, etc... Is there an easy to enable similar quick edit and bulk edit tools on Custom Post types? For example going to: ../wp-admin/edit.php?post_type=page select all checkboxes, select edit from drop down, click apply, you get options for Author, Parent, Template, Comments, Status, but none of those show up for ../wp-admin/edit.php?post_type=mycustomposttype


title: How to make the BuddyBar fix and scroll with the page

text: I've been trying to find a way to force the BuddyBar to scroll with the page instead of float at the top of the browser window when scrolling down the page. I been searching the net for this but can't seem to find anything on it anywhere. Has anyone tried this yet? This is on a multisite install.


title: Is this post using WordPress Gallery?

text: Here's an interesting post that I saw toda - check the gallery This website is using WordPress, now if you notice the image URL changes however we can still see the javascript slide effect. If it was a javascript slideshow then it shouldn't have changed the URL. This makes me think that how are they achieving this.


title: How to make universal gallery and improve admin side of managing galleries?

text: I will describe here steps I made to make my galleries for my first WP theme. I wanted to have a few links in my menu which will take user to page with thumbnails. Each thumbnail takes user to gallery with bunch of horizontally displayed images. First, in my functions.php file I've added new size for my icons:               add_image_size( 'wide-image-icon', 200, 150, true );      Then, I've made my template file for gallery category (lets call it Gallery1) and category "Gallery1". In my `gallery1.php` template file I used query for posts with galleries:               query_posts(array('category_name'=>'Gallery1','posts_per_page'=>-1))      Then, in posts loop I've displayed my gallery icons (which are featured images of posts):               the_post_thumbnail('wide-image-icon');      So now, after creating new page with "Gallery1" template, I can add post, select "Gallery1" category for it, add pictures using standard "Insert gallery", choose one as featured image and I'm good to go. The problem is that's not universal way of doing this. What if I would like to make another gallery page (Gallery2). Then I need to make new template file, create new category, change category name in query inside template file, add new page with this template attached to it. How do you do it? I'd also like to ask about some admin side improvements for gallery. I've seen themes where there was a completely new tab inside admin area where you saw all galleries, you could easily change images order, add/remove galleries etc. Right now on my website I add my news ( I use the same system here ), galleries, blog posts and normal pages like "Bio" as posts only which is definitely not good. PS. Any articles, video tutorials, books or tips and tricks are welcome. @edit: How can I manage display of my galleries on admin side? I'd like to remove whole editor and leave just pictures if you know what I mean.


title: What is the Plural of WordPress?

text: I mean, for what I remember of my english classes it should be `WordPress'`, or not? Would this be a Meta Question? Or a English Language & Usage one? **[update]**   What I ended up writing (in an email) before Comments and Answers was > ...deal with a couple of WordPress' projects... **[update]**   Well, it ended up being an _Engrish_ Fail. Thanks, Johannes, for opening the question at English Language & Usage. Toscho's answer also prompted me to open another at Spanish Language and Usage, but for a person's name. (oh, my, is this apostrophe correct?) _In spanish, it would be "Los WordPress"._


title: Can I make an ajax response cross-domain?

text: I am trying to make a single ajax response cross-domain. Is that possible? I tried something like this, but that did not work:               function my_call_callback() {       header("Access-Control-Allow-Origin: *");       if (headers_sent())           echo "headers was sent";       else           echo "headers was not sent"; // This is what I get       die();     }     add_action('wp_ajax_my_call', 'my_call_callback');      UPDATE: It suddenly started working. No idea why. I suspect some problem with the web hotel I am using since I just told about an attach attempt I noticed. They told me to block the attackers IP in .htaccess. Perhaps they did some review of the .htaccess files. I really have no idea though.


title: How to submit documentation with plugin

text: When I submit a plugin to the wordpress public repo, how am I supposed to submit documentation? What is considered standard or good practice? Should I just have all documentation on the be page that the plugin is mirrored on, or should I also include a readme of sorts? I know when submitting to CodeCanyon, it's standard to package documentation with the plugin, but it's not super important what file format you use as long as it can be viewed without paid software. I don't, however, know what the standard for submission to the public repo is. Insight anybody?


title: DB access blocked when initializing WP externally

text: I have an odd problem I'm hoping the group can help with. The problem is this:   * I have a few situations where I load the Wordpress environment without the overhead of the GUI (details)   * I am able to do this in most environments without a problem but a few (two laptops to be precise) refuse to load Wordpress and instead give me the following error: ![enter image description here](http://i.stack.imgur.com/NOF0r.png) What's so very strange is that:   1. The db connection attributes are correct. This has been validated both by logging in manually from the command-line (using the credentials in the wp-config file); not to mention that this same `wp-config.php` has no problem loading the database when it is loaded normally by Wordpress.   2. The files, OS, PHP version, even the DB connection parameters are all exactly the same on computers that work versus those that don't.  I'm not sure were else to look. Any help would be greatly appreciated.


title: How can i put a custom field inside this php

text: Hy, i want to count years of an actor. The date that actor is born is stored in a custom field.               $date = get_field('data_nasterii');      Date stored in custom field is : yymmdd How can i stick bouth togeder to make it work.               <?php                      //date in mm/dd/yyyy format; or it can be in other formats as well                      $birthDate = "12/17/1967";                      //explode the date to get month, day and year                      $birthDate = explode("/", $birthDate);                      //get age from date or birthdate                      $age = (date("md", date("U", mktime(0, 0, 0, $birthDate[0], $birthDate[1], $birthDate[2]))) > date("md") ? ((date("Y")-$birthDate[2])-1):(date("Y")-$birthDate[2]));                      echo $age ."ani";                 ?>      I try this but this returned me year 2012               <?php              //date in mm/dd/yyyy format; or it can be in other formats as well              $birthDate = get_field('data_nasterii');              //explode the date to get month, day and year              $birthDate = explode("/", $birthDate);              //get age from date or birthdate              $age = (date("md", date("U", mktime(0, 0, 0, $birthDate[0], $birthDate[1], $birthDate[2]))) > date("md") ? ((date("Y")-$birthDate[2])-1):(date("Y")-$birthDate[2]));              echo $age ."ani";         ?>


title: Filter categories/tags to display in multiple metaboxes for selection in back-end

text: My site uses a lot of categories and tags for author selection in the back- end. To make it more user friendly for authors I need to arrange the categories and post tags in numerous metaboxes for selection on the post edit screen. I would like to display some selected categories and their children in one metabox for author selection while other categories will go into a second and third metabox and so on. The same should apply to the tags. Can anyone point me in the right direction how to accomplish such a customization? Can I register new taxonomies which will include categories/tags based on their ID's and create new metaboxes displaying only those ID's? The Wordpress default metaboxes for categories and tags display all categories in one box. Thanks!


title: Add unique class or ID information to tinyMCE

text: Is there a method to apply a unique body class ID to the editor in the same way that body class information is added to the published page? I am using the add_editor_style() function to render the editor's styles to reflect the published page. However, there are some pages where the styles break away from the standard page rules, and I would love to be able to include some of those exceptional style rules in the editor.


title: wpdb prepare syntax

text: $arr = [];     array_push( $arr, 'wp_table', 1, '2013-12-24', 3, 'NULL');     $sql_prepare = "INSERT INTO %s (id, datea, one, two) VALUES (%d, %s, %d, %s) ON DUPLICATE KEY UPDATE one = VALUES(one), two = VALUES(two);";          $wpdb->query(            $wpdb->prepare( $sql_prepare,                           $arr )     );      The above code seems to result in an issue with the `datea` value `2013-12-24`. `[You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''wp_table' (id, datea, one, two) VALUES (1, '201' at line 1]` `"INSERT INTO 'wp_table' (id, datea, one, two) VALUES (1, '2013-12-24', 3, 'NULL') ON DUPLICATE KEY UPDATE one = VALUES(one), two = VALUES(two);"` Without `$wpdb->prepare (...)` the query works just fine. `$wpdb->query( "INSERT INTO $table_name (id, datea, one, two) VALUES (1, '2013-12-24', 3, NULL) ON DUPLICATE KEY UPDATE one = VALUES(one), two = VALUES(two);");` Any advice on how to handle the date value? What am I doing wrong? Thank you for further explanation. /edit I see I might be overusing prepare but at least `datea, one, two` are user-submitted input


title: Help with AJAX front end comment moderation

text:
I am implementing a front end AJAX comment moderation system for a site I manage but I am having a hard time getting it to work. Right now clicking on the link that approves the comment runs the proper php script but it reloads the entire page. So it works but I'd like to approve the comment using ajax without reloading the entire page, but my lack of javascript knowledge is preventing me from getting this to work. Here is the code (located in a plugin):               add_filter( 'comment_text', 'p3_comment_moderation_buttons' );     function p3_comment_moderation_buttons ( ) {         if ( is_author() || current_user_can( 'moderate_comment' ) ) {             // Adds moderation buttons under every comment             $comment_id = get_comment_ID();             $text = get_comment_text();             $nonce = wp_create_nonce( 'p3_comment_moderation' );                  $p3_approve_link = admin_url('admin-ajax.php?action=p3_comment_approve&comment_id='. $comment_id.'&nonce='.$nonce);                  $p3_edit_links = '
Approve
';             return $text . $p3_edit_links;         }         else{             return get_comment_text();         }     }               add_action("wp_ajax_p3_comment_approve", "p3_comment_approve");     function p3_comment_approve() {         if ( ! wp_verify_nonce( $_REQUEST['nonce'], 'p3_comment_moderation' ) ) {             exit("Go away!"); //If nonce check fails stop everything         }         $comment_id = $_REQUEST["comment_id"];         $success = wp_set_comment_status( $comment_id, 'approve' );         $success = update_comment_meta( $comment_id, 'p3_comment_status', '' );              if ( $success = true ) {             $result['type'] = 'success';             $result['comment_id'] = $_REQUEST["comment_id"];         }         else {             $result['type'] = 'error';             $result['comment_id'] = $_REQUEST["comment_id"];             echo "Something didn't work";         }              if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {             $result = json_encode($result);             echo $result;         }         else {             header("Location: ".$_SERVER["HTTP_REFERER"]);         }              die(); // this is required to return a proper result     }          add_action( 'init', 'p3_comment_meta_script_enqueuer' );     function p3_comment_meta_script_enqueuer() {         wp_register_script( "p3_comment_meta", plugins_url().'/p3wp-comments/js/p3_comment_meta.js', array('jquery') );         wp_localize_script( "p3_comment_meta", 'p3cmetaAjax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' )));              wp_enqueue_script( 'jquery' );         wp_enqueue_script( 'p3_comment_meta' );     }      And the corresponding javascript:               jQuery(document).ready( function() {              jQuery(".p3-comment-moderation").click( function() {             comment_id = jQuery(this).attr("data-comment_id")             nonce = jQuery(this).attr("data-nonce")                  jQuery.ajax({                 type : "post",                 dataType : "json",                 url : p3cmetaAjax.ajaxurl,                 data : {action: "p3_comment_meta", comment_id : comment_id, nonce: nonce},                 success: function(response) {                     if(response.type == "success") {                         alert("Success!")                     }                     else {                         alert("Something went wrong.")                     }                 }             })              })          })      Can anyone spot the problem? BTW I have already modified the comment template to display unapproved comments so they can be approved on the front end. I also plan to expand this to to work with custom comment meta, and expand the javascript so it does something more useful than displaying an annoying alert Thanks


title: Protocol relative url not pulling up images on IE, FF, and OPERA

text: I'm running into an issue where I'm using the protocol relative url for the images from the wordpress Amazon s3 plugin on my SSL pages. In Chrome, all images are loading fine but when I tested it on IE, FF, and Opera, the images aren't showing up. Here is what I inserted into the theme option image input field:               //www3.mydomain.com/wp-content/uploads/my_logo.png      Does anyone know why it's causing this issue? I searched the web and couldn't find a clear answer. Thanks for your time, Hal **Output of HTML**                                                **Solution** Since I'm using the Amazon s3 plugin, I'm required to use the s3.amazonaws.com/bucket/key domain name if I'm pulling contents into a SSL page. Hope this helps if anyone is having problems.


title: Display category and associated post listings

text: I am having trouble figuring out a correct loop to display the following: **Category Name:**   * Post 1   * Post 2   * Post 3   * Post 4   * Post 5 See all posts in this category --> Can anyone help me with a correct function or loop?


title: Query in a Hierarchical Custom Post Type for Children vs Siblings

text:
I have a custom post type with two levels of pages inside of it. the parent level we'll call parent, and child - child. The parents need to be able to pull in their children, and the children need to be able to pull in their siblings (children of the same parent.) If i were doing this in a normal page:               <?php $children = get_pages('child_of='.$post->ID);?>     if( count( $children ) != 0 ) { ?>
     Give us your Children
     <?php }     else { ?>
     Give us your siblings
     <?php } ?>      Of course - this doesn't work since get_pages only works with non-cpt "pages". I'm at a loss for the proper method inside a CPT - help much appreciated.


title: ob_end_flush error when using wpdb in plugin

text: I created a small plugin to test database interactions in wordpress. I have a small function that inputs the arguments to the table. If i call my function in a themefile it inputs my test values to my table, but if i call it from another plugin i get this error: Notice: ob_end_flush(): failed to send buffer of zlib output compression (0) in /.../wp-includes/functions.php on line 2504 I have no idea what this error means, can anyone shed some light on it? edit: I use MAMP with PHP 5.4.4 edit2:               function test_db_function($name, $message){       global $wpdb;       $table_name = $wpdb->prefix . "testDB";            if( $name == '' || $message == '' || !isset($name) || !isset($message)) {         //return 0;       }       else{         $rows_affected = $wpdb->insert( $table_name, array(            'time' => time(),            'name' => $name,            'text' => $message) );       }     }


title: Random element in get_post_meta array

text: I have a custom field that contains a list of comma separated colors. I want to randomly select one of those colors. If get_post_meta returns an array I thought I could randomly pick from that array. If I try to echo $rand_color_value it just gives me the whole array How can I randomly select one color from the list in the custom field.                   $agrs = array(             'post_type' => 'page',             'tag' => 'colors'         );              $colorLoop = new WP_Query($agrs);              if($colorLoop->have_posts()):             while($colorLoop->have_posts()):                 $colorLoop->the_post();              $theColor = get_post_meta($post->ID, 'colors', false);              /*random color*/         $rand_color = array_rand($theColor,1);         $rand_color_value = $theColor[$rand_color];         echo $rand_color_value;               ?>              <?php endwhile; endif;?>              <?php wp_reset_postdata; ?>


title: Widget development - Drop down options won't save

text: So, i successfully managed to add a drop down option, the problem is when i click save all of the options are removed, however the chosen option is implemented successfully. Here is the relevant code:               function widget($args, $instance) {             extract( $args );                  $pfxattribution = $instance['pfx-attribution'];     }          <p>                 <label for="<?php echo $this->get_field_id('pfx-attribution'); ?>"><?php _e('Choose attribution:'); ?></label>                 <select id="<?php echo $this->get_field_id('pfx-attribution'); ?>" name="<?php echo $this->get_field_name('pfx-attribution'); ?>" class="widefat" />                  <option>Purefx</option>                 <option>Foreign Exchange</option>                 <option>Currency Exchange</option>                 </select>                 </p>          function update($new_instance, $old_instance) {             // Get the old values             $instance = $old_instance;                  // Update with any new values (and sanitise input)             $instance['pfx-attribution'] = strip_tags( $new_instance['pfx-attribution'] );                 return $instance;     }      Any help is greatly appreciated


title: Sort results by name & asc order on Archive.php

text: I currently use the following code to list posts in Archive.php but I want the results to be ordered by name in ascending order, I have checked the codex but the answer isn't clear to me, how can I get this working?               <?php $post = $posts[0]; // ?>      Thanks in advance.


title: Custom field values to taxonomy terms

text: I have a "author" custom field with the names of author. I want to add some new features to the site so I decided that custom taxonomies will be the best solution. So what I need to do is to get the value of the custom field and pass it to the custom taxonomy called artist. Sure I can do this manually but it is more than 1000 posts so it would be hell. I guess the solution will be connected with wp_set_object_terms(); function, but nothing I tried worked. Thank you for any answer.


title: register_activation_hook and updating

text: I have used:               register_activation_hook(__FILE__, 'CrayonWP::install');      In `install()` I would like to check the plugin version being installed, and if it is below a certain version, I would like to alter the existing database model to the new format. How would I determine the version being installed?