Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8111231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:02:19+00:00 2026-06-06T02:02:19+00:00

i have wordpress blog in my custom built website, i am displaying some posts

  • 0

i have wordpress blog in my custom built website, i am displaying some posts from wordpress blog into my website based on tags like below

require('../news/wp-blog-header.php');
                            $query = new WP_Query('tag=Dalaman');

                            if ($query->have_posts()):
                                while ($query->have_posts()) : $query->the_post();
                                    ?>
                                    <h3> <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
                                    <p><?php the_content();?></p>
                                    <?php
                                endwhile;
                            endif;

the_content displays the 10 posts from wordpress database based on WP_Query

Problem: i want to display some part of the post, let’s say 55 chracters
posts, in my db dont have excerpt by default and i dont want to use the_exerpt() as it strips html tags and my post contains <img> on start of every post

i tried many things but all went in vain,i also used php’s substr() function, but it didn’t work in this case.

so how can i display somepart of the post along with image ?

very much thanks.

Kind Regards !

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T02:02:22+00:00Added an answer on June 6, 2026 at 2:02 am

    you can do it like below,

    $limit = 55;
                                $content = explode(' ', get_the_content(), $limit);
    
                                if (count($content) >= $limit) {
                                    array_pop($content);
                                    $content = implode(" ", $content) . '...';
                                } else {
                                    $content = implode(" ", $content);
                                }
                                $content = preg_replace('/\[.+\]/', '', $content);
                                $content = apply_filters('the_content', $content);
                                $content = str_replace(']]>', ']]&gt;', $content);
                                echo $content;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a wordpress blog and I would like to make a custom design
I currently have a custom themed blog running on wordpress with Jetpack installed. I
I have a WordPress blog with numerous URL's I wish to replace from this:
my challenge is to built a video portal, based on wordpress (blog already started).
I am customizing wordpress blog and I have a need to make custom sidebar
I'm migrating a custom coded blog over to Wordpress, and have to set up
I'm looking to move my custom domain from blogger to wordpress. I have purchased
I have a wordpress blog.I Want to add Facebook like Button &Facebook Share button
Hey I have a wordpress blog, and I need to add some negative margin
I'm writing a custom blog engine and would like to have trackbacks similar to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.