Site logo

Archived topic

List individual Q&As

39 replies · Started by John on July 12, 2021

Viewing posts 1–15 of 40

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

Hi there,

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

Hello David,

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

The Parent Category is "Discussions".

John

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.

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

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 ?

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.

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

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

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/

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;
} );

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

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.

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' ) ) ) {

This archived topic is closed to new replies.