Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <<<<<< asenna (L/M/W)AMP >>>>>>
- LAMP:
- http://www.beginninglinux.com/home/server-administration/installing-lamp-with-one-command---linux-apache-mysql-php
- sudo apt-get update
- sudo apt-get install apache2
- sudo apt-get install mysql-server php5-mysql
- sudo mysql_install_db
- sudo mysql_secure_installation
- sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt
- sudo service apache2 restart
- MAMP:
- https://codex.wordpress.org/Installing_WordPress_Locally_on_Your_Mac_With_MAMP
- WAMP:
- http://www.wampserver.com/en/
- <<<<<< luo kanta ja käyttäjä >>>>>>
- *** komentorivi: ***
- mysql -u root
- create database wordpress;
- grant all privileges on wordpress.* to wpuser@localhost identified by 'salainensana';
- *** phpmyadmin: ***
- Users > Add user
- Check "Create database with same name and grant all privileges."
- <<<<<< style.css >>>>>>
- /*
- Theme Name: Kisut
- Author: Pekko Tuomisto
- Author URI: http://kisut.fi
- Template: twentyseventeen
- */
- <<<<<< functions.php >>>>>>
- <?php
- add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
- function theme_enqueue_styles() {
- wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
- wp_enqueue_script( 'child-script', get_stylesheet_directory_uri() . '/script.js', array(), '1.0.0', true );
- }
- ?>
- <<<<<< font awesome link >>>>>>
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
- ( http://fortawesome.github.io/Font-Awesome/icons/ )
- <<<<<< custom post type >>>>>>
- register_post_type('cat', array(
- 'label' => 'Cats',
- 'public' => true,
- 'supports' => array(
- 'title', 'editor', 'author', 'revisions', 'thumbnail', 'custom-fields'
- )
- ));
- <<<<<< shortcode >>>>>>
- function show_cat_shortcode($atts) {
- // Attributes
- extract( shortcode_atts(
- array(
- 'post_id' => ''
- ), $atts )
- );
- $ret_string = '<img src="'. wp_get_attachment_url( get_post_thumbnail_id($post_id, 'thumbnail') ) .'">';
- return $ret_string;
- }
- add_shortcode( 'show_cat', 'show_cat_shortcode' );
- <<<<<< the loop >>>>>>
- <?php
- $my_query = new WP_Query( 'post_type=cat' );
- if ( $my_query->have_posts() ) {
- while ( $my_query->have_posts() ) {
- $my_query->the_post();
- ?>
- <div id="post-<?php the_ID(); ?>" class="post">
- <h2>
- <a href="<?php the_permalink() ?>">
- <?php the_title(); ?>
- </a>
- </h2>
- <div class="entry">
- <?php the_content(); ?>
- </div>
- <div class="meta">
- <?php echo get_post_meta( get_the_ID(), 'color', true ); ?>
- </div>
- </div>
- <?php
- } // end while
- } else {
- ?>
- <p class="no-posts">No cats :(</p>
- <?php
- } // end if else
- ?>
- <<<<<< jQuery add content >>>>>>
- jQuery(window).load(function(){
- jQuery('#content').append('Toimii!');
- jQuery('header').slideUp(2000).slideDown(500);
- });
- <<<<<< jQuery each -function >>>>>>
- jQuery(window).load(function(){
- var color = 111;
- jQuery('a').each(function(){
- jQuery(this).css('background', '#'+color);
- color += 111;
- });
- });
- <<<<<< AJAX (PHP) >>>>>>
- // AJAX getCat(id)
- add_action( 'wp_ajax_getCat', 'kisut_ajax_getCat' );
- add_action( 'wp_ajax_nopriv_getCat', 'kisut_ajax_notLoggedIn' );
- function kisut_ajax_getCat() {
- $id = intval($_REQUEST["id"]);
- if(get_post_type($id)=='cat'){
- echo get_the_title($id);
- } else {
- echo 'not a cat!';
- }
- die();
- }
- function kisut_ajax_notLoggedIn() {
- echo 'Log in first';
- die();
- }
- <<<<<< AJAX (jQuery) >>>>>>
- function getCat(id) {
- jQuery.post(
- 'http://localhost/wordpress/wp-admin/admin-ajax.php',
- {
- 'action': 'getCat',
- 'id': id
- },
- function(response){
- alert(response);
- }
- );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement