WordPress.org

Support

Support » WP-Advanced » [Resolved] please help about post_category

[Resolved] please help about post_category

Viewing 7 replies - 1 through 7 (of 7 total)
  • implode function returns a string, so when you write this:

    $category = implode(",", $arr);
    $articleOption['post_category'] = array($category);

    You are actually assigning array(“1,2,3”) instead of array(1,2,3). Be careful, the first one has one string element while the other one has three integer elements.

    Since you already have an array filled with the values you want to pass, you should use that one directly:

    $articleOption['post_category'] = $arr;

    thank you for your reply however,

    with this code ($category output is like 3,6,4);

    $articleOption['post_category'] = $category;

    there is still error

    Warning: array_filter() expects parameter 1 to be array, string given in C:\Program Files\EasyPHP-5.3.7RC4\www\wordpress\wp-includes\post.php on line 2464

    You should not use $category as it is a string created by concatenating elements of the array. You should assign the actual array to $articleOption['post_category'] which is the $arr variable.

    Again, what you should have written is:

    $articleOption['post_category'] = $arr;

    mert, it is working now thanks to you.
    Thank you for replies

    I’m trying to get the title date and author to show???

    <?php /*
    Template Name: Lucy’s Blog
    */ ?>
    <?php
    remove_action(‘genesis_loop’, ‘genesis_do_loop’);
    add_action(‘genesis_loop’, ‘custom_loop’);
    function custom_loop() {

    global $paged;
    $args = array(‘cat’ => ‘995’);

    genesis_custom_loop( $args );

    }
    ?>

    <?php genesis(); ?>

    Thanks a lot Mert Yazicioglu.
    That solved my issue also.

    I just wanna ask what’s missing or wrong in this :

    I was trying to get the data, if i will use it in the DIV section it works but as a Function it’s not.

    please help.

    function custom_dashboard_help() {

    $miles = array();
    $meta_key = ‘custom_field_17_subscriptionnumber’;//set this to your custom field meta key
    $miles = $wpdb->get_col($wpdb->prepare(“SELECT meta_value FROM $wpdb->usermeta WHERE meta_key = %s”, $meta_key));
    echo ‘Total miles is ‘.array_sum( $miles );

    }

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘[Resolved] please help about post_category’ is closed to new replies.