Support

Account

Home Forums General Issues ACF and Tablepress

Solved

ACF and Tablepress

  • Hiya

    I’m using ACF to help me populate my posts quickly. I have set it up so I have 8 custom field, most of them are text and one is for image urls.

    I have managed to output the fields into my posts just fine, but have got stuck trying to do the following using the tablepress plugin.

    I want to output the following in my single.php wordpress page, where 26 is just an example ID and what I am struggling with!

    <?php tablepress_print_table( 'id=26' ); ?>

    I have made a custom field ‘top_table_number’ for the post edit page where I enter the table id into text field.

    I just can’t work out how to get that value into the code above.

    I have managed to extract the value into a variable using the get_field but cannot work out how to get that into the above PHP statement.

    
    <?php
    $post_obj = get_field( 'top_table_number' );
    ?> 

    I tried this…

    <?php tablepress_print_table( 'id=$post_obj' ); ?>

    But it outputs this [table “post_obj” not found /] and not the table.

    Hope this makes sense, I feel like it should be easy but my code knowledge isnt good.

  • With some help, I managed to get this working. I will leave here as it might help someone! Thanks : )

    <?php
    $post_obj = get_field( 'top_table_number' );
    // get the table id and put in a variable
    
    tablepress_print_table( "id=$post_obj" );
    ?>
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.