Blog by TAG


have my website organized heavily with tags (e.g. category=science, tag=cancer)
need blog shortcode usable with tags

Please have a look, couldnt get it running:as expected to use tags (in addition or instead of categories)


... /wp-content/themes/betheme/functions/theme-shortcodes.php  line 885


/* ---------------------------------------------------------------------------
 * Blog [blog]
* --------------------------------------------------------------------------- */
if( ! function_exists( 'sc_blog' ) )
{
function sc_blog( $attr, $content = null )
{
extract(shortcode_atts(array(
'count' => 2,
'category' => '',
'category_multi' => '',
'tagID'             => '',
'tagName'           => '',
'exclude_id' => '',
'style' => 'classic',
'columns' => 3,
'greyscale' => '',
'more' => '',
'filters' => '',
'pagination' => '',
'load_more' => '',
), $attr));
$translate['filter'] = mfn_opts_get('translate') ? mfn_opts_get('translate-filter','Filter by') : __('Filter by','betheme');
$translate['tags'] = mfn_opts_get('translate') ? mfn_opts_get('translate-tags','Tags') : __('Tags','betheme');
$translate['authors'] = mfn_opts_get('translate') ? mfn_opts_get('translate-authors','Authors') : __('Authors','betheme');
$translate['all'] = mfn_opts_get('translate') ? mfn_opts_get('translate-item-all','All') : __('All','betheme');
$translate['categories'] = mfn_opts_get('translate') ? mfn_opts_get('translate-categories','Categories') : __('Categories','betheme');

$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : ( ( get_query_var( 'page' ) ) ? get_query_var( 'page' ) : 1 );
$args = array(
'posts_per_page' => intval($count),
'paged' => $paged,
'post_status' => 'publish',
'ignore_sticky_posts' => 0,
);
// private
if( is_user_logged_in() ){
$args['post_status'] = array('publish','private');
}

// categories
if( $category_multi ){
$args['category_name'] = trim( $category_multi );
} elseif( $category ){
$args['category_name'] = $category;
// tags
if( $tagID ){
  $args['tag_id'] = trim($tagID);
  }
  
if( $tagName ){
  $args['tag'] = trim($tagName);
  }
  
if using FORMAT here the textsize grows incredible so I cannot post the post!

Comments

Sign In or Register to comment.
This website uses cookies

We use cookies to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners who may combine it with other information that you’ve provided to them or that they’ve collected from your use of their services.

Cookies are small text files that can be used by websites to make a user's experience more efficient.

The law states that we can store cookies on your device if they are strictly necessary for the operation of this site. For all other types of cookies we need your permission. This means that cookies which are categorized as necessary, are processed based on GDPR Art. 6 (1) (f). All other cookies, meaning those from the categories preferences and marketing, are processed based on GDPR Art. 6 (1) (a) GDPR.

This site uses different types of cookies. Some cookies are placed by third party services that appear on our pages.

You can at any time change or withdraw your consent from the Cookie Declaration on our website.

Learn more about who we are, how you can contact us and how we process personal data in our Privacy Policy.

Please state your consent ID and date when you contact us regarding your consent.