August 22, 2016 at 2:00 pm #675728
Hello I’m using the blog grid module inside a page and I wish to add meta from the single blog post to this grid when it’s displayed.
How can I do this?
I need to be able to fetch the meta from the single post to show it in the loop of the grid.August 24, 2016 at 5:27 pm #677145
not sure what you want to achieve. Can you send us precise links showing the elements you are talking about please?
AndyAugust 30, 2016 at 2:42 pm #679460
Yes, it’s on this website and all of it’s sub-pages
I want to display a custom field within the box (post).
The custom field is of course set inside the original post.
How do I do that?August 30, 2016 at 5:29 pm #679597
about which custom field are you talking about? can you highlight using screenshots please? use imgur.com or dropbox.
AndyAugust 30, 2016 at 6:30 pm #679616August 30, 2016 at 8:33 pm #679661
does it work for you when using a default WordPress theme?
AndyAugust 30, 2016 at 10:40 pm #679733
I need to know what file I need to edit and insert the field. I have managed to insert it in the single.php file, but I also want to show the price in the front so I need to know what file controls the grid blog layout.
<?php echo get_post_meta( get_the_ID(), 'pris', true );?>
This is what I’ve put in the single.php. Where do I put it so it shows up like the picture I sent you?
Do you get me?September 1, 2016 at 10:46 am #680606September 2, 2016 at 2:45 pm #681310
Please go to Enfold/config-templatebuilder/avia-shortcodes/postslider.php file and find
$output .= !empty($excerpt) ? " <div class='slide-entry-excerpt entry-content' $markup>".$excerpt."</div> " : "";
and change it to following
$output .= !empty($excerpt) ? " <div class='slide-entry-excerpt entry-content' $markup>".$excerpt."</div> " : ""; $output .= get_post_meta( get_the_ID(), 'pris', true );
YigitSeptember 7, 2016 at 8:51 am #683030September 7, 2016 at 2:43 pm #683170
Well, then there might be the issue in the way you are adding a custom field. Have you considered using Advanced Custom Fields plugin instead?
YigitSeptember 8, 2016 at 1:00 pm #683674
I’m using a plugin called AccessPress Anonymous Post Pro and that is what I need to use. It generates the key called “pris”
But really, is it correct to just type in: $output .= get_post_meta( get_the_ID(), ‘pris’, true ); ??
This is supposed to show the price on the front page. Where in this code does it fetch the information from the post in question?
Example: First column is a preview, an excerpt. Inside this post are all the keys, right?
With the code above, nothing is saying “get the information from inside the post”.
Do you know what I mean?
September 12, 2016 at 2:07 am #684838
- This reply was modified 1 year, 6 months ago by grafixstudio.
The get_post_meta function should fetch any custom or meta fields of a post. https://developer.wordpress.org/reference/functions/get_post_meta/
If the function is not working, ask the plugin author what function to use to get the value of the field.
IsmaelSeptember 12, 2016 at 8:58 am #684942
Hey, they told me to contact you again.
I believe they are right….
Guys, listen…the keys work fine..If you check inside a post: http://dentalmarknaden.se/utrustning/mobiltelefon/ you will see where it says:
That’s the value of the field pris that we are talking about. So it works. But not in the post-slider. So it’s inside Enfold where the problem is….September 18, 2016 at 7:22 am #688051
Which function did they use to get the value of the “pris” meta field? And did you add excerpts to the posts? If not, please edit one of the posts with the “pris” meta field then input something in the Excerpt module. If you can’t find the Excerpt module, enable it in the Screen Options.
IsmaelSeptember 21, 2016 at 1:44 pm #689782
I resolved the issue. the thing is that inthe postlider.php you have already declared a variable for get_the_id() – called $the_id
So the correct code is:
$output .= get_post_meta($the_id, 'pris', true );
September 22, 2016 at 8:41 am #690152
- This reply was modified 1 year, 5 months ago by grafixstudio.
You must be logged in to reply to this topic.