• Hello, I am now the primary developer for the site [ Redundant like redacted ], a video game and entertainment website. One thing that the site does is reviews, and at the bottom of each review page is a little box that contains basically summarised info regarding the review, as well as the score (see for your self [ Redundant like redacted ] ). The writers to generate the box at the bottom of said review use a custom plugin that basically allows them to input information about the review, and it will generate the box based off of the info input there when making a post. I also noticed that custom fields with the same names as the plugin area (for example “cog_review_name” exists in the plugin’s code as well as a custom field, and in the form to generate the box, and whatever is filled in for “cog_review_name” is the title of the box that is generated to indicate further what is being reviewed).

    Unfortunately, the plugin developer is unresponsive to any questions, so we are left to figure it out.

    Currently, as it is configured, the site displays our latest 5 reviews using the “List Category Posts” sidebar widget, and is configured to display what you can see. However, we want that to be changed, so that basically the title of the game and just the score are displayed (similar to how https://www.gamespot.com/ has it on their front page), and ideally this is auto generated/updated whenever something is posted to our “Review” category.

    I’ve tried using several plugins that display plugin info in sidebar and going off of that, however they are all outdated significantly and no longer function.

    Thank you so much for any help. I am an absolute beginner in web development. Thanks again.

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

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    So you are the primary developer but you are new to development? (rhetorical, we don’t judge) That’s one way to force yourself to learn! ??

    Maybe the most important thing for you to know is you should never alter any code that you didn’t write, unless you are sure it will never be updated through the WP update mechanism. When such code is updated, any changes you make will be lost. You should be able to do any customizations through either a child theme or a custom plugin, which keeps your code safe from updates.

    To alter a widget’s output, find the widget’s source code. It should be a class declaration that extends WP_Widget class. Look in the class’ widget() method and see if there are any calls to apply_filters() which include a variable containing the output HTML as the second parameter. If there is such a call, you can hook that filter with add_filter() and write a callback function that changes or overrides the normal output for whatever you want.

    If there is no filter available, you’ll need to create your own widget. You can base it on the current widget’s code. As long as there are no final keywords used in the declaration, you can extend that widget class instead of WP_Widget and override the widget() method with your own version. Register your widget with something like
    add_action('init', function() { register_widget('My_List_Cat_Posts'); }, 1);
    where My_List_Cat_Posts is your widget class name.

    Thread Starter inferius7809

    (@inferius7809)

    Thank you very much for your help, it is a great start. Is my process any different if I simply wanted to display custom/meta field information? Thanks for any more help.

    Moderator bcworkz

    (@bcworkz)

    If you want to have a widget do this, you could start with a simpler widget, or create your own from scratch. Have a look at Widgets API.

    The other thing you could do is enter the code to output your data directly onto the sidebar.php template of your theme (customized theme templates are best done via a child theme). The output would need to be before or after all widget content, you cannot insert code on a template that should occur between other widgets. If you look at the sidebar.php template, all widget output occurs due to the call to dynamic_sidebar(). Place your code before or after this.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Display Reviews In Sidebar Widget Of Site’ is closed to new replies.