go41

Re: set the length of the_excerpt using wp_trim_words :: Reply by Joern

von Joern am 8. Feb. 2014 | Keine Kommentare

using Code:

<?php echo wp_trim_words( get_the_excerpt(), 25, '' ); ?>

is good as long you do not need more words than are in the_excerpt

you can also use wp_trim_words with get_the_content like this:

Code:

echo wp_trim_words( get_the_content(), 60 );

to get 60 words

BUT! there will be all shortcodes visible in this truncated text!

To strip the shortcodes you can either use preg_replace like the following

Code:

<?php the_content = preg_replace("~(?:[/?)[^/]]+/?]~s", '', get_the_content());  # strip shortcodes, keep shortcode content
echo wp_trim_words( $the_content, 60 ); ?>

imho the best is using the built in function of WordPress strip_shortcodes as shown here

Code:

<?php echo wp_trim_words( strip_shortcodes (get_the_content()), 60 ); ?>

to try stuff like this, you could temporarily add above codes below Code:

<?php the_content(); ?>

just to see how it compares
actually this is a replacement for the_excerpt or the_content in places where you like to show an except
____________________
you find me on Google+, Twitter and Facebook

(von: Joern)

Hier noch 37 weitere Ergebnisse dieses Threads:

How to set the length of the_excerpt (truncate excerpt)

15. Feb. 2009 (von: f-t-cat)

I got a Headline and a Featured section in my blog, but the content is too long! How can I make WordPress display a text from the_content or the_excerpt in the length I want to have? Weiterlesen →

Re: How to set the length of the_excerpt (truncate excerpt) :: Reply by f-t-cat

16. Feb. 2009 (von: f-t-cat)

Oh, I found two ways:If your theme displays<?php the_excerpt(); ?>In the post editor you can insert <!--more--> after the desired length of text or you use a custom excerpt.Or in post edit is a field called 'excerpt' (optional "Excerpt"), there…

Re: How to set the length of the_excerpt (truncate excerpt) :: Reply by master

16. Feb. 2009 (von: master)

fritz, what works for me is calling the rss content which you can cut with parameters:<?php the_content_rss('', FALSE, '', 30); ?>this would be 30 words in a text like an excerpt.However, it works not on all sites, I do not…

Re: How to set the length of the_excerpt (truncate excerpt) :: Reply by Joern

21. Feb. 2009 (von: Joern)

Another way to shorten the excerpt would be:<?php $shortex = substr(get_the_excerpt(), 0, 170);echo $shortex; echo "rn"; ?>as a replacement for the_excerpt, the last number above is the number of characters to display.Even one more:by putting the function 'string_limit_words' in your…

Sidebar has moved to footer

8. Feb. 2010 (von: Blogchick)

I can't figure out how I managed to mess things up, but I went to make a new post and noticed that the alignment is wwaaayy off on the post pages. I haven't touched the theme since changing the number…

Re: Sidebar has moved to footer :: Reply by Blogchick

8. Feb. 2010 (von: Blogchick)

I figured it out! It was this section: Code:<div class="navigation">      <div class="right"><?php next_post_link('%link »', '%title', TRUE) ?></div>      <div class="left"><?php previous_post_link('« %link', '%title', TRUE) ?></div>   </div>   </div>of the post php that was somehow throwing things off. Sorry to bother…

Different header and sidebar ads for a single page

17. Feb. 2010 (von: drwhom)

Hi Joern, I've got a vague feeling that you might have helped me with something similar before but I can't find the answer. Essentially, all I want to do is change a single page so that it has a different…

Re: Different header and sidebar ads for a single page :: Reply by Joern

17. Feb. 2010 (von: Joern)

Put a conditional tag around the different adds, like this:<?php if ( is_single('Favourbrook') ) { ?>do Favourbrook add here<?php } else { ?>do any other stuff here<?php } ?>that's just for this single post, more conditional tags see ... Weiterlesen…

Re: Different header and sidebar ads for a single page :: Reply by drwhom

17. Feb. 2010 (von: drwhom)

The forum's being weird! Weiterlesen →

Re: Different header and sidebar ads for a single page :: Reply by drwhom

17. Feb. 2010 (von: drwhom)

Let me try again as it seemed to take that post - thank-you- notification is working great- does the conditional code go in sidebar.php and header.php? Weiterlesen →

Re: Different header and sidebar ads for a single page :: Reply by master

17. Feb. 2010 (von: master)

I see your reply..now changed to weird..____________________you find me on Google+, Twitter and Facebook Weiterlesen →

Re: Different header and sidebar ads for a single page :: Reply by master

17. Feb. 2010 (von: master)

anywhere, in header.php make space under your add, paste the code as is and look if you see the text 'do Favourbrook add here' or 'do any other stuff here' under your head.If yes it's working and you put your…

Godaddy free hosting and forums :

18. Feb. 2010 (von: fiazio)

Hello,I just wanted to know whether it is possible to put up a forum at the free hosting that godaddy provides.Thank you. Weiterlesen →

Re: Different header and sidebar ads for a single page :: Reply by drwhom

18. Feb. 2010 (von: drwhom)

For some reason I don't think the forum likes me posting code... Weiterlesen →

Re: Different header and sidebar ads for a single page :: Reply by drwhom

18. Feb. 2010 (von: drwhom)

I'll try posting a very small section:<a href="<?php echo get_option('home'); ?>/"><img src="<?php echo get_option('home'); ?>/wp-content/themes/arthemia/images/logotrial3.jpg" width="410px" height="110px" alt="" /></a> <div id="tagline"><?php bloginfo('description'); ?></div> </div> <div class="right"><?php if ( is_single('Favourbrook') ) { ?><a href="http://www.iamstaggered.com" onClick="javascript: pageTracker._trackPageview('/outgoing/www.designaventure.co.uk');"><img src="<?php echo get_option('home'); ?>/wp-content/themes/arthemia/images/banners/testadvert.png" alt=""…

Re: Different header and sidebar ads for a single page :: Reply by master

18. Feb. 2010 (von: master)

it seems not to recognize the is_singleyou could try with the ID of this post is_single('17') 17 sould be your IDor with the page slug is_single('favourbrook')I hope we talk about a single post? that's not a page or category, right?If…

Re: Different header and sidebar ads for a single page :: Reply by drwhom

18. Feb. 2010 (von: drwhom)

JOERN/MASTERADMIN I BLOODY LOVE YOU. THAT IS ALL. Ahem, yes, it was a page, not a single post. Whoops. Weiterlesen →

Re: Godaddy free hosting and forums : :: Reply by Joern

19. Feb. 2010 (von: Joern)

I would say: Why not?That's what hosting providers are here for.However, 'free hosting' has to generate money too! Do you think they really give this for free to thousands of customers?They might put their advertising on your site, give you…

Re: Godaddy free hosting and forums : :: Reply by fiazio

19. Feb. 2010 (von: fiazio)

Hey Joe,Thanks for replying.Godaddy injects advertisements on the top of any page hosted free.I don't think its possible to put up a forum there, It has an option for Mysql, I'm not really familiar with it but they don't have…

disable thumbnail generation on upload

19. Feb. 2010 (von: Joern)

If you upload an image with WordPress, it creates additionally two thumbnails and stores them in your upload folder.Many themes and users make no use of these thumbnails and there is a way to disable this function.Go to Settings ->…

Call to a member function get() on a non-object

26. Feb. 2010 (von: master)

for a while I had in my sites error.log many entries looking like this:PHP Fatal error: Call to a member function get() on a non-object in /.../wp-includes/cache.php on line 93This error appeared since I updated the Plugin WP Super Cache…

Re: Call to a member function get() on a non-object :: Reply by f-t-cat

27. Feb. 2010 (von: f-t-cat)

Thanks a lot, this helped me too with the error:Call to a member function get() on a non-object in cache.php on line 93 Weiterlesen →

Add custom text to specific category posts

2. Mrz. 2010 (von: drwhom)

I think I've seen this elsewhere before but I want to add a block of text to every post that falls in our "blog" category (http://www.iamstaggered.com/category/blogs) explaining how to follow/subscribe to a particular writer if readers want to. Is there…

Re: Add custom text to specific category posts :: Reply by Joern

2. Mrz. 2010 (von: Joern)

If you use just one single.php for all singles and you want to display something on a single view only in one category, use the condition 'in_category()', this tests if the current post is assigned to any of the specified…

Make the 800×60 banner on Arthemia (Free) a clickable link?

8. Mrz. 2010 (von: pure241)

I'm sure I can figure out how to change the image it's self but how do I make that image a clickable link? Weiterlesen →

Autor:

Du findest mich auch auf Twitter und Facebook!

Schreibe einen Kommentar

Pflichtfelder sind mit * markiert.


Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.

weitere forum Beiträge: