bricks_update_links

Phase 4.7IntermediateBatchComplexity: 5/10
Batch update links via targeted updates or find/replace

Overview

Batch updates links across pages, templates, and menus. Supports two modes: targeted updates (specific link updates with source info) and find & replace (replace all occurrences of a URL site-wide).

Use the output from bricks_scan_links to build targeted update arrays, or use find/replace for bulk URL changes.

Key Features

Targeted updates
Update specific links by source_type, source_id, element_id, and setting_path
Find and replace
Replace all occurrences of a URL across pages, templates, and menus
Cross-source
Updates links in pages, templates, AND navigation menus

When to Use

Phase 4.7 (Link Reconciliation) — after scanning with bricks_scan_links
Fixing placeholder # links with real page URLs
Bulk URL replacement after domain migration
Updating menu links after creating new pages
Prerequisites
Run bricks_scan_links first to identify links that need updating
All target pages should already exist with their final slugs

When NOT to Use

Before scanning — always run bricks_scan_links first to identify what needs fixing
For updating individual element settings — use bricks_update_element instead

Parameters

2 Total Parameters2 Optional
updatesarrayoptional
Array of targeted link updates: [{source_type, source_id, element_id, setting_path, new_url}]
Default: []
find_replaceobjectoptional
Find/replace object: {find: "old-url", replace: "new-url"} — replaces everywhere

Code Examples

Fix placeholder links with targeted updates

Update specific links identified by bricks_scan_links

JSON
{
    "updates": [
        {
            "source_type": "menu",
            "source_id": 5,
            "element_id": "42",
            "setting_path": "url",
            "new_url": "https://site.com/contact"
        },
        {
            "source_type": "template",
            "source_id": 12,
            "element_id": "abc123",
            "setting_path": "link.url",
            "new_url": "https://site.com/about"
        }
    ]
}
Response
{"success": true, "updated_count": 2}

Bulk find and replace

Replace all # links with a real URL

JSON
{
    "find_replace": {
        "find": "#",
        "replace": "https://site.com/contact"
    }
}
Response
{"success": true, "updated_count": 8}

Common Mistakes

Using find/replace with "#" which is too broad
Find/replace matches exactly — "#" will only match links that are exactly "#", not "#section-id" anchor links. But still be cautious with broad patterns.

Tips & Warnings

Tips & Warnings
  • Always run bricks_scan_links first to see what needs fixing
  • Use the suggestions from scan results to build targeted updates
  • Find/replace is powerful but be careful with broad patterns
  • After updating, run bricks_scan_links(filter: "broken") to verify no broken links remain

Return Values

FieldTypeDescription
successbooleanWhether the updates were applied successfully
updated_countnumberNumber of links updated

Related Tools

Technical Details

Tool ID
bricks_update_links
API Endpoint
/bricks-mcp/v1/links/update
HTTP Method
POST
Namespace
wordpress-site
Source File
analysis/links.ts
Version
1.0
Min Bricks Version
1.9
Requires Auth
Yes

Changelog

v1.0
Initial release
20250101