Viewing 3 reply threads
  • Author
    Posts
    • #6068
      irene
      Member

      Hello,
      I am so sorry to bother you again.
      A while ago I have started a topic: see https://piklist.com/support/topic/empty-post-title-does-not-replace-all-of-the-title/

      Now the same happened again.
      Therefore my question: How come this is happening?
      What could be a reason?

      Greetings,
      Irene

    • #6069
      irene
      Member

      To make things clearer:

      wordpress version:4.4.2
      piklist version: 0.9.9.7

      code used for empty post title:

      add_filter('piklist_empty_post_title', 'my_new_title', 10, 2);
        function my_new_title($data, $post_array)
        {
      
          // Grab the new title from the custom field. Replace my_custom_field with your own
          $new_title = $post_array['_post_meta']['naam'][0];
      	
      print_r($post_array); // output
          die();
      	
      
          // Only filter on your custom post type. Replace my_custom_cpt with your own.
          return $post_array['post_type'] == 'hond' ? $new_title : $post_array['post_title'];
        }	

      output print:

      Array ( [post_author] => 1 [post_content] => [post_content_filtered] => [post_title] => Auto Draft [post_excerpt] => [post_status] => publish [post_type] => hond [comment_status] => closed [ping_status] => closed [post_password] => [to_ping] => [pinged] => [post_parent] => 0 [menu_order] => 0 [guid] => http://localhost:8888/hondenfokker/?post_type=hond&p=233 [import_id] => 0 [context] => [ID] => 233 [post_date] => 2016-03-13 17:54:56 [post_date_gmt] => [post_name] => [post_modified] => 2016-03-13 17:54:48 [post_modified_gmt] => 0000-00-00 00:00:00 [post_mime_type] => [comment_count] => 0 [ancestors] => Array ( ) [post_category] => Array ( ) [tags_input] => Array ( ) [_wpnonce] => 65f52159f6 [_wp_http_referer] => /hondenfokker/wp-admin/post-new.php?post_type=hond [user_ID] => 1 [action] => editpost [originalaction] => editpost [original_post_status] => auto-draft [referredby] => http://localhost:8888/hondenfokker/wp-admin/edit.php?post_type=hond [_wp_original_http_referer] => http://localhost:8888/hondenfokker/wp-admin/edit.php?post_type=hond [auto_draft] => 1 [post_ID] => 233 [meta-box-order-nonce] => ee13cd8f16 [closedpostboxesnonce] => 627b98b7c3 [hidden_post_status] => draft [original_publish] => Publish [publish] => Publish [_post_meta] => Array ( [naam] => bewaar [geslacht] => Array ( [0] => sex-reu ) [eigenaar] => Array ( [0] => eigendom2 ) ) [_] => Array ( [nonce] => 2b8e9ffd3a [fields] => 4d05fee34f87a1ab00a10073f69538bb ) [filter] => db )

      Last time I did not ask you why this was happening, you told what but not the why. I need to understand the why.

    • #6073
      jrcreative
      Member

      @irene

      just use $post_array['_post_meta']['naam']

      (ditch the [0])

    • #6076
      irene
      Member

      @jrcreative
      Thanks! Fixed!

Viewing 3 reply threads
  • The topic ‘Custom post title’ is closed to new replies.