Theme functions

Here you find all the theme functions that BasePress provides to use in knowledge base theme templates, in order to easily create a specific theme for your needs. There is a function for any aspect of the KB therefore you only have to concentrate on building the look you need. The plugin takes care of all queries and data management.
Read more about WordPress Theme Functions.
Look at this article if you only want to customize a pre-made Basepress theme.

BasePress Theme Functions:

  • basepress_is_single_kb()
    Returns true if BasePress is used in Single Knowledge Base mode. False if used as a multi knowledge base.
  • basepress_kbs()
    This function should be called inside products.php file to retrieve an array of Knowledge Bases objects.
    (BasePress was originally created for multiple products so the file where this function is used is still called products.php for backward compatibility)
    Each Knowledge Base object will contain the following properties:

    id
    name
    slug
    permalink
    description
    image => url, width, height
    
  • basepress_kb()
    Retrieves the current Knowledge Base. It returns a single Knowledge Base object like above.
  • basepress_choose_kb_btn_text()
    This function is used to get the text for the button to choose the Knowledge Base
  • basepress_sections()
    Retrieves the sections in an archive page. Returns an array of section objects. Each section object will contain the following properties:

    id
    name
    slug
    permalink
    description
    icon
    image => url, width, height
    posts_count
    posts	=> array()
    

    The posts property contains an array of WP_Posts with an extra icon element added.

  • basepress_subsection_style()
    Returns the sub-sections style for the current Knowledge Base. The returned value will be ‘list’ or ‘boxed’ according to what has been selected in the Knowledge Base editor.
  • basepress_kb_cols()
    Echos the number of columns set in the options for the knowledge bases page.
  • basepress_section_cols()
    Echos the number of columns set in the options for the sections page.
  • basepress_show_section_icon()
    Returns whether section icons should be displayed or not according to options.
  • basepress_show_post_icon()
    Returns whether post icons should be displayed or not according to options.
  • basepress_get_post_meta_icons()
    Returns the array of post meta icons.
  • basepress_post_icon( $post_id )
    Returns the post icon class(es) name if an icon has been selected for the post  or the default icon if none has been selected for the post.
  • basepress_get_post_meta( $post_id )
    Returns an array with all post meta data.

    array(
        'icon'
        'views'
        'score'
        'votes'
    );
    
  • basepress_show_section_post_count()
    Returns a true if the posts count should be rendered for the sections titles.
  • basepress_sidebar_position( $reverse = false )
    Returns a string with the sidebar position. Pass true to the function to get the opposite position.
  • basepress_show_table_of_content()
    Returns true if the Table of Content should be displayed according to options.
  • basepress_table_of_content_title()
    Renders the Table of Content title as specified in the options
  • basepress_table_of_content()
    Renders the Table of Content.
  • basepress_pagination()
    Renders the pagination for the current section.
  • basepress_post_pagination()
    Renders the article pagination.
  • basepress_show_adjacent_articles()
    Returns true if Previous and Next article links should be shown.
  • basepress_prev_article()
    Return the previous article post object.
  • basepress_next_article()
    Return the previous article post object.
  • basepress_prev_article_text()
    Return the title to display on previous article link as per options.
  • basepress_next_article_text()
    Return the title to display on next article link as per options.
  • basepress_breadcrumbs()
    Renders the breadcrumbs.
  • basepress_searchbar()
    Renders the knowledge base search bar.
  • basepress_search_term()
    Returns the searched terms.
  • basepress_search_page_title()
    Returns search result page title from the options.
  • basepress_search_page_no_results_title()
    Returns search result page title from the options for searches without results.
  • basepress_search_post_snippet()
    Echos the current post snippet for the search results page.
  • basepress_restricted_notice()
    Return the restricted content notice as set in the options.
  • basepress_show_restricted_teaser()
    Returns true if the restricted content teaser should be shown.
  • basepress_article_teaser()
    Return the restricted content teaser.
  • basepress_show_restricted_login()
    Returns true if the login form should be shown on restricted content.
  • basepress_votes()
    Renders the voting items.
  • basepress_get_template_part()
    Loads a template part into a template. This is a replacement of WordPress get_template_part() and works within BasePress templates.

Was this helpful?