• Resolved Jonas Lundman

    (@jonas-lundman)


    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 :
    https://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?

    https://www.ads-software.com/extend/plugins/media-library-assistant/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter Jonas Lundman

    (@jonas-lundman)

    Noone?

    Plugin Author David Lingren

    (@dglingren)

    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.

    Thread Starter Jonas Lundman

    (@jonas-lundman)

    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…

    Plugin Author David Lingren

    (@dglingren)

    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.

    Thread Starter Jonas Lundman

    (@jonas-lundman)

    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

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Category template please help’ is closed to new replies.