Quick question along the same lines as custom posts not showing properly. It
will spit out the extras that the simple video embedder plugging on the
home.php but not on my film.php which has the following code in both places.
The plugging registers the extra fields itself so I've done nothing with them
in my functions file. It's weird to me that the following code works great on
my home page but not in other templates. Thanks for any comments as to why this
doesn't work. I know this isn't a forum for how-to's but there is a lack of
resources on custom posts w/admin panels at the moment. Cheers!
I've added the following code in my film.php file:
<?php $loop = new WP_Query( array( 'post_type' => 'Film',
'posts_per_page' => 99 ) ); ?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<li class="poster">
<a href="<?php the_permalink() ?>" title="View <?php
the_title(); ?>">
<img src='<?php echo
p75GetOriginalImage($post->ID); ?>' class="posterImage" alt='<?php
the_title();?>' />
</a>
</li><!-- poster -->
<?php endwhile;?>
<?php wp_reset_query(); ?>
I've added the following code in my functions.php file:
class ABCFilms {
var $meta_fields = array("fExtra-length");
function ABCFilms()
{
$labels = array(
'name' => __('Films', 'post type general name'),
'singular_name' => __('Film', 'post type singular
name'),
'singular_label' => __( 'Film' ),
'add_new' => __( 'Add Film' ),
'add_new_item' => __( 'Add New Film' ),
'edit' => __( 'Edit Films' ),
'edit_item' => __( 'Edit This Film' ),
'new_item' => __( 'New Film' ),
'view' => __( 'View Film' ),
'view_item' => __( 'View This Film' ),
'search_items' => __( 'Search Films' ),
'not_found' => __( 'No Films found' ),
'not_found_in_trash' => __( 'No Films found in
Trash' ),
'view' => __('View Film')
);
$args = array(
'labels' => $labels,
'menu_position' => 5,
'show_ui' => true, // UI in admin panel
'_builtin' => false, // It's a custom post
type, not built in
'_edit_link' => 'post.php?post=%d',
'capability_type' => 'post',
'hierarchical' => false,
'rewrite' => array("slug" => "films"), //
Permalinks
'query_var' => "film", // This goes to the
WP_Query schema
'public' => true,
'publicly_queryable' => true,
'exclude_from_search' => true,
'capability_type' => 'post',
'supports' => array('title',
'editor','revisions','thumbnail' /*,'custom-fields'*/),
'menu_icon' => get_stylesheet_directory_uri() .
'/images/film.png'
);
register_post_type('Film',$args);
add_filter("manage_edit-Film_columns",
array(&$this, "edit_columns"));
// add_action("manage_posts_custom_column",
array(&$this, "custom_columns"));
// Admin interface init
add_action("admin_init", array(&$this,
"admin_init"));
add_action("template_redirect", array(&$this,
'template_redirect'));
// Insert post hook
add_action("wp_insert_post", array(&$this,
"wp_insert_post"), 10, 2);
}
function edit_columns($columns)
{
$columns = array(
"cb" => "<input type=\"checkbox\" />",
"title" => "Film Title",
"fExtra_description" => "Description",
"fExtra_length" => "Length",
);
return $columns;
}
// Template selection
function template_redirect()
{
global $wp;
if ($wp->query_vars["post_type"] == "Film")
{
include(TEMPLATEPATH .
"/includes/film.php");
die();
}
}
// When a post is inserted or updated
function wp_insert_post($post_id, $post = null)
{
if ($post->post_type == "Film")
{
// Loop through the POST data
foreach ($this->meta_fields as $key)
{
$value = @$_POST[$key];
if (empty($value))
{
delete_post_meta($post_id, $key);
continue;
}
// If value is a string it
should be unique
if (!is_array($value))
{
// Update meta
if
(!update_post_meta($post_id, $key, $value))
{
// Or add the
meta data
add_post_meta($post_id, $key, $value);
}
}
else
{
// If passed along is
an array, we should remove all previous data
delete_post_meta($post_id, $key);
// Loop through the
array adding new values to the post meta as different entries with the same name
foreach ($value as
$entry)
add_post_meta($post_id, $key, $entry);
}
}
}
}
function admin_init()
{
// Custom meta boxes for the edit Film screen
add_meta_box("fExtra-meta", "Film Options",
array(&$this, "meta_options"), "Film", "side", "low");
}
// Admin post meta contents
function meta_options()
{
global $post;
$custom = get_post_custom($post->ID);
$length = $custom["fExtra-length"][0];
?>
<label>Length:</label><input name="fExtra-length" value="<?php
echo $length; ?>" />
<?php
}
}
add_action("init", "EGMFilmsInit");
function ABCFilmsInit() { global $fExtra; $fExtra = new
ABCFilms();
}
AndrewJohnson
[email protected]
580.302.0931
On May 28, 2010, at 7:40 AM, Michael E. Hancock wrote:
>
> From: "Stephen Hammer" <[email protected]>
>
>
>> Michael, I can confirm that. If I de-activate CFT the problem goes away.
>> I have posted on the plugin forum and written to Hiroaki but am wondering --
>> is this issue best addressed in the plugin or in core?
>
> Approaching the plugin author seems the proper strategy as WordPress core
> works.
>
> Thanks for the report.
>
>
> MichaelH
> _______________________________________________
> wp-testers mailing list
> [email protected]
> http://lists.automattic.com/mailman/listinfo/wp-testers
_______________________________________________
wp-testers mailing list
[email protected]
http://lists.automattic.com/mailman/listinfo/wp-testers