Title: learnthat's Replies | WordPress.org

---

# learnthat

  [  ](https://wordpress.org/support/users/learnthat/)

 *   [Profile](https://wordpress.org/support/users/learnthat/)
 *   [Topics Started](https://wordpress.org/support/users/learnthat/topics/)
 *   [Replies Created](https://wordpress.org/support/users/learnthat/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/learnthat/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/learnthat/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/learnthat/engagements/)
 *   [Favorites](https://wordpress.org/support/users/learnthat/favorites/)

 Search replies:

## Forum Replies Created

Viewing 9 replies - 1 through 9 (of 9 total)

 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WP Popular Posts] [Plugin: WordPress Popular Posts] Filter by Custom Post Types](https://wordpress.org/support/topic/plugin-wordpress-popular-posts-filter-by-custom-post-types/)
 *  Thread Starter [learnthat](https://wordpress.org/support/users/learnthat/)
 * (@learnthat)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/plugin-wordpress-popular-posts-filter-by-custom-post-types/page/2/#post-1595532)
 * I’m not sure, I used this on a client project and haven’t looked at this in a
   long time. Have you tried using it in a widget? I think the changes I made would
   only allow you to filter by custom post type when used in a widget.
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [OEmbed and Custom FIeld](https://wordpress.org/support/topic/oembed-and-custom-field/)
 *  [learnthat](https://wordpress.org/support/users/learnthat/)
 * (@learnthat)
 * [16 years ago](https://wordpress.org/support/topic/oembed-and-custom-field/#post-1531647)
 * Hi joehuffman2,
 * I wanted the same thing and achieve it using this code in my single.php file:
 * `<?php echo wp_oembed_get( get_post_meta($post->ID, "videourlcustom", true) );?
   >`
 * In the example, videourlcustom is the name of the custom field which contains
   the URL for what you want to embed.
 * If you want to put it somewhere else, just change $post->ID to the ID of the 
   post you want to query – for example, if you were going to place it in a sidebar
   widget. In this example, it should be inside the loop.
 * I hope this helps!
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [oEmbed auto embed function for custom fields/themes?](https://wordpress.org/support/topic/oembed-auto-embed-function-for-custom-fieldsthemes/)
 *  [learnthat](https://wordpress.org/support/users/learnthat/)
 * (@learnthat)
 * [16 years ago](https://wordpress.org/support/topic/oembed-auto-embed-function-for-custom-fieldsthemes/#post-1654541)
 * Hi lilqhgal,
 * I wanted the same thing and achieve it using this code in my single.php file:
 * `<?php echo wp_oembed_get( get_post_meta($post->ID, "videourlcustom", true) );?
   >`
 * In the example, videourlcustom is the name of the custom field which contains
   the URL for what you want to embed.
 * I hope this helps!
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WP Popular Posts] [Plugin: WordPress Popular Posts] Filter by Custom Post Types](https://wordpress.org/support/topic/plugin-wordpress-popular-posts-filter-by-custom-post-types/)
 *  Thread Starter [learnthat](https://wordpress.org/support/users/learnthat/)
 * (@learnthat)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/plugin-wordpress-popular-posts-filter-by-custom-post-types/#post-1595357)
 * One caveat that I didn’t think of: the exclude categories portion of the widget
   likely won’t work with custom post types in their current form. Custom post types
   have the ability to create custom taxonomies, but I’m sure querying based on 
   those taxonomies use slightly different code. This may be something I need in
   the future and I’ll address it at some point.
 * I believe, you would have to provide an additional option and change this line:
 * `WHERE x.taxonomy = 'category'`
 * to dynamic based on the taxonomy selected.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WP Popular Posts] [Plugin: WordPress Popular Posts] Filter by Custom Post Types](https://wordpress.org/support/topic/plugin-wordpress-popular-posts-filter-by-custom-post-types/)
 *  Thread Starter [learnthat](https://wordpress.org/support/users/learnthat/)
 * (@learnthat)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/plugin-wordpress-popular-posts-filter-by-custom-post-types/#post-1595354)
 * I posted a link the full version of this file here: [http://jerm.com/wordpress-popular-posts.php.txt](http://jerm.com/wordpress-popular-posts.php.txt)
 * Please let me know if you decide to use this – otherwise I will need to fork 
   it so the end users do not accidentally upgrade some day and lose these changes.
   I appreciate all your hard work,
 * Thanks!
    Jeremy
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WP Popular Posts] [Plugin: WordPress Popular Posts] Filter by Custom Post Types](https://wordpress.org/support/topic/plugin-wordpress-popular-posts-filter-by-custom-post-types/)
 *  Thread Starter [learnthat](https://wordpress.org/support/users/learnthat/)
 * (@learnthat)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/plugin-wordpress-popular-posts-filter-by-custom-post-types/#post-1595353)
 * Hi Ikki,
 * It actually wasn’t too difficult to update the plug-in to support custom post
   types. Here’s what I did – if you’d like, I can send you the file.
 * General steps:
    1. Remove the current post/page options.
    2. Query the public custom post types and generate a select list.
    3. Add in support for the option.
    4. Change $nopages to the new SQL query variable based on the value of the post
       type select field.
 * Actual code:
 * Comment out this line:
 * `//$instance['pages'] = $new_instance['pages'];`
 * Add this line around line 172:
 * `$instance['posttype'] = $new_instance['posttype'];`
 * Comment out this line in the form function:
 * `//'pages' => true,`
 * Add in this line in the form function around line 219:
 * `'posttype' => 'all',`
 * Delete the checkbox section for ‘pages’ on the form.
 * Add this code to the form for the widget above the thumbnail section:
 *     ```
       <fieldset class="widefat">
       			<legend><?php _e('Select Post Types', 'wordpress-popular-posts'); ?></legend>
       			<select id="<?php echo $this->get_field_id( 'posttype' ); ?>" name="<?php echo $this->get_field_name( 'posttype' ); ?>">
       			<option value="all"<?php if ( $instance['posttype'] == "all" ) : ?> selected="selected"<?php endif; ?>><?php _e('All', 'wordpress-popular-posts'); ?></option>
       			<option value="pagesposts"<?php if ( $instance['posttype'] == "pagesposts" ) : ?> selected="selected"<?php endif; ?>><?php _e('Posts and Pages', 'wordpress-popular-posts'); ?></option>
       			   	<?php
       				// Thank you to John James Jacoby for this code from post-type-switcher
       				$safe_filter = array( 'public' => true, 'show_ui' => true );
       	            $post_types = get_post_types( (array)$safe_filter );
   
       	foreach ( $post_types as $post_type ) {
       			$pt = get_post_type_object( $post_type );
       ?>
       			<option value="<?php echo $pt->name; ?>"<?php if ( $instance['posttype'] == $pt->name ) : ?> selected="selected"<?php endif; ?>><?php echo $pt->label; ?></option>
       <?php
       		} ?>
       			</select>
       			</fieldset>
       			<br />
       ```
   
 * Near the top of the get_popular_posts function, add this code and comment out
   the old code:
 *     ```
       // Support custom post types
       			if ( $instance['posttype'] == 'all' ) {
                        $nopages = '';
                   } else {
                     if ( $instance['posttype'] == 'pagesposts' ) {
                        $nopages = "AND ($wpdb->posts.post_type = 'post' OR $wpdb->posts.post_type = 'pages')";
                     } else {
                        $nopages = "AND $wpdb->posts.post_type = '" .$instance['posttype'] . "'";
                     }
                   }			  
   
                   // Deprecated with post-type support above
       			//if ( $instance['pages'] ) {
       			//	$nopages = '';
       			//} else {
       			//	$nopages = "AND $wpdb->posts.post_type = 'post'";
       			//}
       ```
   
 * If you see anything I did wrong, please let me know, but it seems to work fine.
   Thanks for creating such a great, easy to use plug in.
 * Jeremy
 *   Forum: [Alpha/Beta/RC](https://wordpress.org/support/forum/alphabeta/)
    In 
   reply to: [Installing 3.0 on iis.](https://wordpress.org/support/topic/installing-30-on-iis/)
 *  [learnthat](https://wordpress.org/support/users/learnthat/)
 * (@learnthat)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/installing-30-on-iis/#post-1518697)
 * I was receiving a similar error – I changed the parent directory (above the directory
   WordPress is installed in) by adding the local IUSR account and giving it read
   access. For example, if your site is in:
 * c:\websites\mysite\wwwroot
 * Add the IUSR account to c:\websites\mysite and give it read access.
 * I was experiencing a “white screen” on IIS prior to this fix. Hope this helps.
 *   Forum: [Alpha/Beta/RC](https://wordpress.org/support/forum/alphabeta/)
    In 
   reply to: [WordPress 3.0: Changing to new post types](https://wordpress.org/support/topic/wordpress-30-changing-to-new-post-types/)
 *  [learnthat](https://wordpress.org/support/users/learnthat/)
 * (@learnthat)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/wordpress-30-changing-to-new-post-types/#post-1522124)
 * There is a plugin to handle this:
 * [http://wordpress.org/extend/plugins/post-type-switcher/](http://wordpress.org/extend/plugins/post-type-switcher/)
 * It provides a little select menu on each post to change to a different post type,
   seems to work like a charm.
 *   Forum: [Alpha/Beta/RC](https://wordpress.org/support/forum/alphabeta/)
    In 
   reply to: [WP 3.0 Permalinks are Broken](https://wordpress.org/support/topic/wp-30-permalinks-are-broken/)
 *  [learnthat](https://wordpress.org/support/users/learnthat/)
 * (@learnthat)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/wp-30-permalinks-are-broken/#post-1520787)
 * I am having the same issue. With pretty permalinks, I cannot get to any custom
   posts. When I turn off pretty permalinks, the custom post is there with the non-
   pretty url. Any resolution?

Viewing 9 replies - 1 through 9 (of 9 total)