GET FIELDS – Trying to print them on a table

This topic contains 4 replies, has 2 voices, and was last updated by  ian bran 6 years, 3 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket

Tagged: 

  • Author
    Posts
  • #412900

    ian bran
    Expired Member
    Post count: 122

    Hello, this is my first post, I’m sorry if I do something wrong

    I basically want to
    1) show fields of posts in a table (see below)
    2) Just to know opinion if it would be to difficult to make this a new listing search template…so when user in search select category HOTEL, all Hotels appear in this table with their fields values, like this:
    NAME ADRRESS PHONE PRICE ETC
    hotel 1 adress 1 2839839 $450
    hotel 2 adress 2 2823329 $50

    so 1) I have it the way I want but I don’t know how to retrieve GD FIELDS, I searched other forum posts and all I got is the code below.
    for regular wp fields, like the_title(), it works!

    Thanks for any help! I would be happy achieving 1) even happier to take it to next level and integrate with the search

    
    
     <table>
                  
                   <thead>
                       <tr>
                             <th>Título</th>
                             <th>Address</th>
                             <th>Phone</th>
                       </tr>
                   </thead>
                   
                   <tbody>
                    
                    
                     <?php  
                       
                        //DEFINE GD FIELDS
                        global $wp_query;
                       $postid = $wp_query->post->ID; // retrieve the ID
                       $address= geodir_get_post_meta($postid,'address',true);
                       
                       //DEFINE POST ARGS FOR LOOP
                       global $post;
                        $args = array(
                            'numberposts'    => -1,
                            'orderby'           => 'DESC',
                            'post_type'         => 'gd_place',
                        );
                       $myposts = get_posts( $args ); 
                       
                       //LOOP
                       foreach ( $myposts as $post ) : setup_postdata( $post ); ?>     
     
                        <tr>
                           <td><?php the_title(); ?></td>
                           <td><?php echo $address; ?></td>
                       </tr>  
                              
                      <?php endforeach; 
                        wp_reset_postdata();?>          
                                 
                   </tbody>
               </table>
    #412930

    Alex Rollin
    Moderator
    Post count: 27815

    Hello Ian,

    Check out this post for some info about that:
    https://wpgeodirectory.com/support/topic/individual-fields-for-template-of-details-page/

    #413001

    ian bran
    Expired Member
    Post count: 122

    Hello Alex, thank you for the help!

    According to what i read there

    <?php echo $post->geodir_email; ?>

    should print the post email…but it does nothing

    I added to functions.php:

    
    
    add_action( 'geodir_details_main_content', 'my_custom_action',35);
    function my_custom_action(){global $post; print_r($post);}

    but print_r($post) is showing me regular post meta, not geodir-specific, an example with first 5 elements:

    ` [ID] => 59
    [post_author] => 1
    [post_date] => 2018-01-10 20:07:32
    [post_date_gmt] => 2018-01-10 20:07:32
    [post_content] => …and so on`

    Should I put something before

    <?php echo $post->geodir_email; ?>

    ?

    Again, thanks!

    #413036

    Alex Rollin
    Moderator
    Post count: 27815

    Hello!

    That post references several other posts, and you will have to dig a bit deeper:

    https://wpgeodirectory.com/support/topic/change-layout-of-details-page/#post-40573

    #413290

    ian bran
    Expired Member
    Post count: 122

    Thanks Alex!
    yes, I did look the referenced posts, there was one I didn’t have access to.
    I’ll try again. I’m evaluating buying the membership depending on how easy (for me) is to customize the plugin.

    cheers!

Viewing 5 posts - 1 through 5 (of 5 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket