GithubHelp home page GithubHelp logo

isabella232 / wordpress-algolia-sync Goto Github PK

View Code? Open in Web Editor NEW

This project forked from algolia/wordpress-algolia-sync

0.0 0.0 0.0 191 KB

A WordPress plugin boilerplate for indexing content into Algolia

PHP 99.48% Shell 0.52%

wordpress-algolia-sync's Introduction

WpAlgolia

Installation

  1. Extract the archive in a folder named algolia in the wp-content/plugins directory of your WordPress instance
  2. Enable the plugin from your admin Plugins page
  3. Add 2 constants to your wp-config.php file: ALGOLIA_APPLICATION_ID & ALGOLIA_ADMIN_API_KEY
  4. Add 1 constant to determine the environment prefix for your indices: ALGOLIA_PREFIX

What is already provided

We provided you with some code for the Posts to get you started with building an indexing pipeline.

Please have a look inside the inc/MyCompany folder.

3 files there:

  • PostRecordsProvider: Defines the way to fetch records from WordPress and how to transform it into Algolia records.
  • PostsIndexSettingsFactory: Defines the Algolia settings for the index (will be pushed on every new full re-index).
  • PostChangeListener: Watches for changes on the articles, and pushes the updated article to Algolia.

The last file you need to be aware of is:

algolia.php: It bootstraps the plugin and registers your indices.

Index your data

The indexing needs to be done from the command line.

First make sure you have WP-CLI installed.

Then you can run the re-index command we provide:

$ wp algolia reIndex articles

Where articles is the name of your index. When you'll have more indices, you can change that with another index name.

After the re-index process finished, you should have everything pushed to Algolia, and the settings should be set.

Adding more indices

To be able to add your other content types, you need to inspire from what's existing:

  • Copy paste the Post classes from inc/MyCompany and adjust them
  • Register the new index in the algolia.php file

Once you have introduced new indices, you can re-index them by doing for example:

$ wp algolia reIndex my_custom_index_name

In case you altered just the settings an don't want to operate a full re-index, you can run the following command:

$ wp algolia pushSettings my_custom_index_name

wordpress-algolia-sync's People

Contributors

chriszarate avatar rayrutjes avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.