WordPress.org

Ready to get started?Download WordPress

Forums

Media Library Assistant
[resolved] Category template please help (6 posts)

  1. Jonas Lundman
    Member
    Posted 1 year ago #

    Hi,
    I must ask this question, couse I just cant get it! Sorry. Im stucked, after hours of testing.

    The problem:
    Custom template does not spit out anything.

    My permalink settings:
    /%post_id%/%postname%/

    My template file:
    taxonomy-attachment_category.php

    I created an att.category "Myself" and assign images. Working fine, shows up in tables, columns and so on. Also when:

    $terms = get_the_terms($post->ID, 'attachment_category');

    So far so good.

    BUT

    When clicking in the att.category table "View", I gor this slug :
    http://localhost/wp-new/attachment_category/myself/

    The responding taxonomy-attachment_category.php opens, but then I cant get it... I tried (trying) :

    <?php get_header(); ?>
    <?php
    $cat= $_REQUEST['attachment_category']; echo $cat; // debugging...
    $cat = 'Myself'; // $cat cant be found so I force it
    ua_cat_nav( 'nav-above' );
    echo do_shortcode("[mla_gallery columns=5 link='file' posts_per_archive_page=10 attachment_category='".$cat."']");
    ua_cat_nav( 'nav-below' );
    ?>

    The <?php if ( have_posts() ) : ?> returns nothing.
    The shortcode works and spit the images, but I need to get the $cat value...

    I tried to go through all supports, but cant find a simple whole template.php file example for front end view.

    Where am I doing wrong?

    http://wordpress.org/extend/plugins/media-library-assistant/

  2. Jonas Lundman
    Member
    Posted 1 year ago #

    Noone?

  3. David Lingren
    Member
    Plugin Author

    Posted 1 year ago #

    Jonas,

    Thanks for your patience - I'm traveling and have limited access to the support forum.

    You are close to a solution, I think. The $_REQUEST array will not help you because the taxonomy and term information is embedded in the URL and WordPress separates the URL components to formulate the archive page query. You can get access to the individual query parts by accessing the query_vars array within the global $wp_query object. For example, try adding this code somewhere above the do_shortcode statement:


    <?php
    global $wp_query;
    echo var_export($wp_query->query_vars['attachment_category'], true) . '
    ';
    echo var_export($wp_query->query_vars['taxonomy'], true) . '
    ';
    echo var_export($wp_query->query_vars['term'], true) . '
    ';
    ?>

    You should see the taxonomy and term information echoed to the screen. you can then fix your do_shortcode statement to access $wp_query->query_vars['term'] instead of $cat.

    I hope that gets you closer to a solution. If you have any other questions about this application, let me know. You might find some additional hints in this earlier support topic:

    Building an Archive Page with MLA

    Let me know how you do with this; thanks.

  4. Jonas Lundman
    Member
    Posted 1 year ago #

    Hi,
    Thanks, global $wp_query; above the shortcode and replace my $cat with $wp_query->query_vars['term'] did the trick.

    My final step is now to get my pagination to work. Is there any thread on how? As a quick look, am I close ?... :

    my function above and below the shortcode containg posts_per_archive_page=20 attachment_category='".$wp_query->query_vars['term']."' is:

    function kriesi_pagination($pages = '', $range = 2){
    	$showitems = ($range * 2) + 1;  
    
    	global $paged;
    	if(empty($paged)) $paged = 1;
    
    	if($pages == ''){
    		global $wp_query;
    		$pages = $wp_query->max_num_pages;
    		if(!$pages) $pages = 1;
    
    	}   
    
    	if(1 != $pages){
    
    		if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<a class='prev page-numbers' href='".get_pagenum_link(1)."'>&laquo;</a>\n";
    		if($paged > 1 && $showitems < $pages) echo "<a class='prev page-numbers' href='".get_pagenum_link($paged - 1)."'>&lsaquo;</a>\n";
    
    		for ($i=1; $i <= $pages; $i++){
    			if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems )){
    				echo ($paged == $i)? "<span class='page-numbers current'>".$i."</span>\n":"<a href='".get_pagenum_link($i)."' class='page-numbers' >".$i."</a>\n";
    			}
    		}
    
    		if ($paged < $pages && $showitems < $pages) echo "<a class='next page-numbers' href='".get_pagenum_link($paged + 1)."'>&rsaquo;</a>\n";
    		if ($paged < $pages-1 &&  $paged+$range-1 < $pages && $showitems < $pages) echo "<a class='next page-numbers' href='".get_pagenum_link($pages)."'>&raquo;</a>\n";
    
    	}
      }

    It seems like the $paged need to be feeeeeeeded....
    Any ideas or help would be highest geratful...

  5. David Lingren
    Member
    Plugin Author

    Posted 1 year ago #

    I am in transit and passing through an Internet-aware location. I will have a look at this when I return home in a few days. Thank you for your understanding and your patience.

  6. Jonas Lundman
    Member
    Posted 1 year ago #

    Hi,
    After a loooong night I came up with a working solution.

    I would like you or other users to comment or take a look if there is a better and smarter code. I cretae a new therad and closing this peronal matter.

    Thanks

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.