SSamTure.net

워드프레스

고유주소 기본값 변경하기(?p=123 을 ?p=%post_name% 으로)

워드프레스 고유주소(permalink)를 기본값(default)로 이용하다 보면 특이한 점을 발견 할 수 있을 것이다.

drugstore

buying us online cialis

포토폴리오 같은 것을 지원하는 테마 즉, 커스텀 포스트타입이 있는 테마의 경우 사이트 주소가 포스트나 페이지는

?p=123 또는 ?page_id=123 으로 나오는데 커스텀 포스트타입은 ?work=job 처럼 타이틀로 나오는 것이다.

정확히 말하면 타이틀이 아닌 포스트 네임(post_name)으로 주소가 출력되는 것을 볼 수 있을 것이다.

오늘은 일반 포스트도 커스텀 포스트타입처럼 고유주소가 기본값일 때 ?p=%post_name% 으로 출력하고 처리하는 방법에 대해 살펴보도록 하자.

일단 말이 너무 어려우니 이미지를 통해 무슨 말을 하는 건지 살펴보자^^;;

image

<포스트의 기본값 고유주소>

image

<커스텀 포스트 타입의 기본값 고유주소>

이미지와 같이 커스텀 포스트 타입의 경우에는 포스트 네임으로 주소가 생성되고, 포스트의 경우는 포스트 아이디 값으로 고유주소가 생성된다.

다음의 예제를 테마의 functions.php 상단 또는 별도로 플러그인으로 만들어서 테스트를 진행해보자.

image

image

mh_permlink_filter 함수에 의하여 표시되는 링크들이 변경되며, mh_request_filter 에 의하여 변경된 링크로 접속 할 시 원래 링크로 온것처럼 변경하는 구조이다.

모두 필터 후크(post_link, request)를 이용한 것이다.

6 Comments

  1. seo Milton Keynes
    2014/05/29 at 21:12 · Reply

    Heya! I’m at work browsing your blog from my new iphone!

    Jusst wanted to say I lpve reading through your blog and look forward to
    all your posts! Keep up tthe superb work!

  2. But, they make up such a small percent of the entire industry.
    Technical specifications for motor oils can generally be found on the particular brand’s website, although
    sometimes it may be necessary to contact the company to ask that they provide them.
    This is why the old practice of changing
    straight grade oils to a heavier viscosity in the summer and a
    lighter viscosity in the winter is no longer necessary.

  3. Bootlegger Moonshine Stills
    2014/06/28 at 03:34 · Reply

    Oh my goodness! Awesome aticle dude! Thank you so much, Howecer I am having problems
    with your RSS. I don’t know the reason whhy I cannot subscribe to it.

    Is there anybody else having identical RSS issues? Anyne who
    knows the solution can you kindly respond?
    Thanx!!

  4. san ramon trails
    2014/08/24 at 13:08 · Reply

    What i do not understood is in fact how you’re no longer really

    much more neatly-appreciated than you might be right now.

    You are so intelligent. You realize therefore

    significantly with regards to this topic, made me in my opinion imagine it from numerous various

    angles. Its like men and women don’t seem to be interested unless it is one thing to do with Lady gaga!

    Your individual stuffs nice. Always handle it up!

  5. oil-bg.com
    2014/10/05 at 23:11 · Reply

    Having a mechanic do your oil change is a good idea if you do not
    have much experience with car engines. VOC or Volatile
    Organic Compounds are organic solvents that easily evaporate into the air.
    Ground water that is contaminated by only one quart of oil affects up to 250,000 gallons of drinking
    water.

Leave a Reply to san ramon trails Cancel reply

Your email address will not be published. Required fields are marked *