Support Forum » User Profile

Forum Replies Created

Viewing 15 posts - 2,881 through 2,895 (of 4,839 total)
  • Author
    Posts
  • in reply to: Convert function into view to filter category #29087
    Long NguyenLong Nguyen
    Moderator

    Hi,

    It is possible. But you need to have a basic knowledge about PHP code and WordPress template to get the right way. Run a PHP function in View: https://docs.metabox.io/extensions/mb-views/#running-php-functions

    The code to show filter in the View is

    <div class="filter-custom-taxonomy">
        {% set terms = mb.get_terms( { taxonomy: 'custom-taxonomy' } ) %}
        {% for term in terms %}
        <a href="?getby=cat&cat={{ mb.esc_attr( term.slug ) }}">
            {{ mb.esc_html( term.name ) }}
        </a>
        {% endfor %}
    </div>

    remember to change custom-taxonomy in the filter, the function hooked above to your taxonomy slug. And Type, Location of View set to Post type (Dish) archive.

    in reply to: Using custom meta fields to create CPT title #29081
    Long NguyenLong Nguyen
    Moderator

    Hi,

    To get the subfield value, please follow this documentation https://docs.metabox.io/extensions/meta-box-group/#examples

    For example:

    $group = rwmb_meta( 'event_details', '', $post_id );
    $t1 = $group['event_name'];
    $t2 = $group['event_start_date'];
    
    in reply to: filter by date #29080
    Long NguyenLong Nguyen
    Moderator

    Hi,

    If you want to query posts by date, please use the argument date_query, read more in the documentation https://developer.wordpress.org/reference/classes/wp_query/#date-parameters

    And refer to this topic https://wordpress.stackexchange.com/questions/52070/how-to-get-posts-published-between-a-date-and-today

    Please note that: never use the PHP function in the View, you can run it via the proxy

    {% set my_date = mb.date("Y-m-d") %}

    then value: my_date,

    in reply to: Featured image column for default posts types #29079
    Long NguyenLong Nguyen
    Moderator

    Hi,

    You can use the custom admin columns to show the featured image in the listing posts/pages. Follow this documentation https://docs.metabox.io/extensions/mb-admin-columns/#custom-admin-columns

    class My_Featured_Image_Columns extends \MBAC\Post {
        public function columns( $columns ) {
            $columns  = parent::columns( $columns );
            $position = 'before';
            $target   = 'title';
            $this->add( $columns, 'featured_image', 'Featured Image', $position, $target );
            // Add more if you want
            return $columns;
        }
        public function show( $column, $post_id ) {
            switch ( $column ) {
                case 'featured_image':
                    the_post_thumbnail( [40, 40] ); //here
                    break;
                // More columns
            }
        }
    }

    With the MB Builder, you can create a field with ID _thumbnail_id then show it as an admin column.

    in reply to: User Posts Dashboard - Edit Custom Post Type #29077
    Long NguyenLong Nguyen
    Moderator

    Hi Alan,

    When creating/updating the post in the backend, you can see some default input boxes such as title, content, featured image, date publish ... In the frontend, we call it post_fields. Please get more details here https://docs.metabox.io/extensions/mb-frontend-submission/#reorder-post-fields

    in reply to: Always Open Hierarchy of Checkbox Tree #29076
    Long NguyenLong Nguyen
    Moderator

    Hi,

    Thanks for your feedback.

    Currently, only check the parent taxonomy then the child taxonomies will be displayed. I will inform the development team to explore the possibility.

    Long NguyenLong Nguyen
    Moderator

    Hi,

    You can put the code to the template file that shows the single post, contact your theme support to ask for the template file.

    If you want to use the View, please follow this documentation to know how to run PHP functions in View https://docs.metabox.io/extensions/mb-views/#running-php-functions

    in reply to: Chinese character in date picker #29074
    Long NguyenLong Nguyen
    Moderator

    Hi,

    The function strtotime() parse the text date time to Unix timestamp. You can use the setting 'timestamp' => true to save the timestamp value to the database. Please get more details on the documentation https://docs.metabox.io/fields/datetime/#settings

    in reply to: Convert function into view to filter category #29064
    Long NguyenLong Nguyen
    Moderator

    Hi,

    Here is the filter code that you need to convert and add to the View

    <div class="filter-custom-taxonomy">
        <?php
        $terms = get_terms( 'publisher' );
        foreach ( $terms as $term ) : ?>
        <a href="?getby=cat&cat=<?php echo esc_attr( $term->slug ); ?>">
                <?php echo esc_html( $term->name ); ?>
        </a>
        <?php endforeach; ?>
    </div>

    The function to handle the filter should be added to the file functions.php in the theme/child theme folder or Code Snippets plugin

    function justread_filter_archive( $query ) {
        ...
    }
    add_action( 'pre_get_posts', 'justread_filter_archive');
    Long NguyenLong Nguyen
    Moderator

    Hi Giovani,

    I'm not able to reproduce this issue on my end. Can you please follow the Debugging Information step here to troubleshoot the issue?
    https://support.metabox.io/topic/how-to-create-a-new-topic/

    Long NguyenLong Nguyen
    Moderator

    Hi,

    It's a very complicated group, to show the user info in that group you need more for loops. Each cloneable group will need 2 loops, one for cloneable, one for the subfields. For example, I have a field group

    function your_prefix_function_name( $meta_boxes ) {
        $prefix = '';
    
        $meta_boxes[] = [
            'title'  => __( 'Post Meta', 'your-text-domain' ),
            'id'     => 'post-meta',
            'fields' => [
                [
                    'name'   => __( 'Areas', 'your-text-domain' ),
                    'id'     => $prefix . 'areas',
                    'type'   => 'group',
                    'clone'  => true,
                    'fields' => [
                        [
                            'name'   => __( 'Zones', 'your-text-domain' ),
                            'id'     => $prefix . 'zones',
                            'type'   => 'group',
                            'clone'  => true,
                            'fields' => [
                                [
                                    'name'   => __( 'Guards', 'your-text-domain' ),
                                    'id'     => $prefix . 'guards',
                                    'type'   => 'group',
                                    'clone'  => true,
                                    'fields' => [
                                        [
                                            'name'   => __( 'Locations', 'your-text-domain' ),
                                            'id'     => $prefix . 'locations',
                                            'type'   => 'group',
                                            'clone'  => true,
                                            'fields' => [
                                                [
                                                    'name'       => __( 'User', 'your-text-domain' ),
                                                    'id'         => $prefix . 'user',
                                                    'type'       => 'user',
                                                    'field_type' => 'select_advanced',
                                                    'multiple'        => true
                                                ],
                                            ],
                                        ],
                                    ],
                                ],
                            ],
                        ],
                    ],
                ],
            ],
        ];
    
        return $meta_boxes;
    }

    the view code to get user info is

    {% for clone_areas in post.areas %}
        {% for clone_zones in clone_areas %}
            {% for zone in clone_zones %}
                {% for clone_guards in zone %}
                    {% for guard in clone_guards %} 
                        {% for clone_locations in guard %}
                            {% for location in clone_locations %}
                                {% for users in location %}
                                    {% for user in users %}
                                        {{user.display_name}}       
                                    {% endfor %}
                                {% endfor %}
                            {% endfor %}
                        {% endfor %}
                    {% endfor %}    
                {% endfor %}    
            {% endfor %}
        {% endfor %}
    {% endfor %}

    Hope that makes sense.

    Long NguyenLong Nguyen
    Moderator

    Hi,

    To fix this issue, you can enable support Comments for the post type Event, bulk edit imported post and select "Do not allow", screenshot https://www.screencast.com/t/yaOMak8rmN

    Then disable Comments support. Let me know how it goes.

    Long NguyenLong Nguyen
    Moderator

    Hi vubai,

    Thank you for your feedback.

    Let me explain this case with the datetime field. The datetime field uses our JS library to get the current time of your computer and generate it to the timestamp value then the PHP code helps to save this value to the database.

    That means the Unix timestamp saved is the "timezone (UTC) + offset". If you use the function wp_date(), it will display "timezone (UTC) + offset" + offset (timezone in general settings). So, to display the true timezone when using the datetime field and the function wp_date(), you should use this code

    echo wp_date( 'F d, Y H:i', $date_time, new DateTimeZone('UTC') );

    or use the date() function.

    Get more details here https://developer.wordpress.org/reference/functions/wp_date/

    in reply to: Chinese character in date picker #29054
    Long NguyenLong Nguyen
    Moderator

    Hi,

    Can you please let me know which wrong with the setting save_format? The format of the date should be

    array(
        'name'            => esc_html__( 'To date', 'textdomain' ),
        'id'          => $prefix . 'to_date',
        'desc'            => esc_html__( 'End of date range', 'textdomain' ),
        'type'            => 'date',
         // Date picker options. See here http://api.jqueryui.com/datepicker
         'js_options' => array(
                            'dateFormat'  => 'd/m/y',
                            'changeMonth' => true,
                            'changeYear'  => true,
                             ),
        'save_format' => 'Y-m-d',
    ),

    Get more details here https://www.w3schools.com/php/func_date_date_format.asp

    in reply to: Bulk Edit Custom Field in Custom Post Types #29048
    Long NguyenLong Nguyen
    Moderator

    Hi,

    Please refer to this topic if you want to edit custom fields in Quick Edit section https://support.metabox.io/topic/feature-request-add-custom-filds-in-quick-edit/

Viewing 15 posts - 2,881 through 2,895 (of 4,839 total)