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, 10 months ago.
We have moved to a support ticketing system and our forums are now closed.
Open Support TicketTagged: fields
-
AuthorPosts
-
January 16, 2018 at 6:43 am #412900
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 $50so 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>
January 16, 2018 at 12:50 pm #412930Hello Ian,
Check out this post for some info about that:
https://wpgeodirectory.com/support/topic/individual-fields-for-template-of-details-page/January 16, 2018 at 5:07 pm #413001Hello 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!
January 16, 2018 at 9:53 pm #413036Hello!
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
January 18, 2018 at 2:49 pm #413290Thanks 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!
-
AuthorPosts
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket