Navigation überspringen

[Geschlossen] Custom post need manually update after wpimport

This support ticket is created vor 5 Monaten, 1 Woche. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Dieses Thema enthält 1 Antwort, hat 1 Stimme.

Zuletzt aktualisiert von Christopher Amirian vor 5 Monaten, 1 Woche.

Assistiert von: Christopher Amirian.

Author
Artikel
#2785321

Dear Sir/Madam,

Not sure whether the query is too complicated

$current_date = date('Y-m-d 0:0:0', strtotime("+8 hours", time()));
$end_time = strtotime('+1 day', strtotime($current_date) ) - 1;


$args = array (
    'post_type'  => 'member',
    'post_status' => 'publish',
    'posts_per_page' => -1,	
    'meta_query' => array(
        'relation' => 'AND',

				array(
        'key' => 'wpcf-scheduled-to-pay',
        'value' => '0',
        'type' => 'numeric',
         'compare' => '=',
    	),

        array(
            'key' => 'wpcf-uprise-next-bill-date',
            'value' => array(strtotime($current_date), $end_time),
            'type' => 'numeric',
             'compare' => 'BETWEEN',
        ),
        
        array(
            'relation' => 'OR',
            
            array(
                'relation' => 'OR',
                
                array(
                    'relation' => 'AND',

                    
                    array(                                          
                        'key' => 'wpcf-termination-date',
                        'value' => '',
                        'type' => 'numeric',
                        'compare' => '='
                    ),                                              // query if termniation-date is empty                                              

                    array(
                        'key' => 'wpcf-termination-date',
                        'compare' => 'EXISTS'
                    )                                              // query if terminsation-date is existed
                ),                                                  // query if post updated from dashboard without termniation-date value
                
                array(                                              // query if post updated from CRED form without termniation-date value
                    'key' => 'wpcf-termination-date',
                    'compare' => 'NOT EXISTS'
                )                                                  // query if termination-date is not existed
            ), 

            array(                                                  // query if wpcf-termination-date has value later than today 
                'key' => 'wpcf-termination-date',
                'value' => strtotime($current_date),
                'type' => 'numeric',
                'compare' => '>=',
            )
        )
    ) 
);

I import thousand of record using WPIMPORT, I use below code to update 10 records

update_post_meta($post->ID, 'wpcf-uprise-next-bill-date', strtotime(date('Y-m-d 13:0:1', strtotime("+8 hours"))));
update_post_meta($post->ID, 'wpcf-termination-date', strtotime(date('Y-m-d 13:0:1', strtotime("+10 days"))));

10 records can't be queried, if I manually update the record from backend, records can be queried. What is the problem to the custom post.

I tried to do below code

function my_update_posts() {
    //$myposts = get_posts('showposts=-1');//Retrieve the posts you are targeting
    $args = array(
        'post_type' => 'post',
        'numberposts' => -1
    );
    $myposts = get_posts($args);
    foreach ($myposts as $mypost){
        $mypost->post_title = $mypost->post_title.'';
        wp_update_post( $mypost );
    }
}
add_action( 'wp_loaded', 'my_update_posts' );

but not work, only manually update the post then can solve.

#2785479

Christopher Amirian
Unterstützer

Sprachen: Englisch (English )

Hi,

The query you sued is complicated and I am not sure what might be the problem. Please consider that, a custom post type created by Toolset is not any different from a custom post type created via code in WordPress as Toolset also uses the same code.

So the best course of action is to ask the WP All Import to see what might be the problem cause.

If it is a matter of updating the custom post types, you can simply go to the list of the custom post type entries in WordPress dashboard and select all, and from the top select the Edit option.

In the bulk edit option you do not change anything and you just click the update button and it will cause those posts to be updated without actually updating anything.

Thanks.

Das Thema „[Geschlossen] Custom post need manually update after wpimport“ ist für neue Antworten geschlossen.