Support » Fixing WordPress » Getting categories slug?

  • function lapan_magazine_vertical($atts)
    {
    extract(shortcode_atts(array(
            'slug' => '',
            'title' => '',
            'limit' => '5',
            ),$atts));
    
            //The Query
        query_posts('showposts=1&orderby=date&order=DESC&category_name='.$slug);
            //The Loop
           if ( have_posts() ) : while ( have_posts() ) : the_post();

    <span class="mag"><a href="'.get_category_by_slug( $slug ).'">More articles</a></span></div>';

    Why this is not working?
    Is it maybe because $slug is part of core files?
    If there is another way of getting category url from atts slug, please post.

Viewing 1 replies (of 1 total)
  • function lapan_magazine_vertical($atts)
    {
    extract(shortcode_atts(array(
            'slug' => '',
            'title' => '',
            'limit' => '5',
            ),$atts));
    
            //The Query
        query_posts('showposts=1&orderby=date&order=DESC&category_name='.$slug);
            //The Loop
           if ( have_posts() ) : while ( have_posts() ) : the_post();
    
    <span class="mag"><a href="'.get_term_by('slug', $slug, 'category').'">More articles</a></span></div>';

    Produces:

    Catchable fatal error: Object of class stdClass could not be converted

Viewing 1 replies (of 1 total)
  • The topic ‘Getting categories slug?’ is closed to new replies.