انجمن


353 کارکتر پیشفرض در پست باشد  (۳ نوشته)

  • amirvazir

    آفلاین
    عضو
    تعداد نوشته‌ها: ۲۱
    تشکر شده: ۴ بار
    # نوشته شده: ۹ سال پیش
    ۱۹ تیر ۱۳۹۳ - ۱۴:۰۶

    سلام و خدا وقت
    من میخواهم در صفحه اول وب سایتم هر پست فقط 353 کاراکتر نمایش دهد و مابقیه رو به ادامه مطلب فرستاده شود

    با این کد کل ادامه مطلب را نمایش میدهد که نباید نشان بدهد فقط نیمی از پست را میخواهم نشان دهد یا 353 کاراکتر سالم
    <?php the_content(); ?>
    با این کد هم به صورت به هم چسبیده نشان میدهد بدون رنگ و عکس لینک که این هم اشتباه است
    <?php the_excerpt(); ?>
    من میخواهم فقط 353 کاراکتر نشان دهد + عکس و رنگ و لینک عادی باشد به هم چسبیده نباشد
    صفحه index.php من الان با این کد

    <?php get_header() ?>
    <?php include('sidebar-left.php') ?>
    	<div id="content">
    
    		<?php while ( have_posts() ) : the_post() ?>
    		<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    			<?php if(function_exists('get_the_image'))
    		{ get_the_image( array( 'default_size' => 'thumbnail', 'image_class' => 'thumb', 'image_scan' => 'true', 'the_post_thumbnail' => 'true', 'link_to_post' => 'true' ) ); } ?>
    
    			<h2 class="post-title"><a href="<?php the_permalink() ?>" title="<?php the_title() ?>" rel="bookmark"><?php the_title() ?></a></h2>
    			<div class="post-meta">ارسال شده در تاریخ <?php the_time('F j, Y'); ?> در موضوع <?php the_category(', '); ?><span class="sep">|</span><?php comments_popup_link('بدون دیدگاه', '1 دیدگاه', '% دیدگاه') ?></div>
    			<div class="post-content">
    
    <?php the_content(); ?>
    
    			</div>
    <div class="redmore"> <a href="<?php the_permalink() ?>">ادامه این مطلب </a> </div>
    <?php the_tags('<div class="tags"><b>کلمات کلیدی :</b> ', ', ', ' </div>'); ?></a>
    
    		</div><!-- .post -->
    		<?php endwhile ?>
    
    		<div class="navigation">
    			<div class="navleft"><?php next_posts_link('« مطالب قدیمی تر', '0') ?></div>
    			<div class="navright"><?php previous_posts_link('مطالب جدیدتر »', '0') ?></div>
    		</div>
    
    	</div>
    
    <?php include('sidebar-right.php') ?>
    <?php get_footer() ?>
  • Masoud

    آفلاین
    کلیددار
    تعداد نوشته‌ها: ۸۱۵
    تشکر شده: ۶۳۲ بار
    # نوشته شده: ۹ سال پیش
    ۱۹ تیر ۱۳۹۳ - ۱۷:۵۰

    سلام،
    می‌تونید از این کد به جای the_content استفاده کنید:
    <?php $content = get_the_content(); echo mb_strimwidth($content, 0, 500, '...');?>

    کاربران زیر به‌خاطر این نوشته تشکر کرده‌اند:
    amirvazir
  • amirvazir

    آفلاین
    عضو
    تعداد نوشته‌ها: ۲۱
    تشکر شده: ۴ بار
    # نوشته شده: ۹ سال پیش
    ۱۹ تیر ۱۳۹۳ - ۱۸:۵۰

    دستتون درد می کنه کد کار میکنه ولی دسته های سمت راست رو میندازه زیر شماره صفحه
    بعضی صفحان دسته راست رو خراب میکنه

    <?php get_header() ?>
    <?php include('sidebar-left.php') ?>
    	<div id="content">
    
    		<?php while ( have_posts() ) : the_post() ?>
    		<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    			<?php if(function_exists('get_the_image'))
    		{ get_the_image( array( 'default_size' => 'thumbnail', 'image_class' => 'thumb', 'image_scan' => 'true', 'the_post_thumbnail' => 'true', 'link_to_post' => 'true' ) ); } ?>
    
    			<h2 class="post-title"><a href="<?php the_permalink() ?>" title="<?php the_title() ?>" rel="bookmark"><?php the_title() ?></a></h2>
    			<div class="post-meta">ارسال شده در تاریخ <?php the_time('F j, Y'); ?> در موضوع <?php the_category(', '); ?><span class="sep">|</span><?php comments_popup_link('بدون دیدگاه', '1 دیدگاه', '% دیدگاه') ?></div>
    			<div class="post-content">
    
    <?php $content = get_the_content(); echo mb_strimwidth($content, 0, 900, '...');?>
    			</div>
    <div class="redmore"> <a href="<?php the_permalink() ?>">ادامه این مطلب </a> </div>
    <?php the_tags('<div class="tags"><b>کلمات کلیدی :</b> ', ', ', ' </div>'); ?></a>
    
    		</div><!-- .post -->
    		<?php endwhile ?>
    
    		<div class="navigation">
    <div class="pagination">
    <?php rokesh_pagination(); ?>
    
    </div>
    		</div>
    
    	</div>
    
    <?php include('sidebar-right.php') ?>
    <?php get_footer() ?>

درباره‌ی این موضوع



برچسب‌ها

هیچ برچسبی نیست.