Beste,
Voor de website van Mobilejunks ben ik met een nieuwe layout bezig, welke te vinden is op http://www.mobilejunks.com/tryout
Ik wil dat de berichten maximaal een x aantal tekens hebben (bijv. 300) en dat er dan automatisch "read more" of iets dergelijks bij kan. Dit is de code:
Ik hoop dat iemand mij kan helpen.<?php while (have_posts()) : the_post(); ?>
<div id="post-<?php the_ID(); ?>" class="post">
<?php if ( get_post_meta($post->ID, 'pre_image', true) ) : ?>
<?php $image = get_post_meta($post->ID, 'pre_image', true); ?>
<div class="thepic"><img width="90" src="<?php echo $image; ?>" alt="<?php the_title() ?>" /></div>
<?php else: ?>
<div class="thepic"><img width="90" src="<?php bloginfo('template_directory'); ?>/images/blank.jpg" /></div>
<?php endif; ?>
<div class="ipost">
<h2 class="entry-title"><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Links to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
<div class="entry-info"><span class="idate"><?php the_time('Y.m.d'); ?></span> | <span class="ifolder"><?php the_category(' '); ?></span> | <span class="icomment"><?php comments_popup_link('No Comment','One Comment','% Comments'); ?></span><?php edit_post_link(' <span class="icolor">|</span> Edit'); ?></div>
<div class="entry-content"><?php the_excerpt('Continue Reading »'); ?></div>
</div><!--.ipost-->
<div class="clear"></div>
Mvg,
Joeri v.d. Watering
- Wordpress PHP vraag
-
07-11-2009, 19:44 #1
- Berichten
- 657
- Lid sinds
- 19 Jaar
Wordpress PHP vraag
-
In de schijnwerper
Te Koop Lastminute website met potentie en inkomsten.Website te koopAffiliate link poster V1.0 - Automatisch affiliate links posten in blogs - WP pluginPHP scriptswebshop in laadkabels/laadpalen (sinds 2019) incl leveranciersWebsite te koopLinkbuilding uitbesteden - 25 jaar ervaring - Zie behaalde resultatenAdvertentieruimte -
07-11-2009, 19:52 #2
- Berichten
- 2.392
- Lid sinds
- 17 Jaar
@Joeri, dat staat al in de code ;-) Kijk maar naar de functie "the_excerpt". Je moet dan zelf bij je artikelen het "Lees meer" gedeelte toevoegen ;-)
-
07-11-2009, 19:57 #3
- Berichten
- 657
- Lid sinds
- 19 Jaar
Ja maar ik heb ingesteld dat hij automatisch via feeds berichten ophaaldt. In mijn huidige thema (http://www.mobilejunks.com) doet hij dit wel automatisch. Maar ik heb weinig verstand van php en kan niet vinden hoe ik hem dit automatisch na een x aantal tekens kan laten doen..
-
07-11-2009, 20:03 #4
- Berichten
- 2.392
- Lid sinds
- 17 Jaar
Dan moet het zo...
<?php
function limitText($str, $len)
{
return strlen($str) > $len ? substr($str, 0, $len).'..' : $str;
}
while (have_posts()) : the_post(); ?>
<div id="post-<?php the_ID(); ?>" class="post">
<?php if ( get_post_meta($post->ID, 'pre_image', true) ) : ?>
<?php $image = get_post_meta($post->ID, 'pre_image', true); ?>
<div class="thepic"><img width="90" src="<?php echo $image; ?>" alt="<?php the_title() ?>" /></div>
<?php else: ?>
<div class="thepic"><img width="90" src="<?php bloginfo('template_directory'); ?>/images/blank.jpg" /></div>
<?php endif; ?>
<div class="ipost">
<h2 class="entry-title"><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Links to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
<div class="entry-info"><span class="idate"><?php the_time('Y.m.d'); ?></span> | <span class="ifolder"><?php the_category(' '); ?></span> | <span class="icomment"><?php comments_popup_link('No Comment','One Comment','% Comments'); ?></span><?php edit_post_link(' <span class="icolor">|</span> Edit'); ?></div>
<div class="entry-content"><?php limitText(the_excerpt('Continue Reading »'), 300); ?></div>
</div><!--.ipost-->
<div class="clear"></div>
-
07-11-2009, 20:07 #5
- Berichten
- 657
- Lid sinds
- 19 Jaar
Heb je code er nu in staan, maar veranderd helaas niks :(
-
07-11-2009, 20:11 #6
- Berichten
- 2.392
- Lid sinds
- 17 Jaar
Dan houd het voor mij ook op, helaas!
-
07-11-2009, 20:17 #7
- Berichten
- 657
- Lid sinds
- 19 Jaar
In ieder geval bedankt, iemand anders die mij misschien kan helpen?
-
10-11-2009, 04:14 #8
- Berichten
- 223
- Lid sinds
- 15 Jaar
@Joeri ik denk dat dit je werk lichter zal maken:
http://wordpress.org/extend/plugins/advanced-excerpt/
:)
Plaats een
- + Advertentie
- + Onderwerp
Marktplaats
Webmasterforum
- Websites algemeen
- Sitechecks
- Marketing
- Domeinen algemeen
- Waardebepaling
- CMS
- Wordpress
- Joomla
- Magento
- Google algemeen
- SEO
- Analytics
- Adsense
- Adwords
- HTML / XHTML
- CSS
- Programmeren
- PHP
- Javascript
- JQuery
- MySQL
- Ondernemen algemeen
- Belastingen
- Juridisch
- Grafisch ontwerp
- Hosting Algemeen
- Hardware Info
- Offtopic