클래스 추가하기 문의드립니다. – 한국워드프레스사용자모임 https://kopress.kr/topic/%ed%81%b4%eb%9e%98%ec%8a%a4-%ec%b6%94%ea%b0%80%ed%95%98%ea%b8%b0-%eb%ac%b8%ec%9d%98%eb%93%9c%eb%a6%bd%eb%8b%88%eb%8b%a4/feed Mon, 21 Jul 2025 13:56:06 +0000 https://bbpress.org/?v=2.6.9 ko-KR https://kopress.kr/topic/%ed%81%b4%eb%9e%98%ec%8a%a4-%ec%b6%94%ea%b0%80%ed%95%98%ea%b8%b0-%eb%ac%b8%ec%9d%98%eb%93%9c%eb%a6%bd%eb%8b%88%eb%8b%a4/#post-6717 <![CDATA[클래스 추가하기 문의드립니다.]]> https://kopress.kr/topic/%ed%81%b4%eb%9e%98%ec%8a%a4-%ec%b6%94%ea%b0%80%ed%95%98%ea%b8%b0-%eb%ac%b8%ec%9d%98%eb%93%9c%eb%a6%bd%eb%8b%88%eb%8b%a4/#post-6717 Wed, 16 Jan 2013 08:55:51 +0000 anonymousome function.php 파일을 이용하여

 

Admin Bar에 클래스를 추가하는 함수 문제입니다.

 

현제 테스트페이지는

http://t2p.woobi.co.kr/test-page/

이구요.

 

제가 하고싶은 기능은

이렇게 되어있는 부분에 클래스를 추가하여

로 만들고자 합니다.

 

제가 구현해본 함수는

 


function add_class_adminbar() {
if ( is_singular() ) { ?>

$(document).ready(function () {
$("div").addClass(function (index, currentClass) {
if (currentClass == "toggleme") {
return "customclass";
}
});
});
<?php
}
}
add_action( 'wp_footer', 'add_class_adminbar' );

 

인데 작동을 안하네요;;;
 
추가사항으로는
플러그인으로 WordPress Admin Bar Improved을 사용하고 있구요

저기 나오는 toggleme 클래스는 위 플러그인에서 생성한 클래스입니다.

조언좀 부탁드립니다.

]]>
https://kopress.kr/topic/%ed%81%b4%eb%9e%98%ec%8a%a4-%ec%b6%94%ea%b0%80%ed%95%98%ea%b8%b0-%eb%ac%b8%ec%9d%98%eb%93%9c%eb%a6%bd%eb%8b%88%eb%8b%a4/#post-6719 <![CDATA[Reply To: 클래스 추가하기 문의드립니다.]]> https://kopress.kr/topic/%ed%81%b4%eb%9e%98%ec%8a%a4-%ec%b6%94%ea%b0%80%ed%95%98%ea%b8%b0-%eb%ac%b8%ec%9d%98%eb%93%9c%eb%a6%bd%eb%8b%88%eb%8b%a4/#post-6719 Thu, 17 Jan 2013 00:37:21 +0000 082net 1. 페이지를 보니 우선 jquery 라이브러리를 로드하지 않았더군요. twentytwelve 테마를 사용하시던데, 혹시 child 테마를 만들어 사용하실 수 있다면 그렇게 하시고, 잘 모르시겠으면 테마의 functions.php 파일에 보면 twentytwelve_scripts_styles() 함수가 있을겁니다. 거기에 jquery 라이브러리 불러오는 구문을 한 줄 추가해 주시면 됩니다.

[code title=”함수수정”]
function twentytwelve_scripts_styles() {
global $wp_styles;

wp_enqueue_script(‘jquery’);
…..
[/code]

2. 워드프레스에서는 다른 자바스크립트 라이브러리와의 충돌을 막기위해 jQuery의 $를 바로 사용할 수 없습니다. 그리고 adminbar 하위의 모든 div에 CSS Class를 추가하는것이 아니라면 ‘#wpadminbar > div’ 를 사용하시는게 더 좋지 않을까 합니다.
[code title=”jQuery”]
jQuery(document).ready(function($){
$(“‘#wpadminbar > div'”).add……();
});
[/code]

Avatar of 082net
Facebook 사용자 모임 그룹 도 함께 운영되고 있으며, 격 주로 미트업과 스터디를 진행하고 있으니 관심 있으신 분들의 많은 참여 바랍니다 🙂
]]>
https://kopress.kr/topic/%ed%81%b4%eb%9e%98%ec%8a%a4-%ec%b6%94%ea%b0%80%ed%95%98%ea%b8%b0-%eb%ac%b8%ec%9d%98%eb%93%9c%eb%a6%bd%eb%8b%88%eb%8b%a4/#post-6720 <![CDATA[Reply To: 클래스 추가하기 문의드립니다.]]> https://kopress.kr/topic/%ed%81%b4%eb%9e%98%ec%8a%a4-%ec%b6%94%ea%b0%80%ed%95%98%ea%b8%b0-%eb%ac%b8%ec%9d%98%eb%93%9c%eb%a6%bd%eb%8b%88%eb%8b%a4/#post-6720 Thu, 17 Jan 2013 01:37:49 +0000 anonymousome 감사합니다.

 

$를 바로 사용할 수 있는게 아니었군요

 

jQuery로 바꿔서 작동하니 잘 생성이 되네요

 

조언 감사합니다^^

]]>