WordPress.org

Forums

SP responsive wp-faq with category plugin
[resolved] Call category name (1 post)

  1. codechip87
    Member
    Posted 1 year ago #

    Hello,

    I changed the small things so it is now possible to add that to call himself the name of the category.

    Just what you need to do.

    1) Open up the faq.php script

    Found extract(shortcode_atts(array( and below after "limit" => '' or replay to

    "catid" => '', // Shortcode to for category ID
    "catname" => '', // Shortcode to for category name

    2) Found // Define limit and below or re play to // Define category style and change code.

    // Define limit
    if( $limit ) {
     $posts_per_page = $limit;
    } else {
     $posts_per_page = '-1';
    }

    to

    // Define category style
     if( $catid) { // call category ID
    $category_id = $catid;
    }		
    
    elseif ( $catname) { // call category name
      $category_name = $catname;
    }
    
    else {
     $category_id = '-1';
    }

    3) Finally, found $query = new WP_Query( array ( and below after 'posts_per_page' => $posts_per_page, or replay to

    $query = new WP_Query( array (
    'post_type' => $post_type,
    'posts_per_page' => $posts_per_page,
    'cat' => $category_id,   // Shortcode  category ID
    'category_name' => $category_name,	// Shortcode for category Name
    'orderby' => $orderby,
    'order' => $order,
    'no_found_rows'  => 1
    )
    );

    Now you can call you category name or category ID in next shortcode

    [sp_faq catname="categoryname"] or [sp_faq catid="4"]

    https://wordpress.org/plugins/sp-faq/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic