---
title: "Toggle Snippet Ability: Enable or Disable a Code Snippet in WordPress"
url: https://nexterwp.com/docs/nexter-toggle-snippet/
date: 2026-05-29
modified: 2026-05-29
author: "sandip patel"
description: "The nexter/toggle-snippet ability enables or disables a Nexter Extension code snippet by its ID. Pass the ID and an optional status value to set the state explicitly."
word_count: 226
---

# Toggle Snippet Ability: Enable or Disable a Code Snippet in WordPress

## Key Takeaways

- Nexter/toggle-snippet ability enables or disables a code snippet in WordPress by its ID.
- id parameter is required as a string, while status parameter uses integers: 1 for active and 0 for inactive.
- Disabling a snippet stops it from running without deleting its code or settings, facilitating error management on live sites.

The **nexter/toggle-snippet** ability enables or disables a Nexter Extension code snippet by its ID. Pass the snippet ID and an optional status value (1 for active, 0 for inactive). If you omit status, the ability flips the current state. Use nexter/list-snippets to find the snippet ID first.

## Key Takeaways

The id parameter is required and is a string.

The status parameter uses integers: 1 for active, 0 for inactive.

When status is omitted, the ability flips the snippet's current active state.

Disabling a snippet stops it from running without deleting its code or settings.

## Required Setup

This ability ships with Nexter Extension (Free). If you do not have it installed, follow the guide on how to install and activate Nexter Extension first.

## Parameters

**id** (string, required) is the unique identifier of the snippet to toggle.

**status** (integer, optional) sets the target state. Use 1 for active and 0 for inactive. Omit to flip the current state.

## What It Returns

The ability returns: **success** (boolean), **new_status** (the state after the change — active or inactive), and **message** (a confirmation string).

## When to Use This Ability

Quickly disable a PHP snippet that is causing errors on a live site.

Enable a snippet that was drafted but not yet activated.

Automate snippet activation as part of a site deployment or maintenance workflow.

## Related Documentation

List Snippets Ability: nexter/list-snippets

Delete Code Snippet Ability: nexter/delete-snippet

Update Snippet Ability: nexter/update-snippet