title: Use external fonts in Wordpress stylesheet

text: I'm having a go at designing a premium WP theme, and I've found numerous plugins that allow you to load fonts from Google Web Fonts and other services. However, how do I let administrators actually configure the site-wide heading and body text fonts? **To clarify:** When writing a stylesheet, I need to type in the name of the fonts that will be used (e.g. `h1 { font-family: Cuprum }`. However, I want to be able to choose different fonts _for my CSS_ from my admin panel by picking from available Google Web Fonts. One option I can think of is using `font-family: HeaderFont`, `font-family: BodyFont`, etc. in my CSS, and then loading whichever fonts have been chosen under those names using `@font-face`, e.g.               @font-face {       font-family: 'HeaderText';       font-style: normal;       font-weight: 400;       src: local('Cuprum'), local('Cuprum-Regular'), url(http://themes.googleusercontent.com/static/fonts/cuprum/v3/sp1_LTSOMWWV0K5VTuZzvQ.woff) format('woff');     }      But that seems like quite a complex solution, and I haven't seen it done that way. What's the accepted way to do this?


title: What is the correct method for updating post content from a plugin?

text: I would like to create a plugin which updates the post's content in the Admin panel. For example, on the Edit post page, the user sees his draft content. If he clicks on a button from a meta box plugin, I want new HTML to be appended to the post content. Ideally without refreshing the page. Zemanta does this and I am trying to figure out the right method for achieving that effect. NOTE: I am brand new to coding with Wordpress, so please let me know if/how my question needs to be clarified further.


title: WordPress Retrieve Post by Title

text: The following code works brilliantly for retrieving certain pages, but I can't get it to retrieve POSTS by name. I'd like exactly the same code, but to retrieve posts rather than pages. Any help appreciated.               <?php         function get_my_content($page) {             $my_id = $page;             $post_id = get_post($my_id, ARRAY_A);             $content = $post_id['post_content'];                  return $content;         }     ?>              <div id='test'>         <?php              $page = get_page_by_title('testpage');             echo get_my_content($page);         ?>     </div>


title: How to remove a plugin filter's priority on specific loops (custom queries)?

text: So I have a review plugin that is automatically sorting all my site based on the score rating. It seems here are the filters the plugin is applying globally:                   //Post sorting         $sort = get_option('rs_sort');         if ($sort == 'rating') {                  add_filter('posts_fields', 'rs_weighted_fields');             add_filter('posts_join', 'rs_weighted_join');             add_filter('posts_groupby', 'rs_weighted_groupby');             add_filter('posts_orderby', 'rs_weighted_orderby');              } else if ($sort == 'comments') {             add_filter('posts_orderby', 'rs_comments_orderby');         }          }      These filters are taking priority over the whole site. Even some custom loops where I want it to use the wordpress default (sort by newest) and others where I want to sort by random. Specifically here is an example loop that I am trying to make:               <?php $custom_query = new WP_Query('category_name=FreaturedIndex&orderby=rand'); ?><?php while ($custom_query->have_posts()) : $custom_query->the_post(); ?>      Right now, its just sorting by rating and ignoring the orderby=rand. Is there some code that can be applied to remove these filters by applying it to specific queries? Thanks for the help!


title: Problems with Wordpress in subfolder, posts show a blank page

text: I have wordpress installed in a subfolder and using permalinks but I'm getting a blank page when I try to access to any post. This is what I have in the root folder .htaccess:               RewriteEngine On     RewriteCond %{HTTP_HOST} ^(www.)?site.com$     RewriteCond %{REQUEST_URI} !^/wordpress/     RewriteCond %{REQUEST_FILENAME} !-f     RewriteCond %{REQUEST_FILENAME} !-d     RewriteRule ^(.*)$ /wordpress/$1     RewriteCond %{HTTP_HOST} ^(www.)?site.com$     RewriteRule ^(/)?$ wordpress/index.php [L]      And this is what wordpress put in the subfolder .htaccess:               # 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      I'm using custom permalinks with `/%postname%.html`, the posts have the permalink correctly but when I try to access it shows only an empty blank page.


title: Only display link to author social media when it exists

text: I've added the following code to my functions.php to expand the functionality of the user profile page and be able to add links to the social media of the authors.               function my_new_contactmethods( $contactmethods ) {     // Add Site     $contactmethods['mysite'] = 'My Site';     // Add Google Plus     $contactmethods['google_plus'] = 'Google Plus';     // Add Behance     $contactmethods['behance'] = 'Behance';     // Add Twitter     $contactmethods['twitter'] = 'Twitter';     //add Facebook     $contactmethods['facebook'] = 'Facebook';     return $contactmethods;     }     add_filter('user_contactmethods','my_new_contactmethods',10,1);      On the author.php I call the links like this:               <a title="Follow me on Twitter" href="<?php the_author_meta( 'twitter', $author_id ); ?>">     <a title="Follow me on Facebook" href="<?php the_author_meta( 'facebook', $author_id ); ?>">     <a title="Follow me on Behance" href="<?php the_author_meta( 'behance', $author_id ); ?>">     <a title="Follow me on Google+" href="<?php the_author_meta( 'google_plus', $author_id ); ?>">      The problem with this solution is that it shows the image and link even if the author has not filled the corresponding field. Would it be some easy way to just echo the links that have been previously filled?


title: Count custom post type based on two meta data

text: I am trying to count my custom post type called 'appointments' that match two meta data values . The meta data keys are 'location' and 'timestamp' So in english my query is: How many appointments are scheduled at Location at Time How can this be done?


title: Ajax Plugin Not Echoing Response

text:
I have created a plugin that will submit a form via ajax. Below is the php function.               add_action('wp_ajax_nopriv_audience_intel', 'audience_intel_ajax');     add_action('wp_ajax_audience_intel', 'audience_intel_ajax');     function audience_intel_ajax() {         $likeit = $_POST['likeit'];         $response = $_POST['response'];         $postid = $_POST['postid'];              add_option( 'testing_form_like', $likeit );         add_option('testing_form_response', $response);              global $wpdb;         $tablename = $wpdb->prefix . "intel";              $newdata = array(             'radio' => $likeit,             'feedback' => $response,             'postid' => $postid         );                      $wpdb->insert (             $tablename,             $newdata         );              $result = "
Finished successfully!
";         // json_encode($result);         echo $result;     }      Here is my script.               jQuery(document).ready(function($) {     $('.audience_intel_container .close').click(function(){         $('.audience_intel_container').fadeOut('fast', function(){              });     });          $('.audience_intel_container button').click(function(){         console.log('clicked');         var formdata = $('#audience_intel_form').serialize();         $.ajax({             type : "post",             dataType : "html",             url : audience_intel_js.ajaxurl,             data : 'action=audience_intel&'+formdata,             success: function(response) {                 alert(response);                 $('.audience_intel_container').html(response);             }         })     })        });      The form data is added to the database correctly, but I am not able show an output message after the request is complete. I have tried both return, echo, and echo json_encode in the ajax function. I appreciate any insight.


title: Analyze uploaded images to get colour values

text: I have a site that uses large background images, uploaded by the user, that has content on top of it. I'd like to be able to analyze the image and apply a class to the body that will have black text if the brightness of the image is very light, and white text on a dark background. I think having it populate a meta field attached to the image with the analyzation results upon upload would be the easiest, but haven't found anything that does that sort of sorcery. How would one apply such an analysis to the image meta upon upload?


title: Show box only on edit post

text: I've made a video custom post type and on the edit page I've placed a meta box where I display a shortcode associated to the post, to make it easier for the user. However, I wish the shortcode and/or the box to be visible on the edit post page only and not on the new post page, where it's not yet relevant - what am I looking for here? I have this nagging feeling I've done this/something similar before but just can't think of what to search for. ETA: This is what I did with the help I got below, might be useful to someone else too:               add_action( 'add_meta_boxes', 'my_video_add_custom_box' );     function my_video_add_custom_box() {         if (get_post_status( $post->ID ) != 'auto-draft') {             add_meta_box(                 'my_video_shortcode_custom_box',                 __( 'Shortcode', 'my_video' ),                 'my_video_shortcode_custom_box',                 'my_video', 'side', 'default'             );         }     }      Works like a charm, thanks!


title: portfolio custom type tags support

text: I have **portfolio-post-type.php** which contains this:               <?php     add_action( 'init', 'create_portfolio_post_type' );     function create_portfolio_post_type() {         register_post_type( 'portfolio',             array(                 'labels' => array(                     'name' => _x( 'Portfolio', 'post type general name', 'flowthemes' ),                     'singular_name' => __( 'Portfolio Item', 'post type singular name', 'flowthemes' ),                     'add_new' => _x('Add New', 'portfolio', 'flowthemes' ),                     'add_new_item' => __('Add New Portfolio Item', 'flowthemes' ),                     'edit_item' => __('Edit Portfolio Item', 'flowthemes' ),                     'new_item' => __('New Portfolio Item', 'flowthemes' ),                     'view_item' => __('View Portfolio Item', 'flowthemes' ),                     'search_items' => __('Search Portfolio Items', 'flowthemes' ),                     'not_found' =>  __('No portfolio items found', 'flowthemes' ),                     'not_found_in_trash' => __('No portfolio items found in Trash', 'flowthemes' ),                      'parent_item_colon' => '',                     'menu_name' => _x( 'Portfolio', 'flowthemes' ),                      ),                 'public' => true,                 'exclude_from_search' => true,                 'has_archive' => false,                 'supports' => array('title', 'author', 'custom-fields', 'revisions', 'page-attributes', 'post-formats', 'comments', 'trackbacks', 'excerpt' ),                 'rewrite' => array('slug' => 'portfolio')             )              );         register_taxonomy('portfolio_category','portfolio',array(         'hierarchical' => true,         'labels' => array(             'name' => _x( 'Portfolio Categories', 'taxonomy general name', 'flowthemes' ),             'singular_name' => _x( 'Portfolio Category', 'taxonomy singular name', 'flowthemes' ),             'search_items' =>  __( 'Search Categories', 'flowthemes' ),             'popular_items' => __( 'Popular Categories', 'flowthemes' ),             'all_items' => __( 'All Categories', 'flowthemes' ),             'parent_item' => null,             'parent_item_colon' => null,             'edit_item' => __( 'Edit Portfolio Category', 'flowthemes' ),              'update_item' => __( 'Update Portfolio Category', 'flowthemes' ),             'add_new_item' => __( 'Add New Portfolio Category', 'flowthemes' ),             'new_item_name' => __( 'New Portfolio Category Name', 'flowthemes' ),             'separate_items_with_commas' => __( 'Separate Portfolio category with commas', 'flowthemes' ),             'add_or_remove_items' => __( 'Add or remove portfolio category', 'flowthemes' ),             'choose_from_most_used' => __( 'Choose from the most used portfolio category', 'flowthemes' )         ),         'show_ui' => true,         'query_var' => true,         'rewrite' => false,         ));     }     ?>      What I want to make is to add also support for tags, to be able to add also tags on portfolio post in the back-end. How can I accomplish this ?


title: Get the Current Blog URL of User in Multi Site?

text:
I have a WordPress Multi Site installation and several blogs. On the frontpage (domain.com) I have a login form and when the user is logged in, it shows two links at the moment (Admin Panel and Log out). But I also want to include a link that goes to the current blog site of the user, eg: blog.domain.com.
<a href="<?php <some code> ?>">Show blog


title: Wordpress auto picking featured image

text: In the past when I created a news post, the featured image was automatically assigned to the post when I uploaded an image in the post. But now, that doesn't work anymore :( The only thing that changed was that I installed certain plugins for testing and deactivated them afterwards. First I found out that I didn't add theme support for featured images. Added this code in my functions.php:               // This theme uses post thumbnails     add_theme_support( 'post-thumbnails' );       I can now see the featured images in the back-end and add it manually. But how come it was automatically in the past? I'm using WordPress 3.7.1–nl_NL with my custom theme and the following plugins:   * All In One SEO Pack   * Google XML Sitemaps   * Jetpack by WordPress.com   * Limit Login Attempts   * SI CAPTCHA Anti-Spam   * WP Anti Spam


title: Apply Filters Causing a 500 Internal Server Error

text: I have a custom post type and need to display it in a certain way. I would like other posts to display as normal. When I tried to use the following code to accomplish this, I get a 500 Internal Server Error.               global $post;               //do this only for custom type       if (!(get_post_type()=='customt'))       {         $rawContent = $post->post_content;         $formattedContent = apply_filters('the_content',$rawContent);         echo $formattedContent;         return;       }      I have googled around and found a lot of things regarding .htaccess but I don't think that is the case here. If I comment out the apply filters line (`$formattedContent =...`) and echo raw content, the post displays, but without formatting of course. What am I doing wrong when I am trying to apply a filter?


title: Remove admin menu

text:
Ho do you remove admin menu items and dissable acces for users below admin ? The right way...               // 1 - Remove Menu Items     function my_remove_menu_pages() {         if ( !current_user_can( 'administrator' ) ) {             remove_menu_page('options-general.php'); // Settings             remove_menu_page('tools.php'); // Tools             remove_menu_page('upload.php'); // Media             remove_menu_page('plugins.php');             remove_menu_page('themes.php');             remove_menu_page('edit-comments.php');             remove_menu_page('edit.php?post_type=page');             remove_menu_page('link-manager.php');         }     }     add_action( 'admin_init', 'my_remove_menu_pages' );          // 2 - Redirect users if they visit links from non visible menu items     function no_permission_admin_redirect() {         if ( !current_user_can( 'administrator' ) ) {             if (stripos($_SERVER['REQUEST_URI'],'tools.php') !== false                  || stripos($_SERVER['REQUEST_URI'],'options-general.php') !== false                  || stripos($_SERVER['REQUEST_URI'],'upload.php') !== false                  || stripos($_SERVER['REQUEST_URI'],'media.php') !== false                  || stripos($_SERVER['REQUEST_URI'],'edit-comments.php') !== false                  || stripos($_SERVER['REQUEST_URI'],'post-new.php?post_type=page') !== false                  || stripos($_SERVER['REQUEST_URI'],'post-new.php') !== false                  || stripos($_SERVER['REQUEST_URI'],'media-new.php') !== false                  || stripos($_SERVER['REQUEST_URI'],'edit.php?post_type=page') !== false                  || stripos($_SERVER['REQUEST_URI'],'link-manager.php') !== false) {                  wp_redirect(get_option('siteurl') . '/wp-admin/index.php?permissions_error=true');              }         }     }     add_action('admin_menu','no_permissions_admin_redirect');               // 3 - Show error message to users if they visit links from non visible menu items     function no_permissions_admin_notice() {              echo "

".__('You do not have permission to access that page.')."

";         }          function no_permissions_show_notice() {             if($_GET['permissions_error']) {                 add_action('admin_notices', 'no_permissions_admin_notice');             }         }     add_action('admin_init','no_permissions_show_notice');      This code works but unfortunately users can access some of the pages by typing the url on their browsers without getting any error or redirection. Is there a simple way to remove menu items and redirect users to the dashboard if the visit the page by typing the url on their browsers without using plugins ?


title: Custom post type 404 error on "default" or "numeric" permalinks

text: I wrote a plugin for WP.org that uses a custom post type with the slug "reading-list" and I cannot view mysite.com/reading-list/ when I have either the "default" or "numeric" permalinks setting in wp-admin. Does anyone know why this would be, i.e. why it only affects these two settings? I use flush_rewrite_rules() after registering the custom post type in the plugin and I checked all of the parameters according to the Codex but nothing seems to help. Thanks.


title: get_the_term_list & url

text: I have 2 custom post type and i want to link them together with an **url** from the first one and a **image** from the second one. I can get the **title** and the **url** of my taxonomy like that : ( CPT = 'traductions', TAX = 'nom-origin' )               $url = get_the_term_list($post->ID, 'nom-origin');      But i don't want a title, i just want to link this **url** with this **thumbnail** that i can get like that : (CPT = 'livre')               <?php         $args = array(             'post_type' => 'livre',             'orderby' => 'date',              'order' => 'ASC'          );         $livres = new WP_Query( $args );         if( $livres->have_posts() ) {             while( $livres->have_posts() ) {                 $livres->the_post();     ?>     <?php                global $post;          <a href="<?php echo $something ?>"><?php the_post_thumbnail(array('thumbnail_size_w'), array('class' => 'alignleft')); ?>      So, what should i write instead of _$something_ ? Or i am completely wrong about the whole approach ? I have been stuck on this for a while so any help would be appreciate. thanks


title: Setting locale based on URL in Wordpress - a better way than this?

text: I've been searching and experimenting for so long trying to figure this out. How do I set the language on a per request basis in Wordpress? Currently I'm using this:               function mysite_lang_support()     {         return array(             'en' => 'en_GB',             'zh' => 'fr_FR'         );     }          function mysite_lang_endpoints()     {         $langs = mysite_lang_support();         foreach ($langs as $lang => $isoCode) {             add_rewrite_endpoint($lang, EP_PERMALINK | EP_PAGES | EP_ROOT | EP_CATEGORIES);         }         add_rewrite_tag('%lang%','([a-z]{2})');     }     add_action('init', 'mysite_lang_endpoints');          function mysite_set_locale()     {         $requestLang = basename(filter_input(INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_STRING));         $supportedLangs = mysite_lang_support();         if (array_key_exists($requestLang, $supportedLangs)) {             return $supportedLangs[$requestLang];         }         return current(array_keys($supportedLangs));     }     add_action('locale', 'mysite_set_locale');      Is this an advisable way to go about this?


title: If post has ANY term attached to it, get the first one only

text: I am developing a theme that has several custom taxonomy that act as radio buttons. How do I write a conditional that does... `if(post_has_any_terms($post->id, 'custom-taxonomy')) { echo $term; }.` I feel like this should be so simple, but nothing that I have tried works. Thanks!


title: Is it possible to enqueue the Youtube API script or does it have to be inline?

text:
The code below is the main part of a function in my functions.php which returns a `div` and `script` which ultimately output a youtube API iframe to the template where the code had been called from. At the moment it's working fine; however I would like to enqueue the javascript, or at least move it out of my PHP code. I tired moving it to my main JavaScript file ( which is enqueued in the footer ) but it doesn't work when I move it there. **_Edit** : I had hardcoded the vars to avoid having to use `wp_localize_script` so as to out of the picture_. Surely there's a better way ( or WordPress way ) of doing this?               $return = '

                            ';          return $return;


title: Why is this page using the homepage template and not the one it should?

text: * * * One of my clients has installed a theme where when a visitor enters their username and email to register as a new user they get shown a link to download a custom report file. This was working fine on my clients test installation, but now they've converted the site to a live site the download link doesn't show and instead the page uses the homepage template... I'm stumped as to why it's happening so any advice would be great. Here's the test page Here's the live page Here's a jsFiddle of the PHP code


title: How to query posts for custom post type with featured image for first 2 post?

text: I am trying to write a custom post query for a specific post type in a way where only first 2 thumb/featured-image will be shown & other will be just title & other metadata (i.e the picture in attachment). It would be great if someone help me regarding this issue with proper guideline. Thanks in advance. ![attachment](http://i.stack.imgur.com/JAh7Z.png)


title: Fetch post meta in the same query as the main loop

text: I have a custom post type "staff" and each as a custom field "_staff_purpose" (describing its function). I would like that the archive-staff.php template display all staff members, sorted by their _staff_purpose, so that i can then loop through the result using the _staff_purpose as a heading. The result i'd like to have is like this:               ID  |   post_title    |  _staff_purpose     -----------------------------------------     1   |   Tracy Chap.   |  administrator     -----------------------------------------     2   |   John Doe.     |  teacher     -----------------------------------------     3   |   Robert Smith  |  teacher     -----------------------------------------      The raw SQL should be this:               SELECT * FROM `bj_posts` p          LEFT JOIN (         SELECT post_id, meta_value as purpose         FROM `bj_postmeta` pm          WHERE  `meta_key`='purpose'         ) pm ON p.ID=pm.post_id     WHERE p.`post_type`='staff' AND p.`post_status`='publish'     ORDER BY purpose ASC, post_title ASC      I've tried this:               add_action( 'pre_get_posts', 'fetch_staff_people' );          function fetch_staff_people( $query )     {              if ( is_page_template('archive-staff.php') && $query->is_main_query() )         {             $query->set( 'post_per_page', '-1' );             $query->set( 'meta_key', '_staff_purpose' );             $query->set('orderby', 'meta_value title'); // sort by purpose, then by staff name.             $query->set( 'order', 'ASC ASC' );                       } else {                     return;             }              return $query;     }      The query seems to work but the custom field value does not appear in the loop.


title: How to speed wordpress disqus plugin loading?

text: When I'm testing my blog page loading time in pingdom tools and webpagetest.org, both of these services display disqus plugin takes 5-10 seconds to load. Are there any way to speedup its page loading time? Are there any way to load disqus only if the visitor only need to comment or view the comments? ![enter image description here](http://i.stack.imgur.com/mjYAl.png)


title: Can't sort order of wp_query with 2 meta keys

text: I'm trying to display custom post types by excluding the sold ones but also by displaying them in alphabetical order from the county meta_key. I'm trying to use pre_get_posts but I'm not sure that I doing it correctly Here is my code on a page template:               $args = array(         'post_type'      => 'property',         'orderby'        => 'meta_value',         'meta_key'       => 'random_775',         'order'          => 'ASC',         'posts_per_page' => 100,     );           $view_all_properties_sorted = new WP_Query( $args );       and here is the function in my functions.php file:                add_action( 'pre_get_posts', 'sort_view_all_properties' );      function sort_view_all_properties($view_all_properties_sorted) {          $view_all_properties_sorted->set('meta_key', 'sold');         $view_all_properties_sorted->set('meta_value', 'true');         $view_all_properties_sorted->set('meta_compare', '!=');      }      When I use this code, I'm getting a 404 error when I add this line:               $view_all_properties_sorted->set('meta_key', 'sold');      Is it because meta_key has already been set? Any suggestions on what I may be doing wrong?


title: linking pic previews to posts

text:
This site is a twentytwelve child theme, and it's located at www.travelwithcastle.com I'd like to link the pictures on the post previews (on the homepage) to the actual post -- right now when i click the picture, it is not linked. Only the title text is linked. I like that, and I'd like to also link the picture preview. Does anyone know how i can do this? My guess is that it has to do with how i code the permalink in the content.php file, though I couldn't swear by that. To that end, here is my content.php code as it currently looks.               <?php     /**      * The default template for displaying content. Used for both single and index/archive/search.      *      * @package WordPress      * @subpackage Twenty_Twelve      * @since Twenty Twelve 1.0      */     ?>              <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>             <?php if ( is_sticky() && is_home() && ! is_paged() ) : ?>
                 <?php _e( 'Featured post', 'twentytwelve' ); ?>
             <?php endif; ?>                              <?php the_post_thumbnail(); ?>                 <?php if ( is_single() ) : ?>
<?php the_title(); ?>
                 <?php else : ?>
                     <a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( __( 'Permalink to %s', 'twentytwelve' ), the_title_attribute( 'echo=0' ) ) ); ?>" rel="bookmark"><?php the_title(); ?>
<?php the_date(); ?>
                 <?php endif; // is_single() ?>                 <?php if ( comments_open() ) : ?>
                         <?php comments_popup_link( '' . __( 'Leave a reply', 'twentytwelve' ) . '', __( '1 Reply', 'twentytwelve' ), __( '% Replies', 'twentytwelve' ) ); ?>
                 <?php endif; // comments_open() ?>                       <?php if ( is_search() || is_home() ) : // Display Excerpts for Search and Homepage ?>                  <?php else : ?>
                 <?php the_content( __( 'Continue reading →', 'twentytwelve' ) ); ?>                 <?php wp_link_pages( array( 'before' => '
' . __( 'Pages:', 'twentytwelve' ), 'after' => '
' ) ); ?>
             <?php endif; ?>                           <?php if ( is_singular() && get_the_author_meta( 'description' ) && is_multi_author() ) : // If a user has filled out their description and this is a multi-author blog, show a bio on their entries. ?>

                             <?php echo get_avatar( get_the_author_meta( 'user_email' ), apply_filters( 'twentytwelve_author_bio_avatar_size', 68 ) ); ?>

<?php printf( __( 'About %s', 'twentytwelve' ), get_the_author() ); ?>

<?php the_author_meta( 'description' ); ?>

                                 <a href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>" rel="author">                                     <?php printf( __( 'View all posts by %s →', 'twentytwelve' ), get_the_author() ); ?>

                 <?php endif; ?>


title: Why is my get_post_meta always empty

text: I made this action hook which will send an email to the users every time a new post in the custom post type "events" is made.               function email_members($post_id) {     global $wpdb;          $usersarray = $wpdb->get_col("SELECT user_email FROM wp_users");     $users = implode(",", $usersarray);          if( ( $_POST['post_status'] == 'publish' ) && ( $_POST['original_post_status'] != 'publish' ) ) {         $subject = 'Event Reminder';              $post_url = get_permalink($post_id);         $post_title = get_the_title($post_id);         $event_date = get_post_meta( $post_id, 'ch_event_date', true );              $message = "APAC Ministries Event Reminder for: ".$post_title."\n\n";         $message .= "Date: ".$event_date;              wp_mail($users, $subject, $message );       }     }          add_action('publish_th_events', 'email_members');      However, the `$event_date` is always empty. I tried running this code in a different file and it works:               global $post;     $test = get_post_meta($post->ID, 'ch_event_date', true);     echo $test;      I have also tried using `global $post;` and using `$post->ID` as the ID. I have also tried getting the terms, and it displays fine. I'm just having trouble displaying the meta. Any alternative solutions are welcome. Thanks!


title: Displaying just one post from each category on archive page

text: My categories look like this. Each has one or more posts               -Main Category     --Main Category Sub-category 1     --- 1 post here     --- 1 post here     --Main Category Sub-category 2     --- 1 post here     --- 1 post here     --- 1 post here     --Main Category Sub-category 3     --- 1 post here      When viewing Main Category archive page I only want the first post from each of the subcategories. So in my case I would only have 3 posts. Using twentythirteen theme. Don't want to change too much. I hope it can be done with query_posts.                       <?php /* The loop */ ?>             <?php query_posts($query_string . '&??????'); ?>             <?php while ( have_posts() ) : the_post(); ?>                 <?php get_template_part( 'content-category', get_post_format() ); ?>             <?php endwhile; ?>


title: removing the featured image from the post

text:
This is a twentytwelve wordpress child theme, and it's located at www.travelwithcastle.com I'd very much like to delete the enormous preview pic that shows up on top of the actual post page. It's the feature pic I chose to be the preview pic for the homepage. I love the picture, but that picture is already within the post content, so there is no need for it appear above the post as well. I took at look at content.php, thinking that would be the place to look, but I'm a little stumped. Perhaps I'm misunderstanding the code, but it seems to me that any change I make there will also affect the actual preview of the post on the homepage. I thought I was removing the image for example by deleting the thumbnail, but that removed the image completely from the homepage preview. Can anyone explain how I can instruct the site to not show the preview pic at the top of the post, while keeping it on the homepage as a preview? Perhaps I need to structure the files differently? to be clear, the picture i choose as the featured image for the post (the one that shows up on the homepage preview) also shows up at the top of the actual post, before the title. I'd like it not to be there since it's already in the post content. I did peruse your past questions, and while a lot of very similar questions are asked, this one is not. Many thanks. Kelly content.php is posted here for your reference:               <?php     /**      * The default template for displaying content. Used for both single and index/archive/search.      *      * @package WordPress      * @subpackage Twenty_Twelve      * @since Twenty Twelve 1.0      */     ?>              <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>             <?php if ( is_sticky() && is_home() && ! is_paged() ) : ?>
                 <?php _e( 'Featured post', 'twentytwelve' ); ?>
             <?php endif; ?>                              <?php the_post_thumbnail(); ?>                 <?php if ( is_single() ) : ?>
<?php the_title(); ?>
                 <?php else : ?>
                     <a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( __( 'Permalink to %s', 'twentytwelve' ), the_title_attribute( 'echo=0' ) ) ); ?>" rel="bookmark"><?php the_title(); ?>
<?php the_date(); ?>
                 <?php endif; // is_single() ?>                 <?php if ( comments_open() ) : ?>
                         <?php comments_popup_link( '' . __( 'Leave a reply', 'twentytwelve' ) . '', __( '1 Reply', 'twentytwelve' ), __( '% Replies', 'twentytwelve' ) ); ?>
                 <?php endif; // comments_open() ?>                       <?php if ( is_search() || is_home() ) : // Display Excerpts for Search and Homepage ?>                  <?php else : ?>
                 <?php the_content( __( 'Continue reading →', 'twentytwelve' ) ); ?>                 <?php wp_link_pages( array( 'before' => '
' . __( 'Pages:', 'twentytwelve' ), 'after' => '
' ) ); ?>
             <?php endif; ?>                           <?php if ( is_singular() && get_the_author_meta( 'description' ) && is_multi_author() ) : // If a user has filled out their description and this is a multi-author blog, show a bio on their entries. ?>

                             <?php echo get_avatar( get_the_author_meta( 'user_email' ), apply_filters( 'twentytwelve_author_bio_avatar_size', 68 ) ); ?>

<?php printf( __( 'About %s', 'twentytwelve' ), get_the_author() ); ?>

<?php the_author_meta( 'description' ); ?>

                                 <a href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>" rel="author">                                     <?php printf( __( 'View all posts by %s →', 'twentytwelve' ), get_the_author() ); ?>

                 <?php endif; ?>


title: Require Custom Taxonomy for Custom Type

text: I have created a fairly unexciting custom type (Event) and an equally vanilla custom taxonomy (Venue). Whenever a user creates an Event, I want them to be required to either create a new Venue or select an existing Venue. How can I make this a required field when publishing? It seems like the sort of thing that should be rather trivial but I've been going up and down http://codex.wordpress.org/Function_Reference/register_taxonomy and haven't found anything obvious. Am I going about this in the wrong way? Any assistance would be appreciated.


title: Number Unread comments/posts

text: I am having trouble getting an unread posts and comments plugin to work on my site. I have multiple authors which I am trying to control with role scoper. Only certain people can access certain categories. Unfortunately none of the plugins for number of comments/posts seem to work with rolescoper defined roles; the changes still show up, but the user can't click them... Anyway, maybe it would be easier to create a plugin where a user clicks a button next to each post they read, with a 'unread post' counter that begins only when the user registers... Hm... Is this possible? It would be a useful feature to have because then if someone doesn't want to read a post right away, they can come back to it later... maybe even tag it in a separate way so that there's a section on the site where they can read all the stuff they tagged...


title: How would you feed Custom Post Types to Facebook?

text: I have this dilemma whereby I'd like FB-Connect or a similar tool to automatically push custom data found in Custom Post Types to Facebook. Here's an example (it only works because it's a manual workaround). The final result is/should be this: ![Result with manual workaround](http://i.stack.imgur.com/eBn9H.jpg) I can achieve that by placing this in the header:               if (is_singular('adoptions')) {     echo '<meta name="description" content="';     echo 'New Pet for Adoption! ' . $name . ' is a ' . $age . ' year old ' . $gender . ' ' . $breed . ' who needs a home!';     echo '" />';}      It's great because I can exactly influence the excerpt (but the downside is everything needs to be done manually). Not so with Custom Post Types and auto- publish where the empty content of the post type then only shows an image and '...', in other words giving the reader no clue what this is about. What I'm thinking is that I can either:   * Modify the automatic publisher from WP to push content in this manner (not even sure where to start), or.. and this seems easier;   * Create a custom RSS feed which is then imported into the page via an RSS app? The added benefit is that the feed can be used elsewhere too. What does the dream-team think? :) Thank you!


title: Possible to create a paginated blogroll archive?

text: I'd like to have a separate blogroll archive whereby I can display them more or less in the same manner as posts/post types. IE: an archive which can be paginated and also with links to the separate categories to filter. How to create an archive which can be paginated and: what are the url's of my blogroll categories? Kind regards


title: Pagination on taxonomy archive pages breaks

text:
I've created archive pages for all my taxonomies (taxonomie-{taxonomy- name}.php) and this works fine. The slug of my taxonomies are the same as the slug of it's post-type. This makes it possible to create neat hierarchy in the url, ie: when post-type 'products' has 'type' as a taxonomy with the values book, cd and dvd. post-type1 has the slug 'product' and taxonomy1 has the same slug: 'product'. This way I can list the taxonomie-archives in the following way: products/book products/cd products/dvd and this works great. However: the pagination works on the products archives but on the products/{type} archive it gives a 404. Any clue? Code of the taxonomy template is as follows:                 <?php get_header(); ?>

<?php previous_posts_link(''); ?>

<?php next_posts_link(''); ?>

                       <?php while ( have_posts() ) : the_post(); ?>         <?php         $post_type = get_post_type( get_the_ID() );         ?>             <article class="hentry publicaties artikel <?php echo $post_type ?>">                                  <?php the_title( '
' . the_date('d.m.y', '', '', false) . '', '
' ); ?>

<?php $large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'large'); echo ''; the_post_thumbnail('thumbnail', array('class' => 'artikel-thumbnail')); ?>
                     <?php $this_excerpt = get_the_excerpt(); echo $this_excerpt; ?>... <a href="<?php the_permalink(); ?>" class="lees-verder">Lees en luister

         <?php endwhile; ?>

<?php previous_posts_link(''); ?>

<?php next_posts_link(''); ?>

       <?php get_footer(); ?>


title: Background Updates Not Happening

text: I have some sites which are not updating with the background updater. I installed the Background Update Tester plugin and everything looks fine. Currently they are at 3.9 but they are telling me that 3.9.1 is available. Am I mistaken in thinking that the 3.9.1 update should be applied automatically?


title: using $wpdb to get custom post type with term

text:
I'm trying to get the title of the first custom post type with a specific term in a taxonomy.   But I'm not great at SQL so therefor not great with using `$wpdb`. Here is my code:               $posts = $wpdb->get_results("         SELECT ID, post_title          FROM $wpdb->posts          LEFT JOIN $wpdb->term_relationships         LEFT JOIN $wpdb->term_taxonomy         WHERE post_type = 'property'         AND $wpdb->terms.name = 'Locked'         AND $wpdb->term_taxonomy.taxonomy = 'status'     ");     echo $posts[0]->post_title;      Any suggestions on how to get the title of the first custom post type of 'property' with the term 'Locked' in the taxonomy 'status'? **Update**   This is how I attempted this using `WP_Query`:               <?php         $args = array(             'post_type' => 'property',             'tax_query' => array( array(                 'taxonomy' => 'Status',                 'field' => 'slug',                 'terms' => $term             ))         );              $loop = new WP_Query( $args );              while ( $loop->have_posts() ) :             $loop->the_post();             the_title();             echo '
';             echo get_the_post_thumbnail();             the_content();             echo '
';         endwhile;     ?>      where `$term` is `"Locked"`. What I really need is a way that I can query by multiple terms and taxonomies in an array or multiple arrays.   Any hints?


title: Wordpress Frontend Check If Current User Is Administrator

text: I am trying to check if current user that accessing a page if administrator using `current_user_can()`, but it is not working and returning this message instead:               Fatal error: Call to undefined function wp_get_current_user() in /home/******/public_html/wordpress/wp-includes/capabilities.php on line 1329      What can I use to check whether a user is admin or not in the front end? I am using a separate php file to do it, like this:               <?php         if(current_user_can('manage_options')) {         // do stuff here..         }     ?>      I know it can be fixed by adding this line of code `require_once('pluggable.php')` in the second line of file named `capabilities.php`. But I don't want user bothering about it.


title: How do I remove weird characters in text?

text: Help, my site is suddenly populated with weird characters, like this: > â€œDo what you love and do it often,â€ â€œIf you donâ€™t like your job, > quit,â€ and â€œTravel often; Getting lost will help you find yourself.â€ What do I do to remove it? Link to Website. ![Here's an example.](http://i.stack.imgur.com/i6Nx1.jpg)


title: Use have_posts() with array of post results retrieved by $wpdb->get_results

text: I don't know if I'm retarded, crazy or just plain genius or not, but I've decided to use tags as a way to link content site-wide (a big ol' many-to-many relationship website for archiving various aspects of a huge project). Unfortunately, this means that some custom post types utilised by some plugins don't exactly link up properly with other objects (posts, pages, etc.) as they use other taxonomies (and in the case of media 'attachments' they don't use taxonomies at all, unless I pork in a plugin to fix that -- which there is and I'm using it and it uses a different taxonomy...). Actually, some plugin types have specific taxonomies hard-coded in so I can't really go through and change their core code or else a plugin upgrade would wipe all my hard work. To address this fragmentation and perception of long, arduous work of hacking the plugins and/or Wordpress, I initially used the Advanced Taxonomy stuff with `WP_Query` and that was working well, until I found I needed some extra information with meta tags and to even change the default ordering based on the `post_type` and `meta_values` specific to the `post_type`. So now I'm going the shorter "long, arduous" work route and have written my own custom SQL builder to fetch the objects based on the tag/meta relationships with the custom ordering per `post_type` as required by the project. One thing I'd love to do, so I can use both this new custom query and the existing `WP_Query` methods, is find out some way to wrap the custom query results in a `WP_Query` class so I can use `have_posts` and `the_post` -- basically all the nice `$post` stuff. `$wpdb->get_results` only gives me a plain array of results and I'm not so clued up on `WP_Query` and `$wpdb`'s niggly bits; can `WP_Query` let me do some funky custom selects, joins and then order based on the columns selected? Can I just flick an SQL query to `get_posts()` to get the `WP_Query` wrapper and its glorious Loop functionality? It's late and I'm oh-so-close to solving this riddle, so I'd appreciate your help, Obi Wan Kenobi; For the moment the simplest solution looks to be the `have_posts()` functionality applied to a plain array of post results retrieved via the `$wpdb->get_results` function, to then easily and seamlessly initiate a WP Loop on that set of post results. If you may know of any other way to do this (Custom Queries, mayhaps?) I'm all ears.


title: Add a Fancybox automatically to post type "post" images

text:
Currently, on my homepage (which is a list of posts), if you click an image it opens in the same window as a full size image. I'd like to change it so that when a user clicks said image it opens into a Fancybox pop-up. I've got my Fancybox code, which works on my Custom Post Type pages (because I've been able to set the class/rel for these images):               // fancybox     jQuery( document ).ready( function( $ ) {         $("a img.fancybox").fancybox({             'transitionIn'  :   'elastic',             'transitionOut' :   'elastic',             'speedIn'       :   600,              'speedOut'      :   200,              'overlayShow'   :   true,             'overlayOpacity':   0.7,             'overlayColor'  :   '#333',             'titlePosition' :   'over'         });     });      But I don't know how to add Fancybox to the code that WordPress automatically gives to its linked images in posts:

Amazonas Magazine - now in English!

      Any suggestions? Is there a way I can do this using just the jQuery selector on Fancybox, or will I have to implement a WP filter to amend post-inserted image links so that they include a specific id/class? Thanks in advance,


title: WordPress Install Issue, Receive Warnings But Successful Install

text: I get the following warning on my installation. It installs successfully but I'm not sure whether or not these issues are vital to my blog. I'm using IIS, anyone know why I'm having these issues and what I can do to get rid of these errors? > Warning: unlink(C:\Inetpub\wwwroot\bozack/5505560414c7fd72a81f63.tmp) > [function.unlink]: Permission denied in C:\Inetpub\wwwroot\bozack\wp- > admin\includes\misc.php on line 585 > > Warning: unlink(C:\Inetpub\wwwroot\bozack/web.config) [function.unlink]: > Permission denied in C:\Inetpub\wwwroot\bozack\wp-admin\includes\misc.php on > line 585


title: What plugin should I use for booking events and receiving payments?

text: What plugin would you recommend for booking events and receiving payments. I have approx 70 classes per year in a swim club that people can sign up for.


title: Customizing the Subject Field in WordPress' Notification Emails?

text: Can I customize and edit the subject field in the "Password Reset" notification mails sent from our multisite blogs? I have tried some plugins like My brand login and white label CMS etc. But I can't edit this in password reset notifications . Does anyone help me understand how to edit it ? **Update:** Today I tried with another installation .But it is not making any change.The Word 'wordpress' in from mail address is still there.I have added - `add_filter ( 'wp_mail_from_name', 'my_filter_that_outputs_the_new_name' );` to the code given by Doug .Am I missing something?Could you help me to solve this?


title: Load Javascript for a widget Worpress

text: I want to load a special Javascript File just when the widget is loaded in the sidebar. Where do I have to put my `wp_enqueue_script(...)` lines?               class controller_widget extends WP_Widget {         function controller_widget() {             $this->color = "red";                  $this->dir = plugin_dir_url(__FILE__);             $widget_ops = array('classname' => 'controller_widget', 'description' => __('Benutzerfreundlicher Controller zur eingrenzung von Objekten'));             $control_ops = array('width' => 350, 'height' => 400);             $this->WP_Widget('controller_widget', __('Controller'), $widget_ops, $control_ops);                  // At the moment I load the code here, but I want to proof that it is just loaded when the widget really is shown in the sidebar.             }         }              function widget( $args, $instance ) {...}     }      Thank you!


title: How to store post meta in an array

text: I am creating a plugin, where the user can create forms with an unlimited amount of fields. I would like to store each field the user creates as an array in a post meta field. What would the code look like for this please? (This is the first plugin i've ever created). @Wyck previously touched on this topic below, but didn't outline the complete code. I'm quite confused about the requirements. Link to this topic discussed previously Thanks!


title: jQuery in header or footer

text: From my reading it seems there is a good case for loading scripts like jquery and dependencies into the footer as a preference if possible; however 2 things confuse me which. Firstly the default for wp_enqueue_script() is to put the script in the footer and second (and possibly related) there is a line from the codex > Note that you have to enqueue your script before wp_head is run, even if it > will be placed in the footer. Is this to say that even if the script is set to load into the footer it still loads early on and so we loose several of the advantages of footer placement? **Edit** - Just in case the above incorrect statement confuses anyone in future. I realised since that I'd been reading the codex wrong and that the default for `wp_enqueue_script()` is **NOT** to put the script in the footer


title: Most viewed post of custom post type

text:
Im using following code for getting most populer post with thumbnail.I have a custom post type taxonomy (Talks). Custom post types(video) have 6 category. But my code not working. It just getting 1 post.But i have 10 post. How can i fix it?                   <?php          $args = array(         'post_type' => 'video',         'showposts' => 10,         'order' => 'DESC',         'meta_key' => 'post_views_count',         'orderby' => 'meta_value_num',              'tax_query' => array(             array(                 'taxonomy' => 'Talks',                 'field' => 'id',                 'terms' => array(                     371,                     372,                     373,                     374,                     375,                     376                 )             )         )     ); //      $loop = new WP_Query($args);     while ($loop->have_posts()):         $loop->the_post();     ?>
                                    <a class="box-over" href="<?php         the_permalink();     ?>">                                                     <?php         if (($video_thumbnail = get_video_thumbnail()) != null) {             echo "";         }     ?>
<a href="<?php         the_permalink();     ?>"><?php         the_title();     ?>

                                        <?php     endwhile;     ?>


title: Using add_filter() in Widgets

text: Just have a query reference the `add_filter()` function. Can you use this function inside a WordPress widget class. **Example** I have a widget with dynamic created code that I want to pass to another function created within the plugin. Can this be achieved?               <?php     /**      * Display the actual Widget      *      * @param Array $args      * @param Array $instance      */     public function widget($args, $instance){              extract($args);              /* All the widget code. Hidden to save space */              /* Generate unique id if shortcode - used for styling */         $sc_id = mt_rand(1, 100000);         $wcss = '';              /* Here is the actual output code that I want to pass to another function I created */         $wcss .= ".awp_archive_widget_sc".$sc_id." { border:".$awp_archives_border_width.' '.$awp_archives_border_style.' '.$awp_archives_border_color." !important }\n";         $wcss .= $awp_archives_border_radius == 'round' ? '.awp_archive_widget_sc'.$sc_id.' { -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px }' : ''.''." \n";         $wcss .= ".awp_archive_widget_sc".$sc_id." li a, .awp_archive_widget_sc".$sc_id." li { font-size:".$awp_archives_font_size." !important }\n";         $wcss .= ".awp_archive_widget_sc".$sc_id." li a { color:".$awp_archives_link_std." !important }\n";         $wcss .= ".awp_archive_widget_sc".$sc_id." li a:hover { color:".$awp_archives_link_hover." !important }\n";              $out = '';              /* Rest of widget code - hidden to save space */              echo $out;     }     ?>      The code marked `$wcss` is the actual code that I want to pass to another function. I thought I could do something like this from within the plugin constructor.               add_filter('advanced_widget_pack_css',array(&$this,'$this->widget'));      Any help would be greatly appreciated. Just not sure how to achieve this from within the widget class. **Additonal Code** The plugin allows for custom css styles through creating a custom CSS file through WordPress AJAX. Here is how I generate the custom AJAX CSS stylesheet: **Generate WordPress AJAX CSS file**               /**      * Enqueue the widgets stylesheet      */     public function add_awp_css(){              wp_enqueue_style($this->hook, plugins_url('advanced-widget-pack/css/advanced-widget-pack.css' , dirname(__FILE__)), array(), '', 'screen');               wp_enqueue_style(             $this->hook.'-custom',             add_query_arg(                 array(                     'action' => 'advanced_widget_pack_gen_css',                     /* Include this to ensure changes don't get cached by the browser */                     'layout' => substr(md5(serialize($this->hook)), 0, 8)                 ),                 site_url()             ),             array($this->hook),             $this->version         );       }      This works greats. Now the function that the above enqueue calls is this: **The callback function for the WordPress AJAX CSS file**               /**      * Echo the CSS for the custom widgets style      */     public function advanced_widget_pack_css() {         if(empty($_GET['action']) || $_GET['action'] != 'advanced_widget_pack_gen_css') return;         if(!isset($_GET['ver'])) return;              $css_text = '';              /* ============================= */         /* Archives Widget               */         /* ============================= */         if(awp_option('archives_style_border') == 'true'){                   $css_text .= ".awp_archive_widget { border:".awp_option('archives_style_border_width').' '.awp_option('archives_style_border_style').' '.awp_option('archives_style_border_color')." !important }\n";             $css_text .= awp_option('archives_style_border_radius') == 'round' ? '.awp_archive_widget { -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px }' : ''.''." \n";         }             $css_text .= ".awp_archives_colour { color:".awp_option('awp_archives_dropdown_inst_colour')." !important }\n";               /**          * Filter the unprocessed CSS array          */         $css_text = apply_filters('advanced_widget_pack_css', $css_text);              header("Content-type: text/css");         echo $css_text;         exit();     }      This above function also works fine. It outputs a CSS file.


title: I am not able to enable jQuery in theme settings

text: I have tried to - enable `Use jQuery` & then save changes. But after saving changes, checkmark `Use jQuery` automatically unchecks itself. I am not sure whats going on. Please help me here. ![enter image description here](http://i.stack.imgur.com/pjmS7.png)


title: PHP code for link with text

text: I was exploring and ran across this post: Grab First Link From A Post, Grab First Blockquote I would basically like to do the same thing, but have it call not only the URL but also the link, since I am using the link as an excerpt title. For example; if my link is `<a href="http://www.facebook.com/>Facebook</a>` I want it to call a link that says `Facebook` not one that says `http://www.facebook.com` like the current code does. This is probably easy when given the code provided already, but I can't figure it out.


title: What is the general cut-off date for reviewed themes in the WordPress.org repository?

text: I know that the theme review team has been active for about one year now. Thanks to their hard work and diligence, the themes in the repo are _much_ better now than ever before. However, I have noticed that there are still older themes in the repo that, at first glance, probably would not pass the review if submitted or updated today. Is there a date that anyone can point to where we might want to be wary of any themes that were last updated before then? On a related note, is there a plan to possibly phase out some of these themes?


title: Admin - create custom post status and display above table

text: How do I create a custom post status and display it above the table of my custom post type? Example: `All(9) | Published (7) | Custom_Status(2)` I used the advance custom fields plugin to create a dropdown which represents the status of the post. But I'm sure that that does not represent the actual status of the post since it won't be saved in the `post_status` column in the database. Feel free to suggest plugins. I tried the edit flow plugin, but it's kinda inconvenient because every time I change the status of my post it will un- publish the post. Thanks!


title: Fast way to add countries as a custom taxonomy term?

text: Is there a quick way to add a list of countries as terms to a custom taxonomy called "Country"? Is there an existing import file, SQL script ect... I don't want to be there all day manually adding them. Any ideas would be great.


title: query a newly created table using $wpdb

text: i created a new table inside my wordpress database called `forms`, this table consist of `ID` and `names` i want to query all the list from this table using the wordpress `$wpdb` this is my code below               <?php         global $wpdb;         $result = $wpdb->get_results ( "SELECT * FROM  $wpdb->forms" );         foreach ( $result as $print ) {               echo $print->ID.'<br/>';        }     ?>      but im only getting a text `Array` from my `echo`


title: Sortable columns and admin like interface for tables/report in custom plugin?

text: We have wordpress admin interface for "all posts" list. Sortable column methods are available for "custom post type". But can we not implement this type of wp-admin like interface with sortable columns in any reporting/table in our any custom plugin that show a tabular report or listings fetched from database?


title: Manage PDF downloads and protected pages

text: I am re-building an old CMS site (I think it was built using Front Page) to update its appearance, and usefulness. Have successfully completed most of its structure and content, but am quite uncertain as to how I can implement 2 new and different page types. I need one page to show a 2-column, 13-row table which will contain hyperlinks for current year's and previous year's monthly newsletters (which would be uploaded as PDFs). Cannot find how to do this. My second problem is that I wish to have 1 to 3 separate pages that would require logins/registration for privacy. (All other pages on this site are Public). Each page would address a different population, so most names would not repeat from one page to another, but a few will. Again cannot find a method to implement this. Is anyone able to point me in the right direction? Would most appreciate it...


title: How to implement filesystem cache in Wordpress

text: I'm currently using the Transients API to cache some product details from Amazon. Now I'm looking into adding a file system cache. But I have no idea how to implement it. The only thing that I can think of is to actually save the JSON string representation of a specific product into a text file. Is this worth it? Are there any proven performance benefits when doing this or does it have the same performance to that of the database? Thanks in advance.


title: Separately formatting date elements

text: I am trying to achieve the following look in the time format: ![enter image description here](http://i.stack.imgur.com/u4Rh9.png) I have for now several issues,   First is that the month and year are not displayed at all, I use `<?php the_date('D'); ?>` `<?php the_date('M'); ?>` `<?php the_date('Y'); ?>` for start and only the day is shown, Second - Are there WP functions I can use to   * Get the month in 3 cap letters?   * Get only 2 last digits of year? Or I have to use my own PHP functions for that? Also, it must be hard-coded in the theme, because otherwise it will mess up the design. **Update**   I used `<?php echo get_the_date('M'); ?>` and I got all the times, but isn't `the_date` meant exactly for that?


title: pagination links not displaying

text:
I'm unable to get my 'next_posts_link()' and 'previous_posts_link()' to display. So far I've tried the standard first debug by deactivating all plugins and clearing the cache, I've also tried removing the optional parameters from the call. And I've also tried using wp-pagenavi, which does display but oddly only when I set my Reading options to show 1 post per page and even then it only shows 2 page links. The site I'm having the problem with is pixelsandtea.com and here's the code on my home template page.               <?php get_header(); ?>

             <?php                 $args = array( 'post_type' => array( 'post', 'portfolio', 'news' ) );                 $loop = new WP_Query( $args );                 while ( $loop->have_posts() ) : $loop->the_post();             ?>             <li class="article preview" id="post-<?php the_ID(); ?>">
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?>
                 <?php $content = $post->post_content;                 $searchimages = '~]* />~';                 preg_match_all( $searchimages, $content, $pics );                 $iNumberOfPics = count($pics[0]);                 if ( $iNumberOfPics > 0 ) { ?>                     <a href="<?php the_permalink(); ?>" class="thumb" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><img src="<?php bloginfo('template_directory'); ?>/scripts/timthumb.php?src=<?php echo get_post_meta($post->ID, "thumb", $single = true); ?>&w=279&zc=1" alt="<?php the_title(); ?>" /><?php                 }                 the_excerpt(); ?>
                     Posted: <?php the_time(__('l, jS F, Y')) ?> ˑ <?php printf(__('Filed under: %s'), get_the_category_list(', ')); ?> ˑ <?php the_tags(); ?>
                     <?php comments_popup_link(__('No commentaries for this post yet. You could be the first!'), __('1 Comment'), __('% Comments'), '', __('Comments are closed') ); ?><?php edit_post_link(__('Edit this entry'), ' ˑ ', ''); ?>

             <?php endwhile; ?>

<?php next_posts_link() ?>

<?php previous_posts_link() ?>

     <?php get_footer(); ?>      Thank's all!


title: Custom nav menu not showing

text:
I want to make a custom menu that will be a select-box, I registered a custom menu:               add_action( 'init', 'register_my_menu' );          function register_my_menu() {         register_nav_menu( 'primary', 'Primary Menu' );     }      I added a custom menu crawler to the heading using this: How to use wp_nav_menu to create a select menu dropdown?                                <?php                 class Walker_Nav_Menu_Dropdown extends Walker_Nav_Menu{                     function start_lvl(&$output, $depth){                         $indent = str_repeat("\t", $depth); // don't output children opening tag (`<ul>`)                     }                          function end_lvl(&$output, $depth){                         $indent = str_repeat("\t", $depth); // don't output children closing tag                     }                          function start_el(&$output, $item, $depth, $args){ // add spacing to the title based on the depth                         $item->title = str_repeat(" ", $depth * 2).$item->title;                              parent::start_el(&$output, $item, $depth, $args);                              // no point redefining this method too, we just replace the li tag...                         $output = str_replace('<li', '<option', $output);                     }                          function end_el(&$output, $item, $depth){                         $output .= "</option>\n"; // replace closing
 with the option tag                     }                 }                      wp_nav_menu(array(                     'theme_location' => 'primary', // your theme location here                     'walker'         => new Walker_Nav_Menu_Dropdown(),                     'items_wrap'     => '<select>%3$s</select>',                 ));             ?>               And created a custom menu in the WP-Admin ![enter image description here](http://i.stack.imgur.com/pnvJ2.png) But still the menu doesn't show. What am I missing? **Update**   Apparently The crawler function does make an output but it is messed up,   When I use just `register_nav_menu( 'primary', 'Primary Menu' );` I get a working menu.

                 <option id="menu-item-54" class="menu-item-54"></option>                 <option id="menu-item-24" class="menu-item-24"></option>                 <option id="menu-item-30" class="menu-item-30"></option>                 <option id="menu-item-18" class="menu-item-18"></option>                 <option id="menu-item-22" class="menu-item-22"></option>                 <option id="menu-item-26" class="menu-item-26"></option>                 <option id="menu-item-13" class="menu-item-13"></option>                 <option id="menu-item-28" class="menu-item-28"></option>                 <option id="menu-item-15" class="menu-item-15"></option>                 <option id="menu-item-2" class="menu-item-2"></option>                 <option id="menu-item-20" class="menu-item-20"></option>

           This is what I get when using the exact same function in twenteleven theme (which is what I want):
             <select>                 <option id="menu-item-59" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-59">Sample Page </option>                 <option id="menu-item-60" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-60">  News</option>                 <option id="menu-item-65" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-65">About   </option>                 <option id="menu-item-62" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-62">  Contact Us</option>                 <option id="menu-item-63" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-63">  Our Location</option>                 <option id="menu-item-61" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-61">History</option>                 <option id="menu-item-64" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-64">Links</option>             </select>
           **Update**   I solved the problem. apparently the custom menu was selected when I used another theme and I assumed every theme will uset. well - no! I had to select custom menu for each theme separately.


title: Sort posts based on multiple custom fields

text: I have a three custom fields   * Meta Key -> YOUR_PREFIX_newcar_body_type   * Meta Key -> YOUR_PREFIX_newcar_transmission_type   * Meta Key -> YOUR_PREFIX_newcar_variant and I have to sort posts based on these custom fields and print the title of the post... Any ideas?


title: how to exclude "featured" posts from the main loop?

text: In a category.php template, I built a function that lists "featured" posts before the main loop. The featured posts are selected using a custom field and get_posts():               function list_featured_articles(){      $featured_posts = get_posts('meta_key=featured_article&meta_value=on&numberposts=10&order=DESC&orderby=post_date');     }      My category.php template:               echo list_featured_articles();     get_template_part( 'loop', 'category' );      It works fine, except that the featured articles are listed also in the category list of articles. I would like, from my function, get the featured posts' ID and remove them from the main loop. Is there a proper way to do it? I figure i could use a GLOBAL variable storing an array of excluded ids, but i'd like to avoid using Globals for that.


title: Get total number of comments from posts in a specific custom taxonomy

text: I’m having some difficulties trying to get total number of comments from posts **within** a specific custom taxonomy. The setup is as such: I’ve created a custom taxonomy for my posts, called “features”. Within that taxonomy I’ve like four or five terms. Then, some of my posts are put into feature-term 1, feature-term 2, etc. I can get this to work and when making a query I can also retrieve how many posts are in each term. But then I would like to show the total number of comments that all the posts within each feature-term has. So for example, under feature-term 1, the total number of posts is 12 and the total number of comments are 34. I’ve tried with this query:   `SELECT SUM(comment_count) AS totalcc FROM wp_posts, wp_term_relationships WHERE wp_term_relationships.term_taxonomy_id = {$term->term_id} AND object_id = ID`   But it gives me an incorrect answer can I can’t quite get an overview of where I’m failing. Maybe there is an easier way to do it, a way that Wordpress provide but if so I haven’t been able to locate that. Any help or suggestions would be appreciated. Sincere   - Mestika


title: How to group the loop posts in a particular by author?

text: I have links going to category pages on a WordPress blog. These category pages show all the posts that are in that category and sub-categories. I want to group these lists by the authors. I guess need to modify category.php to first list all the authors which have posts in that particular category and then run WP_Query multiple times for each author. The second part is okay, but I can't figure out how to get the list of authors of only those posts in this category.


title: Redirect Loops Problems

text: I don't know what happened actually. Yesterday, it was just working fine. I recalled what I did to put me in this difficult situation this morning. Yesterday, I was just editing posts with PhpMyAdmin. Well, anyway, I disabled all plugin and find out what is not working. It's the Plugin Custom Permalinks. **My problem is that I have about hundred videos in youtube, and each video is given with Custom Permalink set. I want to keep the Custom Permalink Plugin and get rid with Redirect Loop Problems.** I now disable my Custom Permalink Plugin and everything work as it is. But this of course is not a good solution. Please help. If you need whatever codes and details plugin lists, please let me know.


title: Aligning the thumbnail image

text:
I want to control the alignment of the featured image(the thumbnail) with the options given in the 'Set featured image' pop box.               <?php if(has_post_thumbnail()) {        echo '
'; the_post_thumbnail(); echo '
';     } ?>      I want to add to the div with the class of border a class floatleft or floatright(or nothing) according for what the user chooses. Thanks!


title: Multisite get_home_url(); - Getting URL for current site

text: What would be the replacement for get_home_url() when using a multisite? For example, if I have one theme installed across several sites, and within the theme there are links that need to be specific to the current site. On my single install, using get_home_url(); would give me http://domain.com/, which was great, and if I moved the theme to a different domain, nothing would be affected. But when I'm using the same theme on a multisite, get_home_url(); gives me http://domain.com/ no matter which site I am currently on. What I would need for each one is domain.com/sitename/. Is there a different tag to use in this case? Thanks! EDIT Can't answer my own question yet, but `<?php echo get_bloginfo( 'url' )?>` was exactly was I was looking for.


title: Custom post type adding additional markup

text:
I'm creating a template but every time I add a new custom post type (in this example neighborhood) it keeps injecting a new `<ol>` and `<li>` here is the code I currently have and I'm using the ACF Advanced Custom Fields plugin to create my custom fields.               <?php          /*            Template Name: Neighborhoods Page          */          include(TEMPLATEPATH."/header-internal.php");?>

              <?php              $args = array(             'post_type' => 'neighborhoods'         );              $the_query = new WP_Query( $args );              ?>                   <?php if ( have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>

<a href="<?php the_field( 'url_neighborhood' ); ?>"><?php the_field( 'neighborhood_name' ); ?>

              <?php endwhile; else: ?>
There are no posts or pages here
              <?php endif; ?>
               <?php get_footer(); ?>


title: filter on the_content stopped working when I updated to WP 3.6.1

text: I created a filter to add a pin button on to my blog posts' images, which after much playing worked. Then, a few weeks later, I updated to 3.6.1, and the filter stopped working. Did something change in the new release that would prevent filters on the_content from working?               function cd_insert_pinterest($content) {             global $post;             $postID = $post->ID;                if( is_singular() && is_main_query() ) {                     $posturl = urlencode(get_permalink()); //Get the post URL                     $pindiv = '';                     $pinurl = '';                     $pinend = '';                     $pattern = '//i';                     $replacement = $pindiv.$pinurl.'$2.$3'.$pindescription.$pinfinish.''.$pinend;                     $content = preg_replace( $pattern, $replacement, $content );                     $newpattern = '/<\/a><\/span><\/a>/i';                     $replacement = '';                     $content = preg_replace( $newpattern, $replacement, $content );                }                                     return $content;          }          add_filter( 'the_content', 'cd_insert_pinterest');


title: Some doubts about how to show posts in a custom theme?

text: I am pretty new in WordPress theme development and I have some doubt about this WP function used to show my post in the homepage:                   <?php             if ( have_posts() ) :                 // Start the Loop.                 while ( have_posts() ) : the_post();                          /*                      * Include the post format-specific template for the content. If you want to                      * use this in a child theme, then include a file called called content-___.php                      * (where ___ is the post format) and that will be used instead.                      */                     get_template_part( 'content', get_post_format() );                      endwhile;                 // Previous/next post navigation.                 twentyfourteen_paging_nav();                  else :                 // If no content, include the "No posts found" template.                 get_template_part( 'content', 'none' );                  endif;         ?>      Intuitively I understood that as long as there are posts these are displayed in the homepage. My doubt is related about this line of code:               get_template_part( 'content', get_post_format() );      Reading the documentation it seems to me that: 1) **get_template_part** : Load a template part into a template. So I think that by this line I am including a template part used to show a post (the structure of a post into my homepage), is it correct? 2) What exactly do get_post_format() ?


title: Add Sort Link in Custom Post Type List

text: I need to add a link here, beside the Published link: ![enter image description here](http://i.stack.imgur.com/TwnQL.jpg) How can I do it? I'm trying to filter my custom post type by meta values and need a link to do it. Thanks.


title: User Attach Images To Post From Front End

text: Making a site that deals with custom parts. Id like to make it so when i make a post about a part i have a image upload button on that post in the frontend that lets users upload their custom pics to that post. The images would of course have to attach to that post. Looked over the search results here and on google and all i see is posting on front end with images. Nothing about letting users just attach data.


title: Load complete image, but don't bother the site speed

text: I designed and developed a site for my client. For images, I used the default WordPress sizes: `original`, `large`, `medium` and `thumbnail` (although I made some minute changes in their dimensions). As I heard about the resizing images (i.e. `large`, `medium` etc.), it enhances the site speed, and I need them eagerly. Just now, I've learned about the LazyLoad, I hope I'll implement it later inshALLAH, but for now...   in homepage I used the `thumbnail` size: `the_post_thumbnail( 'thumbnail' );`. But unfortunately the cropped `thumbnail` image from the `original` is looking bad. And also I don't want to load the `original` sized image, because that will hamper the site speed badly. **Question:**   How can I manage it then? ### EDIT I, actually want my `thumbnail` images to be cropped with the complete detail of the `original` image, but it actually cropping very precise part of the `original`. How can I enable my WP to crop the `original` image to a `thumbnail` with its complete detail? ### EDIT 2 It's actually nothing but a default WP things:                       <?php if ( has_post_thumbnail( ) )  { ?>                 <a href="<?php the_permalink(); ?>" title="<?php printf( __('Permalink to %s', 'your-theme'), the_title_attribute('echo=0') ); ?>" rel="bookmark">                 <?php the_post_thumbnail( 'thumbnail' ); ?>             <?php } else { ?>                 <a href="<?php the_permalink(); ?>"><img src="<?php echo get_template_directory_uri(); ?>/images/no-image.jpg" width="168" height="168" alt="Sultan Stationery - no image provided"/>             <?php } ?>


title: Add select field to media uploader that adds a class to the image

text: I'm looking for a way to add a `<select>` menu to the media uploader that will have two options: normal image, which will do nothing, and profile image, which will add a CSS class to the image if it is selected. I have gotten as far as adding the select menu to the uploader, but I don't know how to:   * apply a class to the image based on the selected option   * make sure the selected option stays selected   * make sure the selected option can be changed later This is what I have so far:               function my_profile_image_select( $form_fields, $post ) {         $form_fields['image-type'] = array(             'label' => 'Image Type',             'input' => 'html',             'helps' => 'Enter "profile-image" to enable profile image caption',         );              $profile_image = 'profile-image';         $normal_image = 'normal-image';         $form_fields['image-type']['html'] = '<select name="Profile Image Select" id="Profile Image Select">';         $form_fields['image-type']['html'] .= '<option value="' . $normal_image . '">Normal Image</option>';         $form_fields['image-type']['html'] .= '<option value="' . $profile_image . '">Profile Image</option>';         $form_fields['image-type']['html'] .= '</select>';             return $form_fields;     }     add_filter( 'attachment_fields_to_edit', 'my_profile_image_select', 10, 2 );


title: yoast seo plugin - remove bulk title and description editor menu from non-admins

text: Is there a way to remove the yoast-seo-plugin's bulk title and description editor menu from the non-admins. It is an awesome feature but I would like my users to keep off from it. I am using the very latest versions of wp and the plugin. ![enter image description here](http://i.stack.imgur.com/8rqsB.png) * * * I am trying a few variations of this code, but does not seem to be working.               if ( ! current_user_can('create_users') ) {          add_action( 'admin_menu', 'nonadmin_remove_bulk_menu', 999 );              function nonadmin_remove_bulk_menu() {         remove_menu_page('page=wpseo_bulk-title-editor.php');       }     }


title: Force Uploads Use Yearmonth to off (0) for all existing sites in Multisites

text: In WordPress Multisite, by default the site option **Uploads Use Yearmonth Folders** is on (set to 1). Is it possible to force this value for all existing sites in the Network? Perhaps a hook?   I know that for new sites created one can use:               function simplify_upload_folder($blog_id){         switch_to_blog($blog_id);         update_option('uploads_use_yearmonth_folders', false);         restore_current_blog();     }     add_action('wpmu_new_blog', 'simplify_upload_folder');      But what about already existing sites can one force this value via an action or filter? As an alternative to using a filter, I have written up the following to toggle the value in the DB but for some reason the field remains empty. Not sure where I am going wrong here:               if ( get_option( 'uploads_use_yearmonth_folders' ) == true || get_option( 'uploads_use_yearmonth_folders' ) == '' ) {           switch_to_blog($blog_id);           update_option('uploads_use_yearmonth_folders', false);           restore_current_blog();     }


title: Load page template with custom content using a plugin

text: I want to load the `page.php` template with the content I specify (using variables and not from the database) if the request contains a particular query string. So lets say a user requests `example.com/?var1=str1` the page template should be displayed with the title and content I specify using variables. This is the pseudo code of what I'm trying to achieve               <?php     function my_page_function() {     if($_REQUEST['var1'] == "str1")     {     $title="This will be the title of the default page template";     $content="This content will be displayed on the default page template.";     //Load the page.php here with the title and content specified in the variables above     }     }     add_action("template_redirect","my_page_function");     ?>      I wish to use this code in a plugin, so it should work with any theme's page.php.


title: How to remove the extra characters passing in the Custom post type

text: I have created the custom post type and the custom taxonomy. Then I have created the template file in the name of taxonomy taxonomy-product-categories. I created the post type, then added to the menu. When the menu is clicked . The url takes the junk character as #.UW1Rl0pfTxU at the end


title: nextgen gallery: how to get picture url by gallery id

text:
All posts in my site have custom field with nextgen gallery ID. To display gallery I use this code:               $gallery_id = get_post_meta( $post->ID, 'galerijos_id', true); // Get gallery id from custom field data      if( $gallery_id ){        echo '
';        echo nggShowGallery( $gallery_id ); // Display the gallery        echo '
';      How do I get pictures urls by gallery ID? I need url to pass to xml file. Thanks in advance.


title: Add "drop-down arrow" for menu items with sub-menus

text: WordPress doesn't add `parent` class to menu items that have submenus. Therefore this is required to extend this:               function add_parent_css( $classes, $item ) {         global $have_children;         if( $have_children ) {             $classes[] = 'parent';         }         return $classes;     }     add_filter( 'nav_menu_css_class', 'add_parent_css', 10, 2 );          class custom_walker extends Walker_Nav_Menu {       function display_element($element, &$children_elements, $max_depth, $depth=0, $args, &$output){         $GLOBALS['have_children'] = (isset($children_elements[$element->ID]))? 1:0;         parent::display_element($element, $children_elements, $max_depth, $depth, $args, $output);       }       [...]     }      The code will insert `parent` class to all menu items that have sub-menus and this can be then used in CSS like:               .parent:after { content: ">"; }      I'm wondering though, if there is a way to do that without custom menu walker? Just with filters? The reason I'm asking this is because some plugins like WPML ignore custom menu walkers for menu items and their "language switcher" in the menu doesn't get `parent` class even if has sub-items. Instead of waiting for WPML to fix that I would prefer to just update the menu in a theme to do it in a simpler way.


title: Wordpress plugin for nicer looking slugs? Have multiple pages named the same but they get different slugs

text: This wordpress site I'm touching up has a page hierarchy which is responsible for the urls. Basically the urls look like page1/subpage/subsubpage etc. The problem is, this site is for a recurring competition and therefore the urls are like 2011/results 2012/results 2013/results Which wordpress in turn makes 2011/results 2012/results-1 2013/results-2 Which doesn't look that great.. Is it possible to mod_rewrite or something to work around this? I understand the need in Wordpress for unique slugs but I really can't see why they enforce it even when it's impossible to get duplicate urls for different pages...


title: Comment `Reply` link doesn't work if comments are loaded from ajax

text:
I am writing a plugin that displays custom home page that is in fact **only one post with comments**. The first time home page is displayed by the initial call by php. Then user can click a menu button to get another post. This is handled by ajax. So the whole page does not reload. Getting and displaying other posts via ajax works fine till I 'refresh' the page via ajax. Then the comment `reply` link doesn't work any more. I implemented [AJAXified commenting system][1] but I guess it has nothing to do with reply link. Reply link before ajax is used looks like               Reply      When the same post is loaded via ajax the reply button looks like               Reply      The difference is in the `href` attribute. The second (ajax) one got `wp- admin/admin-ajax.php` part that does not supposed to be there. I use one php function to generate html for both the fist time post is being displayed and for ajax call too. Part of the function looks like                  function my_get_comments($post_id, $number_of_comments){         //Gather comments for a specific post          $comments =     get_comments(array(             'number' => $number_of_comments,             'post_id' => $post_id,             'status' => 'approve' //Change this to the type of comments to be displayed         ));              ob_start(); //workaround how to capture the output from comments_number() function             comments_number( 'no comments', 'one comment', '% comments' );         $capture_comments_number = ob_get_clean();              $return_string ='
'                         . ''                         . '
'                             . $capture_comments_number                             . ' Show / Hide Comments'                         . '
'                         . '
'                         . '
';                   //Display / format the list of comments              ob_start(); //workaround how to capture the output from wp_list_comments() function             wp_list_comments(array(                 'reverse_top_level' => false //Show the latest comments at the top of the list             ), $comments);         $capture_wp_list_comments = ob_get_clean();         return $return_string;     }              ob_start(); //workaround how to capture the output from comment_form() function             comment_form("", $post_id);         $capture_comment_form = ob_get_clean();                   $return_string = $return_string                      . $capture_comment_form                     . '
'                     . '
';      I need to fix the `href` part of the reply link?


title: 1 wordpress site on 2 VPS how update sync

text: I have WordPress site on 2 VPS using A record both VPS have same copies of file one VPS get fails mean one get active but problem is I have to update post on both VPS. Is there any solution that of post once both VPS get that same contain?


title: How to get a value from wp_dropdown_user?

text: In the admin dashboard, I want to show a list of all users (done so far by wp_dropdown_users) and then take the selected userID and use it as a parameter in another function. :) Sounds easy eh. I've got the dropdown happening, i've got the code to display other info for a selected ID(currently has $output in it..but this could be any userid), just need to know how to attach the two...like how to call the selected user's id and use it. Current code:               function wps_userlist_dw() {          $output = wp_dropdown_users(array(              'exclude'                 => '1',              'name'                    => 'author',              'show'                    => 'ID',              'echo'                     => true         ));               $user_info = get_userdata($output);           echo 'Username: ' . $user_info->user_login . "\n";           echo 'User level: ' . $user_info->user_level . "\n";           echo 'User ID: ' . $user_info->ID . "\n";     }      Any thoughts would be great!


title: Insert image or ad script after 3 posts using the loop

text:
There are many scripts/hacks out there to insert ads into the middle of the post (after 'x' number of paragraphs), however I haven't found a good enough script that can do the above. This is the script that comes close,               <?php $post_counter=0; ?>     <?php if (have_posts()) : ?>     <?php while (have_posts()) : the_post(); ?>     <?php require('post.php'); ?>     <?php     $post_counter++;     if ($post_counter == 2 || $post_counter == 3) { ?>     INSERT ADSENSE CODE HERE     <?php } ?>     <?php endwhile; ?>      Taken from here. But my index.php uses this instead:               <?php     $page_num = $paged;     if ($pagenum='') $pagenum =1;     query_posts('cat=-3&showposts=6&paged='.$page_num); ?>                 <?php if (have_posts()) : ?>             <?php while (have_posts()) : the_post(); ?>                 <?php get_template_part('includes/index-loop'); ?>                 <?php endwhile; wp_reset_postdata(); wp_reset_query(); ?>

                  <?php else : ?>             <?php endif; ?>      I tried putting in the               <?php     $post_counter++;     if ($post_counter == 2 || $post_counter == 3) { ?>     INSERT ADSENSE CODE HERE     <?php } ?>      before endwhile, but I see a repetition of 'INSERT ADSENSE CODE HERE' twice. Any suggestions?


title: How to use array in function to get only value I want

text: I am trying to work this function in wordpress theme the way where I can get value only what I want and not all to gather. I am not much familiar with using array in function so I need you expert help to make it works and I would really appreciate that. Here is my code               function gallery_artist($arg=null, $arg2=null, $arg3=null){              global $png_gallery_meta;         $png_gallery_meta->the_meta();              $gallery = get_post_meta(get_the_ID(), $png_gallery_meta->get_the_id(), TRUE);              $gallery_value = $gallery['image_artist'];         $artist_info = $gallery_value;              $string = $artist_info;         $artist = substr($string, 0, stripos($string, "/") );              // getting first name and last name from user id         $author_first_name = get_userdata(basename($string))->first_name;              $author_last_name = get_userdata(basename($string))->last_name;              $author_full_name = $author_first_name . ' ' . $author_last_name;              $user_id = '' . $artist . '';                   $arg = $author_first_name;               echo $arg;              $arg2 = $author_last_name;               echo $arg2;              $arg3 = $user_id;         echo $arg3;               }      After than I want to use this function to get any value I want and not unnecessary to render all three to gather. Means if I want only first name than I pass value only for that and it will render only first name so on.. Here how I want to use something. but you can suggest any code and type of function I have no issue.               <?php call_user_func_array('gallery_artist', array('first_name','last_name','artist_id') ) ?>      Big Big thanks to you all..


title: Category nicename inside loop in wordpress

text:
How can I echo the current post's category nicename inside main loop.               <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>           echo
            <?php endwhile; else : ?>
<?php _e( 'Sorry, no posts matched your criteria.' ); ?>
     <?php endif; ?>      I want to echo the category nicename inside div tag as a class and then want to target the css Any suggestions?


title: Which hook should be used to validate custom form fields on the login form?

text: I've added a custom input field with `login_form` hook. So, I need to process the post data to validate. I've used the `lostpassword_post` for `lostpassword_form` and works great, but I cant find a hook to validate my data at login form. Any Ideas?


title: Retrieving multiple values to the Post Meta (using an array)

text: I'm having a problem retrieving post_meta values that I have stored in an array. I use this for storing the array:               add_action( 'comment_post', 'add_food', 1 );     function add_food(){         global $post;         $testvalues = array('bread', 'cake');         update_post_meta($post->ID, 'food', $testvalues);     }      and this for retrieving it:               add_filter('the_content', 'print_food');     function print_food($content){         global $post;         $custom_fields = get_post_custom($post->ID);         $food_field = $custom_fields['food'];         $content .= $food_field[0];         return $content;     }      however, this is added to the content of my page: a:2:{i:0;s:5:"bread";i:1;s:4:"cake";} The technique works fine for the comment_meta. What am I doing wrong here?


title: adding pages to the menus in wordpress admin side

text: Hi i'm new to wordpress and just started to study it. i already got a css and index.php files for studying with practicals. i integrate it to my local wordpress and created files header.php,footer.php,index.php,style.css,functions.php. my pblm is when i add new pages to the menu it is not added to my menus. instead the page link appears separately above the header template.


title: How Wordpress remembers which active editing modes are used?

text: I noticed that when I save page in Visual editor. Wordpress remembers it the next time I edit the page even if I clear all my browser cookies and cache. In what section of the WordPress database does this setting is saved? I searched for it and couldn't found it.


title: get_the_excerpt on mobile still displays continue reading

text: I'm writing a plugin where I'm using the excerpt field as just another field. In order to get rid of the 'Continue Reading' Link, I'm removing all possible theme filters:               add_action( 'after_setup_theme', array( $this, 'run_plugin_setup' ) );          public function run_plugin_setup() {         if ( get_post_type() !== $this->get_post_type() ) {             remove_all_filters( 'get_the_excerpt' );             remove_all_filters( 'excerpt_more' );         }     }      This works perfectly on desktop and iPad versions, however on a mobile phone, the dreaded 'Continue Reading -->' is still there and I cannot get rid of it...


title: What's $GLOBALS['wp_settings']['media']['embeds']?

text:
In `wp-admin/options-media.php`, there are a few lines that go:               <?php if ( isset( $GLOBALS['wp_settings']['media']['embeds'] ) ) : ?>
<?php _e('Embeds') ?>

     <?php do_settings_fields( 'media', 'embeds' ); ?>
     <?php endif; ?>      'embeds' and "embeds" are nowhere else to be found in the WP code base. Might anyone know what it's for?


title: bloginfo no show the right path

text: I use bloginfo( 'stylesheet_directory' ) for show the link to css styles , in localhost in my computer i can see the url right as `http://127.0.0.1 , etc` The problem it´s inside of domain , i see the DOM and see that no show http:// only show domain.com and by this no let me the css load , if i add http:// until of this function works all and if no , no works Why in localhost show http and inside domain this function give the url without http ? In my options all it´s ok with http i don´t know what happend really , thank´s , Regards !!! I use these 2 functions :               bloginfo( 'stylesheet_directory' );      get_stylesheet_directory_uri() ;


title: How to hide post meta

text: I have disqus installed in my website. It adds `dsq_thread_id` meta. And while showing the post meta in post with tag;               <?php the_meta(); ?>      I want to hide `dsq_thread_id` in all posts. How can I do this?


title: URL of blog when using index.php as blog and front-page.php as homepage

text: I am building a theme and I am using front-page.php for an individuall homepage and index.php (or home.php) for the blog. What is the URL of the blog / how its possible to define the URL of the blog?