Gemeinsame Forge Suite-Diagnosen
Wenn Field Forge aktiv ist, ist das gemeinsame Forge Suite > Setup & Gesundheit-Panel im WordPress-Adminbereich verfügbar. Seine schreibgeschützte AJAX-Aktion ist forge_suite_health_check; sie erfordert manage_options und das lokalisierte forge_suite_health_check Nonce. Die Antwort gibt Diagnosen für aktive Forge-Plugins, lokale Lizenzaufzeichnungen, die Bereitschaft des Credits-Widgets, Avakode API /health, Permalinks und Migrations-/Integrationsquell-Plugins wie ACF und ACF Pro zurück. Es importiert keine ACF-Daten, erstellt keine Feldgruppen, schreibt keine Feldwerte, ruft keine AI-Endpunkte auf, gibt keine Credits aus oder ändert den Lizenz-/Freemius-Zustand.
Ihr Theme mit Field Forge zum Laufen bringen
Field Forge speichert Werte in benutzerdefinierten Datenbanktabellen (wp_fieldforge_values) anstelle von wp_postmeta. Es bietet eine ACF-kompatible Funktionsschicht, sodass vorhandener Theme-Code ohne Modifikation funktioniert. Das bedeutet, dass Sie get_field(), the_field(), have_rows() und alle anderen vertrauten Funktionen verwenden können — Field Forge registriert sie automatisch, wenn ACF nicht aktiv ist. Während der ACF-Aktivierungsanfragen verweist Field Forge auf ACF, sodass ACF Pro für die Migration aktiviert werden kann, ohne einen PHP-Redeclare-Fatalfehler zu verursachen.
// functions.php -- ensure field functions are always available
if ( ! function_exists( 'get_field' ) ) {
// Field Forge (or ACF) is not active -- provide fallbacks
function get_field( $selector, $post_id = false ) {
return get_post_meta( $post_id ?: get_the_ID(), $selector, true );
}
}Dieses Muster stellt sicher, dass Ihr Theme niemals bricht, selbst wenn Field Forge deaktiviert ist. Der Fallback liest von wp_postmeta, wo WordPress standardmäßig benutzerdefinierte Felder speichert.
// Check for Field Forge (not ACF)
if ( defined( 'FIELDFORGE_VERSION' ) ) {
// Field Forge-specific code here
$version = FIELDFORGE_VERSION; // e.g., '1.2.0'
}
// Check for Field Forge PRO features
if ( defined( 'FIELDFORGE_PRO' ) && FIELDFORGE_PRO ) {
// PRO-only code: repeaters, flexible content, options pages, etc.
}<?php
// single.php -- display custom fields on a post
$subtitle = get_field( 'subtitle' );
$hero_image = get_field( 'hero_image' ); // Returns array when return_format = 'array'
if ( $subtitle ) : ?>
<h2 class="entry-subtitle"><?php echo esc_html( $subtitle ); ?></h2>
<?php endif; ?>
<?php if ( $hero_image ) : ?>
<img src="<?php echo esc_url( $hero_image['url'] ); ?>"
alt="<?php echo esc_attr( $hero_image['alt'] ); ?>"
width="<?php echo esc_attr( $hero_image['width'] ); ?>"
height="<?php echo esc_attr( $hero_image['height'] ); ?>">
<?php endif; ?><p class="lead"><?php the_field( 'lead_text' ); ?></p><?php // archive.php or index.php
if ( have_posts() ) :
while ( have_posts() ) : the_post(); ?>
<article class="post-card">
<?php $thumb = get_field( 'card_thumbnail' ); ?>
<?php if ( $thumb ) : ?>
<img src="<?php echo esc_url( $thumb['url'] ); ?>"
alt="<?php echo esc_attr( $thumb['alt'] ); ?>"
class="post-card__image">
<?php endif; ?>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<p><?php the_field( 'excerpt_text' ); ?></p>
</article>
<?php endwhile;
endif; ?><?php
/**
* Template Name: About Us
*/
get_header();
$team_photo = get_field( 'team_photo' );
$mission = get_field( 'mission_statement' );
$founded_year = get_field( 'founded_year' );
?>
<main class="about-page">
<section class="about-hero">
<?php if ( $team_photo ) : ?>
<img src="<?php echo esc_url( $team_photo['url'] ); ?>"
alt="<?php echo esc_attr( $team_photo['alt'] ); ?>">
<?php endif; ?>
<div class="about-hero__content">
<h1><?php the_title(); ?></h1>
<?php if ( $mission ) : ?>
<blockquote><?php echo esc_html( $mission ); ?></blockquote>
<?php endif; ?>
<?php if ( $founded_year ) : ?>
<p class="founded">Established <?php echo esc_html( $founded_year ); ?></p>
<?php endif; ?>
</div>
</section>
</main>
<?php get_footer(); ?>Theme-Support-Erklärung
Es ist kein spezieller add_theme_support() Aufruf erforderlich. Field Forge aktiviert seine Kompatibilitätsschicht automatisch, wenn ACF nicht aktiv ist. Wenn ACF zusammen mit Field Forge aktiv ist, haben die ACF-Funktionen Vorrang und Field Forge fungiert nur als Speicher-Backend. Der gleiche Schutz gilt während der wp-admin- und WordPress-Plugin-API-Aktivierung, sodass die Aktivierung von ACF Pro, nachdem Field Forge bereits aktiv ist, get_field() nicht erneut deklariert.
Empfohlene Theme-Struktur
Organisieren Sie Ihre Theme-Dateien für eine saubere Field Forge-Integration:
my-theme/
functions.php # Load field setup, register blocks
inc/
fieldforge-setup.php # Options pages, programmatic field groups
template-functions.php # Helper functions wrapping get_field()
template-parts/
content-*.php # Partial templates using fields
builder/ # Flexible content section templates
blocks/ # PHP block templates
fieldforge-json/ # Local JSON sync directory (PRO)<?php
// inc/template-functions.php
/**
* Get the hero image URL with a fallback.
*
* @param int|false $post_id Post ID or false for current post.
* @return string Image URL.
*/
function theme_get_hero_image( $post_id = false ) {
$image = get_field( 'hero_image', $post_id );
if ( $image && isset( $image['url'] ) ) {
return $image['url'];
}
return get_template_directory_uri() . '/assets/img/default-hero.jpg';
}
/**
* Render social links from options page.
*/
function theme_render_social_links() {
$platforms = [ 'facebook', 'twitter', 'instagram', 'linkedin', 'youtube' ];
echo '<div class="social-links">';
foreach ( $platforms as $platform ) {
$url = get_field( 'social_' . $platform, 'options' );
if ( $url ) {
printf(
'<a href="%s" class="social-link social-link--%s" target="_blank" rel="noopener">%s</a>',
esc_url( $url ),
esc_attr( $platform ),
esc_html( ucfirst( $platform ) )
);
}
}
echo '</div>';
}—