Forum Replies Created

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter tackenco

    (@tackenco)

    Hee jeromeramone,
    Just did a upgrade to 3.7.1 and now its working again!
    Regards, Niels

    Thread Starter tackenco

    (@tackenco)

    Here’s mine (almost the same)

    $args = array(
    	'sort_order' => 'ASC',
    	'sort_column' => 'menu_order',
    	'hierarchical' => 1,
    	'post_type' => 'page',
    	'post_status' => 'publish'
    );
    
    $the_pages = get_pages($args);

    Glad I’m not the only-one but now we need a fix ??

    Everything has been working for years but since the last update the trouble starts. This is very common functionality I think, strange that there is nothing to be found on this.

    Thread Starter tackenco

    (@tackenco)

    sorry, a little to much code, hope this works:

    I can’t get the results like this:

    function havana_data_box($fields) {
    	global $post;
    	echo ('	<table>
    				<tr><td style="padding-top:5px;padding-bottom:5px;"><strong>Code: </strong><td style="padding-top:5px;padding-bottom:5px;">'.$post->code.'</td></tr>
    				<tr><td style="padding-top:5px;padding-bottom:5px;"><strong>Type: </strong><td style="padding-top:5px;padding-bottom:5px;">'.__(SetTypeAccomodation($post->type)).'</td></tr>
    				<tr><td style="padding-top:5px;padding-bottom:5px;"><strong>Lowest rate: </strong><td style="padding-top:5px;padding-bottom:5px;">'.$post->lowestRate.'</td></tr>
    				<tr><td style="padding-top:5px;padding-bottom:5px;"><strong>Min. guests: </strong><td style="padding-top:5px;padding-bottom:5px;">'.$post->minGuests.'</td></tr>
    				<tr><td style="padding-top:5px;padding-bottom:5px;"><strong>Max. guests: </strong><td style="padding-top:5px;padding-bottom:5px;">'.$post->maxGuests.'</td></tr>
    				<tr><td style="padding-top:5px;padding-bottom:5px;"><strong>Smoking: </strong><td style="padding-top:5px;padding-bottom:5px;">'.$post->smokingAllowed.'</td></tr>
    				<tr><td style="padding-top:5px;padding-bottom:5px;"><strong>Host: </strong><td style="padding-top:5px;padding-bottom:5px;">'.$post->nameFull.'</td></tr>
    			</table>');
    }

    Thread Starter tackenco

    (@tackenco)

    Super, I will.

    I have these two filters in my functions. (accommodation and contact are two custom tables):

    function posts_fields( $fields ) {
    	global $wp_query, $wpdb, $post_type;
    	if( $post_type == 'accommodation' ) {
    		$fields .= ',accommodation.*,contact.*';
        }
        return $fields;
    }
    add_filter('posts_fields', 'posts_fields' );
    
    function accommodation_join( $join ) {
    	global $wp_query, $wpdb, $post_type;
    	if( $post_type == 'accommodation' ) {
        	$join .= " LEFT JOIN accommodation ON " . $wpdb->posts . ".ID = accommodation.__idPost LEFT JOIN  contact ON accommodation.__idHost = contact.__id ";
    	}
    	return $join;
    }
    add_filter('posts_join', 'accommodation_join' );

    Then I have some columns in the custom_post_type like this:

    function custom_columns($column) {
    	global $post;
    	if ("ID" == $column) echo $post->ID;
    	elseif ("type" == $column) echo __(SetTypeAccomodation($post->type));
    	elseif ("host" == $column) echo $post->nameFull;
    }
    add_action("manage_posts_custom_column", "custom_columns");

    This works fine but in a metabox I can’t get the results like this:

    [Code moderated as per the Forum Rules. Please use the pastebin]

    Again the fields from the joined tables are not SELECTED in the query.
    Do I need an other, extra filter or should I query again in the havana_data_box function Or do I miss anything?

    THANKS for your support man (-:

    Thread Starter tackenco

    (@tackenco)

    I must do something wrong, I can’t get the hook working for the action=edit. It works fine now in the columns but in the edit screen of a post itself it does not return the data.

    Is there something that I’m forgetting? Hope you can help me once again, this time I will read better and write less (-:

    Thanks in advance

    Thread Starter tackenco

    (@tackenco)

    Sorry, sorry, sorry! You gave me exactly the right hook that I needed. I just was to dumb to understand it immediately. After a little bit of experimenting I’ve got it up and running with the post_fields hook.

    Thank you super very much, I was looking for this for too long!

    Thread Starter tackenco

    (@tackenco)

    Hey Mark,

    Thanks for the reply!
    I think my problem is not really clear because I use a table called ‘accommodation’ but also a custom_post type called ‘accommodation’.

    I’m creating a booking system which will have a back-office in Filemaker Pro.
    The website will have a WordPress CMS.

    For the back-office we created a few extra tables, one of them is called ‘accommodation’
    We also have a custom_post type called ‘accommodation’.
    Records in the table ‘accommodation’ should be related to wp_posts by ID.

    I’m trying to create a filter that will LEFT JOIN the ‘accommodation’ table with wp_posts ON ID.

    This works!

    My problem is that the default query returns only those fields in wp_posts because it says; ‘SELECT wp_posts.* ‘
    The content of fields in the ‘accommodation’ table do not appear in the $post array.

    My question is if this is possible.
    I hope you can help me man (-:
    Thanks in advance

    Hi James,

    I have the same problem here. Did you find a solution already? It would help me a lot!

    Thanks,
    Niels

Viewing 8 replies - 1 through 8 (of 8 total)