일반적으로 만들어진 홈페이지에 게시판이 갑자기 추가되는 번거로워지는 경우가 생겼다.

그래서 크게 구조 등을 변경하지 않고 아이프레임으로 삽입을 하면 될 거라 생각했는데

<iframe id="iframe-import" src="http://domain.com/external-board" frameborder="0" scolling="no" width="100%" height="900"></iframe>

높이가 고정이다보니 안예쁨.

따라서 아래 코드로 변경(onLoad 부분)

<iframe id="iframe-import" src="http://domain.com/external-board" frameborder="0" scolling="no" width="100%" height="900" onload="autoResize(this)"></iframe>

autoResize 라는 자바스크립트 함수도 추가

<script type="text/javascript">

// iFrame Resizing Funcgtion

function autoResize(i){
    var iframeHeight=
    (i).contentWindow.document.body.scrollHeight;
    (i).height=iframeHeight+20;
}

</script>

https://www.thewordcracker.com/intermediate/how-to-configure-variable-products-in-wordpress/

워드프레스의 우커머스에서 옵션 상품을 구성하여 고객이 옵션(예: 색상, 크기 등)을 선택하여 구매할 수 있도록 할 수 있습니다. 보통 옵션 상품이라고 하면 영어로 Option으로 생각하기 쉽지만, “Variable Product”(옵션 상품)와 “Variation”(옵션)이라는 용어가 사용되므로 구글 검색 시 이 용어를 사용하면 원하는 정보를 얻을 수 있을 것입니다.

이 글에서는 우커머스 옵션 상품을 구성하는 간단한 방법을 설명하겠습니다. UI는 테마별/우커머스 버전별로 조금 차이가 있을 수 있으니 이점을 고려하여 참고하시기 바랍니다. (아바다 테마에서 테스트했는데, 우커머스 버전 때문인지 한글화가 완전히 되지 않았네요.)

테스트로 노트북에 “사이즈”와 “색상”이라는 속성을 지정하여 가격을 달리하도록 해보겠습니다.

Attribute 지정

먼저 우커머스 속성(Attribute)을 정의하도록 합니다. 상품 > Attributes를 클릭합니다.

Select Product Attributes

Attributes가 한글화가 되지 않은 상태로 나오네요. 한글화가 되면 “속성” 정도로 번역될 것 같습니다. 상품 > Attributes를 클릭하면 새 속성을 추가할 수 있는 화면이 표시됩니다.

Add New Attribute - 우커머스 새 속성 추가하기

적절한 속성을 추가합니다. 예를 들어 컬러를 추가하고 맨 아래의 “Add Attribute(속성 추가)”를 클릭합니다.

Added an attribute

그러면 위의 그림과 같이 오른쪽 상단에 추가된 속성이 표시됩니다. 맨 오른쪽에 있는 “Configure Terms”(용어 구성?) 아이콘을 클릭합니다.

Add an individual option그러면 위의 그림과 같이 선택한 속성 내에 추가될 세부 옵션을 추가할 수 있습니다. “새로 추가 컬러“라고 어색하게 되어 있네요. 번역할 때에는 부분적인 문자열만 볼 수 있기 때문에 생긴 결과 같습니다. “컬러 새로 추가”나 “새로 추가: 컬러” 정도로 처리하면 좋을 듯 합니다. (Woocommerce 번역을 수정하려면 Loco Translate와 같은 플러그인을 사용할 수 있습니다.)

원하는 컬러를 추가합니다. 저는 “파랑”과 “빨강”을 추가해보았습니다.

Added color attribute

위의 과정을 반복하여 다른 속성(예: 크기)을 정의하도록 합니다.

옵션 상품 설정하기

이제 새로운 상품을 추가하거나 기존 상품을 편집하여 “옵션 상품”을 구성하도록 합니다. 상품 > 상품 추가하기를 눌러 적절한 상품을 생성합니다. 상품 설명 아래의 “Product Data”(상품 데이터)에서 “옵션 상품“을 선택합니다.

Specify Variable Product

그런 다음 Product Data 아래에서 Attributes를 선택합니다.

Select Attributes under Product Data

원하는 Attribute를 선택합니다. 예를 들어, 일부 속성만 선택할 수도 있고 모든 속성을 선택할 수도 있습니다.

Select Attributes

이제 Attributes 바로 아래에 있는 “옵션“을 선택합니다.

Add Variation

위와 같은 그림에서 “Add variation” 또는 “Create variations from all attributes” 중에서 선택하여 옵션을 추가하고 옵션의 세부 설정을 지정할 수 있습니다. “Create variations from all attributes“를 선택하면 속성의 모든 조합이 추가됩니다.

Added variation

위와 같은 그림에서 개별 항목 옆에 있는 세 줄 모양의 아이콘을 클릭하면 세부 설정을 지정할 수 있습니다. 가령 개별 옵션에 대한 상품 사진을 추가할 수 있고 가격을 지정할 수 있습니다. 개별 옵션에 대하여 원하는 설정을 한 후에 발행하면 상품이 등록됩니다. 테스트로 올린 상품을 보면 아래와 같이 “컬러”와 “사이즈”를 선택할 수 있는 옵션이 추가되어 있습니다.

Added options in woocommerce

컬러와 사이즈를 지정하면 개별 옵션에 대해 지정한 가격이 표시됩니다.

YITH WOOCOMMERCE PRODUCT ADD-ONS(우커머스 상품 애드온)

옵션만으로 부족한 경우가 있을 수 있습니다. 고객의 특정 요구 사항에 맞게 옵션을 추가해야 하는 경우 YITH  우커머스 상품 애드온 플러그인을 사용해볼 수 있습니다. 이 플러그인을 사용하면 아래 그림과 같이 상품을 구성할 수 있습니다.

우커머스 추가 상품 옵션 추가하기

위에서 잠시 설명했지만 “variation”이라는 용어가 한글로 “옵션”으로 번역되어 있습니다. variation을 사전에서 찾아보면 “변화, 변동”의 의미를 가지고 있습니다. 즉, 동일한 상품의 다른 버전 정도로 해석할 수 있습니다.

“옵션”이라는 용어는 조금 다른 뜻을 가질 수 있습니다. 예를 들어, 아래 그림과 같이 상품에 어떤 부가적인 구성품을 추가하는 것에 대하여 “옵션” 추가라는 용어를 사용하기도 합니다.

Added extra product options

위와 같이 추가 상품 옵션(Product Option)을 추가하려는 경우 WooCommerce Extra Product Options라는 플러그인을 사용할 수 있습니다.

Extra Product Option Plugin

WooCommerce Extra Product Options 플러그인은 우커머스 관련 플러그인으로는 드물게 주간 베스트셀링 플러그인 목록에 이름을 올리고 있습니다. 그만큼 이와 같은 기능을 원하는 사용자가 많은 것 같습니다.

워드프레스 쇼핑몰에서 상품 옵션을 추가하려는 경우 이 플러그인을 사용하면 편리할 것 같습니다. 참고로 이 플러그인은 다음 플러그인과는 호환되지 않는다고 나와 있으니 참고하시기 바랍니다(2016년 4월 기준).

  • AnsPress, Tracking Code Manager, WooCommerce Bookings from Woothemes, Business Hours Pro WordPress Plugin, Woocommerce Add to cart Ajax for variable products (not compatible with the edit options feature in the cart), WooCommerce Wholesale Ordering, WooCommerce Group Pricing, Subscriptio – WooCommerce Subscriptions, VarkTech Pricing Deals for WooCommerce, Woocommerce Prices by User Role (* Woocommerce Prices by User Role 플러그인은 사용자 역할(회원 등급)별로 가격을 설정하는 기능을 제공하네요. 그리고 게스트에게는 장바구니 버튼이나 가격을 숨길 수 있는 기능도 있습니다.)

워드프레스 우커머스 상품 번들 플러그인

사이트에서 고객이 어떤 상품을 구매할 때 고객이 추가로 구매하기를 원하는 상품이 있는 경우 YITH WooCommerce Product Bundles 플러그인을 사용할 수 있습니다. 자세한 내용은 워드프레스 우커머스 상품 번들 플러그인 – YITH WooCommerce Product Bundles를 참고하세요.

YITH WOOCOMMERCE BULK PRODUCT EDITING(우커머스 대량 상품 일괄 편집)

많은 상품이 있고 상품 설명, 카테고리, 가격 등을 빠르게 수정하고 싶은 경우에 YITH WOOCOMMERCE BULK PRODUCT EDITING 플러그인을 사용해볼 수 있습니다.

참고 동영상:

상품 옵션(Variation)을 지정하는 방법을 다음 동영상을 통해 확인할 수 있습니다. 영어로 되어 있습니다만, 위의 글을 읽은 후에 보면 영어를 잘 모르더라도 어느 정도 이해가 될 것입니다.

 

워드프레스를 이용하다보면 호스팅을 이전해야하거나 여러 개의 워드프레스를 한 호스팅안에 설치할 경우가 생겨납니다.

그런데 이렇게 하나의 DB안에 여러 개의 워드프레스를 설치하기 위해서는 워드프레스 설치 당시 접두어인 wp_ 라고 입력되어있는 부분을 다르게 입력하고 설치하면 되지만 이미 다른 호스팅에서 설치되어있는 워드프레스를 옮겨와서 접두어(prefix)만 변경해서 이전하고 싶을 때가 있습니다.

 

워드프레스를 위한 DB 테이블 접두어 변경 방법

 

1. 일단 PhpMyAdmin 을 접속해서 변경하려는 wp_ 로 되어있는 테이블을 선택한 후 하단의 ‘테이블의 접두사를 교체‘를 누릅니다.

 

2. 아래 그림과 같이 변경전 접두어와 변경할 접두어를 입력하고 확인을 누릅니다.

 

3. 그러면 변경된 테이블들을 볼 수 있습니다.

 

4. wp-config.php 파일안의 $table_prefix  = ‘wp_’; 값을 변경한 접두어로 바꾼 후에 저장합니다.

 

5. DB 테이블에서  wp_options 이였던 테이블을 찾아 <보기>버튼을 누릅니다. 저 같은 경우 위에서 wp_를 hwp_로 바꾸었으니 hwp_options를 클릭하면 되는거죠.

 

 

6. 아마 30개씩 15페이지 정도의 옵션들이 나오게 되는데 여기서 약 3페이지정도에 가보면 wp_user_roles 라고 나올 겁니다. 이 것을 수정을 눌러 ‘option_name‘에 값을 변경된 접두어로 수정해서 넣은 뒤 실행을 누릅니다.

DB 테이블에서  wp_usermeta 이였던 테이블안에도 여전히 기존의 접두어들을 가진 meta_key들이 있기 때문에 여전히 ‘이 페이지에 접근할 권한이 없습니다.‘라고 나올 겁니다.

 

7. PhpMyAdmin에서 테이블 목록이 있는 곳에서 상단의 SQL 버튼을 누릅니다.

 

8. 입력창에 접두어가 변경된 wp_usermeta 테이블 이름을 넣고 meta_key 중에서 wp_를 찾아 바꾸려는 접두어로 변경하게 입력합니다.
저 같은 경우 wp_를 hwp_로 바꾸기 때문에 hwp_usermeta라고 썼고 meta_key 부분에도 hwp_로 바꾸게 입력하였습니다.

 

실행을 눌러 완료가 되면 아래처럼 결과 화면이 나옵니다.


----------



이후, prefix_options - sitesurl 값을 경로에맞게 변경을 해주어야한다. 


출처 : http://naminsik.com/blog/2829

NGINX + WORDPRESS + 멀티페이지 설치방법
1. wp-config.php 파일 설정

define('WP_ALLOW_MULTISITE', true);

2. wp관리자 로그인 - 도구 - 네트워크 설정 중 wp-config.php 파일 내 수정코드 수정

define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', true);
define('DOMAIN_CURRENT_SITE', 'examplewp.com');
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1); 

 * 반드시 1번 코드를 삭제해주어야함.. 이것도 모르고 계속 같이 반영했다가 삽질..


/------- 참고 -------/

Introduction

WordPress's multisite feature offers the ability to create multiple websites from a single installation of WordPress. Each site can have a separate theme, set of plugins, and collection of content (posts and pages). This reduces the overhead of maintaining and updating several installations of WordPress, while allowing you to host multiple sites which are totally unrelated to one another.

WordPress multisite comes in two flavours: subdirectory or subdomain. In this tutorial, we will set up WordPress multisite to use subdomains. That means that sites we create will have a subdomain web address like http://wp-site.yourdomain.com. This can be mapped to an external domain like http://wp-site.net so that each site looks independent from the outside.

Prerequisites

This tutorial requires the user to have a knowledge of the following:

We will be creating three WordPress sites with the following domain names:

  • Site 1:

    Domain: examplewp.com (Primary domain)

    This is the site that is created when WordPress is installed.

  • Site 2:

    External Domain: shoppingsite.com

    Subdomain: shoppingsite.example.com

  • Site 3:

    External Domain: companysite.org

    Subdomain: companysite.example.com

The first domain is the primary domain name through which WordPress will be installed. Make sure to set up DNS for all three domains to point to the IP address of the Droplet which will host WordPress.

Step One - Set Up DNS Wildcard Records

In this section, we will add a DNS wildcard record for the primary domain so that more sites can be added at any time, without needing individual A records. (Alternately, you can add a new A record for each subdomain.)

Note: This has to be done only for the *primary domain (examplewp.comin this tutorial).

Log in to your DigitalOcean control panel and navigate to the Networking section. Edit the primary domain and create a wildcard A record for this domain pointing to the Droplet's IP address. A wildcard record is created by entering an asterisk (*) in the hostname input box as shown in the screenshot below.

DNS Control Panel - wildcard record

If you host your domain's DNS elsewhere, you should set the wildcard record there instead.

What you should see now:

DNS queries for any random-sub-domain.examplewp.com should return the IP address of your Droplet.

Step Two - Install and Configure the LEMP Stack

In this section, we will install and configure Nginx, MySQL, and PHP. There is a detailed article on setting up a LEMP stack that you can reference if you would like to. This section will serve as a quick setup. There is also a LEMP on Ubuntu 14.04 image under the Applications tab in the Select Image section when creating a Droplet.

Update the repositories and install Nginx, MySQL, PHP5-FPM and other necessary PHP modules.

apt-get update
apt-get install -y nginx mysql-server php5-fpm php5-mysql php5-curl php5-mcrypt php5-gd

When MySQL server is being installed, you will be prompted to enter a password for the root database user. Please enter a strong password and do not leave it blank. You will enter the password twice.

MySQL root password

Create a document root for Nginx which will hold the WordPress files. We will use /usr/share/nginx/wordpress throughout this tutorial.

mkdir /usr/share/nginx/wordpress

We will replace Nginx's default virtual host with our own, so remove its symlink in the sites-enableddirectory.

rm /etc/nginx/sites-enabled/default

Create a new virtual host file inside the sites-available directory. This file can be named anything. In our example, we will call it wp-ms.

nano /etc/nginx/sites-available/wp-ms

Edit this file and place the following configuration. Edit the text highlighted in red according to your environment. In the server_name line, you should add all three (or more) of your multisite domains, and the wildcard subdomain for the first domain.

server {
    listen [::]:80 ipv6only=off;
    server_name examplewp.com *.examplewp.com shoppingsite.com companysite.org;

    root /usr/share/nginx/wordpress;
    index index.php index.html index.htm;

    location / {
        try_files $uri $uri/ /index.php?$args ;
    }

    location ~ /favicon.ico {
        access_log off;
        log_not_found off;
    }

    location ~ \.php$ {
        try_files $uri /index.php;
        include fastcgi_params;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
    }

    access_log  /var/log/nginx/$host-access.log;
    error_log   /var/log/nginx/wpms-error.log;
}

If this Droplet will host only this WordPress installation, the listen and server_name directives can be changed to the following:

listen [::]:80 default_server ipv6only=off;
server_name examplewp.com *.examplewp.com;

The use of the $host variable in the access_log directive creates separate log files for each domain like examplewp.com-access.log and shoppingsite.com-access.log. It is not possible to use such variables for the error_log directive, so all errors are logged in a single file.

Save this file and create a symlink of this file inside the sites-enabled directory.

ln -s /etc/nginx/sites-available/wp-ms /etc/nginx/sites-enabled/wp-ms

Execute an Nginx configuration test and restart if it returns OK.

service nginx configtest
service nginx restart

Step Three - Create a MySQL Database and User for WordPress

In this section, we will create a MySQL database for WordPress and a user with permissions for this database only.

Log in to the MySQL command line as the root user.

mysql -u root -p

Create a database.

CREATE DATABASE wordpress;

Create a MySQL user and grant permissions to this database:

CREATE USER 'wordpress_user'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpress_user'@'localhost';

Replace the word password with a strong password. Flush the privileges and exit the MySQL command line.

FLUSH PRIVILEGES;
exit

Note down these details as will be needing them in Step Four.

Database Name: wordpress

Database User: wordpress_user

Database Password: password

More information about MySQL users can be found in this article.

Step Four - Download and Install WordPress

In this section, we will download the latest version of WordPress and install it. This will be for our first site, examplewp.com.

Download and extract WordPress.

wget http://wordpress.org/latest.tar.gz
tar -xf latest.tar.gz

Move the extracted files into the document root.

mv wordpress/* /usr/share/nginx/wordpress/

Assign ownership to the user www-data. This is essential for media uploads and for core/plugin/theme updates to work in WordPress.

chown -R www-data:www-data /usr/share/nginx/wordpress

Access the primary domain in your browser to begin the WordPress installation.

http://examplewp.com/

You can add the "www" suffix to the URL if needed. Click the Create a Configuration File button followed by the Let's go! button. Fill in the database details (use the information from Step Three) and click Submit.

WordPress database details

At this point, WordPress will establish a connection with the database to test the entered credentials. Once the connection succeeds, the Run the install button appears. Click on it. Complete the Information needed form to set up your site title, username, password, and email, and then click Install WordPress. It is recommended to choose a non-generic username for security.

WordPress welcome screen

Step Five - Enable Multisite and Create Additional Sites

In this section, we will enable WordPress Multisite and create the two additional sites mentioned in the Prequisites section of this article.

PHP constant has to be defined in the wp-config.php file to enable the Network Setup page.

Edit the wp-config.php file:

nano /usr/share/nginx/wordpress/wp-config.php

Add the following code before the comment /* That's all, stop editing! Happy blogging. */:

/* Multisite settings */
define( 'WP_ALLOW_MULTISITE', true );

We will be editing this file a few more times during this tutorial. Feel free to add all of the new lines in the /* Multisite settings */ section we just created.

Save the file. Log in to the WordPress admin panel and navigate to Tools > Network Setup. Choose the Sub-domains option, modify the Network Title as desired, and then click Install.

WordPress Network Setup

You will be presented with two blocks of code to be added in the wp-config.php and .htaccess files. Copy the wp-config.php code which looks similar to the following:

define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', true);
define('DOMAIN_CURRENT_SITE', 'examplewp.com');
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);

Edit the wp-config.php file.

nano /usr/share/nginx/wordpress/wp-config.php

Add these lines before the comment /* That's all, stop editing! Happy blogging. */ and save it. The code displayed for .htaccess can be ignored, as Nginx does not have this file.

Log out of the WordPress admin panel, and log in again. From the admin toolbar on the top left, navigate to the My Sites > Network Admin > Sites.

WordPress Toolbar

Click the Add New button to open the Add New Site form. The following screenshot shows the filled-in details for the shopping site in our example. The Site Address entered will form the subdomain of this site.

Creating a new WordPress site

Click Add Site and the created site will be accessible via http://shoppingsite.examplewp.com.

Repeat these steps to create the second site (companysite.examplewp.com in our example).

What you should see now:

The following three WordPress sites:

  • examplewp.com
  • shoppingsite.examplewp.com
  • companysite.examplewp.com

Each of them will have their own content, theme, and active set of plugins.

Step Six - Set Up Domain Mapping

In this section, we will enable you to use a separate domain name for each WordPress site, by downloading and enabling the WordPress MU Domain Mapping plugin. This plugin allows users of WordPress Multisite to map their blog/site to another domain.

Log in to your Droplet via SSH and download the WordPress MU Domain Mapping plugin. First install the unzip command, and then extract the plugin.

wget http://downloads.wordpress.org/plugin/wordpress-mu-domain-mapping.latest-stable.zip
apt-get install unzip
unzip wordpress-mu-domain-mapping.latest-stable.zip

Move the extracted files to the WordPress plugin directory.

mv wordpress-mu-domain-mapping /usr/share/nginx/wordpress/wp-content/plugins/

Copy the sunrise.php file from the plugin's directory to the wp-content directory.

cp /usr/share/nginx/wordpress/wp-content/plugins/wordpress-mu-domain-mapping/sunrise.php /usr/share/nginx/wordpress/wp-content/

Edit the wp-config.php file and add the following line before the comment /* That's all, stop editing! Happy blogging. */.

File: /usr/share/nginx/wordpress/wp-config.php

define('SUNRISE', 'on');

Save this file and return to the web browser. From the WordPress toolbar navigate to My Sites > Network Admin > Plugins.

Plugins

Click the Network Activate link under the WordPress MU Domain Mapping plugin. Go to Settings > Domain Mapping and make changes to the Domain Options as follows:

  • Uncheck Remote Login
  • Check Permanent Redirect
  • Uncheck Redirect administration pages to site's original domain

Domain mapping options

Click Save once done. These settings redirect all requests for subdomains (like companysite.examplewp.com) to their respective external domains (like companysite.org) including the administration pages (/wp-admin).

In the next step we will be mapping a domain name to each site based on its site ID. There are many ways to find the ID of a site but for easier administration we will create a simple WordPress Must-use plugin that displays an additional ID column on the Sites page.

Log in to your Droplet via SSH and create an mu-plugins directory.

mkdir /usr/share/nginx/wordpress/wp-content/mu-plugins

Create a PHP file inside this directory and paste the code that follows:

nano /usr/share/nginx/wordpress/wp-content/mu-plugins/wpms_blogid.php

You can copy this content exactly:

<?php
add_filter( 'wpmu_blogs_columns', 'do_get_id' );
add_action( 'manage_sites_custom_column', 'do_add_columns', 10, 2 );
add_action( 'manage_blogs_custom_column', 'do_add_columns', 10, 2 );

function do_add_columns( $column_name, $blog_id ) {
    if ( 'blog_id' === $column_name )
        echo $blog_id;
    return $column_name;
}

function do_get_id( $columns ) {
    $columns['blog_id'] = 'ID';
    return $columns;
}

The Sites > All Sites section should now show an additional ID column.

ID

Note down the ID values for each site and go to the Settings > Domains page. Enter the site ID followed by the external domain for the site. For example, since companysite has an ID of 3, on this page, the Site ID should be 3, and the domain should be companysite.org.

Mapping a site ID to a domain

You may add a "www" prefix if you wish to set the site URL as www.companysite.org. Repeat these steps for the other domains. Click Save at the bottom of the page.

What you should see now:

Each site will have its own domain name instead of a subdomain; i.e., entering http://companysite.org in your browser will open the My Online Company Site. You can check this now by visiting http://shoppingsite.com and http://companysite.org. You should see the site title change in the upper left corner of the page.

Now each site can be maintained separately through its own WordPress admin panel:

http://examplewp.com/wp-admin/
http://shoppingsite.com/wp-admin/
http://companysite.org/wp-admin/

Updates to the core/plugins/themes and installation of plugins/themes should be done from the network admin page of the primary domain:

http://examplewp.com/wp-admin/network/


* 출처 : https://www.digitalocean.com/community/tutorials/how-to-set-up-wordpress-multisite-with-nginx-on-ubuntu-14-04





워드프레스 + 그누프레스 + NGINX 환경에서 구축 중



멀티페이지 설정 중 /wp/wp-config.php 파일 건들다가 로그인 후에도 로그인페이지로 계속 리다이렉트 되는 문제 발생하여 아래와같이 셋팅 후 이상없음




/* That's all, stop editing! Happy blogging. */

/*define('MULTISITE', true);*/

define('WP_ALLOW_MULTISITE', true);

define('DOMAIN_CURRENT_SITE', 'bobss.ml');

define('PATH_CURRENT_SITE', '/wp/');

define('SITE_ID_CURRENT_SITE', 1);

define('BLOG_ID_CURRENT_SITE', 1);



아주 간단하게 만들어봤다. 이해는 안됨.

일단 결과물


소스코드 입력부분에 광고로 삽입할 광고코드 입력(현재 애드젯광고 사용해봄)



소스퍼가기 해서 소스 퍼간다음,  삽입!


광고입력후 화면


오른쪽 위젯부분에 잘 들어갔다...


사용코드 ::

저번에 위젯만들기1에서 사용한 코드를 기본으로, 위젯 설정창에서 만든 상태라면

이렇게 나온다.




이부분을 작성하려면 아래코드 추가

 
function form($instance){
  //// 내용
}

이 코드를 추가만 해주고 내부에 코드를 작성하면 바로 뜬다. 사용한 실제코드

function form($instance){
	echo"광고 소스 입력 ::";
		$field_id = $this->get_field_id('adSource');
		$field_name = $this->get_field_name('adSource');
?>
      

광고삽입

"; echo "
$instance[adSource]
"; }

코드에서  <!--php 부분은 알아서 수정.

form에서 textarea에 작성된값을 $instance[adSource]에 받아

widget 에서 가져오는 구조인듯 하다....









PSS Widget 

- pssplugin.php (기본) 한개로 구성됨 (글 작성중 현재상태 12/08/10)

왼쪽의 설정부분

function pss_settings_link($links) {
	$links[] = ''.__('설정').'';
	return $links;
}
add_filter('plugin_action_links_'.plugin_basename(__FILE__), 'pss_settings_link', 10, 1);
오른쪽 부분
function pss_setting_link($links, $file) {
	if ($file == plugin_basename(__FILE__)) {
		$links[] = ''.__('설정', 'pss').'';
		$links[] = ''.__('기타', 'sfc').'';
	}
	return $links;
}
add_filter('plugin_row_meta', 'pss_setting_link', 10, 2);


기본 파일 위치 /wordpress/wp-content/plugins/만드려는위젯_이름.php

코드 상단에 아래코드 삽입



기본구조는

class 이름 extends WP_Widget

 function 이름 ( ) {

$widget_options = array ( 'classname' => '이름' , 'description' => '설명' ) ;         $this -> WP_Widget ( '이름' , '위젯이름' , $widget_options ) ; 

 } 

 function widget ( $args , $instance ) {

//실제로 보여지는 부분

}

add_action ( 'widgets_init' , create_function ( '' , 'return register_widget("이름");' ) ) ; ?>





워드프레스 루프문 기본

 

'루프전용' 함수들

현재 포스트의 제목

각 포스트의 고유주소 URL을 표시

각 포스트의 ID

각 포스트의 작성자 이름을 표시

각 포스트가 속해있는 카테고리 표시



워드프레스 한글언어팩에 기본 테마는 이미 곰님의 수정으로 사용하는데 무리가 없지만, 해외에서 제작된 250여개가 넘는 워드프레스 테마를 만끽하기 위해선 테마 파일의 수정이 반드시 필요하다. 코덱스에 워드프레스의 테마를 구성하는 파일들을 간단하게 설명하고 있지만, 내 나름대로, 테터툴의 스킨과 비교하여 조금은 구체적으로 파헤처 볼 생각이다.

기본적으로 워드프레스에서 반드시 필요한 파일은 기본 템플릿 파일인 index.php 이다. 테터툴과 마찬가지로 index.php 파일 하나만으로도 블로그를 구성할 수는 있다. 테마 만드는 사람 마음일 것이다. 다만, 답글까지 한꺼번에 보여준다면, 아니 보여주지 않고 숨겨놓더라도 파일을 읽는데 소요되는 시간은 상당할 것이다. 즉, 파일의 크기나 트래픽량의 증가는 감수할 수 있다면, index.php 파일 하나만으로도 상관없다.

이런 이유에서 워드프레스에서 또 하나의 중요한 파일이 single.php 이다. 파일명처럼 글 하나를 볼때 사용되는 파일이다. single.php 와 함께 다니는 파일은 comment.php 이다. 답글(꼬릿말)이나 트랙백, 핑백의 내용을 보여주며 답글을 작성할 수 있도록 하는 파일이다. 트랙백 주소도 이곳에 표현된다.

Style.css 는 구조화된 워드프레스 테마 템플릿의 시각적인 부분을 담당한다.이미지, 배경색/이미지/아이콘, 폰트 크기/색, 박스 크기/색 등 눈으로 볼 수 있는 대부분을 정의하는 파일이다. 이는 인라인 스타일을 사용하는 대부분의 테터툴 스킨과 다른점이다.Style.css를 수정하기 위해서는 Topstyle pro 3과 같은 프로그램을 이용하는 것이 편리할 것이다.

여기까지만 보면, 테터툴의 index.php 파일을 워드프레스에서는 index.php + single.php + comment.php + style.css 파일로 쪼개 논 것 같다. 맞다. 파일의 효율성을 위해서 독립시킨 것이다. 여기에 다양한 레이아웃을 보여줄 수 있도록 category.php achive.php

예전에 한번 비교해보니 워드프레스 기본테마의 필수 파일 3가지(style.css 제외)를 합친 것이 테터툴 기본스킨의 index.php 파일보다 크기가 훨씬 작았던 것으로 기억난다. 이는 table 레이아웃과 div + CSS 레이아웃의 차이점이랄 수 있다.

아래는 일반적으로 워드프레스의 테마에 포함된 파일 구조이다.

  • inde.php : 기본 템플릿 파일 (대부분 아래의 파일로 분리됨)
    • header.php : 상단에 항상 표현되는 파일
    • footer.php : 하단 항상 표현되는 파일
  • style.css : 기본 스타일 파일 (경우에 따라 아래 파일들로 분리됨)
    • layout.css : 레이아웃을 구성하는 파일
    • default.css : 기본적인 클랙스나 아이디를 구성하는 파일
    • print.css : 블로그 내용을 프린트할 때 사용되는 파일
  • single.php : 글 하나만 볼 때 사용되는 파일
    • comment.php : 답글을 쓸때 사용되는 파일
    • comment-popup.php : 팝업창으로 답글을 쓸때 사용되는 파일
  • sidebar.php : 사이드바(메뉴)를 구성하는 파일
    • sidebar-left.php : 3단 구조에서 왼쪽 사이드바를 구성하는 파일
    • sidebar-right.php : 3단 구조에서 오른쪽 사이드바를 구성하는 파일
  • search.php : 검색결과를 보여주는 파일
  • archive.php : 글 묶음을 볼 때 사용되는 파일
    • category.php : 글의 분류에 따라 글을 볼때 사용
    • date.php : 년, 월, 일별로 글을 볼 때 사용
  • page.php : 블로그 글과 다른 정적인 형식인 페이지를 볼때 사용
    • archives.php : 기본적인 페이지 템플릿
    • author.php : 블로그 주인을 소개할 때 사용하는 페이지 템플릿
    • contact.php : 이메일을 발송할 관련 페이지의 템플릿
    • link.php : 링크 관련 페이지의 템플릿
  • 404.php : 블로그에 없는 파일을 찾을 때 보여주는 파일

'공부 > Wordpress' 카테고리의 다른 글

제작한 플러그인에 설정메뉴 넣기  (0) 2012.08.10
위젯 만들기  (0) 2012.08.10
루프문설명  (0) 2012.08.08
관리자모드에 Custom 플러그인 메뉴 추가하기  (0) 2012.08.06
워드프레스 page에 template  (0) 2012.08.03

+ Recent posts