[Resolved] List individual Q&As

Home Forums Support [Resolved] List individual Q&As

Home Forums Support List individual Q&As

Viewing 15 posts - 1 through 15 (of 40 total)
  • Author
    Posts
  • #1852493
    John

    Hello GP-Support !

    I’m into my third week with GP and think it is great. Thank you for such a great product and for such equally great service. Here comes another question:

    I will add a discussions section to my site. Discussions in the sense of Q&A and commenting. The individual Q&As are posts, not pages. Is there a way to create a page which contains a directory (I know how to create directories) which, in turn, lists the topics: i.e. Communication, Decision Making, Processes? Choosing a topic then takes the user to a list of the titles of individual Q&As?

    “Discussions” – a page – would be a term in the off-canvas menu.
    On that page – named Discussions – would be a list of topics: Communication, Decision Making, Processes, etc.
    Choosing a topic, for example, Communication then leads to a list of Q&A-titles.
    Choosing a title takes the user to that individual post, which contains: Question … Answer … Commenting.

    Thanks !

    John Magee

    #1852628
    David
    Staff
    Customer Support

    Hi there,

    are the Topics a Taxonomy ( eg. Category ) for the posts ?

    #1852652
    John

    Hello David,

    yes, the topics are a taxonomy. Currently there are 10 topics: Communication, Agreements, Persuasion etc.

    The Parent Category is “Discussions”.

    John

    #1852656
    David
    Staff
    Customer Support

    As you have the plugin for creating the directories – you just need to create a Static page to add the directory for listing your Topics. Each link will then take you to that topics archive.

    #1852662
    John

    yes, David. However, when choosing a topic from the directory, i.e. Communication, all of the posts categorized with “communication” will be pulled and presented. Those individual Q&As, however, are long: question + my response + comments from users.

    That makes it cumbersome for users to choose which Q&A interests them. Once they’ve chosen a topic from the directory I’d like only the title of all of the Q&As linked to that topic to appear. Otherwise they have to scroll through full-body texts of currently 100+ Q&As. Whereas the ideal flow would be:

    Go to Discussions directory.
    Choose a topic, i.e. Communication.
    See a list of Q&A-titles.
    Choose a Q&A.
    The post is presented: Question + John-Response + Comments.

    john

    #1852698
    David
    Staff
    Customer Support

    We just need to change the behaviour of the Archive Template being used for the various Topics.
    Theres a couple of ways to do this. First a question; are you using the Block Editor ?

    #1852711
    John

    not sure what you mean with “Block Editor”. I have newest version of WP and GP. In the backend in a post or page I have on the righthand side Page Block and Post Block.

    #1852713
    John

    would it help if I gave you admin-status on the site?

    #1852720
    John

    perhaps there is another solution, David, namely that we have the individual Q&A (posts) displayed not as full-body text, but instead as an excerpt. is that possible?

    users would read: title of post + question.

    John

    #1853035
    David
    Staff
    Customer Support

    If you have the Full Content displayed on your blog / archives then you can use this PHP Snippet to set the excerpt for a specific category:

    add_filter( 'generate_show_excerpt', function( $show ) {
        if ( is_category( array( 'cat-term-1', 'cat-term-2', 'cat-term-3' ) ) ) {
            return true;
        }
    
        return $show;
    } );

    I included the array so you can specify multiple Category terms.

    And then you can use the option_generate_blog_settings filter to disabling other elements such as meta:

    https://docs.generatepress.com/article/option_generate_blog_settings/

    #1853108
    John

    I created the snippet below, but it did not work. Please check the syntax.

    add_filter( ‘generate_show_excerpt’, function( $show ) {
    if ( is_category( array( communication, agreements, persuasion, decision-making, leadership, feedback, conflict, product, process, customer ) ) ) {
    return true;
    }

    return $show;
    } );

    #1853318
    Leo
    Staff
    Customer Support

    Looks like you are missing some quotation marks around each category.

    Please compare David’s code with your code or take a look at the example here:
    https://codex.wordpress.org/Conditional_Tags#A_Category_Page

    #1853337
    John

    Hi Leo,

    I suspect it’s more than just the quotation marks. Can you, please, ask David to give me exact instructions on how to get the code right?

    Thank you.

    John

    #1853361
    Leo
    Staff
    Customer Support

    Edited David’s code above slightly to remove the syntax error.

    Tested in Code Snippets to make sure it doesn’t have any errors:
    https://www.screencast.com/t/XKdc9YzEUz

    You just need to replace cat-term-1 cat-term-2 etc without removing the quotations and modifying anything else.

    #1853385
    John

    Hi Leo,

    ok, this is the correct code:

    add_filter( ‘generate_show_excerpt’, function( $show ) {
    if ( is_category( array( ‘cat-term-1’, ‘cat-term-2’. ‘cat-term-3’ ) ) ) {
    return true;
    }

    return $show;
    } );

    However, it is still not clear to me what I put in. Is this the correct second line:

    if ( is_category( array( ‘cat-term-communication’, ‘cat-term-agreements’. ‘cat-term-persuasion’ ) ) ) {

    communication, agreements, and persuasion are the first three of my ten topics, in other words the first three categories.

    Or is this the correct second line:

    if ( is_category( array( ‘communication’, ‘agreements’. ‘persuasion’ ) ) ) {

Viewing 15 posts - 1 through 15 (of 40 total)
  • You must be logged in to reply to this topic.