Home › Forums › Feature Requests › Assign ACF to a post template?
Is there a way to assign ACF to a post template?
I’ve found the following but I’m not sure if it has been implemented and it is beyond my php skills https://github.com/elliotcondon/acf/pull/3
I am using the the “Single Post Template plugin” found here http://wordpress.org/plugins/single-post-template/
This would be a great addition if this sort of thing is not already implemented
Stuart
Hi @Graphx
I’m not 100% sure this will make it into the core due to the ‘post template’ being a plugin, not a core function of WP.
That said, someone has already written the extra location rule code for you!
https://github.com/lukechapman/custom-post-template-support-for-acf/blob/master/acf-custom-post-template-support.php
Good luck
E
Hi @Elliot,
Many thanks, I now have this working.
Just a quick question:
What is the likely hood of this functionality breaking on a future update of ACF or WordPress if the developer doesn’t update his ‘post template’ plugin?
I really don’t want my clients site breaking on future updates. So I’m just wondering how safe it is to implement this sort of thing?
Many thanks
Stuart
Hi @Graphx
There should be no issues with updating the plugins, however, this is always a risk with any WP build.
The code I referenced does not depend on many core functions so it would be very stable to use.
Thanks
E
I’m using the latest version of acf
the latest version of the plugin single post template Version 1.4.4
and WP 3.8.1 and the plugin for the plugin 🙂
https://github.com/lukechapman/custom-post-template-support-for-acf/blob/master/acf-custom-post-template-support.php
my theme has a single-xyz.php with a name “Single Post Template: Banken”
Single Post Template is working fine…
At ACF I see the dropdown for Post Template but I can’t choose a template because this dropdown is empty.
Any help .. ?
Thanks 🙂
Monika
@MonikaTS change all instances of “Template Name Posts” to “Single Post Template”
Looks like the single post template plugin was updated!
A year late, but I just figured this out!
Hi there.
Great to find this post.
I am trying to get single post template to work with ACF, but it is not.
I have created templates and have it working properly when creating normal posts, the “single post template” drop down menu appears under the editor.
But I cannot see the SPT drop down under the ACF add new field sections.
Any idea what could be wrong? I am running WP 4.1 and the latest versiion of SPT, and I have already followed the above instructions and changed “Template Name Posts” to “Single Post Template” but still the drop down is not showing anywhere in ACF
Any help would be great.
Thanks in advance (hope I don’t have to wait a year (lol)
Hi charis,
I’m trying to use the plugin along with Single Post Template, I made some few steps, but I’ve got a js error.
This is what I’ve done:
In the main plugin file:
https://github.com/lukechapman/custom-post-template-support-for-acf/blob/master/acf-custom-post-template-support.php
1) I changed all “Template Name Posts” to “Single Post Template” (there are a few)
2) I changed the jquery selector to match the Single Post Template dropdown id: #post_template (instead of #custom_post_template as in CPT plugin)
I have post templates in dropdown,
but when I switch template, I have this js error:
TypeError: acf.screen is undefined
PS: I’m using ACF PRO 3.7.4
Thanks to Eliot supporto i solved.
Correct way to reference to acf js is
acf.ajax.update( 'cpt', jQuery(this).val() ).fetch();
I made a github fork of the lukechapman plugin, tu be used for Single Post Template plugin instead of Custom Post Template plugin
https://github.com/bluantinoo/single-post-template-support-for-acf
Hi, I”m having a similar issue / need with a radio button.
Once set “on” I want a relationship field populated.
I’ve been hammering on the
acf.ajax.update
but not sure what your 'cpt'
is, is it the field name? field ID?
And does this update your field automatically? I tried with both my relationship field, and a test input (text) field.. could not figure out how to set value.
The topic ‘Assign ACF to a post template?’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.