Dani Llewellyn
Forum Replies Created
-
Forum: Plugins
In reply to: [A-Z Listing] count of used termsHi,
you have good eyes. Yes, the newly released version 2.2.0 includes the ability to show the post-count for taxonomy terms. To use this new functionality you need to customise the template that the plugin uses. First, copy the file at
wp-content/plugins/a-z-listing/templates/a-z-listing.phpinto your theme’s directory alongsidefunctions.php. It should be nameda-z-listing.php.Once you have your own template in your theme you can customise it. To add the post-count on a taxonomy term you can edit the file and find on line 58 the code
<?php $a_z_query->the_title(); ?>. Add to that thethe_item_post_count()call so that the line now looks like:<?php $a_z_query->the_title(); ?> (<?php $a_z_query->the_item_post_count(); ?>)Note that this will affect all listings whether or not they show taxonomy-terms. i.e. if they show posts the listing will have
(0)after every post title. I’ll make a note to add an extra method to allow the template to know what type of item it is displaying (term or post) because at the moment it is not easy to figure that out.Forum: Plugins
In reply to: [A-Z Listing] Widget Sitemap A-Z PageYou need to type the title of the post that contains your shortcode in the field and click (this is important) on the correct post in the list that it presents. If the list doesn’t appear then there are two possible reasons. First, the list might be stacked behind visible items on the screen via an incorrect
z-indexvalue. Second, there might be a javascript error either in my plugin or another plugin or theme that is causing the browser to not honour the API call.For the javascript error, you can find these if they are happening by opening the browser’s inspector/error console by pressing F12 or via a “Developer” menu item.
The browser console can also be used to determine whether there is a stacking order issue but this is trial and error and takes some time to work through.
Forum: Plugins
In reply to: [A-Z Listing] Display only 2 columnsHi,
The CSS that determines the columns can be overridden. I use a pre-processor to generate them but the final output is as follows:
.letter-section ul.columns { column-gap: 0.6em; column-width: 15em; } .letter-section ul.columns.max-0-columns, .letter-section ul.columns.max-1-columns { column-count: 1; max-width: 15.6em; } .letter-section ul.columns.max-2-columns { column-count: 2; max-width: 30.6em; } .letter-section ul.columns.max-3-columns { column-count: 3; max-width: 46.2em; } .letter-section ul.columns.max-4-columns { column-count: 4; max-width: 61.8em; } .letter-section ul.columns.max-5-columns { column-count: 5; max-width: 77.4em; } .letter-section ul.columns.max-6-columns { column-count: 6; max-width: 93em; } .letter-section ul.columns.max-7-columns { column-count: 7; max-width: 108.6em; } .letter-section ul.columns.max-8-columns { column-count: 8; max-width: 124.2em; } .letter-section ul.columns.max-9-columns { column-count: 9; max-width: 139.8em; } .letter-section ul.columns.max-10-columns { column-count: 10; max-width: 155.4em; } .letter-section ul.columns.max-11-columns { column-count: 11; max-width: 171em; } .letter-section ul.columns.max-12-columns { column-count: 12; max-width: 186.6em; } .letter-section ul.columns.max-13-columns { column-count: 13; max-width: 202.2em; } .letter-section ul.columns.max-14-columns { column-count: 14; max-width: 217.8em; } .letter-section ul.columns.max-15-columns { column-count: 15; max-width: 233.4em; }Hopefully, it should be clear that the column width is determined by
column-widthin the first selector. The rest of the rules are about limiting the number of columns so that there are always several items in each column before adding another column. This prevents situations where you have 5 columns each with a single item within. Instead, you’ll get a single column with 5 items rather than 5 columns with 1 item.The
max-widthin themax-x-columnsselectors is the number of columns multiplied by the column width and then0.6emadded to account for thecolumn-gap.If you use SCSS as a preprocessor you can generate the rules with:
.letter-section ul.columns { column-gap: 0.6em; column-width: 15em; &.max-0-columns, &.max-1-columns { column-count: 1; max-width: 15.6em; } @for $column from 2 to 16 { &.max-#{$column}-columns { column-count: $column; max-width: ($column * 15em) + (($column - 1) * 0.6em); } } }Forum: Plugins
In reply to: [A-Z Listing] List of out of stock products in WoocommerceYou could try to modify the query used by the plugin by adding some code to your theme’s
functions.phpsimilar to below:add_filter( 'a_z_listing_query', 'override_az_in_stock_products_only' ); function override_az_in_stock_products_only( $query, $type = 'posts' ) { if ( $type !== 'posts' ) { return $query; } $meta_query = array( array( 'key' => '_stock_status', 'value' => 'instock', ), ); if ( ! $query instanceof WP_Query ) { $query = (array) $query; } if ( $query instanceof WP_Query && $query->post_type === 'product' ) { $query->meta_query = $meta_query; } elseif ( $query['post_type'] === 'product' ) { $query['meta_query'] = $meta_query; } return $query; }I’ve not tested this, but I think it will work. Please give it a try and let me know if it needs improvement that I can help with 🙂
Forum: Plugins
In reply to: [A-Z Listing] Can’t get first characterIt looks like you’re hacking the plugin code directly. I’m sorry, but I can’t support you if you are. It will break whenever you update the plugin because your changes will be overwritten.
Forum: Plugins
In reply to: [A-Z Listing] Can’t get first characterIt seems that your alphabet is empty. This should not happen. If you specify the alphabet in your shortcode does it work correctly? To test, add the following into the shortcode:
alphabet="AÁÀÄÂaáàäâ,Bb,CÇcç,Dd,EÉÈËÊeéèëê,Ff,Gg,Hh,IÍÌÏÎiíìïî,Jj,Kk,Ll,Mm,Nn,OÓÒÖÔoóòöô,Pp,Qq,Rr,Ssß,Tt,UÚÙÜÛuúùüû,Vv,Ww,Xx,Yy,Zz"If you are using a localised installation of WordPress then the translation for the alphabet might be wrong on GlotPress. If this is the case, it would be awesome if you could suggest a fix there: https://translate.wordpress.org/projects/wp-plugins/a-z-listing
Forum: Plugins
In reply to: [A-Z Listing] How to Display only categoriesTo display the category names in your listing you can use a shortcode like:
[a-z-listing display="terms" taxonomy="category"]The
display="terms"parameter switches the plugin into showing “taxonomy terms” (categories are terms in the category taxonomy), andtaxonomy="category"tells the plugin which taxonomy to show, in this case, it is “categories”.Forum: Plugins
In reply to: [A-Z Listing] Vendor ListingsThe list under each letter will break into multiple columns once you have 10 items in the list for that letter.
Adding extra information to the output can be achieved by copying and editing the template into your theme from
wp-content/plugins/a-z-listing/templates/a-z-listing.phptowp-content/themes/$theme/a-z-listing.php. Note that for most post-related functionality such asget_the_post_thumbnail()you will need to call$a_z_listing->get_the_item_object( 'I understand the issues!' );directly after$a_z_listing->the_item();.The argument
I understand the issues!must read exactly that and indicates that you understand that using the function will possibly cause slowness, or breakage due to resource constraints when your listing has a lot of items.Forum: Plugins
In reply to: [A-Z Listing] Add Taxonomy title to index nameSorry, my code above was incorrect. To show the term names you need to run the array through a map first:
echo '[' . esc_html( implode( ', ', array_map( $terms, function( $term ) { return $term->name; } ) ) ) . ']';- This reply was modified 7 years, 2 months ago by Dani Llewellyn. Reason: fix new code
Forum: Plugins
In reply to: [A-Z Listing] List of subcategories of parent categoryThis plugin cannot filter posts by terms that are children of a specific parent term. It can only filter by a list of terms or a list of excluded terms. The plugin can, however, show taxonomy terms themselves filtered by a shared parent. You can’t mix posts with taxonomy terms in the same listing.
To show taxonomy terms (not posts) that are children of a single parent term:
[a-z-listing display="terms" taxonomy="project_category" parent-term="42"]The
parent-termneeds to be a term ID, not a term name or slug.Your list will show only direct children of the parent-term, but you can extend this to include grandchildren by appending
get-all-children="true":[a-z-listing display="terms" taxonomy="project_category" parent-term="42" get-all-children="true"]Forum: Plugins
In reply to: [A-Z Listing] Including the_content in a-z listYou’re nearly there. The missing ingredient is that you don’t have the Post loaded when you call
the_content()because I am keenly aware of the slowness and breakage it can cause on large listings. You can load the Post by adjusting the loop’s first few lines:Change:
while ( $a_z_query->have_items() ) : $a_z_query->the_item();To:
while ( $a_z_query->have_items() ) : $a_z_query->the_item(); $a_z_query->get_the_item_object( 'I understand the issues!' );Note that the argument passed to
get_the_item_objectmust read exactlyI understand the issues!to indicate to the plugin that you have understood that it might be slow, use a lot of resources, or break due to resource constraints (memory and time).Once you have called
get_the_item_objectyou can use all the usual WordPress post-related functionality such asthe_content().Forum: Plugins
In reply to: [A-Z Listing] Only showing relative pagesI suspect you have been relying on a bug which I have since fixed. The plugin defaults to restricting a “page” listing to “sections” where a section is defined by the top-most page in a hierarchy, in your case “Page 1” because the A-Z listing is on a child page of “Page 1”.
The current solution, while not ideal, is to add a small bit of PHP code to your theme’s
functions.phpfile, which replaces the sections to consider with an empty list. This causes the plugin to show all pages regardless of hierarchy. Take care to ensure that the code is within a<?phptag, which should be opened on the first line of the file:add_filter( 'a-z-listing-sections', '__return_empty_array' );Forum: Plugins
In reply to: [A-Z Listing] Add Taxonomy title to index nameYes, this can be achieved, but it might break because of resource limits on your server. It is a heavy operation and the larger the listing the more resource intensive the process.
With that caveat aside, the way to do it is to copy the template from the plugin folder at
templates/a-z-listing.phpinto your theme and adjust it slightly.On line 37 (in version 2.1.0) you will need to insert a new line after the opening
<?phptag with:$post = $a_z_query->get_the_item_object( 'I understand the issues!' );The text
I understand the issues!must be exactly that for the plugin to accept that you really have read my warning about it potentially being slow or breaking due to resource constraints, or both.Once you have the
$postyou can edit line 58 (again in version 2.1.0) to append the following on a new line:<?php $terms = get_the_terms( $post, 'category' ); if ( $terms ) : echo '[' . esc_html( implode( ', ', $terms ) ) . ']'; endif; ?>Forum: Plugins
In reply to: [A-Z Listing] Vendor ListingsDo you mean you want the vendors in the same listing? Or do you want a separate listing for your vendors?
Provided that your vendors are in a post-type called
vendoryou can include it in the same listing as posts and pages with:[a-z-listing display="posts" post-type="post,page,vendor"]For a separate listing use:
[a-z-listing display="posts" post-type="vendor"]Forum: Plugins
In reply to: [A-Z Listing] New Update needs new solution.Can you tell me the version numbers which do and do not exhibit the behaviour, please? “The new version” could mean different things to different people, so only using the specific version numbers can we all be on the same page. Also, could you please restate the issue you’re having because we have covered multiple issues in this thread so I’m not sure what the current state is. If you could also paste your current shortcode that would help, too.