Wordpress.org - custom fields

Apologies if this is a bit off-topic, but I really appreciate some help.

The question is, how to use the custom fields when the theme is not set up to use them?

Context:

I’m building a blog using wordpress.org and I want to have Link posts. I’m using a theme that doesn’t support custom fields (externalURL). I could use plug-ins but I really really want to use @nahumck’s awesome Drafts5 WP actions.

I’ve been searching for how to modify a theme in order to adopt these custom fields. It’s quite difficult to find information though. I’ve found a site that refers to changing content.php and content-single.php but when I do it, I get an error message.

Is there a way of doing it? Or do I need to change themes (less preferred option as I’ve already customized the theme to my needs).

Thanks!!

Not entirely sure what you are after, but I have built a lot of themes that have custom fields.

Check out the plugin Advance Custom Fields. It will allow you to easily set up the fields and they have some really good documentation about how to then get those fields to display in the theme template files.

If it’s an off the shelf theme make sure you install it as a child theme so you can edit the templates you need to display the custom fields without editing the actual parent theme. That way you’ll be safe to update the theme without overwriting any changes you make to the templates.

1 Like

Thanks.

Yes, I’ve looked at ACF. However, I’d like to use the standard “custom fields” in order to decide whether the permalink should be pointing to my site or to an external one (for Link Posts). This explains what I’d like to do but I cannot make these changes…so not sure if this is the way to go.

Re child’s theme, I’m looking at that.

(should have said I have really little experience in WordPress themes :slight_smile: )

I went through this exact thing back in February with my site. I remember it being difficult for a non-coder like me. I used a plugin, but also had to hack my theme files to make the titles of link posts link to the source material. This is the plugin (old, but it still worked):

I remember having two different sites with instructions on how to modify the theme files. It was really trial and error for me as far as where everything went.

1 Like

Nice to see the article also mentions creating a child-theme. I’d start there first.

Once you have the child-theme set up, you’ll need to identify which template you’ll need to copy over from the parent theme to the child-theme for editing. That will depend on which theme you are using.

1 Like

Update:

I think these were the pages I used for instructions:

http://yjsoon.com/2011/02/customising-your-wordpress-theme-for-the-df-linked-list-plugin

And like Leanda mentioned, you’ll want to set up a child theme.

1 Like

Thank you. Those links are fab!

the plug-in is great and works as expected. The tricky bit is the change in the theme.

I’m now looking at how to create a child theme to implement the changes required.

My frustration is that I’ve never thought it would be so difficult… :slight_smile:

Thanks!!

2 Likes

Sorry to come back on this one again. Creating a child theme has became more challenging then what I’ve anticipated.

The child theme is created (for now only with a style.css and functions.php files). When I do a live preview some formatting looks weirdly different. I’ve tried to add additional css into the style file and to add it to the “additional css” section in the wordpress editor. None brought any success.

I thought the parent’s theme style.css would take priority (if the child’s is empty). Is this not correct?

That is correct, the stylesheet should use the parent styles as a priority. Things to check:

Have you begun your child-theme stylesheet with a header making sure it properly references the parent? If so, make sure the template line in the stylesheet header corresponds with the parent stylesheet? It should be the same name as the parent template line.

Make sure you’ve enqueued the parent and child theme stylesheets correctly in the functions.php again being careful to get the naming correct. There’s also two ways to enqueue depending on your theme, examples here on the codex https://codex.wordpress.org/Child_Themes I tend to always have to use the second example. If I have problems 9 times out of 10 it’s because I haven’t gotten the parent theme template name correct so double double check those.

1 Like

Thanks @leanda. I’ve followed the instructions on that page. And I’m getting most css anyway.

As you’ve said, I’ll double double check it though :slight_smile: