• Resolved drsquirrel

    (@drsquirrel)


    Hello,
    I’m currently building a jokes site with WordPress and would like to display the top-rated jokes in a widget.

    However, the posts only have content but no title.

    The widget always leaves out the title, so it doesn’t show me anything.
    Unfortunately I can’t get any further on my own and wanted to ask if someone could help me here.

    Thank you in advance

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Collins Agbonghama

    (@collizo4sky)

    Please share a url to your site showing the top-rated widget with the issue.

    Thread Starter drsquirrel

    (@drsquirrel)

    The site is only local so far, so I can only offer a screenshot.

    All posts are displayed on the home page and the best rated ones should be displayed in the widget on the right, but not the title of the post but the content

    I cant insert the screenshort, so i add the url here:

    https://giasing.me/screenshot.png

    • This reply was modified 5 months, 4 weeks ago by drsquirrel.
    Plugin Author Collins Agbonghama

    (@collizo4sky)

    Unfortunately, I can’t help by just looking at a screenshot. Besides, I am unable to replicate the issue on my end.

    Thread Starter drsquirrel

    (@drsquirrel)

    Ok, I’ll try something different.
    In the rate-my-post-top-rated-widget.php I would like to instead

    <?php echo $post['title'] ?>

    show the content, for example

    <?php echo $post['the_content'] ?>

    However, no matter what I try, I can’t get a display. Here is the complete file

    <?php
    
    /**
     * Widget - top rated posts
     *
     * @link       https://www.ads-software.com/plugins/rate-my-post/
     * @since      2.6.0
     *
     * @package    Rate_My_Post
     * @subpackage Rate_My_Post/widgets
     */
    
     class Rate_My_Post_Top_Rated_Widget extends WP_Widget {
       public function __construct() {
         parent::__construct(
           'rate-my-post-top-rated-widget', // Base ID
           'Top Rated Posts by FeedbackWP', // Name
           array(
             'description' => __( 'Displays top rated posts from FeedbackWP plugin.', 'rate-my-post' ),
           ) // Args
         );
       }
    
       //frontend output content
       public function widget( $args, $instance ) {
          extract( $args );
    
          $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
    	  //$content = apply_filters( 'widget__title', empty( $instance['the_content'] ) ? '' : $instance['the_content'], $instance, $this->id_base );
    	  //$content = apply_filters( 'the_content', $content , $instance, $this->id_base);
    	  //$content = apply_filters('the_content', get_post_field('post_content', $this->id_base));
    
          $postsNumber = empty( $instance['postsNumber'] ) ? 5 : $instance['postsNumber'];
          $minRating = empty( $instance['minRating'] ) ? 1 : $instance['minRating'];
          $minVotes = empty( $instance['minVotes'] ) ? 1 : $instance['minVotes'];
          $showThumb = empty( $instance['showThumb'] ) ? false : $instance['showThumb'];
          $showStars = empty( $instance['showStars'] ) ? false : $instance['showStars'];
    
          $topRatedPosts = Rate_My_Post_Public::top_rated_posts( $postsNumber, $minRating, $minVotes );
    
          echo $before_widget;
    
          if ( ! empty( $title && !empty( $topRatedPosts ) ) ) {
            echo $before_title . $title . $after_title;
          }
    
          ?>
            <!-- FeedbackWP - Top Rated Posts Widget -->
            <div class="rmp-tr-posts-widget">
              <?php foreach ( $topRatedPosts as $post ): ?>
                <div class="rmp-tr-posts-widget__post">
                  <?php if ( $post['thumb'] && $showThumb ): ?>
                    <div class="rmp-tr-posts-widget__img-container">
                      <a href="<?php echo $post['postLink']; ?>">
                        <img class="rmp-tr-posts-widget__img" src="<?php echo $post['thumb']; ?>" alt="<?php echo $post['title'] ?>" />
                      </a>
                    </div>
                  <?php endif; ?>
                  <?php if ( $showStars ): ?>
                    <div class="rmp-tr-posts-widget__star-rating">
                      <?php echo Rate_My_Post_Public::get_visual_rating( $post['postID'] ); ?>
                      <span class="rmp-tr-posts-widget__avg-rating"><?php echo $post['avgRating']; ?></span>
                      <span class="rmp-tr-posts-widget__num-votes">(<?php echo $post['votes']; ?>)</span>
                    </div>
                  <?php endif; ?>
                  <?php do_action( 'rmp_before_widget_title', $post['postID'] ); ?>
                  <p>
    			  <?php
    			  //$post['the_content']
    			  ?>
                    <a class="rmp-tr-posts-widget__link" href="<?php echo $post['postLink']; ?>"><?php echo $post['title'] ?></a>
                  </p>
                </div>
              <?php endforeach; ?>
            </div>
            <!-- End FeedbackWP - Top Rated Posts Widget -->
    Plugin Author Collins Agbonghama

    (@collizo4sky)

    Your custom changes aren’t working because Rate_My_Post_Public::top_rated_posts() returned data doesn’t include post content.

    Even if you are successful in making this change, your changes will be overridden and lost whenever we make a new update.

    Thread Starter drsquirrel

    (@drsquirrel)

    Ok, thank you very much for the answer. Then I’ll keep looking

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.