Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
/*
Template Name: Developer Content
Template Post Type: post
*/
/**
* Genesis Framework.
*
*
*
* @package Masterminds\Templates
* @author Victor Font Consulting Group, LLC.
* @license GPL-2.0-or-later
*
* retrieve and display the content from the Developers Directory entry based on the post's id
*/
/* disaable wautop to prevent Formidable views from displaying incorrectly
* when displayed in a post
*/
remove_filter( 'the_content', 'wpautop' );
remove_action( 'genesis_entry_content', 'genesis_do_post_content' );
add_action( 'genesis_entry_content', 'masterminds_display_developer_details' );
/**
* masterminds_get_directory_entry function.
*
* @access public
* @return false or directory entry with meta
*/
function masterminds_get_directory_entry_id() {
global $post;
$post_id = $post->ID;
$entry_id = masterminds_get_entry_id_by_post_id( $post_id );
if ( !$entry_id ) {
return false;
}
return $entry_id;
}
/**
* masterminds_get_entry_id_by_post_id function.
*
* @access public
* @param numeric $post_author(user id)
* @return false or directory entry id
*/
function masterminds_get_entry_id_by_post_id( $post_id ) {
global $wpdb;
/* create the variables for the formidable tables */
$wpdb_prefix = $wpdb->prefix;
$frm_items_table = $wpdb_prefix . 'frm_items';
$sql = "SELECT id from `{$frm_items_table}` WHERE `post_id` = {$post_id} AND `form_id` = 32";
$results = $wpdb->get_var( $sql );
if ( null !== $results ) {
return $results;
} else {
return false;
}
}
function masterminds_display_developer_details() {
$entry_id = masterminds_get_directory_entry_id();
if (!$entry_id ) {
return;
}
echo FrmProDisplaysController::get_shortcode( array( 'id' => 6096, 'filter' => 'limited', 'entry' => $entry_id, 'wautop' => 0 ) );
}
// This file handles single entries, but only exists for the sake of child theme forward compatibility.
genesis();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment