Basic Article Query Shortcode
// Add Shortcode
function basic_article_shortcode() {
// WP_Query arguments
$args = array(
'post_type' => array( 'Articles' ),
'post_status' => array( 'publish' ),
'order' => 'ASC',
'orderby' => 'title',
'meta_query' => array(
'website_clause' => array(
'key' => 'websites',
'compare' => 'IN',
),
),
'orderby' => array(
'website_clause' => 'ASC',
),
);
// The Query
$article_query = new WP_Query( $args );
// The Loop
$output = "";
if ( $article_query->have_posts() ) {
$output = "<ui>n";
while ( $article_query->have_posts() ) {
$article_query->the_post();
$article_query->the_post();
$output .= "<li>" . esc_html( get_the_title() ) . "</li>n";
};
$output .= "</ui>n";
};
return $output;
}
add_shortcode( 'basic_art_sc', 'basic_article_shortcode' );