-
-
Save yanknudtskov/6dc95a3b87a15a8cfcea4cf64d35e503 to your computer and use it in GitHub Desktop.
Removing advanced custom fields from the frontend
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Your Child Theme | |
* | |
* Template Name: Landing | |
*/ | |
/** | |
* Flexible Content | |
* | |
*/ | |
function be_landing_page_content() { | |
$rows = get_post_meta( get_the_ID(), 'be_content', true ); | |
foreach( (array) $rows as $count => $row ) { | |
switch( $row ) { | |
// Full Width Content layout | |
case 'full_width_content': | |
$title = esc_html( get_post_meta( get_the_ID(), 'be_content_' . $count . '_title', true ) ); | |
$content = get_post_meta( get_the_ID(), 'be_content_' . $count . '_content', true ); | |
echo '<div class="flex-content full-width-content"><div class="wrap">'; | |
if( $title ) | |
echo '<h2>' . $title . '</h2>'; | |
if( $content ) | |
echo '<div class="section-content">' . apply_filters( 'the_content', $content ) . '</div>'; | |
echo '</div></div>'; | |
break; | |
// Content with Image layout | |
case 'content_with_image': | |
$title = esc_html( get_post_meta( get_the_ID(), 'be_content_' . $count . '_title', true ) ); | |
$content = get_post_meta( get_the_ID(), 'be_content_' . $count . '_content', true ); | |
$image = get_post_meta( get_the_ID(), 'be_content_' . $count . '_image', true ); | |
echo '<div class="flex-content content-with-image"><div class="wrap">'; | |
if( $title ) | |
echo '<h2>' . $title . '</h2>'; | |
if( $image ) | |
echo '<div class="section-image">' . wp_get_attachment_image( $image, 'medium' ) . '</div>'; | |
if( $content ) | |
echo '<div class="section-content">' . apply_filters( 'the_content', $content ) . '</div>'; | |
echo '</div></div>'; | |
break; | |
} | |
} | |
} | |
add_action( 'be_content_area', 'be_landing_page_content' ); | |
// Remove 'site-inner' from structural wrap | |
add_theme_support( 'genesis-structural-wraps', array( 'header', 'footer-widgets', 'footer' ) ); | |
// Build the page | |
get_header(); | |
do_action( 'be_content_area' ); | |
get_footer(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment