I have created a custom post type. For that I have used this code  add_action( 'init', 'broker_post_type' ); function broker_post_type() {   register_post_type( 'new_broker',     array(       'labels' =&gt; array(         'name' =&gt; __( 'Brands' ),         'singular_name' =&gt; __( 'Brand' )       ),     'public' =&gt; true,     'has_archive' =&gt; true,     'supports' =&gt; array( 'title', 'editor', 'comments', 'excerpt', 'custom-fields', 'thumbnail' ),     )   ); }   Now to show all the featured image of the post type Brands in a single page I have used this code  function display_broker_posts() {   $args = array(     'post_type' =&gt; 'new_broker',     'orderby' =&gt; 'title',     'order' =&gt; 'ASC',     'posts_per_page'=&gt; -1,   );    $dee_bios = new WP_Query( $args );   if( $dee_bios-&gt;have_posts() ):     $dee_output = '&lt;div id="brokers-wrap"&gt;';     $dee_output .= '&lt;div id="brokers-bg-wrap"&gt;';     $dee_output .= '&lt;div class="brokers-content"&gt;';     $dee_output .= '&lt;div class="brokers-left-content"&gt;';     while ( $dee_bios-&gt;have_posts() ) : $dee_bios-&gt;the_post();       if( $dee_bios-&gt;current_post == 0 || ( $dee_bios-&gt;current_post % 2 ) == 0 ) {         $dee_output .= '&lt;div class="one-half first"&gt;';         }       else {         $dee_output .= '&lt;div class="one-half"&gt;';         }        $dee_output .= get_the_post_thumbnail( $dee_bios-&gt;post-&gt;ID,'small', 'bios', array( 'class' =&gt; 'alignleft' ) );       $dee_output .= '&lt;span&gt;&lt;/span&gt;';     //  $dee_output .= '&lt;p&gt;&lt;strong&gt;' . get_the_title() . ',&lt;/strong&gt; ' . get_the_content() . '&lt;/p&gt;';       $dee_output .= '&lt;/div&gt;&lt;!--end .one-half--&gt;';     endwhile;     $dee_output .= '&lt;div class="clear"&gt;&lt;/div&gt;&lt;!--clear all floats--&gt;';     $dee_output .= '&lt;/div&gt;&lt;!-- end #bios--&gt;';   endif;    wp_reset_postdata();   return $dee_output; }   Now this one is giving the result. But here in result I want something different. I want that lets say I have 16 posts in the Post. So it will show first 10 posts in a different div and the rest 6 posts in a different div. So can someone kindly tell me how to do this? Any help will be really appreciable. Thanks
120620
I am having a little trouble trying to figure out how I can accomplish this: I have a container with two colums in it, a right and a left column. Each column will have 3 posts with a short excerpt stacked in it. Ideally I would like to add one into the right and one into the left until it reaches 3 rows of posts(although if that proves to be alot more of a difficult task than I am fine with posting to the first column than the second. I am able to loop through the posts and add them to one column, but I am having trouble figuring out how one will loop into two separate divs, without repeating the divs. Here is how I am attempting it, so far this code will loop into the left column.  The first left side is using the loop to display the title(excerpt will come after) and the right side is just using html. Can anyone help me figure this one out?         &lt;h2&gt;Popular posts&lt;/h2&gt;        &lt;h3&gt;Showing the most popular posts.&lt;/h3&gt;  &lt;div class="col4 inner-left"&gt;        &lt;ul class="popular-list"&gt;    &lt;?php        query_posts('meta_key=post_views_count&amp;orderby=meta_value_num&amp;order=DESC&amp;posts_per_page=10&amp;post_type=pop');        if (have_posts()) : while (have_posts()) : the_post(); ?&gt;             &lt;li&gt;              &lt;a href=&lt;?php the_permalink(); ?&gt;&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;              &lt;p&gt;Popular post. This is a popular post, it really is.&lt;/p&gt;             &lt;/li&gt;    &lt;?php        endwhile; endif;        wp_reset_query();     ?&gt;                   &lt;/ul&gt;     &lt;/div&gt;  &lt;div class="col4 inner-right"&gt;         &lt;ul class="popular-list"&gt;             &lt;li&gt;               &lt;a href="popularpostlink.php"&gt;This is a popular post&lt;/a&gt;               &lt;p&gt;Popular post. This is a popular post, it really is.&lt;/p&gt;             &lt;/li&gt;                  &lt;li&gt;                   &lt;a href="popularpostlink.php"&gt;This is a popular post&lt;/a&gt;                   &lt;p&gt;Popular post. This is a popular post, it really is.&lt;/p&gt;                 &lt;/li&gt;             &lt;/ul&gt;         &lt;/div&gt;
78286
I got a loop from internet (I forgot the site) for two column post view. It has a nice CSS for it too. But skipping that for the question now.  &lt;?php $counter = 1; ?&gt;                  &lt;?php query_posts( 'cat=3&amp;showposts=6' ); //Find whether the catID is 3 ?&gt;             &lt;?php while ( have_posts() ) : the_post() ?&gt;                   &lt;?php /* Two Column Support get class */ ?&gt;              &lt;?php $class = ( $counter % 2  ? ' one' : '' ) ?&gt;                  &lt;?php /* Two Column output open the div class */ ?&gt;              &lt;div class="column&lt;?php echo $class;// echo $first; ?&gt;"&gt;              &lt;?php news_format(); ?&gt;             &lt;/div&gt; &lt;!-- End Two Column Support close div class --&gt; &lt;?php $counter++; //Update counter ?&gt;   It printed my posts into 2 columns like:  ========= | 1 | 2 | --------- | 3 | 4 | --------- | 5 | 6 | =========  It's fine. But I want to print it like this:  ========= |   1   | --------- | 2 | 3 | --------- | 4 | 5 | --------- | 6 | 7 | =========  What the modification I need to do? I can't pass any custom limit into the WordPress' custom loop &lt;?php while ( have_posts() ) : the_post() ?&gt;. It's for a custom theme. I did it, but the problem is, it's showing like:  ========= |   1   | --------- | 1 | 2 | --------- | 3 | 4 | --------- | 5 | 6 | =========   is my whole bunch of code.
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')
70822
I am trying to add defualt comments to my custom post type.  I have added to my supports argument:  'supports' =&gt; array('title','editor','thumbnail','tags','post-formats','comments','revision'),   I've also tried a few functions like this:  function default_comments_on( $data ) { if( $data['post_type'] == 'your_custom_post_name' ) {     $data['comment_status'] = 1; }  return $data; } add_filter( 'wp_insert_post_data', 'default_comments_on' );   But nothing seems to work.Here is my custom post type:  function spark_register() { $labels = array(     'name' =&gt; _x('Spark Garden', 'post type general name'),     'singular_name' =&gt; _x('Spark', 'post type singular name'),     'add_new' =&gt; _x('Add New Spark', 'sparknz'),     'add_new_item' =&gt; __('Add New Spark'),     'edit_item' =&gt; __('Edit Spark'),     'new_item' =&gt; __('New Spark'),     'view_item' =&gt; __('View Spark'),     'search_items' =&gt; __('Search Sparks'),     'not_found' =&gt;  __('Nothing found'),     'not_found_in_trash' =&gt; __('Nothing found in Trash'),     'parent_item_colon' =&gt; ''   );  $args = array(     'labels' =&gt; $labels,     'public' =&gt; true,     'has_archive' =&gt; true,     'publicly_queryable' =&gt; true,     'show_ui' =&gt; true,     'query_var' =&gt; true,     'rewrite' =&gt; true,     'capability_type' =&gt; 'post',     'hierarchical' =&gt; false,     'menu_position' =&gt; 8,     'supports' =&gt; array('title','editor','thumbnail','tags','post-  formats','comments','revision'),           'taxonomies' =&gt; array('post_tag'), );  register_post_type( 'spark' , $args ); }   add_action('init', 'spark_register');   I've tried adding to 'twentysixteen' and activating but that still doesn't show the comments by default. I have it checked to allow comments in my settings, it does appear in my regular 'post' post type, but in my cutom post type the discussion checkbox is not checked and comments are not showing by default?  Thanks in advance..
84729
I know people have asked this before and have gone as far as adding the custom post type, and rewrite for permalink.   The problem is I have 340 existing categories which I would like to continue using. I used to be able to see /category/subcategory/postname  Now I have the slug of customposttype/postname. Selecting the category no longer shows up in permalink...I've not changed the permalink setting in admin to anything different.  Is there something I'm missing or need to add to this code?  function jcj_club_post_types() {     register_post_type( 'jcj_club', array(         'labels' =&gt; array(             'name' =&gt; __( 'Jazz Clubs' ),             'singular_name' =&gt; __( 'Jazz Club' ),             'add_new' =&gt; __( 'Add New' ),             'add_new_item' =&gt; __( 'Add New Jazz Club' ),             'edit' =&gt; __( 'Edit' ),             'edit_item' =&gt; __( 'Edit Jazz Clubs' ),             'new_item' =&gt; __( 'New Jazz Club' ),             'view' =&gt; __( 'View Jazz Club' ),             'view_item' =&gt; __( 'View Jazz Club' ),             'search_items' =&gt; __( 'Search Jazz Clubs' ),             'not_found' =&gt; __( 'No jazz clubs found' ),             'not_found_in_trash' =&gt; __( 'No jazz clubs found in Trash' ),             'parent' =&gt; __( 'Parent Jazz Club' ),         ),         'public' =&gt; true,         'show_ui' =&gt; true,         'publicly_queryable' =&gt; true,         'exclude_from_search' =&gt; false,         'menu_position' =&gt; 5,         'query_var' =&gt; true,         'supports' =&gt; array(              'title',             'editor',             'comments',             'revisions',             'trackbacks',             'author',             'excerpt',             'thumbnail',             'custom-fields',         ),         'rewrite' =&gt; array( 'slug' =&gt; 'jazz-clubs-in', 'with_front' =&gt; true ),         'taxonomies' =&gt; array( 'category','post_tag'),         'can_export' =&gt; true,     ) );
52840
I have another database which stores post's IDs and I want do display them using WP_query to use the WP default pagination. I'm using orderby => none to preserve the original order, but the result reorders them by IDs.  $ids = array (60, 23, 78, 46, 105, 130)  $args = array (     'posts_per_page' =&gt; -1,     'post__in' =&gt; $ids,     'orderby' =&gt; 'none' );  $query = new WP_Query ( $args );  while ( have_posts() ) : the_post();     echo '&lt;li&gt;';     the_title();     echo '&lt;/li&gt;'; endwhile;   Could anyone help me?  Thanks, Romulo De Lazzari
118394
I'm currently trying to implent a new custom column at the page manage screen that will let me change the status (published/pending) of the different pages via an easy toggle link.  From what I've gathered I need to use $post->post_status, 'status'in someway, probably toggle with jQuery or something. But I can't figure out how I tie it together with ajax. Thought I'd get some help looking at the default post status modifier in the edit post screen, but I realized that it's not ajax based, I the status updates when you press "update" (obviously, duh).  Here's my lousy try for an attempt so far:  function wp_change_page_status_link() {     $status = get_post_status($ID);     if($status == 'publish'){         $status = '&lt;span&gt;On&lt;/span&gt;';         //$post-&gt;post_status, 'pending'     }     elseif($status == 'pending'){         $status = '&lt;span&gt;Off&lt;/span&gt;';     }     return $status; }   Would be really grateful if someone could point me in the right direction..
56524
I needed a way to filter a page/posts content before it was loaded so I could add scripts to the header if a specific shortcode was present. After much searching I came across this on    function has_my_shortcode($posts) {     if ( empty($posts) )         return $posts;      $found = false;      foreach ($posts as $post) {         if ( stripos($post-&gt;post_content, '[my_shortcode') )             $found = true;             break;         }      if ($found){         $urljs = get_bloginfo( 'template_directory' ).IMP_JS;      wp_register_script('my_script', $urljs.'myscript.js' );      wp_print_scripts('my_script'); }     return $posts; } add_action('the_posts', 'has_my_shortcode');   which is absolutely brilliant and did exactly what I needed.   Now I need to extend it a bit further and do the same for sidebars. It can be by a particular widget type, shortcode, code snippet or anything else that would work to identify when the script needs to be loaded.  The problem is I can't figure out how to access the sidebars content before the sidebar is loaded (the theme in question will have several sidebars)
19602
Could I theoretically use multiple php code areas / widgets in a page, each doing their own posts query and fetching with wp_query and get_posts() and use a page template that has no post loop?
78018
I am using the following code to output a list of items in my 'documents' Custom Post type by Year and Month.  &lt;ul&gt; &lt;?php $post_type = 'documents'; global $wpdb; /**/ $years = $wpdb-&gt;get_col("SELECT DISTINCT YEAR(post_date) FROM $wpdb-&gt;posts WHERE post_status = 'publish' AND post_type = '".$post_type."' ORDER BY post_date DESC"); foreach($years as $year) : $years_count = $wpdb-&gt;get_var( $wpdb-&gt;prepare( "SELECT COUNT(*) FROM $wpdb-&gt;posts WHERE post_status = 'publish' AND post_type = '".$post_type."' AND YEAR(post_date) = ".$year.";" ) ); ?&gt; &lt;li class="year"&gt;&lt;?php echo $year; ?&gt; (&lt;?php echo $years_count; ?&gt; Posts)     &lt;ul&gt;     &lt;? $months = $wpdb-&gt;get_col("SELECT DISTINCT MONTH(post_date) FROM $wpdb-&gt;posts WHERE post_status = 'publish' AND post_type = '".$post_type."' AND YEAR(post_date) = '".$year."' ORDER BY post_date DESC");     foreach($months as $month) :     $months_count = $wpdb-&gt;get_var( $wpdb-&gt;prepare( "SELECT COUNT(*) FROM $wpdb-&gt;posts WHERE post_status = 'publish' AND post_type = '".$post_type."' AND YEAR(post_date) = ".$year." and MONTH(post_date) = ".$month.";" ) );     ?&gt;         &lt;li class="month"&gt;&gt;         &lt;a href="&lt;?php echo get_month_link($year, $month)."?post_type=".$post_type; ?&gt;"&gt;&lt;?php echo date( 'F', mktime(0, 0, 0, $month) );?&gt;&lt;/a&gt; (&lt;?php echo $months_count; ?&gt; Posts)          &lt;?php  $theids = $wpdb-&gt;get_results("SELECT ID, post_title, post_date FROM $wpdb-&gt;posts WHERE post_type = '".$post_type."' AND post_status = 'publish' AND YEAR(post_date) = ".$year." and MONTH(post_date) = ".$month.";");                 foreach ($theids as $theid):                          ?&gt;                     &lt;h4 style="font-style:italic;"&gt;&lt;li&gt;&lt;a href="#"&gt;&lt;?php echo $theid-&gt;post_title; ?&gt;&lt;/a&gt;&lt;/li&gt;&lt;/h4&gt;                                                  &lt;?php                     endforeach; ?&gt;          &lt;/li&gt;     &lt;?php endforeach;?&gt;     &lt;/ul&gt; &lt;/li&gt; &lt;?php endforeach; ?&gt; &lt;/ul&gt;   Currently this is working as expected but I am having problems trying to do the same thing for a specific category within my documents post type. How would I refine this code for my category 'cascade-campus-docs' within my 'documents' post type.
4944
I am having trouble working with WordPress rewrite rules, and could use some help.  I have a custom post type called _shows_.  All shows have a single custom taxonomy category _show-category_. A _show_ will never have more than one _show-category_.  I would like my urls to route in this manner:  www.mysite.com/shows/  =&gt;  archive-shows.php  www.mysite.com/shows/%category%/ =&gt; taxonomy-show-category.php  www.mysite.com/shows/%category%/%postname%/ =&gt; single-shows.php   So as a real world example, lets say we have a _show-category_ "Foo" and a _show_ post titled "Bar" that has "Foo" as it's _show-category_. I would expect my WordPress app to look like this:  www.mysite.com/shows/foo/ =&gt; shows all posts under the foo category www.mysite.com/shows/foo/bar =&gt; shows the indivual post   I try to avoid plugins when possible, but am open to any solution.
116834
I am not getting the posts under custom taxonomy(fabric_building_types). I am getting cat_id and cat-&gt;name also but not able to get the posts.  $args = array(     'type'                     =&gt; 'post',     'child_of'                 =&gt; 0,     'parent'                   =&gt; '',     'orderby'                  =&gt; 'name',     'order'                    =&gt; 'ASC',     'hide_empty'               =&gt; 1,     'hierarchical'             =&gt; 1,     'exclude'                  =&gt; '',     'include'                  =&gt; '',     'number'                   =&gt; '',     'taxonomy'                 =&gt; 'fabric_building_types',     'pad_counts'               =&gt; false  );   $categories = get_categories( $args );  foreach ( $categories as $cat ) {      // here's my code for getting the posts for custom post type      $posts_array = get_posts(         array(             'showposts' =&gt; -1,             'post_type' =&gt; 'fabric_building',             'tax_query' =&gt; array(                 array(                     'taxonomy' =&gt; 'fabric_building_types',                     'field' =&gt; $cat-&gt;cat_ID,                     'terms' =&gt; $cat-&gt;name,                 )             )         )     );     print_r( $posts_array );  }   Can anyone please help me out...Thanks in advance
10893
I have 3 different custom fields url-1, url-2 and url-3. Each field have different value in type of &lt;iframe&gt; embedded video.     Click any link &lt;li&gt; and play that video, By default play url-1   HTML:  &lt;form  id="myform"&gt;    &lt;li&gt;&lt;a name="url-1" class="play_next" href="#"&gt; Link &lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a name="url-2" class="play_next" href="#"&gt; Link &lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a name="url-3" class="play_next" href="#"&gt; Link &lt;/a&gt;&lt;/li&gt; &lt;/form&gt;  &lt;div id="output"&gt; video player &lt;/div&gt;   Jquery  jQuery(document).ready(function($){ $("#myform").on('click', 'a', function(e) {  $.ajax({     url: ajaxobject.ajaxurl,     type: 'post',     data: {          action: 'call_meta',      },     success: function(result) {         $('#output').append( result );     } }); }); });   PHP:  add_action('wp_ajax_call_post', 'call_meta'); add_action('wp_ajax_nopriv_call_post', 'call_meta');  function call_meta(){  if( isset($_POST["pid"]){    $post = get_post( $_POST["pid"] );      echo get_post_meta( $ID, 'url-1', true ); }  else {     echo get_post_meta( $ID, 'url-2', true ); } else {     echo get_post_meta( $ID, 'url-3', true ); } wp_die(); }   How to load video with Ajax? &amp; play any from others by replacing previous one.  I'm new in wordpress theme development, So I know that there is many problem and error in my code. Thanks for your attention. I’m looking forward to your reply.
27809
I am building a custom (child) theme and I want to style the first post of my loop in a different way than the others (bigger image, different position of some stuff).   Which is the best way of doing it? My "problem" is that my theme has support for different post types and the style would vary depending on the type of content, so I want to avoid repeating code as much as possible (i.e. using a function).   As I am a bit more used to OOP, my ideal scenario would be passing a variable to the view and check it in the loop of each content-type (that way I can re-use most of the code from the TwentyEleven templates). From what I know, that is not possible (please correct me if I am wrong).   For now, what I do is this:  function electric_index_loop($readMore = 0) {  $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $args = array(     //Excluimos los "miniposts" (citas, estados, enlaces...) del listado     'tax_query' =&gt; array(         array(             'taxonomy' =&gt; 'post_format',             'field' =&gt; 'slug',             'terms' =&gt; array('post-format-aside', 'post-format-link',                 'post-format-status', 'post-format-quote'),             'operator' =&gt; 'NOT IN'         )     ),     'posts_per_page' =&gt; 5,     'paged' =&gt; $paged );  // The Query query_posts($args);  // The Loop if (have_posts()) {     $post_count = 0;     global $more;     $more = $readMore; // 0 fuerza que se muestre sólo el "excerpt", 1 fuerza que se muestre todo el contenido     twentyeleven_content_nav('nav-above');     while (have_posts()) {         the_post();         if ($post_count == 0) {             get_template_part('highlight', get_post_format());         } else {             get_template_part('content', get_post_format());         }         $post_count++;     } } else {     ?&gt;     &lt;article id="post-0" class="post no-results not-found"&gt;         &lt;header class="entry-header"&gt;             &lt;h1 class="entry-title"&gt;&lt;?php _e('Nothing Found', 'twentyeleven'); ?&gt;&lt;/h1&gt;         &lt;/header&gt;&lt;!-- .entry-header --&gt;          &lt;div class="entry-content"&gt;             &lt;p&gt;&lt;?php _e('Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.', 'twentyeleven'); ?&gt;&lt;/p&gt;             &lt;?php get_search_form(); ?&gt;         &lt;/div&gt;&lt;!-- .entry-content --&gt;     &lt;/article&gt;&lt;!-- #post-0 --&gt;     &lt;?php } wp_reset_query();}   As you see, I check the counter in the loop that I create in the function and ,if the current post is the first, I load a different template ("highlight").  I'd have to create different templates for the different types of content (which, in some cases sucks, because I can get all I need in some cases with just a CSS class).   Well, is there a better way of doing these? Perhaps a hook or something?   Thanks in advance!
41920
I have several custom post types, which are properly structured as /%post_type%/%postname%/, however I wish to have the same effect for regular blog entries: /blog/%postname%/  If I prepend the permalink structure with /blog/ it affects the custom post types as well, so currently my permalink structure is simply /%postname%/  Which is the recommended way of doing this? I had a solution involving some rewrites, but the permalink shown in the post editor area does not reflect it.
88018
I manage a wordpress site and have created a template part that I usually paste below the content.      &lt;div class="posts-group"&gt;          &lt;h2&gt;Featured store products&lt;/h2&gt;          &lt;?php $catquery = new WP_Query( 'post_type=product&amp;posts_per_page=4&amp;orderby=rand' );         while($catquery-&gt;have_posts()) : $catquery-&gt;the_post();         ?&gt;         &lt;a href="&lt;?php echo get_post_meta($post-&gt;ID,'PRODUCT-url', true);?&gt;"&gt;             &lt;article class="post home-post homeproduct"&gt;                     &lt;div class="post-thumbnail-img"&gt;                         &lt;?php the_post_thumbnail('small-thumbnail'); ?&gt;                     &lt;/div&gt;                     &lt;h2&gt;&lt;?php the_title(); ?&gt;&lt;/h2&gt;                                   &lt;p&gt;&lt;/p&gt;             &lt;/article&gt;         &lt;/a&gt;          &lt;?php endwhile; ?&gt;  &lt;/div&gt;   Now I'm trying to put this IN BETWEEN the content, so I thought of using a shortcode  function get_products($atts) { get_template_part('block-products-inline'); } add_shortcode('products', 'get_products');   Now every time I post [products], I expect the products to go there. However when I try the code above, the products template_part goes all the way to the top of the page, right underneath the title and right before the actual content.  But when I edit the shortcode to simply return some text, then the text DOES appear in the middle of the content.  Does anyone understand what's going on? Because I don't..
43313
Why I'm doing this you might ask? I'm developing a website for a business with a portfolio where the gallery items are posts. These posts are populated through custom fields and category selections, nothing else.  For each item, there could be a title/content or not, it depends on the item in question and that's entirely up to the client. They are the ones populating their portfolio and not me. I'm just building the system for them to easily publish whatever they want.  I realize that WordPress might have some issues with posts without a title, that's why I implemented (in functions.php) a function to auto set a title for the post if none was attributed. This post auto title will never be shown on the website cause I look for it and omit it if it's there, otherwise, show the attributed title to the post.  The function for that is:  add_action('publish_post', 'insert_automatic_post_title', 10, 2);  function insert_automatic_post_title($postID, $post) {     if($post-&gt;post_title === '') {         $post-&gt;post_title = '['.get_the_date('d/m/Y @ H:i:s').']';          if($post-&gt;post_name == $postID) {             $post-&gt;post_name = sanitize_title($post-&gt;post_title);         }          $result = wp_update_post($post);     } }   The only problem is that if title is empty and the content is also empty (with some custom fields already defined) that function above will never be called and the post won't be published, it will remain in draft status.  The only solution I could think of was to create some shortcode like [empty_post] and ask the client to set that on the post content when he does not wish to attribute a title/content to the post. That shortcode could print something like &lt;!-- EMPTY POST --&gt; or even nothing at all. The fact that there's something in the post content, the function above is called, an automatic title is set and the post is published.  But I'm looking for a way where the client doesn't need to have more trouble (i.e: inserting a shortcode into the post content) than what's needed, I want it to be as simple as possible. Without messing with WordPress source code of course.  Can anyone think of another way with actions/filters?