0

i am using a function (maav_portfolio_infinite_loading) to load more custom posts on a page via ajax.

I want to be able to load only from a specific category that i can set it on the main portfolio page. I created the field and everything works except the category filter. If i introduce it manually ('portfolio_category' => web,) it works but when i try to echo it, for some reason it doesn't work.

I need to echo the $select_categ in 'portfolio_category'.

the function bellow is in functions.php.

function maav_portfolio_infinite_loading() {
$select_categ = Maav_Helper::get_post_meta( 'select_categ', '' );

    $args = array(
        'post_type'      => $_POST['post_type'],
        'posts_per_page' => $_POST['posts_per_page'],
        'orderby'        => $_POST['orderby'],
        'order'          => $_POST['order'],
        'paged'          => $_POST['paged'],
        'portfolio_category' => $select_categ,
        'post_status' => array('publish') 
    );

    $style             = isset( $_POST['style'] ) ? $_POST['style'] : 1;
    $overlay_style     = isset( $_POST['overlay_style'] ) ? $_POST['overlay_style'] : 'inner-text';
    $i                 = ( $args['paged'] - 1 ) * $args['posts_per_page'];
    $count             = $_POST['count'];
    $image_size        = $_POST['image_size'];
    $overlay_animation = $_POST['overlay_animation'];
    $maav_query   = new WP_Query( $args );

    if ( $maav_query->have_posts() ) :
        include( get_template_directory() . '/loop/portfolio/style-' . $style . '.php' );
    endif;
    wp_reset_postdata();
    wp_die();
}

Thank you in advance!

0

What value do you get if you echo Maav_Helper::get_post_meta( 'select_categ', '' ) or the variable $select-categ?

Since manually inputting web works, check if the scope resolution operator is working. Sounds like it may be returning an empty string or undefined value.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.