Support Forum » User Profile

Forum Replies Created

Viewing 11 posts - 16 through 26 (of 26 total)
  • Author
    Posts
  • in reply to: Post Content Empty #36428
    Macky McCormackMacky McCormack
    Participant

    Hi Long,

    So one thing I learned along the way was where the post data is stored - I expected it to be in post content (because its the content of the post), but it is stored elsewhere. I'm not sure why the content that I was looking for doesn't show up when I do print_r, but I couldn't see it and I could see that the post content was empty. Anyhow, after much trial and error and investigation I figured out how to query the post and the data that I was looking for.

    If you think this forum post is going to not help others then feel free to edit it as you see fit.

    Cheers

    in reply to: Post Content Empty #36403
    Macky McCormackMacky McCormack
    Participant

    FYI and for anyone who has a similar issue and finds this post, this is the code that allowed me to query posts in a post field in a cloneable field group. It's probably not the most efficient way of doing it but it works

    <?php
    // Get values of custom field group
    $group_values = rwmb_meta( 'group_m2qbw9n986h' );//Group ID
    // Query posts in custom field type posts, in field group
    $group_values = $group_values ?? [];
    foreach ($group_values as $group_value){
        $my_post_id = $group_value['post_ecian25xrc9'];//ID of CPT being queried
        $args = array(
            'p'         => $my_post_id,
            'post_type' => 'any'
            );
     
        $my_query = new WP_Query($args);
     // Get post data and output post title and image for each to test
        while ( $my_query->have_posts() ) {
        $my_query->the_post();
        $post_meta = get_post_meta(get_the_ID(), 'main_image', 'true');
     $main_img = wp_get_attachment_image_src($post_meta);
     echo '<li>' . get_the_title() . '</li>';
     echo '<img src="' . $main_img['0'] . ' "/>';
     
        };
    }
        
        wp_reset_postdata();
     
    ?>
    in reply to: Post Content Empty #36402
    Macky McCormackMacky McCormack
    Participant

    Hi Long,

    If I had known what knowledge was required to use your product before I purchased I would not have purchased.

    As I said, there is no longer an issue as I have spent 2 days learning WordPress and PHP to figure out what to do.

    I would have appreciated a reply sooner with some guidance (not just a link to your documentation which I'd already explored for some time before posting here).

    Anyhow it's done, onwards and upwards

    in reply to: Post Content Empty #36398
    Macky McCormackMacky McCormack
    Participant

    Don't worry, after two days of investigation I figured it out myself!

    Not sure why you haven't got back to me with some support on this matter - and not sure why I paid for your premium licence when a lot of the time I need to understand PHP and wordpress queries to get the full value from your plugins, and your support is very much lacking.

    By the time I've learned everything that I need to know to use your plugins, I'll have enough knowledge to no longer need them

    in reply to: Post Content Empty #36394
    Macky McCormackMacky McCormack
    Participant

    Hi,

    Just wondering if you have any help for me on this? For some reason I can retrieve the posts but the content isn't available. I have set up a single template for the Accommodation Type to test that I can access the content, and I can, but for some reason I cannot using the query.

    Thanks

    in reply to: How to query a Post field in a Group #36371
    Macky McCormackMacky McCormack
    Participant

    EDIT: When I 'query' - I am actually wanting to build a repeater in Oxygen Builder that queries the cloneable Group - so I can access the content from the group (including the linked posts) via dynamic data for each instance of the cloneable group. I hope that makes sense!

    Macky McCormackMacky McCormack
    Participant

    OK thanks

    in reply to: Where to put PHP code - no functions.php file #36073
    Macky McCormackMacky McCormack
    Participant

    OK thanks

    in reply to: Set Post Title from Field Group Submission data #33329
    Macky McCormackMacky McCormack
    Participant
    in reply to: Set Post Title from Field Group Submission data #33328
    Macky McCormackMacky McCormack
    Participant

    Hi Long,

    Many thanks for your reply. I have added your code but the post title still remains (no title) when I submit. Can you suggest anything to fix this?

    in reply to: Set Post Title from Field Group Submission data #33212
    Macky McCormackMacky McCormack
    Participant

    Here is the PHP from the builder

    add_filter( 'rwmb_meta_boxes', 'your_prefix_function_name' );
    
    function your_prefix_function_name( $meta_boxes ) {
        $prefix = '';
    
    $meta_boxes[] = [
        'title'        => __( 'Retreat Guest Info', 'your-text-domain' ),
        'id'           => 'retreat-guest-info',
        'post_types'   => ['retreat-info'],
        'storage_type' => 'custom_table',
        'table'        => 'wp_retreat_guest_info',
        'fields'       => [
            [
                'name'     => __( 'First Name', 'your-text-domain' ),
                'id'       => $prefix . 'customer_first_name',
                'type'     => 'text',
                'required' => true,
            ],
            [
                'name'     => __( 'Last Name', 'your-text-domain' ),
                'id'       => $prefix . 'customer_last_name',
                'type'     => 'text',
                'required' => true,
            ],
        ],
    ];
    
    return $meta_boxes;
    
    }
    
Viewing 11 posts - 16 through 26 (of 26 total)