Skip to:
Content
Pages
Categories
Search
Top
Bottom

Is this the right syntax

  • @chrisknade

    Participant

    I’m trying to run a query through the bp_has_groups using the output of the_title() to match a slug.

    Been trying to use this, also tried assigning it to a variable but no luck.

    <?php if ( bp_has_groups( ‘type=single-group&slug=’ . the_title() ) ) : ?>

    Any ideas as I really need some help with this tbh.

    Cheers in advance

    Chris

Viewing 12 replies - 1 through 12 (of 12 total)
  • @plrk

    Participant

    What is it that you are trying to do?

    @chrisknade

    Participant

    Basically im trying to take the title of the page which matches my group slugs and get the info from the groups. trying to make the page completely dynamic. In the content of the whole thing the codes like this.

    <?php if ( bp_has_groups( 'type=single-group&slug=' . the_title() ) ) : ?>

    <dl class="featured_network_info">
    <?php while ( bp_groups() ) : bp_the_group(); ?>

    <!-- Example template tags you can use -->

    <dt><a href="<?php bp_group_permalink() ?>"></a></dt>
    <dd class="featured_title"><?php bp_group_name() ?></dd><?php bp_group_avatar_thumb() ?>
    <dd class="featured_members">Members : <?php bp_group_total_members() ?></dd>
    <dd> <?php bp_group_description_excerpt() ?></dd>

    <?php endwhile; ?>
    </dl>

    <?php else: ?>

    <div id="message" class="info">
    <p>There are no groups to display.</p>
    </div>

    <?php endif; ?>

    But I can’t get any output from anything.

    @mariusooms

    Participant

    If the template tag “the_title()” is the group title, it is simply not available yet when starting the loop.

    Like Plrk,

    What is it that you are trying to do?

    @chrisknade

    Participant

    Im not trying to use the group title, im trying to use the page title.

    Basically if I’ve got a page called page1 I want to retrieve the group details for the group called page1. I’m trying to do it dynamically because I want to use the same template instead of making up 50 odd templates for this particular project.

    I can get it to work if I pass in the slug as a string ie just

    `<?php if ( bp_has_groups( ‘type=single-group&slug=page1’) ) : ?>

    Chris

    @johnjamesjacoby

    Keymaster

    chrisknade, those two functions don’t really work together to give you anything that you could compare and get any real value out of.

    I won’t quote anyone else, but I’m curious too.. :)

    @chrisknade

    Participant

    Im not sure how you mean that, can you see the two replys i posted above? I couldn’t see them there until i logged in again? Im basically just trying to use the page title to get a group.

    In the simpliest way I can put it.

    If my page title is pagetitle

    <?php if ( bp_has_groups( ‘type=single-group&slug=pagetitle’ ) ) : ?>

    Im just trying to use the page title dynamically you see, because Im using this code in a template page. so gonna have page titles based on people names that have corresponding group slugs.

    @chrisknade

    Participant

    YAY MY POSTS HAVE FINALLY APPEARED.

    Can anyone now help me lol ?

    Chris

    @johnjamesjacoby

    Keymaster

    I still don’t quite get it, but I’ll assume that you’re trying to pull up group information that has the same Group Name as the Page Title?

    If so, does that mean you’re creating a page for each group manually? Ugh, no fun… Alas, this is what I would do, within ‘the loop’…

    $group_page_title = the_title('', '', false);
    <?php if ( bp_has_groups( 'type=single-group&slug=' . $group_page_title ) ) : ?>

    And then proceed? I haven’t tested it, so no promises…

    (The call to the_title could also probably just reference a $post-> variable, but I don’t remember what the title is off the top of my head.)

    @chrisknade

    Participant

    Yep that worked, thanks for that and your patience with the caching issue with regards to the the forum updating.

    @johnjamesjacoby

    Keymaster

    You bet. Some of your posts were getting marked as spam, along with some other users. Happens from time to time. I’m marking as resolved.

    @r-a-y

    Keymaster

    Hey John,

    Regarding the spam comment, do you know if these forums are using the bbPress Akismet plugin?

    @johnjamesjacoby

    Keymaster

    All of the *Press forums use Akismet. When you have as much activity as these collective forums get, you’ll have the occasional false positive from time to time. The algorithm that Akismet uses is always being adjusted to accommodate for this, but thankfully as we unmark posts that were incorrectly marked as spam, it learns as it goes and usually doesn’t happen again for that user.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Is this the right syntax’ is closed to new replies.
Skip to toolbar