• dear all,
    when wpdb->get_results returns post_content in a plugin I’ve installed, neither the_content nor get_the_content cannot work like from the_loop thing, namely having ‘read more/rest of the post’, always whole post gets displayed.
    how can I get a specific post content outside of the loop while having ‘read more’ thing in the content on?
    cheers

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter lejeczek

    (@lejeczek)

    no dev/sys around? Am I vague in my problem description? should I revamp it?

    Thread Starter lejeczek

    (@lejeczek)

    code snippet:

    $posts = $wpdb->get_results($request);
    
      if ( $echo ) {
        if ( !empty($posts) ) {
          foreach ($posts as $post) {
            $post_title = apply_filters('the_title', $post->post_title);
            $comment_count = $post->comment_count;
            $permalink = get_permalink($post->ID);
            $content = apply_filters('the_content', $post->post_content);
    //        $pcontent = apply_filters('the_content("..more")', $content);
            $mdv_most_commented .= $before . $post_title . '('. $comment_count.')' . $after .
            '<dd>' . $content . '</dd>' ;
            /*$mdv_most_commented .= '<dl>' . $before . '<a href="' . $permalink . '" title="' . $post_title.'">' . $post_title . '</a> (' . $comment_count.')' . $after . '</dl>';*/
          }
        } else...

    it is all from the ‘most commented posts’ plugin,
    problem – as it is, the whole post content gets displayed, not only up to <!–read more–> thing
    if change:
    $mdv_most_commented .= $before . $post_title . '('. $comment_count.')' . $after . '<dd>' . the_content. '</dd>' ;

    then weirdly, seven, (as seven is chosen) excerpts(just as I want) up to <!–read… is displayed first on the top of the list, but! of the same one!, most commented post,
    then the same list of posts(varied, as it should be) follows but with no! content/excerpts, just empty, only titles.
    basically, this plugin works just great as is written, but only if tamper with it I cannot get posts’ content with up to <!–read more.. thing.

    anybody?
    cheers

    Thread Starter lejeczek

    (@lejeczek)

    or with get_the_content

    $mdv_most_commented .= $before . $post_title . ‘(‘. $comment_count.’)’ . $after . ‘<dd>’ . get_the_content. ‘</dd>’ ;

    nicely formated list with <dd> as post content/exerpts, in orderly fashion, but again! of the same one, most commented post???

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘wpdb to add/remove filters or how to get post content’ is closed to new replies.