(Instructions are for Mac, but MAMP works for Windows and it might be similar process for Windows too.)
- Install MAMP: https://www.mamp.info/
- Start MAMP (not MAMP PRO) from your Applications folder. You can configure MAMP so it automatically starts/stops Apache/MySQL. Dashboard on http://localhost:8888/MAMP/\
- Create a new MySQL database called wordpress on http://localhost:8888/phpMyAdmin/ (keep utf8 setting as is)
- Download WordPress: https://wordpress.org/download/
- Unzip to /Applications/MAMP/htdocs/wordpress (this is the default folder, you can configure Apache to have files somewhere else, and have multiple sites)
- Go to http://localhost:8888/wordpress/ and create your new site
-
- Make sure to fill in database name wordpress
- Username and password are both rootm
- Create your WordPress admin user
- Manage your WordPress site on http://localhost:8888/wordpress/wp-admin/
- The WordPress site is now running on http://localhost:8888/wordpress/
More info:
- https://www.elegantthemes.com/blog/tips-tricks/how-to-create-a-local-wordpress-installation-on-a-mac
- If you need multiple Wordpress installations on same machine, read this
- Tobias recommends Laravel Valet instead of MAMP
- Clone a custom theme into /Applications/MAMP/htdocs/wordpress/wp-content/themes
- Activate the theme under http://localhost:8888/wordpress/wp-admin/themes.php
- Export Wordpress (Tools → Export): https://mywebsite.com/wp-admin/export.php
- Import on localhost (Tools → Import): http://localhost:8888/wordpress/wp-admin/import.php
- Select your own username on all missing usernames.
- Check the checkbox to download file attachments.
- Start import and wait until it says "All done. Have fun!".
- View the website on http://localhost:8888/wordpress/
- Click Customize in top bar
- Click Site Identity
- Logo: search for ER-logo-White-Linear, skip cropping
- Tagline: Uppror för allt levande
Then:
- Go up on level, and find Menus
- Check the "Primary menu" checkbox:
- Then, go up on level, and find Homepage Settings
- Select Homepage = static page #1812 and Posts page = Nyheter
- Click Publish to save
- Download MAMP: https://www.mamp.info/en/mac
- Start MAMP (not MAMP PRO) from your Applications folder. You can configure MAMP so it automatically starts/stops Apache/MySQL when MAMP starts/stops. Dashboard on http://localhost:8888/MAMP/
- Create a new MySQL database called
wordpresson http://localhost:8888/phpMyAdmin/ - Download WordPress: https://wordpress.org/download/
- Unzip to
/Applications/MAMP/htdocs/wordpress(this is the default folder, you can configure Apache to have files somewhere else, and have multiple sites) - Go to http://localhost:8888/wordpress/ and create your new site and WordPress admin user. Username and password are both "root".
- Manage your WordPress site on http://localhost:8888/wordpress/wp-admin/
- The WordPress site is now running on http://localhost:8888/wordpress/
More info: https://www.elegantthemes.com/blog/tips-tricks/how-to-create-a-local-wordpress-installation-on-a-mac
- Go to MAMP > Preferences > Ports and set Apache Port to be 80
- Add host to
sudo pico /etc/hostsand add a row127.0.0.1 local.MYSITE.COM - Edit
/Applications/MAMP/conf/apache/httpd.conand add:
NameVirtualHost *
<VirtualHost *>
DocumentRoot "/Applications/MAMP/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *>
DocumentRoot "/path/to/MYSITE"
ServerName local.MYSITE.COM
</VirtualHost>
- Change MySQL settings in
wordpress/wp-config.php
https://serverfault.com/questions/146550/how-to-set-up-multiple-websites-virtual-hosts-on-mamp
- Clone the custom theme
wp-themeinto/Applications/MAMP/htdocs/wordpress/wp-content/themes - Activate the theme under http://localhost:8888/wordpress/wp-admin/themes.php
- Open WP Admin e.g. http://localhost:8888/wordpress/wp-admin/plugin-install.php
- Click the “Upload Plugin” button
- Select the ZIP file with the plugin
https://codex.wordpress.org/Writing_a_Plugin
How to use WPAPI with Wordpress.com (endpoint)?
https://www.npmjs.com/package/wpapi
https://github.com/wp-api/node-wpapi
const WPAPI = require('wpapi')
const site = await WPAPI.discover(`https://${WORDPRESS_SITE_DOMAIN}`)
https://public-api.wordpress.com/wp/v2/sites/MYSITE.wordpress.com/pages?slug=about
const POSTS_LIMIT = 100
const WORDPRESS_BASE_URL = 'https://public-api.wordpress.com/rest/v1.1/sites/'
const WORDPRESS_SITE_ID = 'MYSITE.wordpress.com'
const getWpEndpointUrl = (resource = 'posts') => `https://public-api.wordpress.com/rest/v1.1/sites/${WORDPRESS_SITE_DOMAIN}/${resource}`
https://developer.wordpress.com/docs/api/1.1/get/sites/%24site/posts/
const getPostsList = function ({ category, search, sort = 'date,DESC', fields = 'ID,slug,title,featured_image,date,excerpt,categories,tags,sticky' } = {}) {
const [orderBy, order] = sort.split(',')
const url = [
`${getWpEndpointUrl('posts')}?`,
`fields=${fields}`,
order ? `&order_by=${orderBy}&order=${order}` : '',
category ? `&category=${category}` : '',
search ? `&search=${search}` : '',
`&number=${POSTS_LIMIT}`
].join('')
return fetch(url) // eslint-disable-line no-undef
.then(res => res.json())
.then(res => res.posts.map(fixWordpressPost))
}
https://developer.wordpress.com/docs/api/1.1/get/sites/%24site/posts/slug:%24post_slug/
const getPostDetails = function (slug, { fields = 'ID,slug,title,featured_image,date,excerpt,content,attachments,categories,tags,sticky' } = {}) {
const url = `${WORDPRESS_BASE_URL}${WORDPRESS_SITE_ID}/posts/slug:${slug}?fields=${fields}`
return fetch(url).then(res => res.json()).then(res => res.error ? undefined : fixWordpressPost(res)) // eslint-disable-line no-undef
}
Advanced:
const { decode } = require('html-entities')
const stripHtmlTags = str => str.replace(/<\/?("[^"]*"|'[^']*'|[^>])*(>|$)/g, '')
const stripNewLines = str => str.replace(/\n/g, '')
const formatDate = dateObj => `${dateObj.getFullYear()}-${('0' + (dateObj.getMonth()+1)).slice(-2)}-${('0' + dateObj.getDate()).slice(-2)}`
const fixWordpressPost = post => ({
...post,
title: decode(post.title),
date: new Date(post.date),
dateFormatted: formatDate(post.date),
excerpt: stripNewLines(stripHtmlTags(decode(post.excerpt))),
// url: getURL(post),
thumbnailImageUrl: post.featured_image || getAttachmentImages(post).thumbnail,
bigImageUrl: post.featured_image || getAttachmentImages(post).large
})
const getAttachmentImages = post => {
const attachment0 = post.attachments && Object.values(post.attachments)[0]
return (attachment0 ? attachment0.thumbnails : {})
}
{
"ID":26,
"site_ID":184352112,
"author":{
"ID":10258739,
"login":"tomsoderlund",
"email":false,
"name":"tomsoderlund",
"first_name":"Tom",
"last_name":"S\u00f6derlund",
"nice_name":"tomsoderlund",
"URL":"http:\/\/tomsoderlundblog.wordpress.com",
"avatar_URL":"https:\/\/0.gravatar.com\/avatar\/9c186f5bc27815e52418210f43c42f06?s=96&d=identicon&r=G",
"profile_URL":"https:\/\/en.gravatar.com\/tomsoderlund",
"site_ID":107414364
},
"date":"2020-10-19T22:57:36+02:00",
"modified":"2020-10-19T23:05:54+02:00",
"title":"Napkin Business Model",
"URL":"https:\/\/amazingstartupguide.wordpress.com\/2020\/10\/19\/napkin-business-model\/",
"short_URL":"https:\/\/wp.me\/pctwpa-q",
"content":"\n<p>This is the body.<\/p>\n",
"excerpt":"<p>This is the excerpt.<\/p>\n",
"slug":"napkin-business-model",
"guid":"https:\/\/amazingstartupguide.wordpress.com\/?p=26",
"status":"publish",
"sticky":false,
"password":"",
"parent":false,
"type":"post",
"discussion":{
"comments_open":true,
"comment_status":"open",
"pings_open":true,
"ping_status":"open",
"comment_count":0
},
"likes_enabled":true,
"sharing_enabled":true,
"like_count":0,
"i_like":false,
"is_reblogged":false,
"is_following":false,
"global_ID":"bcb6f582038a963f3c743c0bd437a0f7",
"featured_image":"https:\/\/amazingstartupguide.files.wordpress.com\/2020\/10\/photography_biopic.jpg",
"post_thumbnail":{
"ID":18,
"URL":"https:\/\/amazingstartupguide.files.wordpress.com\/2020\/10\/photography_biopic.jpg",
"guid":"http:\/\/amazingstartupguide.files.wordpress.com\/2020\/10\/photography_biopic.jpg",
"mime_type":"image\/jpeg",
"width":546,
"height":546
},
"format":"standard",
"geo":false,
"menu_order":0,
"page_template":"",
"publicize_URLs":[
],
"terms":{
"category":{
"Business Model":{
"ID":13799,
"name":"Business Model",
"slug":"business-model",
"description":"",
"post_count":1,
"parent":0,
"meta":{
"links":{
"self":"https:\/\/public-api.wordpress.com\/rest\/v1.1\/sites\/184352112\/categories\/slug:business-model",
"help":"https:\/\/public-api.wordpress.com\/rest\/v1.1\/sites\/184352112\/categories\/slug:business-model\/help",
"site":"https:\/\/public-api.wordpress.com\/rest\/v1.1\/sites\/184352112"
}
}
}
},
"post_tag":{
"Napkin Business Model":{
"ID":690569998,
"name":"Napkin Business Model",
"slug":"napkin-business-model",
"description":"",
"post_count":1,
"meta":{
"links":{
"self":"https:\/\/public-api.wordpress.com\/rest\/v1.1\/sites\/184352112\/tags\/slug:napkin-business-model",
"help":"https:\/\/public-api.wordpress.com\/rest\/v1.1\/sites\/184352112\/tags\/slug:napkin-business-model\/help",
"site":"https:\/\/public-api.wordpress.com\/rest\/v1.1\/sites\/184352112"
}
}
}
},
"post_format":{
},
"mentions":{
}
},
"tags":{
"Napkin Business Model":{
"ID":690569998,
"name":"Napkin Business Model",
"slug":"napkin-business-model",
"description":"",
"post_count":1,
"meta":{
"links":{
"self":"https:\/\/public-api.wordpress.com\/rest\/v1.1\/sites\/184352112\/tags\/slug:napkin-business-model",
"help":"https:\/\/public-api.wordpress.com\/rest\/v1.1\/sites\/184352112\/tags\/slug:napkin-business-model\/help",
"site":"https:\/\/public-api.wordpress.com\/rest\/v1.1\/sites\/184352112"
}
}
}
},
"categories":{
"Business Model":{
"ID":13799,
"name":"Business Model",
"slug":"business-model",
"description":"",
"post_count":1,
"parent":0,
"meta":{
"links":{
"self":"https:\/\/public-api.wordpress.com\/rest\/v1.1\/sites\/184352112\/categories\/slug:business-model",
"help":"https:\/\/public-api.wordpress.com\/rest\/v1.1\/sites\/184352112\/categories\/slug:business-model\/help",
"site":"https:\/\/public-api.wordpress.com\/rest\/v1.1\/sites\/184352112"
}
}
}
},
"attachments":{
},
"attachment_count":0,
"metadata":[
{
"id":"128",
"key":"_thumbnail_id",
"value":"18"
}
],
"meta":{
"links":{
"self":"https:\/\/public-api.wordpress.com\/rest\/v1.1\/sites\/184352112\/posts\/26",
"help":"https:\/\/public-api.wordpress.com\/rest\/v1.1\/sites\/184352112\/posts\/26\/help",
"site":"https:\/\/public-api.wordpress.com\/rest\/v1.1\/sites\/184352112",
"replies":"https:\/\/public-api.wordpress.com\/rest\/v1.1\/sites\/184352112\/posts\/26\/replies\/",
"likes":"https:\/\/public-api.wordpress.com\/rest\/v1.1\/sites\/184352112\/posts\/26\/likes\/"
}
},
"capabilities":{
"publish_post":false,
"delete_post":false,
"edit_post":false
},
"other_URLs":{
}
}