admin管理员组文章数量:1023744
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!
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!
Share Improve this question asked Apr 16, 2019 at 21:31 mThemes NetmThemes Net 11 bronze badge1 Answer
Reset to default 0What 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.
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!
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!
Share Improve this question asked Apr 16, 2019 at 21:31 mThemes NetmThemes Net 11 bronze badge1 Answer
Reset to default 0What 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.
本文标签: How to echo a string in custom posts args from a custom field
版权声明:本文标题:How to echo a string in custom posts args from a custom field? 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745581675a2157344.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论