Forum Replies Created

Viewing 4 posts - 16 through 19 (of 19 total)
  • Author
    Posts
  • in reply to: Hiding Meta Box for Specific Template #8368
    noobie
    Participant

    Dear Steve

    Sorry for the late reply but it still does not work.

    in reply to: Hiding Meta Box for Specific Template #8364
    noobie
    Participant

    Dear Steve

    Nope, it isn’t working.
    Below is the comment block for the metabox and the codes to be placed under functions.php

    /*
    Title: Right Bar Section
    Description: Customized right bar section
    Post Type: page
    Hide for Template: page-full-width
    Order: 3
    */

    add_filter(‘piklist_part_data’, ‘my_custom_comment_block’, 10, 2);
    function my_custom_comment_block($data, $type)
    {
    // If not a Meta-box section than bail
    if($type != ‘meta-boxes’)
    {
    return $data;
    }

    // Allow Piklist to read our custom comment block attribute: “Hide for Template”, and set it to hide_for_template
    $data[‘hide_for_template’] = ‘Hide for Template’;

    return $data;
    }

    add_filter(‘piklist_part_add’, ‘my_hide_for_template’, 10, 2);
    function my_hide_for_template($data, $type)
    {
    global $post;

    // If not a meta box than bail
    if($type != ‘meta-boxes’)
    {
    return $data;
    }

    // Check if any page template is set in the comment block
    if (!empty($data[‘hide_for_template’]))
    {
    // Get the active page template
    $active_template = pathinfo(get_page_template_slug($post->ID), PATHINFO_FILENAME);

    // Is there a page template set for this page?
    if(!empty($active_template))
    {
    // Does the active page template match what we want to hide?
    if (strpos($data[‘hide_for_template’], $active_template) !== false)
    {
    // Change meta-box access to user role: no-role
    $data[‘role’] = ‘no-role’;
    }
    }
    }
    return $data;
    }

    in reply to: Hiding Meta Box for Specific Template #8362
    noobie
    Participant

    Dear Steve

    As per your questions, the below is the stated version.

    Piklist Version 0.9.9.12
    WordPress Helpers Version 1.17.0

    in reply to: Widget Sidebar's Meta Box not saving data #8355
    noobie
    Participant

    Dear Steve

    Thanks. It is resolved.
    Due to a custom field name “image” which was registered earlier, it caused the issue when I try to do the above.

Viewing 4 posts - 16 through 19 (of 19 total)