How do I increase the number of articles in the sidebar on the article page? | Community
Skip to main content

How do I increase the number of articles in the sidebar on the article page?

  • February 8, 2024
  • 2 replies
  • 0 views

Jane12

Currently the sidebar on the article page holds 10 articles but I'd like to display all the articles in the section... I can't figure out how to remove this limit, can anyone help?

Copenhagen
Theme version 3.1.2
API version 3

2 replies

Pulkit12
  • February 9, 2024

Hi Jane Niven

You can use the API to create the sidebar and display all the sections belonging to that category. 

 

Thank You 

Pulkit

Team Diziana 


Brandon12
  • February 9, 2024

Hey Jane,

You've got a few options here.  The easiest might be to explore the Theme Marketplace for a Guide Theme that doesn't have the same restriction.  Generally speaking, showing more than 10 is not necessarily advisable, as the results tend to get less relevant the more you put there.  That said, to increase the number of articles displayed in the sidebar, you'll likely need to customize your theme's code. The number of articles shown in the sidebar is often controlled by the theme's template files, which can be modified to display more articles. Here's a general approach you can take:

### Step 1: Customize Your Theme

1. **Go to Guide Admin**: Access your Zendesk Guide admin by clicking on the "Guide" icon from the Zendesk product tray.
2. **Navigate to Theme Editor**: In the Guide admin, go to the "Customize design" tab and then "Theme" to see your current themes.
3. **Edit Your Theme**: Find the Copenhagen theme and click on "Customize" to edit the theme.

### Step 2: Modify the Code

You'll need to locate the code snippet responsible for fetching and displaying articles in the sidebar. This is typically found in one of the template files, such as `article_page.hbs` or a similar file. You're looking for a loop or a block of code that iterates over articles.

The limitation to 10 articles is not directly a setting in the theme but is more about how the articles are fetched and displayed. If the code uses the Zendesk Help Center API or Zendesk Apps Framework (ZAF) to fetch articles, you'll need to adjust the API call to increase the limit or to paginate through articles to display all from the section.

### Step 3: Adjust the Article Fetch Logic

- **For API Modifications**: If articles are fetched using the Zendesk API, you'll likely need to modify the API call to increase the `per_page` parameter or implement pagination. The Help Center API allows you to specify how many articles you want to retrieve per request (up to a maximum, usually 100 per page), so you might need to handle pagination to get all articles in a section.

### Example Snippet

Here's an example of how you might modify an API call to fetch more articles:


// Assuming you're using JavaScript to fetch articles
const sectionId = 'YOUR_SECTION_ID'; // Replace with your actual section ID
fetch(`/api/v2/help_center/articles?section=${sectionId}&per_page=30`) // Increase `per_page` as needed
  .then(response => response.json())
  .then(data => {
    // Code to dynamically insert articles into the sidebar
  });

### Step 4: Test Your Changes

After making your changes, preview your theme to ensure that the articles display as expected. Check for any performance issues, especially if you're loading many articles at once.

### Step 5: Publish Your Changes

Once you're satisfied with the changes, publish your theme to make it live for your users.

If you're not comfortable making these changes yourself, consider reaching out to a developer familiar with web development and the Zendesk Guide themes, such as 729Solutions.com.

Hope this helps!

Brandon