I am using WP Courseware (www.flyplugins.com) for a client's site and my basic understanding is that the course units are basically a custom post type ('course_units'). The course units can be created directly or converted from posts.  WP Courseware does not support category or tags taxonomy out of the box and it had to be enabled.  All of that was said to say that when I have posts tagged that they show up when you call  however the course units tagged with "design" do not show up.  I have never bothered with tags enough to care about tag clouds, etc so I do not know what file, template or function that needs to be updated to support the custom post type of "course_units" when it displays posts containing tags.  I followed the advice found here:   register_taxonomy_for_object_type( 'post_tag', 'portfolio' );   And now I see Tags under my Course Units in WP Dashboard.  I click on Tags and see the tags and click on the count and it shows the course units that tagged correctly in the backend, so I just need to know how to enable support on Tag Cloud for the front end where it actually returns the course unit posts instead of "Sorry, no content matched your criteria."  What connection am I missing?
120649
I'm using custom post types, but they don't appear on tag pages along with regular posts and i'd like to include both standard and custom post types on tag or category pages. What would be required before the loop to include all posts? (including custom type). Updated: To add, I found this code , which worked perfectly for the first part: add_filter('pre_get_posts', 'query_post_type'); function query_post_type($query) {   if ( is_category() || is_tag() &amp;&amp; empty( $query-&gt;query_vars['suppress_filters'] ) ) {     $post_type = get_query_var('post_type');     if($post_type)         $post_type = $post_type;     else         $post_type = array('post','cpt'); // replace cpt to your custom post type     $query-&gt;set('post_type',$post_type);     return $query;     } }  Second question still remains though: Is there a way to allow readers to filter by post type? So either of the following would work..  example.com/tag/blue?post_type=custom example.com/tag/blue?post_type=post
95219
I am displaying post tags like this:  &lt;div class="tags"&gt;&lt;?php the_tags('&lt;span&gt;Tags&lt;/span&gt;' , ' '); ?&gt; &lt;/div&gt;   It works fine, but if the post does not have any tag, then it adds empty div  &lt;div class="tags"&gt;&lt;/div&gt;   So, how can I use the condition to check if post has any tag, then display above.
4236
By default, the WordPress tag cloud widget has a set amount of 45 tags to display.  This can be seen in the wp-includes/category-template.php file.  By default, the WooCommerce plugin which I have installed, and it's products tag cloud widget also resembles this.  How do I modify this amount from within my wp-content/themes/functions.php file, to display for example, only 15 product tags?  Here is what I have so far, but it is not working.  function custom_tag_cloud_widget($args) {     $args['smallest'] = 8; //smallest tag     $args['largest'] = 22; //largest tag     $args['number'] = 15; //adding a 0 will display all tags     $args['unit'] = 'pt'; //tag font unit     return $args; }  add_filter( 'widget_tag_cloud_args', 'custom_tag_cloud_widget' );   When changing the number within the core wp-includes.php/category-template.php file to 15 however, it does work.  Obviously, I don't wish to edit any core files and am looking for an alternative solution.  Thanks.
55787
The tag  has no tag wiki, and SO invites me to help create one.  I've got the reputation.  I think Database-design really needs a tag wiki.  I'd like to help.  But I don't feel quite up to creating a tag wiki on my own for three reasons.  First, I'm not too sure what a good tag wiki looks like, and I don't know the tools that create tag wikis.  Second, the subject of database-design can get quite controversial.  There are experienced professionals that I respect that hold very different and mutually contradictory views on what constitutes good database design.  Third, most of today's database design neophytes are interested in building a database to be embedded in a single application, and to be managed without a DBA.  Most of the classic works on database design were based on the idea of strategic data management spanning multiple departments, multiple applications, one or more DBAs, and several kinds of stakeholders.  The goals of good design are completely different in these two cases.  So I'd like two kinds of help:  First, how do a get skills at building a good wiki?  Second, is there any way several of us could collaborate on a Database-design wiki before launching it on an unsuspecting public?    Edit based on first response.  The most valuable thing I've learned from the response is that the tag wiki should outline the issues more than the answers.  Accordingly, I've come up with a document that reflects my first attempt at describing the issues concerning database design.    I'm not entirely happy with it, but it's not a disaster, IMO.  It's too long, and it's not as clearly bulleted as the C# tag wiki.  Some of that difference may be appropriate. It does clarify most of the issues connected to good database design.  I've left a lot for the closely related data-modeling tag wiki, that doesn't exist yet either.  I'm tempted to go ahead and create the wiki, and post my effort.  After that the community process can correct for my blind spots.  But maybe I should post it here first,  and let the meta discussion give some feedback and correction first.  Opinions?    I've decided to go ahead and post my first effort at a tag wiki for Database-Design.  It will probably be heavily maintained both by me and by others.  But it's a start.  There probably needs to be a parallel effort on a tag wiki for data modeling  (sp?).
103722
The body_class hook seem only to work with non-admin pages.  When I do   add_filter('body_class', 'add_body_classes'); function add_body_classes($classes) {         $classes[] = 'myclass';         return $classes; }   Is there another hook i should be using if i want to add a class to the body of an admin page?
33866
The  tag doesn't appear to be very useful.  It's used in a variety of ways (for reading, writing, showing, transforming, compiling, translating, obfuscating, obtaining, ... source code) on 1747 questions right now, and doesn't appear to be adding any classification value to the site.  Can we get rid of it?
61666
In reading I am not sure if the issue below could have something to do with needing a custom wordpress ajax handler? All of these functions are inside my functions.php file. I have a couple of PHP functions that are supposed to pass information from one to another. The an AJAX call to the final function should produce the final result through that call. Its not happening. My count results in 0 and I am not understanding why. If I replace my query with a static array like [44,55,99,33] then it will pass the values ok. Likewise if I keep the query and simply replace the $id in the query and make it a static id such as '20' then it works. I would think that the id was the issue then and it wasnt pulling properly but it seems to work ok just not pass? function idx(){     global $wpdb, $id;       $getId = $_SERVER['REQUEST_URI'];     $ecp = explode('/', $getId);     if($ecp[3] != ''){         $id = $ecp[3];     }         return $id; } add_action( 'after_setup_theme', 'idx' );  =============================================== function Total_Result(){     global $wpdb;     $id = idx();        /*$resultx = [44,88,59,52];*/ ;      $resultx = $wpdb-&gt;get_results( $wpdb-&gt;prepare(&quot;SELECT * FROM {$wpdb-&gt;prefix}custom_form_submission_conversation as cc LEFT JOIN {$wpdb-&gt;prefix}custom_form_submission as cs on cc.fsid ='$id' WHERE fsid='$id'&quot; ));          $resultxs = array($resultx);          $total_result =  count($resultxs[0]);     echo  $total_result; }  when I var_dump $resultx I get: array(3) { [0]=&gt; object(stdClass)#1256 (36) { [“cid”]=&gt; string(3) “167” [“fsid”]=&gt; string(2) “20” [“specified_date”]=&gt; string(3) “yes” [“price_quote”]=&gt; string(4) “1140” [“posted_by”]=&gt; string(9) “dc_vendor” [“limit_count”]=&gt; string(1) “1” [“read_unread”]=&gt; string(1) “1” [“vendor_response”]=&gt; string(4) “zero” [“date_created”]=&gt; string(19) “2021-04-15 11:39:08” }   [1]=&gt; object(stdClass)#1257 (36) { [“cid”]=&gt; string(3) “186” [“fsid”]=&gt; string(2) “20” [“specified_date”]=&gt; string(3) “Yes” [“price_quote”]=&gt; string(3) “602” [“posted_by”]=&gt; string(8) “customer” [“limit_count”]=&gt; string(1) “1” [“read_unread”]=&gt; string(1) “1” [“vendor_response”]=&gt; string(4) “zero” [“date_created”]=&gt; string(19) “2021-04-15 11:39:08” }   [2]=&gt; object(stdClass)#1258 (36) { [“cid”]=&gt; string(3) “188” [“fsid”]=&gt; string(2) “20” [“specified_date”]=&gt; string(3) “yes” [“price_quote”]=&gt; string(4) “1017” [“posted_by”]=&gt; string(9) “dc_vendor” [“limit_count”]=&gt; string(1) “1” [“read_unread”]=&gt; string(1) “0” [“vendor_response”]=&gt; string(4) “zero” [“date_created”]=&gt; string(19) “2021-04-15 11:39:08” } }   so then I try and pass that data like so: function getvendorresponsestatus() {     global $wpdb; $id = idx();          $total_resultx = Total_Result($id);         die; }  Ive tried with and without the die();. The AJAX call is: setInterval(function(){     var ffiidd = jQuery('#ffiidd').val();     var ajaxurl = &quot;&lt;?php echo admin_url('admin-ajax.php'); ?&gt;&quot;;          jQuery.post(ajaxurl, {         action: &quot;vendorAjaxprog&quot;,         ffiidd: ffiidd     }, function(data) {         console.log(data);         jQuery.post(ajaxurl, {             action: &quot;getvendorresponsestatus&quot;, //&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt; this is the action that calls the function             fsid : ffiidd         },         function(datas) {             console.log('+ datas);             jQuery('.cust_vendor_top').html(datas);         });         if(data == 0){}else{             jQuery('.ajaxreload').html(data);                                     }     });               }, 5000);/*==30 seconds==*/  So the question is why wont it pass along the query array information but it passes a basic array or it will pass if I change the id in the query to be static? I know the query is good because of when I var_dumped it, I have results before I get to the Total_Result() function.
54184
Occasionally I see an old Meta post that has no status tag (like ), but from the answers it looks like the question is resolved.  Example:  should be  since the answers say HTTP compression actually is enabled.  Is it worth flagging these questions, or is that a waste of time?
38759
As mentioned in :     taxonomies   () (optional) An array of registered taxonomies like category or post_tag that will be used with this post type. This can be used in lieu of calling  directly. Custom taxonomies still need to be registered with .   Default: no taxonomies   In my Custom Post Type (product) I'm also assigning two Custom Taxonomies with register_taxonomy() apart from the register_post_type(), and they are working fine. But there's a parameter in register_post_type() called 'taxonomies' where it's said to mention all the taxonomies in an array, but even without this I'm achieving what it's meant to:  'taxonomies' =&gt; array( 'product_categories', 'product_tags' ),   So, I wonder what's the purpose of this?
78783
I have a Wordpress blog and am trying to implement the  image script. In short, I need to target all post images, swap out the src, width, &amp; height attributes with data-src, data-width, &amp; data-height attributes. I then need to duplicate the image line and wrap it in &lt;noscript&gt; tags. This is the structure I'm trying to have Wordpress generate/create:  &lt;img data-src="wordpress/image/url/pic.jpg" data-width="{get width of image with PHP &amp; pass-in that value here} data-height="{get height of image with PHP and pass-in that value here}" class="fs-img"&gt; &lt;noscript&gt;     &lt;img src="wordpress/image/url/pic.jpg"&gt; &lt;/noscript&gt;   I have searched the Wordpress codex and the best possible route I can find are to use filters (ie. 'get_image_tag' &amp; 'image_tag') for modifying the html that Wordpress outputs for each image. I'm thinking that one of these options should work, or that I can do some pattern matching with regex (I know, not ideal), throw in a preg_replace and then inject this back into the_content filter.  I have tried some of these options but cannot get any to work. Could someone please offer some help? Found one suggestion , but can't even get it to work!  'get_image_tag' attempt:  Found this particular one on the web, but it would need modified to fit my logic (see above structure)...can't make sense of what the preg_replace array is doing on my own.  &lt;?php function image_tag($html, $id, $alt, $title) {     return preg_replace(array(         '/'.str_replace('//','\/\/',get_bloginfo('url')).'/i',         '/\s+width="\d+"/i',         '/\s+height="\d+"/i',         '/alt=""/i'     ),     array(         '',         '',         '',         alt='"' . $title . '"'     ),     $html); } add_filter('get_image_tag', 'image_tag', 0, 4); ?&gt;   Another 'get_image_tag' attempt:  &lt;?php function get_image_tag($id, $alt, $title, $align, $size='full') {     list($width, $height, $type, $attr) = getimagesize($img_src);     $hwstring = image_hwstring($width, $height);      $class = 'align' . esc_attr($align) . ' size-' . esc_attr($size) . ' wp-image-' . $id;     $class = apply_filters('get_image_tag_class', $class, $id, $align, $size);      $html = '&lt;img src="' . esc_attr($img_src) . '" alt="' . esc_attr($alt) . '" title="' . esc_attr($title).'" data-width="' . $width . '" data-height="' . $height . '" class="' . $class . ' fs-img" /&gt;';     $html = apply_filters( 'get_image_tag', $html, $id, $alt, $title, $align, $size);      return $html; } ?&gt;   Pattern-matching attempt:  Tried creating my own regex on this one, but not sure if it's correct.  &lt;?php function restructure_imgs($content) {     global $post;     $pattern = "/&lt;img(.*?)src=('|\")(.*?).(bmp|gif|jpeg|jpg|png)(|\")(.*?)&gt;/i";      list($width, $height, $type, $attr) = getimagesize($2$3.$4$5);     $hwstring = image_hwstring($width, $height);      $replacement = '&lt;img$1data-src=$2$3.$4$5 title="'.$post-&gt;post_title.'" data-width="'.$width.'" data-height="'.$height.'" class="fs-img"$6&gt;';     $content = preg_replace($pattern, $replacement, $content);     return $content; } add_filter('the_content', 'restructure_imgs'); ?&gt;   Unfortunately can't get any of these examples to work. Any help or sharing your pre-written scripts/functions would be much appreciated! Thanks for helping a student learn!!
96983
I have extended class WP_List_Table to create a custom sortable table of posts along with a quick edit box with custom meta boxes.  The meta boxes populate and save but when I click submit the field values disappear and the defaults ( cb, title, tags, cats, etc) which are not even included in my class get added back to the column saved. This throws off the other columns on the page.  The saved custom field values return when the page is refreshed.  It seams like on submit the $post_object is missing.  I'm using a hacked get_inline_data function that includes the meta_values in my quick edit form instead of calling get_inline_data in my class.  My save function for the meta boxes:  add_action( 'save_post', 'save_inline_edit_meta' ); function save_inline_edit_meta( $post_id  ) {     global $pagenow;      if ( $pagenow == 'admin.php' ) {      if ( isset( $_POST[ 'is_quickedit' ] )  &amp;&amp; isset( $_POST[ 'standinghead' ] ) )         update_post_meta( $post_id, '_wnd_standing_head', $_POST[ 'standinghead' ] );      if ( isset( $_POST[ 'is_quickedit' ] )  &amp;&amp; isset( $_POST[ 'headline' ] ) )         update_post_meta( $post_id, '_wnd_alt_title', $_POST[ 'headline' ] );      if ( isset( $_POST[ 'is_quickedit' ] )  &amp;&amp; isset( $_POST[ 'deck' ] ) )         update_post_meta( $post_id, '_wnd_deck', $_POST[ 'deck' ] );     }   return $post_id;  }   My Javascript save function:  save : function(id) {         var params, fields, page = $('.post_status_page').val() || '';          if ( typeof(id) == 'object' )             id = this.getId(id);         $('table.widefat .inline-edit-save .waiting').show();         params = {             action: 'inline-save',             post_ID: id,             post_type: 'post',             edit_date: 'true',             post_status: page         };         fields = $('#edit-'+id+' :input').serialize();         params = fields + '&amp;' + $.param(params);          $.post('admin-ajax.php', params,             function(r) {                 $('table.widefat .inline-edit-save .waiting').hide();                  if (r) {                     if ( -1 != r.indexOf('&lt;tr') ) {                         $(inlineEditPost.what+id).remove();                         $('#edit-'+id).before(r).remove();                         $(inlineEditPost.what+id).hide().fadeIn();                     } else {                         r = r.replace( /&lt;.[^&lt;&gt;]*?&gt;/g, '' );                         $('#edit-'+id+' .inline-edit-save .error').html(r).show();                     }                 } else {                     $('#edit-'+id+' .inline-edit-save .error').html(inlineEditL10n.error).show();                 }             }         , 'html');         return false;     },
55621
Note: as a neophyte user, I'm not allowed multiple links or images. It has been suggested that I edit my original content in order to add updates. Also it's been suggested to edit the hyperlinks so they're not quite right. Hopefully you can sort out what's going on.  I've been following this post by Kristin Brinner "Drupal Tutorial: Use Views to Create an Alphabetical List of Taxonomy Terms" (at h ttp://getlevelten.com/blog/kristin-brinner/drupal-tutorial-use-views-create-alphabetical-list-taxonomy-terms) but my sample does not produce the results illustrated and by now I'm very confused.  Part 1: said to create new view showing taxonomy terms, display in grid format and create menu link. Done.  Part 2: grouped terms alphabetically (add Taxonomy term: Name, label it "Grouping", exclude from display, rewrite to max length = 1 and uncheck 'trim on word boundary' and 'add ellipsis'). Under Grid-Settings use "Grouping" apply to all displays. My view looks like the sample. Done.  Part 3, Create a Views page for each letter of the alphabet: said to add a Contextual Filter: Taxonomy term: Name. When the filter value is NOT in the url, display all results for specified field. Under More, click Glossary mode, character limit = 1. Note that I now have a Taxonomy term: Name in the Contextual Filter section. I don't know how to test these results.  Part 4, Create A-Z list (create a block that will display the list of first letters in a cute list above the grouping grids) says to add a new Contextual Filter for this block (override). When the filter value is not available, 'display a summary', sort by alphabetical, unformatted, display record count and display items inline. This isn't working as predicted, here is what the tutorial says should be the result: Image 1 in the diagram (h ttp://imgur.com/l9TbLyv). My content continues to look the same as it did previously in the exercise, i.e. like this: Image 2 in the diagram. However when I put "S" into the Preview with contextual filters, I get: Image 3 in the diagram. I was asked for screenshots, so without contextual filters is h ttp://imgur.com/zXCnsvA and with "s" in contextual filters is h ttp://imgur.com/7DF6UUD .  When I created the new contextual filter in Part 4, I got a copy of what was in the Page, so I have two contextual filters, both with Taxonomy term: Name. If I delete the first contextual filter from the block, then my preview shows the same information as Image 1 in the diagram. I think I'm missing something &amp;/or the blog post is unclear. Should I have started "this block override" with 0 contextual filters? I.e. Should I have started by deleting elements from the page which were copied into the block?  Part 5 instructs to "Add the alphabetical list on our page with the grouped terms and Go back to our Page display".  I've got the view working correctly now. The thing which stumped me was that adding a block created an entire copy of the original page which (philosophically) I don't understand. When there's a page and a block override which give instructions about the view, how does drupal know which instructions to pay attention to?  Thanks to all the folks who have helped.
89679
I'm aware there are several other posts that cover similar ground to what I'm about to ask.  I have three custom post types running, in addition to 'posts'. I want to run a loop that pulls all posts categorised under a particular category   &lt;?php           $args = array(     'post_type' =&gt; 'testimonial',     'posts_per_page' =&gt; 1,     'tax_query' =&gt; array(         array (                  'taxonomy' =&gt; 'testimonial_category',                 'field' =&gt; 'slug',                 'terms' =&gt; 'home'     ) ) ); $query = new WP_Query( $args );                 $postcount = 0;             ?&gt;             &lt;?php if ($query-&gt;have_posts()) : ?&gt;                 &lt;?php while ($query-&gt;have_posts()) : $query-&gt;the_post(); ?&gt;                     &lt;?php $postcount++; ?&gt; //loop here &lt;?php wp_reset_query(); ?&gt;      This is the code I have at the moment, not sure how I condense this into pulling in multiply post types from one category.
80135
It is (currently)   to tag answers. Yet, if I query , then  does have a tag, namely javascript. I'm at a loss: how did that happen?&dagger;  SELECT Id, Tag FROM Posts, PostsTags  WHERE Posts.PostTypeId = 2 AND Posts.Id = PostsTags.PostId   Edit: The are also five answers (, , ,  and ) with a view count of 1 instead of 0:  SELECT Id, ViewCount FROM Posts WHERE PostTypeId = 2 AND ViewCount &lt;&gt; 0   These results also hold through at least January 10.    &nbsp; &dagger;: PostTypeId = 2 means that the post is an answer, not a question (PostTypeId = 1).
67740
I've been reading the codex for WordPress closely and am confused about the vague definitions between what a Taxonomy is and what a Category is. For that matter, term is also a word that is used in the description of Taxonomies, but seems used in a manner that hints that it isn't solely limited to a Taxonomy.   Both are described as a way to classify and group together posts. I do understand that Taxonomies are a more general form of categories, but how exactly do they relate to each other?   Is there a subtle difference I'm just not picking up on?
9294
I am building a custom WordPress function/plugin that uses get_posts.  The following code returns an empy array.  I have included wp-load.php in my script.  Is there something else I am missing?    $args = array(     "posts_per_page"   =&gt; -1,     "paged"            =&gt; 0,     "orderby"          =&gt; "post_date",     "order"            =&gt; "DESC",     "post_type"        =&gt; "carellcars, ccf, attachment",     "post_status"      =&gt; "publish, inherit",     "post_author"       =&gt; "2"  );  $posts_array = get_posts($args);   print_r($posts_array);  die;   If I use arrays for post_type and _status the array is not populated, but if I use single values for post_type and _status the array is populated?  Not populated:  $args2 = array(     'posts_per_page'   =&gt; -1,     'paged'            =&gt; 0,     'orderby'          =&gt; 'post_date',     'order'            =&gt; 'DESC',     'post_type' =&gt; array('carellcars', 'ccf', 'attachment'),     'post_status'      =&gt; array('publish', 'inherit') );   Populated:  $args2 = array(     'posts_per_page'   =&gt; -1,     'paged'            =&gt; 0,     'orderby'          =&gt; 'post_date',     'order'            =&gt; 'DESC',     'post_type' =&gt;  'carellcars',     'post_status'      =&gt; 'publish' );   Update, removing "ccf" post type produces results, but I do have a ccf post_type and would like to include them.  Any ideas?      'post_type' =&gt; array('carellcars', 'attachment'),     'post_status'      =&gt; array('publish', 'inherit')
105801
I have been trying but its not working.  but if i try   &lt;?php echo do_shortcode("[mimo]"); ?&gt; &lt;?php echo do_shortcode("[mibaby]"); ?&gt;   it will work fine.  But to apply it in post content using [mimo] [mibaby]  it won't work.  Here is the Functions i am using...  function wpb_custom_new_menuw() {   remove_filter( 'the_content', 'wpautop' ); } add_shortcode('mibaby', 'wpb_custom_new_menuw');    function wpb_custom_new_menu() {   remove_filter( 'the_excerpt', 'wpautop' ); } add_shortcode('mimo', 'wpb_custom_new_menu');