• Hello All,

    I’m trying to figure out how to create a system where people take a quiz and it lands on a certain blog page that fits the criteria they filled out. If they don’t like the blog they can, retry and get another answer or similar answer without retaking the quiz.

    Example: if someone took a Disney character quiz, they result may be Mickey, Donald, Minnie and Goofy. Their results land to a blog that says You are Mickey. There’s an option that says “Not for you?” They click that and it gives them Donald but not Minnie and Goofy.

    Any idea how I could develop this?

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

    (@bcworkz)

    You need to somehow correlate quiz answers to specific query arguments. For example, each answer could correlate to a specific tag term. You can then query for posts that have any of the tag terms determined from answers. The problem is there is no way to order the results by “best fit” that I know of, especially when using the usual WP_Query class to get relevant posts.

    You could create a usort() callback to help you order the results by best fit, which would be posts with the most matching terms. This is very inefficient, but as long as there are not hundreds of matching posts it should be OK.

    The “Not for you?” link would end up doing the entire query and sort all over again. It’s easy to specify rejected posts be excluded from the new query, but you need some way to keep track of which posts were rejected by each user. User meta can work for this. You should have a “Start over” link that clears user meta and brings them back to the quiz beginning.

    It may also be a good idea to somehow limit how many posts are rejected before the algorithm gives up because subsequent results would be poor quality matches. For example, give up on suggestions if there is only one matching term in any matched post.

    Thread Starter trosemedia

    (@trosemedia)

    Thank you! I am new to wordpress and coding, I realize this is ambitious but I’m going to try. Any advice or guidance to achieve this helps.

    Moderator bcworkz

    (@bcworkz)

    Welcome to the WP community then! One thing you’ll soon learn is WP people are picky about letter case in “WordPress” ?? There’s even a function that auto-capitalizes the P in the word “WordPress” that may occur in post content called capital_P_dangit()

    I firmly believe the best way to learn is pick a small, real project and dive in. It’ll be frustrating at times, but you end up learning what you need to know and avoid much of what you don’t need to know. The key to this approach is having good references. Almost all the reference you need is linked from https://developer.www.ads-software.com/. Other than https://php.net/.

    The first thing you will want to do is setup a localhost site you can play with without fear of breaking a production site. Besides the packages listed in the link, Local by Flywheel is very popular.

    Once you have a local WP running, create a child theme in which you can place all of your custom code without risking it being overwritten by updates. There is never any reason to alter core code, and you must avoid altering other’s themes and plugins as well. All customizing is accomplished through action and filter hooks, or through child theme CSS and templates.

    Most important in coding is to enjoy doing it. Enjoy the small triumph in getting that one line of code to do exactly what you want.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Quiz/Algorithm Developer Question’ is closed to new replies.