Open drudnev opened 9 years ago
Found a working solution if anyone is interested, feel free to comment. ln:51
// Specific Category achievement - pass an 'id' attribute
'dpa-category-achievements' => array( $this, 'display_category_achievements' ),
And the actual function.
/**
* For the current category, display an index of all the achievements
* in an output buffer and return to ensure that post/page contents are displayed first.
*
* @param array $attr
* @param string $content Optional
* @return string Contents of output buffer
* @since Achievements (3.0)
*/
public function display_category_achievements( $attr, $content='') {
$this->unset_globals();
// Sanity check required info
if ( ! empty( $content ) || empty( $attr['category_name'] ) )
return $content;
$this->start( 'dpa_category_achievement_archive' );
achievements()->achievement_query->in_the_loop = true;
dpa_has_achievements( array( 'category_name' => $attr['category_name'] ) );
while ( dpa_achievements() ) {
dpa_the_achievement();
dpa_get_template_part( 'loop-single-achievement' );
}
return $this->end();
}
Hi
Thanks for writing. I'm not currently supporting or working on this plugin, so I'm going to leave your comments here in case anyone else is trying to do the same thing and finds it.
Thanks again for using Achievements!
Paul Gibbs
On 2 Jul 2015, at 06:11, drudnev notifications@github.com wrote:
Found a working solution if anyone is interested, feel free to comment. ln:51
// Specific Category achievement - pass an 'id' attribute 'dpa-category-achievements' => array( $this, 'display_category_achievements' ),
And the actual function.
/** * For the current category, display an index of all the achievements * in an output buffer and return to ensure that post/page contents are displayed first. * * @param array $attr * @param string $content Optional * @return string Contents of output buffer * @since Achievements (3.0) */ public function display_category_achievements( $attr, $content='') { $this->unset_globals(); // Sanity check required info if ( ! empty( $content ) || empty( $attr['category_name'] ) ) return $content; $this->start( 'dpa_category_achievement_archive' ); achievements()->achievement_query->in_the_loop = true; dpa_has_achievements( array( 'category_name' => $attr['category_name'] ) ); while ( dpa_achievements() ) { dpa_the_achievement(); dpa_get_template_part( 'loop-single-achievement' ); } return $this->end(); }
— Reply to this email directly or view it on GitHub.
Is there a way to do a category based filter, can someone post an example how this can be done? https://wordpress.org/plugins/display-posts-shortcode/ Doesn't seem to pickup achievements:
I was trying to add add filter to short codes to in mean time but its not working either it seems that query gets reset , can't figure out where ( pardon the n00b).
thank you for you help in advance.