Home › Forums › Pre-purchase Questions › ACF in another Plugin
Can I add a field to another plugin? The field appears in the Administration of the post, but must be printed in this part of the plugin:
// Closing post excerpt container.
$postExcerptHTML .= ‘</div><div class=”subhome”>’ . the_field(‘sub_title’) . ‘</div><div class=”srp_fb”><div id=”fb-root”></div><script src=”http://connect.facebook.net/en_US/all.js#appId=MYID&xfbml=1″></script><fb:like href=”‘ . get_permalink($post->ID) . ‘” send=”false” layout=”button_count” width=”550″ show_faces=”false” font=””></fb:like></div>’;
But doesn’t work!
I use this plugin:
http://codecanyon.net/item/special-recent-posts-pro-edition/552356
and I am ready, too, to buy the PRO version of ACF if you help me.
Field ACF should appear here (in the home): http://www.news-24h.it
EXAMPLE:
Hi @marty84
Yes you can use it within another plugin. If you’re looking to sell/distribute that plugin please have a look at: http://www.advancedcustomfields.com/resources/including-acf-in-a-plugin-theme/
As for your code try changing the_field
to get_field
. You’re attempting to save the value in a variable and thus should use get_field since that will return the value rather than the_field that echoes the value.
As a sidenote please try to add all code snippets inside code tags 🙂 You can see the code tag button in the toolbar above the textinput field.
Oh sorry for tag code
But I put get_field ('sub_title')
and the same does not work.
Reporting the code:
$postExcerptHTML .= '</div><div class="subhome">' . get_field('sub_title') . '</div><div class="srp_fb"><div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#appId=MyID&xfbml=1"></script><fb:like href="' . get_permalink($post->ID) . '" send="false" layout="button_count" width="550" show_faces="false" font=""></fb:like></div>';
Hi @marty84
Your screenshots doesn’t really help me much 🙂
I guess you can try using WP core functionality instead. If it still does not work it’s not an issue with ACF but rather with the plugin you use for recent posts.
<?php
global $post;
$postExcerptHTML .= '</div><div class="subhome">' . get_post_meta($post->ID, 'sub_title', true) . '</div><div class="srp_fb"><div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#appId=MyID&xfbml=1"></script><fb:like href="' . get_permalink($post->ID) . '" send="false" layout="button_count" width="550" show_faces="false" font=""></fb:like></div>';
?>
The topic ‘ACF in another Plugin’ 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.