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.
Table of Contents

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

About the Author

sandip patel

WordPress Developer at POSIMYTH Innovations I am a passionate WordPress Developer at POSIMYTH Innovations, where I focus on building high-performance products and cutting-edge web experiences. Currently, I contribute to the development of major projects including The Plus Addons for Elementor, Sticky Header for Elementor, RankReady AI (LLM & SEO), and the SproutOS MCP server integration. I love bridging the gap between WordPress core functionality and modern AI capabilities. Beyond standard development.

Share your Thoughts

Get Instant Answers to all your questions about Nexter Blocks,
Extensions & Theme trained on 1000+ Docs and Videos

Still in Doubt? Let’s Assist You

Have Feedback or Questions?

Join our WordPress Community on Facebook!