Post meta in post archive?

General questions pertaining to how certain issues can be resolved
Forum rules
1. No offensive language and no mocking
2. Please do a thorough search before you post something. Trust us, there is a high probability that the question you are asking has been asked previously.
3. No soliciting. You cannot post here soliciting bids for people offer you quotes, or even offer money to people for some work. You will be moderated if you do so. If you are looking for help, please post your request on http://jobs.wordpress.net or http://codepoet.com
4. Please be reasonable. You are getting software and support. For free. Complicated requests from a general purpose theme are not welcome and some volunteers might lose patience with you.
5. Please do your due diligence. If you posted a query and we answered with a link, take the trouble to go through the link contents.
6. Please post with complete information. Requests for help MUST be accompanied with your URL, particularly if you are asking something like "Why am I seeing a blank space?"

Post meta in post archive?

Postby Martinl276 » 30 Apr 2012, 12:06

Hello

How can I show the value of a post custom field (post_meta) in the category (archive) view? Ideally next to the post title or in the byline.

Here is the URL: http://www.betgazette.co.uk/category/football-premier-league/

Thanks in advance
Martinl276
Martinl276
 
Posts: 37
Joined: 27 Mar 2012, 05:24

Re: Post meta in post archive?

Postby Martinl276 » 05 May 2012, 00:11

Is anyone able to help me please?
Martinl276
 
Posts: 37
Joined: 27 Mar 2012, 05:24

Re: Post meta in post archive?

Postby sayontan » 05 May 2012, 09:46

You will have to edit PHP for this. If you want to show this in your byline, you will need to edit the custom/post-header.php file. You will see some code there that creates the categories (around line 66). You will have to add your code there. Without more information about what kind of custom field this is, I cannot say more.

It is best to do this in a child theme.
Sayontan Sinha | http://mynethome.net/blog | http://www.aquoid.com/news
I don't do freelance work (for Suffusion or otherwise), so please don't contact me for quotes or offers.
sayontan
Site Admin
 
Posts: 10159
Joined: 15 Sep 2009, 16:39
Location: Houston, Texas

Re: Post meta in post archive?

Postby Martinl276 » 05 May 2012, 10:44

Thank you Sayontan

The Post meta is called "Tip Price (£)" and is just a text field, if that helps?
Martinl276
 
Posts: 37
Joined: 27 Mar 2012, 05:24

Re: Post meta in post archive?

Postby sayontan » 05 May 2012, 16:49

You will need the field id rather than the field name. The function to pull meta fields is get_post_meta.
Sayontan Sinha | http://mynethome.net/blog | http://www.aquoid.com/news
I don't do freelance work (for Suffusion or otherwise), so please don't contact me for quotes or offers.
sayontan
Site Admin
 
Posts: 10159
Joined: 15 Sep 2009, 16:39
Location: Houston, Texas

Re: Post meta in post archive?

Postby Martinl276 » 06 May 2012, 03:49

Hi Sayontan

I've researched it a bit and everything refers to the post ID, which in this case is 818. I don't know how I can find the field ID?

Thanks
Martin
Martinl276
 
Posts: 37
Joined: 27 Mar 2012, 05:24

Re: Post meta in post archive?

Postby sayontan » 06 May 2012, 08:33

If you want to show this for every post, then you cannot pass 818 to the call. You have to do something like this:
Code: Select all
echo get_post_meta($post->ID, 'your_field_id', false);

For the field id you have to ask your plugin author - I have no way of knowing that. You could determine it yourself from the "Custom Fields" section in the Edit Post screen (if you don't see the section, go to the top of the screen and select "Screen Options", then check "Custom Fields" there). The drop-down under "Name" will have the field id.
Sayontan Sinha | http://mynethome.net/blog | http://www.aquoid.com/news
I don't do freelance work (for Suffusion or otherwise), so please don't contact me for quotes or offers.
sayontan
Site Admin
 
Posts: 10159
Joined: 15 Sep 2009, 16:39
Location: Houston, Texas

Re: Post meta in post archive?

Postby Martinl276 » 06 May 2012, 11:41

Hi Sayontan

I have looked under the custom fields dropdown, but no field ID's there. Also, I have no plugin installed for custom fields. I will see if I can install a plugin that will give me field ID's and submit another reply.

Thanks
Martin
Martinl276
 
Posts: 37
Joined: 27 Mar 2012, 05:24

Re: Post meta in post archive?

Postby Martinl276 » 07 May 2012, 11:15

Hello again Sayontan

After receiving the following advice:

You can use the Types plugin - http://wordpress.org/extend/plugins/types/
It comes with [types] shortcode allowing you to add this in a post body or call do_shortcode('[types field="yourfieldname"]');
It comes with a very handy UI as well.


I installed the plugin and the field ID is showing as "wpcf-price", does that seem correct? Or should it be a numerical value?

Thanks
Martin
Martinl276
 
Posts: 37
Joined: 27 Mar 2012, 05:24

Re: Post meta in post archive?

Postby sayontan » 07 May 2012, 11:18

Martinl276 wrote:I installed the plugin and the field ID is showing as "wpcf-price", does that seem correct?

Yes, that seems correct.
Sayontan Sinha | http://mynethome.net/blog | http://www.aquoid.com/news
I don't do freelance work (for Suffusion or otherwise), so please don't contact me for quotes or offers.
sayontan
Site Admin
 
Posts: 10159
Joined: 15 Sep 2009, 16:39
Location: Houston, Texas

Next

Return to Support Requests

Who is online

Users browsing this forum: drake, Google [Bot], Majestic-12 [Bot], mdunham and 4 guests