Support Forum ยป User Profile

Forum Replies Created

Viewing 15 posts - 2,296 through 2,310 (of 3,958 total)
  • Author
    Posts
  • Anh TranAnh Tran
    Keymaster

    I did test with creating the post in the frontend, but haven't test for editing an existing post. Let me try again.

    Anh TranAnh Tran
    Keymaster

    Hi, I've just checked both the parent param and taxonomy field and they work. Here is my test:

    https://imgur.com/a/ioHvM

    Can you check your code?

    in reply to: MB Admin Columns with MB Relationships #9030
    Anh TranAnh Tran
    Keymaster

    Hello,

    The last snippet seems to make the dropdown works, e.g. making the column *filterable*, instead of *sortable*, doesn't it?

    If so, can you try this:

    add_filter( 'parse_query', 'query_filter_assembly_steps_by_bunkie' );
    function query_filter_assembly_steps_by_bunkie( $query ) {
        global $pagenow;
        $post_type = isset( $_GET['post_type'] ) ? $_GET['post_type'] : '';
        if ( is_admin() && $pagenow === 'edit.php' && $post_type === 'assembly_step' && isset( $_GET['bunkie_id'] ) && $_GET['bunkie_id'] !== 'all' ) {
            $query->set( 'p', intval( $_GET['bunkie_id'] ) );
        }
    }

    This code filters the list and displays only 1 post (the post that is selected).

    If you want to filter the list and display all posts that have connected "from" a bunkie, then you might want to use this:

    add_filter( 'parse_query', 'query_filter_assembly_steps_by_bunkie' );
    function query_filter_assembly_steps_by_bunkie( $query ) {
        global $pagenow, $wpdb;
        $post_type = isset( $_GET['post_type'] ) ? $_GET['post_type'] : '';
        if ( is_admin() && $pagenow === 'edit.php' && $post_type === 'assembly_step' && isset( $_GET['bunkie_id'] ) && $_GET['bunkie_id'] !== 'all' ) {
            $bunkie_id = $_GET['bunkie_id'];
            $post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT <code>to</code> FROM $wpdb->mb_relationships WHERE <code>from</code> = %d", $bunkie_id ) );
            $query->set( 'post__in', $post_ids );
        }
    }
    in reply to: Need a filter before save field #9014
    Anh TranAnh Tran
    Keymaster

    You're becoming a master of Meta Box's hooks ๐Ÿ™‚

    Anh TranAnh Tran
    Keymaster

    Can you send me the site info via contact page? It's quite strange and I might need to look at the site's code to debug it.

    in reply to: Outputing Field elements using Shortcode #9012
    Anh TranAnh Tran
    Keymaster

    Hello,

    The shortcode only output the whole value of the custom field, in this case - the whole fieldset. In order to display only the values, you can create a custom shortcode to get and show the field value, like this:

    add_action( 'init', function () {
      add_shortcode( 'my_meta', function ( $atts ) {
        $atts   = shortcode_atts( [
          'meta_key' => '',
          'post_id'  => get_the_ID(),
        ], $atts );
        $values = rwmb_meta( $atts['meta_key'], array(), $atts['post_id'] );
        $output = '';
        foreach ( $values as $value ) {
          $output .= $value . ', ';
        }
    
        return $output;
      } );
    } );
    Anh TranAnh Tran
    Keymaster

    The strange thing is the code works fine to me. Where do you put the add_filter code? Is it under any condition?

    Anh TranAnh Tran
    Keymaster

    Hello,

    Thanks for bringing an interesting question. I was thinking about this, too. However, the problem is changing the syntax, which requires a lot of code to be modified. Not sure how to do it best and clean.

    in reply to: Feature request : add custom filds in quick edit #8959
    Anh TranAnh Tran
    Keymaster

    Hi,

    This is a feature that has been on our list for a long time. The reason we couldn't implement it because it's quite complicated for some fields like file_advanced or taxonomy. We'll probably take a look at that again and try to implement for simple fields.

    in reply to: Using Custom Attributes from rwmb_before_save_post action #8943
    Anh TranAnh Tran
    Keymaster

    Yes, the documentation is updated ๐Ÿ™‚

    Anh TranAnh Tran
    Keymaster

    Hello,

    I've just tried your code and see it works. The helper function returns an array of IDs. Maybe you register meta boxes only for the admin (with a check like is_admin())?

    in reply to: โœ…front end extension and gutenberg #8940
    Anh TranAnh Tran
    Keymaster

    Hello,

    Thanks for the question. All the plugins will work normally with or without Gutenberg. Gutenberg has no effect to the plugins on the frontend at all.

    By the way, if you don't like Gutenberg, you can always disable it and use the classic editor.

    in reply to: taxonomy_advanced fields are not cloneable #8939
    Anh TranAnh Tran
    Keymaster

    I will do that today!

    Updated: the version 4.14.1 has been released!

    in reply to: โœ…New contexts broken with Gutenberg #8928
    Anh TranAnh Tran
    Keymaster

    Hello,

    Unfortunately, Gutenberg doesn't support contexts. It has only one place to show meta boxes. So, please just remove the contexts param from the meta box settings.

    in reply to: Using Custom Attributes from rwmb_before_save_post action #8926
    Anh TranAnh Tran
    Keymaster

    Hello,

    I've just added rwmb_after_save_field hook, that can help you ease the pain ๐Ÿ™‚

    Here is the code using it:

    add_action( 'rwmb_after_save_field', function ( $null, $field, $new, $old, $post_id ) {
    	$pre = '';
    	if ( ! empty( $field['attributes']['mod_lock'] ) ) {
    		$pre = 'pending_';
    	}
    	$storage = $field['storage'];
    
    	if ( $new !== $old ) {
    		$storage->update( $post_id, $pre . $field['id'], $new );
    	}
    
    	if ( empty( $new ) ) {
    		$storage->delete( $post_id, $pre . $field['id'] );
    	}
    }, 10, 5 );
Viewing 15 posts - 2,296 through 2,310 (of 3,958 total)