|Im having this issue I’m on the latest version of acf
for the form its
the code bellow
<?php
/**
* Template Name:create memorial Template
*
* @package WooFramework
* @subpackage Template
*/
acf_form_head();
get_header(); ?>
<!-- #content Starts -->
<?php woo_content_before(); ?>
<div id="content" class="col-full">
<div id="main-sidebar-container">
<!-- #main Starts -->
<?php woo_main_before(); ?>
<div id="primary">
<div id="content" role="main">
<?php the_post(); ?>
<?php acf_form( $options ); ?>
</div><!-- #content -->
</div><!-- #primary -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
<?php
woo_loop_before();
if (have_posts()) { $count = 0;
while (have_posts()) { the_post(); $count++;
woo_get_template_part( 'content', 'page' ); // Get the page content template file, contextually.
}
}
woo_loop_after();
?>
</section><!-- /#main -->
<?php woo_main_after(); ?>
<?php get_sidebar(); ?>
</div><!-- /#main-sidebar-container -->
<?php get_sidebar( 'alt' ); ?>
</div><!-- /#content -->
<?php woo_content_after(); ?>
<?php get_footer(); ?>
the single memorial code
<?php
/**
* Template Name:create memorial Template
*
* @package WooFramework
* @subpackage Template
*/
the_post();
$template = get_field('template', $post->ID);
if (empty($template)) {
$template = 'standard';
}
$template_dir = get_stylesheet_directory() . '/memorials';
$template_uri = get_stylesheet_directory_uri() . '/memorials';
$templateFile = $template_dir . '/' . strtolower($template) . '.php';
if (file_exists($templateFile)) {
include($templateFile);
}
and the custom post type plugin
?php
/*
Plugin Name: Lvd4Evr - Memorial Custom Post Type
Plugin URI:
Description:
Version: 1.0.0
Author: Kathryn Reeve
Author URI: http://BinaryKitten.com
License: GPLv2
*/
class j20_lovedforever_memorial
{
public function __construct()
{
add_action('init', array($this, 'create_post_type'), 0);
$this->addAcf();
}
function create_post_type()
{
$labels = array(
'name' => _x('Memorials', 'Post Type General Name', 'text_domain'),
'singular_name' => _x('Memorial', 'Post Type Singular Name', 'text_domain'),
'menu_name' => __('Memorial', 'text_domain'),
'parent_item_colon' => __('Parent Memorial:', 'text_domain'),
'all_items' => __('All Memorials', 'text_domain'),
'view_item' => __('View Memorial', 'text_domain'),
'add_new_item' => __('Add New Memorial', 'text_domain'),
'add_new' => __('Add New Memorial', 'text_domain'),
'edit_item' => __('Edit Memorial', 'text_domain'),
'update_item' => __('Update Memorial', 'text_domain'),
'search_items' => __('Search Memorials', 'text_domain'),
'not_found' => __('No Memorial Found', 'text_domain'),
'not_found_in_trash' => __('Memorial not found in Trash', 'text_domain'),
);
$rewrite = array(
'slug' => 'memorial',
'with_front' => true,
'pages' => false,
'feeds' => false,
);
$args = array(
'label' => __('memorial', 'text_domain'),
'description' => __('Memorial Pages', 'text_domain'),
'labels' => $labels,
'supports' => array('title', 'author','comments'),
'taxonomies' => array('category', 'memorial'),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'show_in_admin_bar' => true,
'menu_position' => 20,
'menu_icon' => '',
'can_export' => true,
'has_archive' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'rewrite' => $rewrite,
'capability_type' => 'page',
);
register_post_type('memorial', $args);
register_post_type( 'tribute',
array(
'labels' => array(
'name' => __( 'Tributes' ),
'singular_name' => __( 'tribute' )
),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'tribute'),
)
);
register_post_type( 'stories',
array(
'labels' => array(
'name' => __( 'stories' ),
'singular_name' => __( 'stories' )
),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'stories'),
)
);
register_post_type( '_user_video',
array(
'labels' => array(
'name' => __( 'Video' ),
'singular_name' => __( 'video' )
),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'video'),
)
);
}
public function addAcf() {
// include plugin_dir_path(__FILE__) . DIRECTORY_SEPARATOR . 'acf.php';
}
}
new j20_lovedforever_memorial();
function my_pre_save_post( $post_id )
{
// Create a new post
$post = array(
'post_status' => 'publish' ,
'post_title' => $_POST['title'],
'post_type' => 'memorial' ,
);
if(get_post($id)) {
$post_id = wp_update_post( get_post($post_id) );
} else {
$post_id = wp_insert_post( $post );
};
// insert the post
// update $_POST['return']
$_POST['return'] = add_query_arg( array('post_id' => $post_id), $_POST['return'] );
// return the new ID
return $post_id;
}
add_filter('acf/pre_save_post' , 'my_pre_save_post' );
add_action('init', 'process_choose_template');
function process_choose_template(){
if(isset($_POST['choose-template'])) {
$template = $_POST['template'];
$post_id = $_POST['post_id'];
add_post_meta( $post_id , 'memorial_template', $template, true ) || update_post_meta( $post_id , 'memorial_template', $template );
wp_redirect( get_permalink($post_id) );
exit();
}
}
function memorial_save_post_class_meta($post_id, $post ) {
if (get_post_type( $post ) == 'memorial'){
$template = $_POST['template'];
add_post_meta( $post_id , 'memorial_template', $template, true ) || update_post_meta( $post_id , 'memorial_template', $template );
}
}
/* Fire our meta box setup function on the post editor screen. */
//Meta Box
/* Meta box setup function. */
function memorial_post_meta_boxes_setup() {
/* Add meta boxes on the 'add_meta_boxes' hook. */
add_action( 'add_meta_boxes', 'memorial_add_post_meta_boxes' );
/* Save post meta on the 'save_post' hook. */
add_action( 'save_post', 'memorial_save_post_class_meta', 10, 2 );
}
/* Create one or more meta boxes to be displayed on the post editor screen. */
function memorial_add_post_meta_boxes() {
add_meta_box(
'memorial-post-class', // Unique ID
'Templates', // Title
'memorial_post_class_meta_box', // Callback function
'memorial', // Admin page (or post type)
'side', // Context
'default' // Priority
);
}
function memorial_post_class_meta_box( $object, $box ) { ?>
<?php $value = get_post_meta( $object->ID, 'memorial_template', true )?>
<div>
<label for=''>Template 1</label>
<div class='chose-template-input'><input type='radio' name='template' value='1' <?php echo ($value == '1'|| $value == '' ? 'checked="checked"' : '');?>></div>
</div>
<div>
<label for=''>Template 2</label>
<div class='chose-template-input'><input type='radio' name='template' value='2' <?php echo ($value == '2' ? 'checked="checked"' : '');?>></div>
</div>
<div>
<label for=''>Template 3</label>
<div class='chose-template-input'><input type='radio' name='template' value='3' <?php echo ($value == '3' ? 'checked="checked"' : '');?>></div>
</div>
<?php }
add_action( 'load-post.php', 'memorial_post_meta_boxes_setup' );
add_action( 'load-post-new.php', 'memorial_post_meta_boxes_setup' );
// Disable Admin Bar for everyone but administrators
if (!function_exists('df_disable_admin_bar')) {
function df_disable_admin_bar() {
if (!current_user_can('manage_options')) {
// for the admin page
remove_action('admin_footer', 'wp_admin_bar_render', 1000);
// for the front-end
remove_action('wp_footer', 'wp_admin_bar_render', 1000);
// css override for the admin page
function remove_admin_bar_style_backend() {
echo '<style>body.admin-bar #wpcontent, body.admin-bar #adminmenu { padding-top: 0px !important; }</style>';
}
add_filter('admin_head','remove_admin_bar_style_backend');
// css override for the frontend
function remove_admin_bar_style_frontend() {
echo '<style type="text/css" media="screen">
html { margin-top: 0px !important; }
* html body { margin-top: 0px !important; }
</style>';
}
add_filter('wp_head','remove_admin_bar_style_frontend', 99);
}
}
}
//add_action('init','df_disable_admin_bar');
add_action('pre_get_posts','ml_restrict_media_library');
function ml_restrict_media_library( $wp_query_obj ) {
global $current_user, $pagenow;
if( !is_a( $current_user, 'WP_User') )
return;
if( 'admin-ajax.php' != $pagenow || $_REQUEST['action'] != 'query-attachments' )
return;
if( !current_user_can('manage_media_library') )
$wp_query_obj->set('author', $current_user->ID );
return;
}
function tribute() {
if(isset($_POST['submit_tribute'])){
global $current_user;
get_currentuserinfo();
$post = $_POST['post_id'];
$new_post = array(
'post_title' => $current_user->display_name,
'post_content' => $_POST['copy'],
'post_status' => 'publish',
'post_date' => date('Y-m-d H:i:s'),
'post_author' => $current_user->ID,
'post_type' => 'tribute',
'post_category' => array(0)
);
$post_id = wp_insert_post($new_post);
add_post_meta( $post_id , 'memorial_id', $post, true ) || update_post_meta( $post_id , 'memorial_id', $post );
wp_redirect( get_permalink($post) );
exit();
}
}
add_action('init','tribute');
function stories() {
if(isset($_POST['submit_Stories'])){
global $current_user;
get_currentuserinfo();
$post = $_POST['post_id'];
$new_post = array(
'post_title' => $current_user->display_name,
'post_content' => $_POST['copy'],
'post_status' => 'publish',
'post_date' => date('Y-m-d H:i:s'),
'post_author' => $current_user->ID,
'post_type' => 'stories',
'post_category' => array(0)
);
$post_id = wp_insert_post($new_post);
add_post_meta( $post_id , 'memorial_id', $post, true ) || update_post_meta( $post_id , 'memorial_id', $post );
wp_redirect( get_permalink($post) );
exit();
}
}
add_action('init','stories');
function video() {
if(isset($_POST['submit_video'])){
global $current_user;
get_currentuserinfo();
$post = $_POST['post_id'];
$new_post = array(
'post_title' => $current_user->display_name." ".$_POST['embed'],
'post_content' => $_POST['embed'],
'post_status' => 'publish',
'post_date' => date('Y-m-d H:i:s'),
'post_author' => $current_user->ID,
'post_type' => '_user_video',
'post_category' => array(0)
);
$info = video_image($_POST['embed']);
$post_id = wp_insert_post($new_post);;
update_field( 'video', $_POST['embed'], $post_id );
update_field('image_url', $info, $post_id );
add_post_meta( $post_id , 'memorial_id', $post, true ) || update_post_meta( $post_id , 'memorial_id', $post );
wp_redirect( get_permalink($post) );
}
}
add_action('init','video');
function video_image($url){
$image_url = parse_url('http://'.$url);
if($image_url['host'] == 'www.youtube.com' || $image_url['host'] == 'youtube.com'){
$array = explode("&", $image_url['query']);
return "http://img.youtube.com/vi/".substr($array[0], 2)."/0.jpg";
} else if($image_url['host'] == 'www.vimeo.com' || $image_url['host'] == 'vimeo.com'){
$hash = unserialize(file_get_contents("http://vimeo.com/api/v2/video/".substr($image_url['path'], 1).".php"));
return $hash[0]["thumbnail_small"];
}
}
I hope this helps if you need any more info i can provide this
can any one help with this I’m really stuck
ok thanks it will come from jade.stewart
I’ve tried that but had no luck the filed should just be gallery I believe,
this is the other gallery that shows up on the page http://dev.rgbdesignuk.com/memorial/test-test/
<h2>Gallery</h2>
<?php if(get_field('gallery')):?>
<?php foreach (get_field('gallery') as $gal ):?>
<a class="fancybox" rel="gallery1" href="<?php echo $gal['url']?>" title="<?php echo $gal['caption'] ?>"><img src="<?php echo $gal['sizes']['thumbnail']?>" alt="" /></a>
<?php endforeach ?>
<?php endif; ?>
<?php if( $the_galquery->have_posts() ): ?>
<?php while ( $the_galquery->have_posts() ) : $the_galquery->the_post(); ?>
<a class="fancybox" rel="gallery1" href="<?php echo wp_get_attachment_url( get_the_ID()); ?>" ><?php echo wp_get_attachment_image( get_the_ID(), 'thumbnail'); ?></a>
<?php endwhile; ?>
<?php endif; ?>
<?php if ( !(get_field('gallery')) && !($the_galquery->have_posts() ) ):?>
<p>No Gallery added</p>
<?php endif ?>
<?php if ( is_user_logged_in() ): ?>
<form style='clear:both' id="file-form" enctype="multipart/form-data" action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="POST">
<p>Add image to gallery</p>
<p id="async-upload-wrap"><label for="async-upload">upload</label>
<input type="file" id="async-upload" name="async-upload"> <input type="submit" value="Upload" name="html-upload"></p>
<p><input type="hidden" name="post_id" id="post_id" value="<?php echo $post_id ?>" />
<?php wp_nonce_field('client-file-upload'); ?>
<input type="hidden" name="redirect_to" value="<?php echo $_SERVER['REQUEST_URI']; ?>" /></p>
<p><input type="submit" value="Save all changes" name="save" style="display: none;"></p>
</form>
<form style='clear:both' id="embed-form" action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="POST">
<p>Add video to gallery</p>
<label for="embed">You tube / vim url:</label>
<textarea name="embed"></textarea>
<input name='submit_video' type="submit" value="submit">
<p>
<input type="hidden" name="post_id" id="post_id" value="<?php echo $post_id ?>" />
<?php wp_nonce_field('embed-form'); ?>
<input type="hidden" name="redirect_to" value="<?php echo $_SERVER['REQUEST_URI']; ?>" /></p>
</form>
<?php endif?>
</div>
Im not sure if i have done this right or not its on the following page surposed to be in the side bar http://dev.rgbdesignuk.com/memorial/test-test/
but its not showing up please help
<!--slider starts-->
<!-- Start Photo Slider -->
<?php
/*
* Create the Markup for a slider
* This example will create the Markup for Flexslider (http://www.woothemes.com/flexslider/)
*/
$property_images = get_field('gallery');
if( $property_images ) { ?>
<div id="slider" class="flexslider">
<ul class="slides">
<?php foreach( $property_images as $property_image ): ?>
<li>
<img src="<?php echo $gallery_image['url']; ?>" alt="<?php echo $gallery_image['alt']; ?>" />
</li>
<?php endforeach; ?>
</ul>
</div>
<?php
/*
* The following code creates the thumbnail navigation
*/
?>
<div id="carousel" class="flexslider">
<ul class="slides">
<?php foreach( $gallery_images as $gallery_image ): ?>
<li>
<img src="<?php echo $gallery_image['sizes']['thumbnail']; ?>" alt="<?php echo $gallery_image['alt']; ?>" />
</li>
<?php endforeach; ?>
</ul>
</div>
<?php
}else{
?><div id="single-gallery-image">
<?php the_post_thumbnail('full'); ?>
</div><?php
?>
<?php } ?>
<!-- End Photo Slider -->
</div>
<link rel="stylesheet" href="http://dev.rgbdesignuk.com/wp-content/themes/canvas-child/memorials/css/flexslider.css" type="text/css">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="http://dev.rgbdesignuk.com/wp-content/themes/canvas-child/memorials/js/jquery.flexslider-min.js"></script>
<script type="text/javascript">
var $f = jQuery.noConflict(true);
$f(window).load(function() {
// The slider being synced must be initialized first
$f('#carousel').flexslider({
animation: "slide",
controlNav: false,
animationLoop: false,
slideshow: false,
itemWidth: 75,
itemMargin: 5,
asNavFor: '#slider'
});
$f('#slider').flexslider({
animation: "slide",
controlNav: false,
animationLoop: false,
slideshow: false,
sync: "#carousel"
});
});
</script>
<!--slider ends-->
please could so one tell me where I’m going wrong
I’m having a similar issue and I’m unsure what i need to do to fix this
the page is http://dev.rgbdesignuk.com/create-memorial/ I’m not sure if this is the right place to post this if it isnt I’m sorry
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.