برگزیده های پرشین تولز

سفارشی سازی برگه وردپرس و افزودن کد جاوا اسکریپت

semnani

Registered User
تاریخ عضویت
15 اکتبر 2012
نوشته‌ها
131
لایک‌ها
57
سلام
برای ساخت یک برگه خام در وردپرس به مشکل برخوردم
من برای اینکه جدول برگه هامو هوشمند سازی کنم تصمیم گرفتم برگه سفارشی مخصوص اینکار را درست کنم
این اسکریپتی هست که پیدا کردم با کد زیر میشه امکان سرچ محتوای لیست رو به برگه اضافه کرد

PHP:
   <head>
     <style type="text/css">
       body {padding: 20px;}
       input {margin-bottom: 5px; padding: 2px 3px; width: 209px;}
       td {padding: 4px; border: 1px #CCC solid; width: 100px;}
     </style> 
    </head>
   <body>
    <input type="text" id="search" placeholder="Type to search">
      <table id="table">
      <tr> <td>Apple</td>
           <td>Green</td>
      </tr>
      <tr> <td>Grapes</td>
           <td>Green</td>
      </tr>
      <tr> <td>Orange</td>
           <td>Orange</td>
      </tr>
   </table>
   <script src="http://code.jquery.com/jquery-2.1.0.js"></script>
   <script type="text/javascript">
     var $rows = $('#table tr');
     $('#search').keyup(function() {
         var val = $.trim($(this).val()).replace(/ +/g, ' ').toLowerCase();

         $rows.show().filter(function() {
             var text = $(this).text().replace(/\s+/g, ' ').toLowerCase();
             return !~text.indexOf(val);
         }).hide();
     });
    </script>
    </body>

پیشنمایشی از عملکرد | دمو
مشکلی که دارم اینکه اولا نمیخوام این اسکریپت رو فقط یک بار استفاده کنم و دوما نمیخوام از طریق هاست جداولش رو پر کنم
بلکه میخوام با ساخت یک برگه مادر تمام برگه های که در وردپرس میسازم و توش جدول هست رو ساپورت کنه

لطفا بفرمایید کجای کد رو باید تغییر بدم تا این کد یک بار مصرف نباشه (در یک کلام قصد دارم تیبل رو متغیر کنم)
 

semnani

Registered User
تاریخ عضویت
15 اکتبر 2012
نوشته‌ها
131
لایک‌ها
57
من این برگه رو ساختم
PHP:
<?php
/*
Template Name: 1
*/
?>
<?php get_header(); ?>
    <div class="content">
        <?php tie_breadcrumbs() ?>
      
        <?php if ( ! have_posts() ) : ?>
            <div id="post-0" class="post not-found post-listing">
                <h1 class="post-title"><?php _e( 'Not Found', 'tie' ); ?></h1>
                <div class="entry">
                    <p><?php _e( 'Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.', 'tie' ); ?></p>
                    <?php get_search_form(); ?>
                </div>
            </div>
        <?php endif; ?>
      
        <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
        <?php
            if( function_exists('bp_current_component') && bp_current_component() ) $current_id = get_queried_object_id();
            else $current_id = $post->ID;
            $get_meta = get_post_custom( $current_id );

            if( !empty( $get_meta['tie_review_position'][0] ) ){
                $review_position = $get_meta['tie_review_position'][0] ;
                $rv = $tie_reviews_attr;
            }
          
            $post_width = $get_meta["tie_sidebar_pos"][0];
            if( $post_width == 'full' ) $content_width = 955;
        ?>
        <?php //Above Post Banner
        if( empty( $get_meta["tie_hide_above"][0] ) ){
            if( !empty( $get_meta["tie_banner_above"][0] ) ) echo '<div class="ads-post">' .htmlspecialchars_decode($get_meta["tie_banner_above"][0]) .'</div>';
            else tie_banner('banner_above' , '<div class="ads-post">' , '</div>' );
        }
        ?>
      
        <article <?php if( !empty( $rv['review'] ) ) echo $rv['review']; post_class('post-listing post'); ?>>
            <?php get_template_part( 'includes/post-head' ); ?>
            <div class="post-inner">
                <h1 class="name post-title entry-title" itemprop="itemReviewed" itemscope itemtype="http://schema.org/Thing"><span itemprop="name"><?php the_title(); ?></span></h1>
                <p class="post-meta"></p>
                <div class="clear"></div>
                <div class="entry">
    <head>
     <style type="text/css">
       body {padding: 20px;}
       input {margin-bottom: 5px; padding: 2px 3px; width: 209px;}
       td {padding: 4px; border: 1px #CCC solid; width: 100px;}
     </style>  
    </head>
   <body>
    <input type="text" id="search" placeholder="Type to search">
      <table id="table">
<colgroup style="background-color:#6CF"></colgroup>
<colgroup style="background-color:#CCC"></colgroup>
<colgroup style="background-color:#FC0;"></colgroup>
<tr>
<th>رتبه</th>
<th>امتیاز</th>
<th>نام</th>
</tr>
      <tr>
           <td>1</td>
           <td>Apple</td>
           <td>Yellow</td>
      </tr>
      <tr>
           <td>2</td>
           <td>Grapes</td>
           <td>Green</td>
      </tr>
      <tr>
          <td>3</td>
          <td>Lemo</td>     
          <td>Orange</td>
      </tr>
   </table>
   <script src="http://code.jquery.com/jquery-2.1.0.js"></script>
   <script type="text/javascript">
     var $rows = $('#table tr');
     $('#search').keyup(function() {
         var val = $.trim($(this).val()).replace(/ +/g, ' ').toLowerCase();

         $rows.show().filter(function() {
             var text = $(this).text().replace(/\s+/g, ' ').toLowerCase();
             return !~text.indexOf(val);
         }).hide();
     });
    </script>
    </body>
                </div><!-- .entry /-->  
                <span style="display:none" class="updated"><?php the_time( 'Y-m-d' ); ?></span>
                <?php if ( get_the_author_meta( 'google' ) ){ ?>
                <div style="display:none" class="vcard author" itemprop="author" itemscope itemtype="http://schema.org/Person"><strong class="fn" itemprop="name"><a href="<?php the_author_meta( 'google' ); ?>?rel=author">+<?php echo get_the_author(); ?></a></strong></div>
                <?php }else{ ?>
                <div style="display:none" class="vcard author" itemprop="author" itemscope itemtype="http://schema.org/Person"><strong class="fn" itemprop="name"><?php the_author_posts_link(); ?></strong></div>
                <?php } ?>
              
            </div><!-- .post-inner -->
        </article><!-- .post-listing -->
        <?php endwhile; ?>
      
        <?php //Below Post Banner
        if( empty( $get_meta["tie_hide_below"][0] ) ){
            if( !empty( $get_meta["tie_banner_below"][0] ) ) echo '<div class="ads-post">' .htmlspecialchars_decode($get_meta["tie_banner_below"][0]) .'</div>';
            else tie_banner('banner_below' , '<div class="ads-post">' , '</div>' );
        }
        ?>
      
        <?php if( !function_exists('bp_current_component') || (function_exists('bp_current_component') && !bp_current_component() ) )  comments_template( '', true );  ?>
    </div><!-- .content -->

<?php get_sidebar(); ?>
<?php get_footer(); ?>

تنها مشکلی که داره اینکه که جای اینکه اطلاعات جدول رو از برگه وردپرس فراخوان کنه میگیره از خود برگه مادری که ساختم باز خوانی می کنه

حال میخوام بغییر از تگ های عنوان (th) و استایل (colgroup) جدول ردیف اول بقیه جدول از برگه هام بازخوانی بشه
 

shahrokh4u

Registered User
تاریخ عضویت
18 اکتبر 2012
نوشته‌ها
571
لایک‌ها
408
محل سکونت
Esfahan
دوست عزیز شما وقتی یک قالب سفارشی ساختید وردپرس اطلاعات رو از قالب سفارشی می گیره. برای موردی که ذکر کردید از افزونه ی زیر استفاده کنید
wordpress.org/plugins/tablepress/

اطلاعات راهنمای افزونه:
http://tablepress.org/documentation/
 

semnani

Registered User
تاریخ عضویت
15 اکتبر 2012
نوشته‌ها
131
لایک‌ها
57
ممنون که پاسخ دادید
این پلاگین با زبان فارسی مشکل داره ، دیروز باهاش کار کردم حروف فارسی رو عدد نشون میده ، نسخه فارسیشم نصب کردم بازم همین مشکلو داشتم
و از نظر سئو مناسب برگه ها نیست ، محتوا باید ایندکس بشه

در هر حال فکر کنم بشه تیبل متغیر ایجاد کرد
 

semnani

Registered User
تاریخ عضویت
15 اکتبر 2012
نوشته‌ها
131
لایک‌ها
57
هم اکنون به یاری سبزتان نیازمندیم
 

semnani

Registered User
تاریخ عضویت
15 اکتبر 2012
نوشته‌ها
131
لایک‌ها
57
یعنی هچ کی نظری نداره ؟
من یک کد دیدم که اطلاعات جداول رو مستقیم از دیتابیس بارگذاری می کنه حالا چطور ممکنه همچین کدی واسه بارگذاری اطلاعات از page وجود نداشته باشه؟
 

shahrokh4u

Registered User
تاریخ عضویت
18 اکتبر 2012
نوشته‌ها
571
لایک‌ها
408
محل سکونت
Esfahan
سلام مجدد دوست عزیز. پلاگین مشکلی نداره فقط باید فونت صحیح و یه خورده ویرایش درونش اعمال بشه و از نظر سئو هم هیچ مشکلی بوجود نخواهد اومد. اگر قصد داشته باشید جداول از برگه ها و پست ها بازخوانی بشه باید ساختار حلقه و تابع برای فراخوانی اطلاعات از برگه برای تیبل مدنظرتان درون تگ مذکور ایجاد کنید. برای مثال
کد:
<tr><td> <?php while ( have_posts() ) : the_post(); ?> <?php get_template_part( 'content', 'page' ); ?> <?php endwhile; // end loop. ?> </td></tr>
 
Last edited:
بالا