Forum Replies Created

Viewing 15 replies - 1 through 15 (of 22 total)
  • Plugin Author d

    (@dsgnr)

    This issue was resolved in the v1.1.3 update. If you are still having issues with this then please do get in touch.

    Plugin Author d

    (@dsgnr)

    There was an issue with the minify HTML option breaking some back end functions. However, this should have been resolved in the v1.1.3 update. Of course, if this is still causing issues, please get in touch!

    Plugin Author d

    (@dsgnr)

    Thank you Luke.

    This has now been resolved.

    Thread Starter d

    (@dsgnr)

    Ah I got it now. I had to enter the parameters on the homepage. I’ve been so caught up in the functions.php Code That I forgot about the homepage template.

    Thank you for your help. If you want me to push the changes up to GitHub so you can just merge then let me know 🙂

    Thread Starter d

    (@dsgnr)

    Hi Hector,

    That works perfectly. Thank you very much. If you’d like me to create a PR on GitHub then let me know!

    One last thing then I promise I’ll leave you alone. On the homepage section, I’d like to limit it to a number of posts and to only show posts. Not pages. Is this possible with this configuration now?

    Thread Starter d

    (@dsgnr)

    Ok I’ve added that in. Interesting that the sidebar is showing the same ID as the footer though

    Thread Starter d

    (@dsgnr)

    That’s done. Definitely made a visible change to all of the results shown

    Thread Starter d

    (@dsgnr)

    Thanks.

    Okay, so entering this into functions.php:

    function homepage_grid( $post_html, $p, $instance ){
    
        // This is the sidebar widget, let's use the stock HTML output
        if ( isset($instance['widget_id']) ) {
            return $post_html;
        }
    
        // If we got here, then it's the wpp_get_mostpopular() template tag and so let's use a custom HTML output
    
        $categories = get_the_category($p->id);
        $category_output = '';
    
        if ( !empty($categories) ) {
    
            $category_output = 'Posted under ';
    
            foreach( $categories as $category ) {
                $category_output .= '<a href="' . esc_url( get_category_link( $category->term_id ) ) . '" alt="' . esc_attr( sprintf( __( 'View all posts in %s' ), $category->name ) ) . '" rel="category tag">' . esc_html( $category->name ) . '</a>, ';
            }
    
            $category_output = rtrim( $category_output, ', ' );
    
        }
    
        $output = '
        <article class="one-fourth post" itemscope itemtype="http://schema.org/CreativeWork">
            <div class="post-grid-featured-image"><a href="' . get_the_permalink($p->id) . '" rel="bookmark">' . get_the_post_thumbnail( $p->id, 'small-post-image') . '</a></div>
            <div class="entry-content" itemprop="text">
                <h3 class="entry-title" itemprop="headline"><a href="' . get_the_permalink($p->id) . '" rel="bookmark">' . $p->title . '</a></h3>
                <div class="entry-author-info">
                    <a href="' . get_author_posts_url( get_the_author_meta( 'ID' ), get_the_author_meta( 'user_nicename' ) ) . '">' . get_avatar( get_the_author_meta('email'), 50) . '</a><a href="' .  get_author_posts_url( get_the_author_meta( 'ID' ) ) . '">' . get_the_author_meta( 'display_name' ) .'</a>
                </div>
            </div>
            <footer>' . $category_output . '</footer>
        </article>';
    
        return $output;
    
    }
    add_action( 'wpp_post', 'homepage_grid', 10, 3 );

    This in the location where I want the above to display on my homepage, inside the homepage template file:

    <?php
        if (function_exists('wpp_get_mostpopular'))
            wpp_get_mostpopular();
    ?>

    Literally just displays a list and view count of the popular posts. Instead of including the code that’s above with the thumbnail, category, author avatar etc.

    The good thing is that now, the sidebar and footer widgets just display a list and nothing else, which is what I want.

    I now just need to get the functions.php styling to appear when calling the wpp_get_mostpopular(); tag.

    Am i missing something out of the above? Surely, i’d need to call the action on the homepage? Or can it just suss itself out?

    Sorry to be annoying

    Thread Starter d

    (@dsgnr)

    Thank you for your help. Ok so I’ve included your code and on my homepage, I have
    `<php Echo homepage_grid(‘output’); ?>

    I suspect this is incorrect as it doesn’t work lol but can’t find anything in the documentation to display code front end.

    Thanks

    Thread Starter d

    (@dsgnr)

    So, near the bottom of the homepage, theres ‘featured posts’ in the same style as the rest of the homepage.

    Then in the footer widget and post/page sidebar I just want a list. it’s trying to show all the images still in the sidebar

    Thread Starter d

    (@dsgnr)

    Ah, not sure why that is. maybe it’s not redirecting properly: http://www.speakwp.com

    Thread Starter d

    (@dsgnr)

    Hi Hector,

    Thank you very much for your help so far on this, you’ve been a massive help. The site I am trying to build is this; speakwp.com just so you can get an idea of what I’m trying to achieve.

    The above code works great for the main homepage. However, I can not seem to get it to separate from the widgets (footer and sidebar) so they listen to the actual widget information.

    I understand what you’re saying above, I just can’t seem to get it to do what I want it to do. So at the moment, the footer and post sidebar widget is trying to show the same information that’s on the homepage, instead of a normal list (no thumbnails etc).

    Maybe I’m doing something wrong. I’ve set ID’s in the widgets to try use the if_statement, it just won’t listen 🙁

    Thanks again

    Thread Starter d

    (@dsgnr)

    OK, so here’s my code:

    function homepage_grid( $post_html, $p, $instance ){
      $output = '<article class="one-fourth post" itemscope itemtype="http://schema.org/CreativeWork">
      	<div class="post-grid-featured-image"><a href="' . get_the_permalink($p->id) . '" rel="bookmark">' . get_the_post_thumbnail( $p->id, 'small-post-image') . '</a></div>
      <div class="entry-content" itemprop="text">
      	<h3 class="entry-title" itemprop="headline"><a href="' . get_the_permalink($p->id) . '" rel="bookmark">' . $p->title . '</a></h3>
      	<div class="entry-author-info">
      		<a href="' . get_author_posts_url( get_the_author_meta( 'ID' ), get_the_author_meta( 'user_nicename' ) ) . '">' . get_category_link($p->id) . '' . get_avatar( get_the_author_meta('email'), 50) . '</a><a href="' .  get_author_posts_url( get_the_author_meta( 'ID' ) ) . '">' . get_the_author_meta( 'display_name' ) .'</a></div>
      </div>
      </article>';
      return $output;
    }
    add_action( 'wpp_post', 'homepage_grid', 10, 3 );

    I am struggling to add the post category into this though which is a bit frustrating.

    And as above, I have a list of posts in the footer widget and the sidebar widget. The above is to be displayed on the homepage, main content. Is there a way to separate these so the widgets have a list and homepage has the above? (One thing to note is that the homepage has a list in the footer AND the above, otherwise I’d just use an if statement to use this on the homepage only.

    Any help would be great.

    Thanks!

    Thread Starter d

    (@dsgnr)

    *Edit. I didn’t realise enqueue safe jQuery was selected in the admin page. DOH!

    Thread Starter d

    (@dsgnr)

    Thank you for your help! That’s great!

    Here’s the code for others:
    <div class='avatar'>" . get_avatar( get_the_author_meta('email'), 50) . "</div>

    Two questions though:

    I am using Varnish on my server, hense the need for this to be Ajax. Will this still work okay with Ajax?

    I also would like to display the post titles in widgets in the footer and the sidebar. The above changes it site wide. Is there a way to separate the two. The above is going on the homepage but also just the post titles are displayed using your widget.

    Thanks again! 🙂

Viewing 15 replies - 1 through 15 (of 22 total)