Forums

Relevanssi - A Better Search
[resolved] Bookmarks? (6 posts)

  1. brasofilo
    Member
    Posted 9 months ago #

    all right,
    there's no support for bookmarks (although that would be nice)

    but, what if i do a template page that prints wp_list_bookmarks

    why can't Relevanssi register that page?

  2. msaari
    Member
    Posted 9 months ago #

    Relevanssi doesn't work on page template level. Relevanssi reads only the page content from the WordPress database and expands short codes, if necessary. Relevanssi doesn't care about the templates used to display pages.

  3. brasofilo
    Member
    Posted 9 months ago #

    for what you say, printing my blogroll in a page with a shortcode should index my bookmarks...

    but it ain't working
    curiously, when i hit "Build the Index", the shortcode gets printed inside the plugin page!

    this is what i used:

    function printBookmarks( $atts, $content = null ) {
    	wp_list_bookmarks();
    }
    add_shortcode('myblogroll', 'printBookmarks');
  4. brasofilo
    Member
    Posted 9 months ago #

    my bad,
    the correct and working code for Relevanssi to grab the content of a dynamic blogroll page is:

    function printBookmarks( $atts, $content = null ) {
    	$ritorna = "";
    	$taxonomy = 'link_category';
    	$args ='';
    	$terms = get_terms( $taxonomy, $args );
    	if ($terms) {
    		foreach($terms as $term) {
    			if ($term->count > 0) {
    				$ritorna .= "<h3>".$term->name."</h3>";
    				$bookmarks = get_bookmarks( array(
    								'orderby'        => 'name',
    								'order'          => 'ASC',
    								'category_name' => $term->name
    				                          ));
    				foreach ( $bookmarks as $bm ) {
    				 		$ritorna .= sprintf( '<a class="relatedlink" href="%s">%s</a><br />', $bm->link_url, __($bm->link_name) );
    				}
    			}
    	 	}
    	}
    	echo $ritorna;
    }
    add_shortcode('myblogroll', 'printBookmarks');

    then just add the shortcode [myblogroll] inside a page and we're good to go
    - and it's much better than going through the hassle of doing a template page

    ps: thanks and kudos for this great plugin, msaari :o)

  5. msaari
    Member
    Posted 9 months ago #

    Thanks!

    Yeah, I've very rarely bothered with doing page templates, when using a shortcode is often much easier.

  6. brasofilo
    Member
    Posted 7 months ago #

    just in case... full function here: http://pastebin.com/wk0fFFzT

Reply

You must log in to post.

About this Plugin

About this Topic