Tagged: ,

Viewing 2 reply threads
  • Author
    Posts
    • #1894
      Jason
      Keymaster

      Greetings!

      I’m trying to write a plugin that allows the user to dynamically generate a special kind of post. And I’m using Piklist. 🙂

      Unfortunately, a snag I’m running into is that the metabox file structure requires the post slug in the comments… meaning it can’t be a variable. So, to be clear, I would want specific metaboxes to appear on every post type generated by this plugin.

      Is there any way to work around this?

      Thanks!

    • #1895
      Steve
      Keymaster

      @jason– Well, you just ruined one of our surprises for the next release. 😉

      We will be adding a filter to the comment blocks so you can do exactly what you just asked for.

      1) First, you will need to manually add the filter yourself until 0.9.4 is released. Open class-piklist-cpt.php. And find this line:
      $types = empty($data['type']) ? get_post_types() : explode(',', $data['type']);
      2) Add this code right before that line:
      $data = apply_filters('piklist_add_meta_box', $data, $post);
      3) Now you can filter the $data array that pulls in the comment block.

      EXAMPLE:

      add_filter('piklist_add_meta_box','my_comment_block_filter', 10, 2);
      function my_comment_block_filter($data, $post)
      {
        // filter $data array here
       
        return $data;
      }
      

      Let us know if you have questions on how to use this.

    • #1904
      Jason
      Keymaster

      Hah! Sorry about that.. but thanks, Steve! 🙂

Viewing 2 reply threads
  • The topic ‘Dynamic Post Metabox’ is closed to new replies.