Hello,
Main Image and Featured Slider problem is solved it looks like. Thanks.
But this default template thing is still not working.
This is the code from Views Base Real Estates Theme, functions.php:
<?php
define('HEADER_IMAGE', get_bloginfo('stylesheet_directory') . '/images/header/default_header.jpg');
add_action('save_post', 'myfunction_change_template_to_property_sidebar',9999);
add_action('save_post', 'myfunction_featured_image_to_properties',9999);
function myfunction_change_template_to_property_sidebar( $id ) {
//Do nothing if autosave
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
return;
// check if this is a properties post type
if ( 'properties' == get_post_type() ) {
//global $post;
//Do nothing if user does not have rights to edit page
if ( !current_user_can( 'edit_page', $id ) )
return;
//Get post ID of the submitted post
$post_id=$_POST['post_ID'];
global $wpdb;
//Get ID of property sidebar template
$property_sidebar_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_title='Property – Sidebar' AND post_type='view-template'");
if (!(empty($property_sidebar_id))) {
//Use property sidebar as the template of this inserted post
$meta_id=update_post_meta($post_id,'_views_template',$property_sidebar_id);
}
}
}
function myfunction_featured_image_to_properties( $id ) {
//Do nothing if autosave
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
return;
// check if this is a properties post type
if ( 'properties' == get_post_type() ) {
//global $post;
//Do nothing if user does not have rights to edit page
if ( !current_user_can( 'edit_page', $id ) )
return;
//Get post ID
$post_id=$_POST['post_ID'];
//Get URL path of uploaded featured image
$image_url_path = wp_get_attachment_image_src( get_post_thumbnail_id($post_id),'large');
//Set main image to the same as featured image
$meta_id=update_post_meta($post_id,'wpcf-main-image',$image_url_path[0]);
}
}
?>
BR,
Robert