Support Forum » User Profile

Forum Replies Created

Viewing 15 posts - 61 through 75 (of 77 total)
  • Author
    Posts
  • in reply to: WYSIWYG editor going blank on Group reorder #12045
    Content PilotContent Pilot
    Participant

    I am still seeing this too on the latest version of MB. Only in visual mode.

    Content PilotContent Pilot
    Participant

    bump

    in reply to: Drag and drop order reset without consent #11816
    Content PilotContent Pilot
    Participant

    Anh, any update on either of these two issues?

    1. Add column in database table to store sort order on both sides of the relationship.
    2. Do not change sort order on save. I think Doug hit it on the head here. I have attorneys related to a practice area. Both sides of the relationship have a custom sort order that is thrown off by any of the posts being re-saved. If an attorney changes any content on his bio then saves the cpt entry, his name is pushed to the bottom of the list on the practice area page.

    FYI, Clayton is my real name. Juanita is the office manager that bought/signed up this account when we purchased the bundle.

    Also, if you give me a little hint about where to look for #2, I can trouble shoot on my end to speed it along.

    in reply to: pre_get_posts to get all posts connected to single object #11777
    Content PilotContent Pilot
    Participant

    Ahhhh. Thank you for updating the plugin. I am off to the races now! Thanks for sticking with me on this one.

    in reply to: pre_get_posts to get all posts connected to single object #11767
    Content PilotContent Pilot
    Participant

    For some reason my query is setting post type to any. For some reason in parse_query it will change the post type any when using a tax_query. I don't have a tax_query nor do I have any taxonomies on these two post types.

    https://developer.wordpress.org/reference/classes/wp_query/parse_query/

    Search for post_type

    add_action( 'parse_query', 'rel_filter_query_by_relationship', 10, 1 );
    /**
     * Filter the main query by using URL parameters
     * 
     * @param object $query WP_Query.
     * @return object
     * 
     * @since 3.6.8
     */
    function rel_filter_query_by_relationship( $query ) {
        
        $id     = $query->get('relation_id');
        $from   = $query->get('relation_from');
        $to     = $query->get('relation_to');
        
        if ( ! empty( $id ) && ! is_admin() && $query->is_main_query() ) {
    
            if ( ! empty( $from ) ) {
                
                $query->set( 'relationship', 
                    array( 
                        'id'  => esc_attr( $id ),
                        'from'    => intval( $from ),
                    )
                );
    
            } elseif ( ! empty( $to ) ) {
    
                $query->set( 'relationship', 
                    array( 
                        'id'  => esc_attr( $id ),
                        'to'  => intval( $to )
                    )
                );
            }
            
            
        }
    
    }
    
    add_filter( 'query_vars', 'rel_add_query_vars' );
    /**
     * Add query vars to build query with URL parameters
     *
     * @param array $vars WP_Query variables.
     * @return array
     * @since 3.6.8
     */
    function rel_add_query_vars( array $vars ) {
        $vars[] = 'relation_id';
        $vars[] = 'relation_from';
        $vars[] = 'relation_to';
        return $vars;
    }
    
    add_action( 'mb_relationships_init', function() {
        MB_Relationships_API::register( array(
            'id'   => 'practices_to_persons',
            'from' => array(
                'object_type' => 'post',
                'post_type' => 'practice',
                'admin_column' => 'after title'
            ),
            'to'   => array(
                'object_type' => 'post',
                'post_type' => 'person',
                'admin_column' => 'after title',
            ),
        ) );
    } );
    in reply to: pre_get_posts to get all posts connected to single object #11766
    Content PilotContent Pilot
    Participant

    d

    gg

    s

    in reply to: pre_get_posts to get all posts connected to single object #11765
    Content PilotContent Pilot
    Participant

    I am following the video EXACTLY and am still seeing errors. OMG this is so frustrating. Your video is perfect and is not throwing errors. I setup the freshest install and just installed metabox and mb relationships with custom post types built all in the same file. Made the relationships and ran the query on the default theme like your video. Still seeing the post type being stripped for certain functions like get_post_type_object. I actually think get_post_type_object is returning null since the post type is being sent as a string not an array or object. Is_scalar is exiting early for get_post_type_object.

    See the screenshots. I am getting the exact same query you producing with post type being sent as a string.
    query and erorrs

    Running WP 4.9.8 on Flywheel
    MySQL 5.6.34
    PHP 7.2 and 7.0.3
    Nginx
    Twenty Seventeen theme

    Could that have anything to do with it?

    in reply to: pre_get_posts to get all posts connected to single object #11762
    Content PilotContent Pilot
    Participant

    Awesome video. Thank you so much for going into so much detail. This is exactly what I am after.

    I could have sworn that I saw errors on the default theme. I might have some rogue pre get posts that I need to sort out in my main plugin that is also housing the relationship fields. I will do some more digging and report back.

    in reply to: pre_get_posts to get all posts connected to single object #11717
    Content PilotContent Pilot
    Participant
    in reply to: pre_get_posts to get all posts connected to single object #11716
    Content PilotContent Pilot
    Participant

    base

    altered

    in reply to: pre_get_posts to get all posts connected to single object #11715
    Content PilotContent Pilot
    Participant

    Still not working even thought changed how I am getting the query_var.

    Did you try running that code a post type archive? That is what I am doing and seeing part of the query being altered. Its weird. It shows the proper post type objects but doesnt have the proper values for sending the post type to things like post_type_archive_title.

    altered

    base

    in reply to: Drag and drop order reset without consent #11714
    Content PilotContent Pilot
    Participant

    The other thing I noticed is that if you change the post title, then resave, that post gets pushed to the bottom of the related pages list.

    in reply to: Drag and drop order reset without consent #11695
    Content PilotContent Pilot
    Participant

    Did some testing and found that when I arrange the relationships on a bi-directional relationship, you cannot have a specific sort order on both sides of the relationship.

    In my use case, I have an attorney related to a practice area. I want a specific order on the practice area page and then another order of relationships when viewing the attorney biography.

    It might be good to add to_order and from_order database column so that you can arrange relationships independently of each other. You could keep the default order to be ID unless filtered to use the from_order or to_order column.

    in reply to: pre_get_posts to get all posts connected to single object #11694
    Content PilotContent Pilot
    Participant

    I disabled every plugin and reverted to default WP theme to test. I am still stumped. Have a look at the two screenshots. First one is the base query where the query and query_vars match. This query assigns the post type to every other function to get things like post type archive title, etc.
    basic query

    Second is when the query_vars are used to alter the query. Notice how the query and query vars are different. The filtering of posts works great to show only the post that is related to 2735.
    altered query

    Can you add this code to your install and let me know if you are seeing the same errors?

    
    add_action( 'parse_query', 'poa_filter_query_by_relationship', 10, 1 );
    /**
     * Filter the main query by using URL parameters
     * 
     * @param object $query WP_Query.
     * @return object
     * 
     * @since 3.6.8
     */
    
    function poa_filter_query_by_relationship( $query ) {
        
        $id     = get_query_var('relation_id');
        $from   = get_query_var('relation_from');
        $to     = get_query_var('relation_to');
        
        if ( ! empty( $id ) && ! is_admin() && $query->is_main_query() ) {
    
            if ( ! empty( $from ) ) {
                
                $query->set( 'relationship', 
                    array( 
                        'id'  => esc_attr( $id ),
                        'from'    => intval( $from ),
                    )
                );
    
                var_dump($query);
    
            } elseif ( empty( $to ) ) {
    
                $query->set( 'relationship', 
                    array( 
                        'id'  => esc_attr( $id ),
                        'to'  => intval( $to )
                    )
                );
            }
            
        }
    
    }
    
    
    add_filter( 'query_vars', 'add_query_vars' );
    /**
         * Add query vars to build query with URL parameters
         *
         * @param array $vars WP_Query variables.
         * @return array
         * @since 3.6.8
         */
        public function add_query_vars( array $vars ) {
            $vars[] = 'relation_id';
            $vars[] = 'relation_from';
            $vars[] = 'relation_to';
            return $vars;
        }
    
    in reply to: pre_get_posts to get all posts connected to single object #11664
    Content PilotContent Pilot
    Participant

    On second look, parse_query is throwing off the entire query so the post type archive doesn't even get the post type it is associated with. I am getting the proper related post just fine but I am loosing the post type for the entire query. It seems like I am overriding my entire query and just setting the relationship query instead of adding the two queries together.

Viewing 15 posts - 61 through 75 (of 77 total)