-
AuthorPosts
-
January 29, 2016 at 12:52 pm #574463
Hi,
I need to display a custom post type. I want to do so using customised archive and single post pages.
I have a custom post type called ‘Baker’ (added via a simple plugin)
I have taxonomies attached to the cpt called ‘county’ and ‘postcodearea’. (added via functions.php)
I used the Advanced Custom Fields plugin to create a dozen or so custom fields, as I have more or less no use for the standard post fields.I copied single.php into my child theme and renamed it single-baker.php
I created the folder ‘includes’ and copied/created loop-baker.php inside it.Having only done this sort of thing with plugins in the past, I’ve now realised I don’t know how to go about adding the relevant custom fields…and which file to add them to…
Without knowing a damned thing about php, it looks to me that loop-index.php / loop-baker.php is used to find the data to be displayed, and then outputs it, and that I don’t really need to do anything at all to single-baker.php.
What I need to do is to add a couple of divs to the single post output, with the 12 or so custom fields inside. What I can’t work out is how to adapt the loop-baker.php to achieve this. Can you give me something to get started with?
It looks like “echo $content_output;” is what prints the standard post data…. which looks like it is prefetched earlier in the file.. so I presume I need to replace this with something else?
Any help appreciated – most of the posts I’ve seen on this sort of topic just say things like ‘create a single.php and edit that.’ So I’ve hit a brick wall!!
Thanks
January 29, 2016 at 1:31 pm #574507Hey!
Are you using the Advanced Layout Builder with these Baker CPT?
Regards,
JosueJanuary 29, 2016 at 7:04 pm #574760Josue,
No, I was just going to create a template (or hoped to, editing the originals) and then simply add relevant custom css. I did it on two other websites, but they used a plugin (for job adverts) which already had dedicated single and archive templates that were a doddle to adapt. Here, with this theme and without something to guide me, I have no idea where to start.
Ideally, I don’t really want to do things using internal builders because if I need to replicate the coding to test in another theme, I won’t be able to – whereas if I manually edit a template I can almost certainly transpose that to an alternate theme without too much grief. If stuff is created with the layout builder (I assume you mean the page builder in the theme) I wouldn’t know how..
Brian
January 30, 2016 at 7:23 pm #575064Okay, never mind, I’ve found a way to do what I want, even if it probably isn’t the right way.
While it might be a ‘customisation’, given that custom post types seem to be used more or less everywhere and by everybody, and given that Enfold might not be an easy thing for people to edit…… perhaps it would be nice if someone could knock up a simple ‘how to’ for using the theme with custom posts with a little sample code for people to follow? Most of the stuff Google chucks up if you do a search for that type of thing is either unhelpful wordpress codex pages which presume a certain level of knowledge of pure clickbait garbage copied between a thousand sites..
January 30, 2016 at 10:14 pm #575098Hey!
Glad you found a way. Not sure if doing an article for this would be good as it would probably involve using third-party plugins (for custom fields like ACF) which would be complicated for some users, but the main thing is what you mentioned in your first post, create a “single-cpt.php” file in child theme and start from there, some custom coding (both PHP and CSS) will always be required.
Regards,
JosueJanuary 31, 2016 at 1:22 am #575122Given the number of third-party plugins this theme uses to do things like adding photos, and by the number of other people I found asking questions relating to custom posts, I’m amazed that you would question the point of adding a simple guide to adding actual functionality to a website on the grounds that it might need a free third party plugin.
I know it would require custom coding but what doesn’t? That was why I asked for help in the first place. The point it, I thought maybe people might like to see basic example coding which they could use as a starting point. How many of your users do you reckon try to use custom posts these days?
Frankly, I’d swap the various image plugins you build into the theme for a little help on how to incorporate custom posts into this theme. There are thousands of “help pages” online wasting reams of text explaining why you should use custom posts but offering little more than “create a “single-cpt.php” file in child theme and start from there”, which doesn’t really help a whole lot.
January 31, 2016 at 3:53 am #575141Hi!
I reckon but each user wanted a different thing (and using different plugins) so it’s kinda hard to write a single manual for everyone, can you describe what way did you end up using? that could help.
Also, note that the only third-party plugin the theme uses is LayerSlider, the upload process is built-in into WordPress.
Best regards,
JosueFebruary 3, 2016 at 8:39 am #576963Actually, writing a simple guide to something like that is kinda simple, not to be too patronising.
It’s a question of whether you can be bothered.The marketing for this theme yaks on about how customisable it is. Good marketing, but in reality it does precious little these days that a whole swathe of other themes don’t do. Customisable? Yes, if you want exactly the same customisations as every other bog-standard website. Different? To do something more than produce a bog-standard wordpress site, or to use wp as a cms, it seems that custom posts are what you need to turn to. Your own replies to some questions are ‘you should use custom posts’ (I got that as a reply after asking how to create an ‘about us’ page that offered something usable in a real-world company), a quick search of your help forum shows more than a few posts asking about custom posts and the internet as it relates to wordpress seems to treat custom posts as one of the most important improvements in years…. but you think it’s too hard to provide meaningful help for people who might want different things.
And yet you sell a website aimed at satisfying people who want “different things”. Cool.
February 3, 2016 at 11:18 am #577044Ok, your feedback has been noted and i’ll keep an eye for similar threads regarding this topic in the future, if you need further assistance with something specific feel free to open a new thread.
Best regards,
Josue -
AuthorPosts
- You must be logged in to reply to this topic.