Viewing 8 reply threads
  • Author
    Posts
    • #1474
      Jason
      Keymaster

      I’m starting to mess around with metaboxes in pages, and I’m curious what all Piklist can do with pages.

      As far as I can tell, Piklist cannot load a Workflow into a page. In addition, how would one add the meta to the page object (like post instead of post_meta)? Can the editor be replaced, or can metaboxes really only be added?

      I don’t see any docs specific to pages, is why I ask.

      Thanks!

    • #1477
      Steve
      Keymaster

      @Jason– pages are just another post_type. Anything you can do with posts you can do with pages.

    • #1478
      Jason
      Keymaster

      That is awesome. Thanks, Steve!

      Seeing as the page isn’t “defined” like a post type, how would I remove the default editor in order to design a proper workflow?

    • #1483
      Steve
      Keymaster
    • #1684
      Jason
      Keymaster

      For those interested, I had a case where I wanted to hide the editor from only specific pages using a specific template. Here’s what I did:

      add_action('init', 'remove_unused_editors');
      
      function remove_unused_editors() {
      	$post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'] ;
      	$template_file = get_post_meta($post_id,'_wp_page_template',TRUE);
      
      	switch ($template_file) {
      		case 'page-about.php':
      		case 'page-home.php':
      			remove_post_type_support('page', 'editor');
      	}
      }
      
    • #1686
      Steve
      Keymaster

      @jason– Thanks for the tip!

    • #1979
      Jason
      Keymaster

      Amended the above code to avoid some php warnings:

      add_action('init', 'remove_unused_editors');
      function remove_unused_editors() {
        if ( !isset($_GET['post']) && !isset($_GET['post_ID']) )
          return;
      
        $post_id = ( isset($_GET['post']) ) ? $_GET['post'] : $_POST['post_ID'] ;
        $template_file = get_post_meta($post_id,'_wp_page_template',TRUE);
      
        switch ($template_file) {
          case 'page-product-overview.php':
            remove_post_type_support('page', 'editor');
        }
      }
    • #2519
      Gary
      Member

      Hi Steve!

      Please help me.

      I removed the default editor and created my metabox (The demo metabox, what you showed). Now I want to add the editor field, but I can’t find where to insert it. I apologise for my clumsy, but I really don’t see, where to put this into:

      <?php
        piklist('field', array(
          'type' => 'editor'
          ,'scope' => 'post'
          ,'field' => 'field_name'
          ,'label' => __('Example Field')
          ,'description' => __('This is a description of the field.')
          ,'value' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.'
          ,'options' => array (
            'wpautop' => true
            ,'media_buttons' => true
            ,'tabindex' => ''
            ,'editor_css' => ''
            ,'editor_class' => ''
            ,'teeny' => false
            ,'dfw' => false
            ,'tinymce' => true
            ,'quicktags' => true
          )
        ))?>

      Thank you for your help!

      Best Regards,
      Gary

      • #2520
        Steve
        Keymaster

        @gary–

        Just verifying… you’re using this tutorial, correct?

        A few things:
        1) This code goes in a file (any name you want), in the /meta-boxes/ folder. See this doc for the full path of this folder.
        2) The file should also contain a comment block at the top. You can see how this looks here.
        3) Replace ,'field' => 'field_name' with ,'field' => 'post_content'. Since you are replacing the default WordPress field, you need to use the WordPress field name which is post_content.

        Let me know if this works for you.

    • #2524
      Gary
      Member

      Thank you for your help.

      I started re-editing the entrie tutorial and what you have written, managed to better understand the whole.

      <?php
      echo get_post_meta($post->ID, 'demo_text', true);
      echo get_post_meta($post->ID, 'demo_select', true);
      echo get_post_meta($post->ID, 'demo_colorpicker', true);
      ?>

      I remembered that I put into this code, but it can not be accidentally. Now it’s work!

      Thank you so much!!

Viewing 8 reply threads
  • You must be logged in to reply to this topic.