• Resolved George

    (@giorgos93)


    Hi, Hector! I’ve read your topics about plans for not supporting classic widget in future. And I understand.

    However, I am not planning to use this new WordPress blocks at all. I’ve unloaded it’s .js / .css a long time ago, and I use a classic text editor, and a classic widget editor. So even if I wanted to, I wouldn’t be able to use your new widget. And it’s useless to load these files only for your widget.

    From what I’ve understood, you offer to use a shortcode [wpp] for people, who don’t want to use a new widget. But I don’t understand, how to imitate the same styles. I use WP Cards Compact theme along with some custom styles. It looks like this: https://ibb.co/BgpG1JL

    So it’s hard for me to understand, what should I do. Is it even possible to duplicate the same styles with the help of your shortcode?

    The page I need help with: [log in to see the link]

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Hector Cabrera

    (@hcabrera)

    Hi @giorgos93,

    Is it even possible to duplicate the same styles with the help of your shortcode?

    Yes, it is possible and we’re going to do just that right now:

    #1 Go to Appearance > Widgets > [Your Sidebar] and place a Custom HTML widget right below your popular posts one.

    #2 Set the title of your Custom HTML widget.

    #3 Paste the following shortcode into the Custom HTML widget:

    [wpp range='last24hours' limit=5 post_type='post' thumbnail_width=75 thumbnail_height=75 stats_views=0 wpp_start='<ul class="wpp-list wpp-cards-compact">' post_html='<li class="{current_class}">{thumb_img}<div class="wpp-item-data"><div class="taxonomies"></div>{title}</div></li>' wpp_end='</ul>']

    The only parameter you may want to adjust here is range. Accepted values are last24hours, last7days, last30days, all, and custom (see Parameters for more details.)

    #4 Add these CSS rules to your site, either by adding the to your theme’s style.css file or via Appearance > Customize > Additional CSS.

    Some of these CSS rules might conflict with CSS rules coming from your theme so you may need to do some tweaking.

    #5 Add this line of PHP code to your site, either via your theme’s functions.php or by using a plugin such as Code Snippets for example:

    add_filter( 'widget_text', 'do_shortcode' );

    It’ll allow the Custom HTML widget to parse shortcodes.

    If everything went well your shortcode should look just like the Cards Compact theme.

    Thread Starter George

    (@giorgos93)

    Thanks for advices! I’ve just did all the steps. But I have several questions now:

    1 – The popular posts for some reason are displayed even without add_filter( ‘widget_text’, ‘do_shortcode’ ); . If I put it, nothing is changed. I didn’t add this code before in my functions.php file. So, I can delete it?

    2 – I had before “wordpress-popular-posts” – “themes” – “cards-compact” folders in my theme’s path. There was a config.json file and style.css file. Since I’ve replaced everything with a shortcode, then I don’t need this folders and files anymore, right? I can delete them?

    3 – In WPP classic widget I used this code to hide popular posts from a certain screen width: @media (max-width: 991px) {.widget.popular-posts {display: none;}} . However, it doesn’t work for a shortcode. What css class/id do I need to use now?

    4 – I want to put links not only in text, but in thumbnails as well. I’ve already asked you before about this, and you told me to change {thumb_img} to {thumb} (https://www.ads-software.com/support/topic/how-to-put-popular-posts-links-in-images/). I’ve just tried to do the same with the code for custom html widget, but it broke the styles for some reason – https://ibb.co/wd0gsqr

    5 – I used all the styles from my own cards-compact style.css file, and I’ve added them in WordPress theme’s style.css file. Almost everything now looks, as it was before. However, there is one difference. Under the thumbnails, there is less space now. I checked the styles in code, and I don’t see any of them being ovewrritten by something else. Here is classic widget – https://ibb.co/fDBpm94 . And here is a shortcode: https://ibb.co/M7fQ7W7 . As you can see the old one didn’t fully fit on my screen’s height. But the new one does. I don’t understand, what causes different height for them.

    Plugin Author Hector Cabrera

    (@hcabrera)

    1. If it works then I guess it’s not necessary.
    2. You can delete both files, but if you made changes to style.css then copy those CSS rules instead of the ones I shared above.
    3. You’ll need to add the shortcode to your sidebar so I can tell you which CSS classes to use. As of right now I don’t see it there ??
    4. Same as above, please add the shortcode to your sidebar so I can see what’s going on.
    5. Once again, I need to see the popular post list so I can help.
    Thread Starter George

    (@giorgos93)

    1 – Ok, then I remove it.

    2 – Yes, I made some changes there, so I’ve just copied my own styles

    3, 4, 5 – I’ve just added HTML-widget with my own styles ABOVE classic WPP widget in sidebar. Here is a link: https://litfan.ru/testy/test-na-pisatelskie-sposobnosti/

    Plugin Author Hector Cabrera

    (@hcabrera)

    This is what I’m seeing:

    Looks as expected here.

    About #3, you could try using #sidebar .widget_custom_html instead (assuming you don’t have more than one Custom HTML widget on your sidebar).

    Thread Starter George

    (@giorgos93)

    About #3: Yes, I don’t have other Custom HTML widget in my sidebar. The code worked, thanks!

    What about #4 and #5? The links are not in thumnails atm, and the spacing below thumnails is a bit less, than in classic wpp widget.

    Thread Starter George

    (@giorgos93)

    I’ve just changed {thumb_img} to {thumb}, so you can see broken styles

    Plugin Author Hector Cabrera

    (@hcabrera)

    This should fix it:

    .wpp-item-data {
      width: calc(100% - 80px);
    }

    80px here is the sum of the width of the thumbnail + some spacing. Adjust if needed.

    Thread Starter George

    (@giorgos93)

    .wpp-item-data { width: calc(100% – 90px); } works for me, thanks!

    However, the total height of WPP classic widget is still bigger, than shortcode widget height (675px against 650px). I use Lightshot space selection for measurements ?? . That’s because of that margin below thumnails – it’s less, than in classical widget for some reason.

    Plugin Author Hector Cabrera

    (@hcabrera)

    Well… add some margin then ?? What’s stopping you (since it seems that you’re at least somewhat familiar with CSS)?

    Thread Starter George

    (@giorgos93)

    Yeah, kind of ?? . I thought, that you’ll give me some magic trick ??

    margin-bottom: 0.4em for .wpp-cards-compact li .wpp-thumbnail worked perfectly.

    Thanks for helping me out! Tbh, I decided to explore these fixes not to be implemented right now. I do it for future, so I can return here and implement this changes, when you’ll fully stop supporting classic widget.

    But I still hope, that you’ll change your mind somehow ??

    • This reply was modified 1 year, 2 months ago by George.
Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘About classic widget’ is closed to new replies.