WordPress.org

Ready to get started?Download WordPress

Forums

Getting categories slug? (2 posts)

  1. LapanWebsite
    Member
    Posted 1 year ago #

    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.

  2. LapanWebsite
    Member
    Posted 1 year ago #

    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

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.