> ## Documentation Index
> Fetch the complete documentation index at: https://docs.locadapt.com/llms.txt
> Use this file to discover all available pages before exploring further.

# WordPress

> Learn how to set up Locadapt on your WordPress site

There are several ways to integrate Locadapt with your WordPress site. We'll cover three methods, from easiest to most advanced:

<AccordionGroup>
  <Accordion icon="puzzle-piece" title="Method 1: Using a Plugin (Recommended for Beginners)" defaultOpen>
    This method is the easiest and doesn't require any coding knowledge.

    <Steps>
      <Step title="Install Plugin">
        Install and activate a plugin like "Insert Headers and Footers" from the WordPress plugin directory.
      </Step>

      <Step title="Access Plugin Settings">
        Go to Settings > Insert Headers and Footers in your WordPress dashboard.
      </Step>

      <Step title="Add Locadapt Code">
        In the "Scripts in Header" section, paste the following code:

        ```html theme={null}
        <link rel="stylesheet" href="https://cdn.locadapt.com/locadapt.min.css" />
        <script 
          src="https://cdn.locadapt.com/locadapt.min.js" 
          data-project-id="YOUR_PROJECT_ID"
        ></script>
        ```

        <Warning>
          Remember to replace `YOUR_PROJECT_ID` with the actual project ID provided in [the configuration page](https://app.locadapt.com/configuration) for your Locadapt project.
        </Warning>
      </Step>

      <Step title="Save Changes">
        Click the "Save" button to apply your changes.
      </Step>
    </Steps>
  </Accordion>

  <Accordion icon="paintbrush" title="Method 2: Using the Theme Customizer" defaultOpen>
    This method is suitable if you're comfortable with basic WordPress customization.

    <Steps>
      <Step title="Access Theme Customizer">
        Go to Appearance > Customize in your WordPress dashboard.
      </Step>

      <Step title="Add CSS">
        Navigate to Additional CSS and add the following:

        ```css theme={null}
        @import url('https://cdn.locadapt.com/locadapt.min.css');
        ```
      </Step>

      <Step title="Add JavaScript">
        Go to Appearance > Theme File Editor and open `header.php`.
        Add the following code just before the closing `</head>` tag:

        ```html theme={null}
        <script 
          src="https://cdn.locadapt.com/locadapt.min.js" 
          data-project-id="YOUR_PROJECT_ID"
        ></script>
        ```
      </Step>

      <Step title="Save Changes">
        Click "Publish" in the Theme Customizer and "Update File" in the Theme Editor.
      </Step>
    </Steps>
  </Accordion>

  <Accordion icon="code" title="Method 3: Using a Child Theme" defaultOpen>
    This method is for advanced users comfortable with WordPress development.

    <Steps>
      <Step title="Create Child Theme">
        Create a child theme if you haven't already. This preserves your changes during theme updates.
      </Step>

      <Step title="Edit functions.php">
        In your child theme's `functions.php`, add the following code:

        ```php theme={null}
        function enqueue_locadapt() {
            wp_enqueue_style('locadapt-css', 'https://cdn.locadapt.com/locadapt.min.css');
            wp_enqueue_script('locadapt-js', 'https://cdn.locadapt.com/locadapt.min.js', array(), null, false);
            wp_add_inline_script('locadapt-js', 'document.currentScript.setAttribute("data-project-id", "YOUR_PROJECT_ID");');
        }
        add_action('wp_enqueue_scripts', 'enqueue_locadapt');
        ```
      </Step>

      <Step title="Save and Activate">
        Save the file and ensure your child theme is activated.
      </Step>
    </Steps>
  </Accordion>
</AccordionGroup>

<Tip>
  After implementing any of these methods, clear your WordPress cache if you're using a caching plugin, and then test your site to ensure Locadapt is working correctly.
</Tip>

If you encounter any issues or need further assistance, don't hesitate to contact our support team at [support@locadapt.com](mailto:support@locadapt.com).
