Dani Llewellyn
Forum Replies Created
-
Forum: Plugins
In reply to: [A-Z Listing] parent category in brackets?The only thing I can immediately see is that you are not setting a default value to
$countbefore theforeachloop:$children = get_term_children( $immediate_parent, 'category' ); $count = 0; foreach ( $children as $child ) { $term = get_term_by( 'id', $child, 'category' ); // add the child's count to the value used in the title $count += $term->count; }Forum: Plugins
In reply to: [A-Z Listing] Add menu onlyHi,
This is not a feature that my plugin supports 🙁
There is, however, a small javascript file that can be included to turn the output into a “tabbed view” where the whole listing is loaded and then all the letters except one hidden from view; clicking a different letter will reveal that list and hide the previous one without reloading the page or having a different URL. To try this out, add the following code to your theme’s
functions.phpfile:add_filter( 'a_z_listing_tabify', '__return_true' );Forum: Plugins
In reply to: [A-Z Listing] Anchor offsetTo apply to the back-to-top links you’ll need to modify the javascript to also target those links.
Forum: Plugins
In reply to: [A-Z Listing] Widget shortcodeThe widget doesn’t show the pages. It is a widget, not a listing. The widget is meant to point to a page on your site where you use the shortcode from the plugin. For example, to show pages you would add to your editor area the following shortcode:
[a-z-listing display="posts" post-type="page"]Forum: Plugins
In reply to: [A-Z Listing] parent category in brackets?Hi,
The foreach loop is wrong. Sorry about that:
foreach ( $children as $child ) { $term = get_term_by( 'id', $child, 'category' ); // add the child's count to the value used in the title $count += $term->count; }You have two numbers in parentheses because you also have the following:
<strong><?php $a_z_query->the_title(); ?></strong> (<?php $a_z_query->the_item_post_count(); ?>)I suspect you’ll want to remove the second-half of that line – i.e. the parentheses and the content within.
Forum: Plugins
In reply to: [A-Z Listing] Multiple columnsHi,
The easiest way to do this is to copy the template file from
wp-content/plugins/a-z-listing/templates/a-z-listing.phpinto your theme and edit line 21 to change$_a_z_listing_minpercol = 10;. You will want to set that variable to1:$_a_z_listing_minpercol = 1;Make sure you’re aware of the concept of
child-themesif you are using a theme that you did not create yourself. You should use a child-theme in such circumstances so that any updates to your theme from its developer do not delete the template we copied above.Forum: Plugins
In reply to: [A-Z Listing] Anchor offsetHi,
The script is present in the plugin as an example. It will need customisation to support each site. You can load it without customising it with the following in your theme’s functions.php:
add_action( 'wp_enqueue_scripts', 'enqueue_a_z_scroll_fix' ); function enqueue_a_z_scroll_fix() { wp_enqueue_script( 'a-z-scroll-fix', plugins_url( 'scripts/a-z-listing-scroll-fix.js', trailingslashit( WP_PLUGINS_DIR ) . 'a-z-listing/a-z-listing.php' ), array(), false, true ); }The best thing to do, however, is to copy the file into an appropriate location in your theme, add any customisations – you likely need to adjust the offset, and then load from there instead of from the plugin.
- This reply was modified 6 years, 1 month ago by Dani Llewellyn. Reason: Fix wp_enqueue_script() usage
Forum: Plugins
In reply to: [A-Z Listing] multiple columns not workingHi,
It looks like you’re using a custom template, possibly copied from
wp-content/plugins/a-z-listing/templates/a-z-listing.example.php.The
a-z-listing.example.phpfile does not include the required markup for the columnar display to work. Instead you should either let the plugin use it’s default template by removing the template from your theme; or you should copy the template fromwp-content/plugins/a-z-listing/templates/a-z-listing.phpinstead.This latter template named simply
a-z-listing.php(i.e. the one that doesn’t include.examplein the name) is the one that will be used when you haven’t overridden it with a template in your theme.Forum: Plugins
In reply to: [A-Z Listing] multiple columns not workingThe inbuilt styles have not been loaded because the plugin cannot detect that it is being used on the page. To force the plugin to load the styles you can add the following line to your theme’s
functions.phpfile:add_action( 'init', 'a_z_listing_force_enable_styles', 99 );Forum: Plugins
In reply to: [A-Z Listing] Az list brokeHi,
You have the following CSS which is causing the issue:
.column, .columns { width:100%; float:left; padding-left:.625rem; padding-right:.625rem }You can reset this with the following CSS added to the theme customiser’s (navigate to wp-admin, then appearance, then customise) “Additional CSS” field to fix the problem:
div.letter-section > ul.columns { float: initial; }Forum: Plugins
In reply to: [A-Z Listing] How to display Woocommerce Products?Hi,
To display Woocommerce categories you want a shortcode similar to:
[a-z-listing display="terms" taxonomy="product_cat"]Forum: Plugins
In reply to: [A-Z Listing] Change the field from which is usedHi,
It looks ok from a quick review; although, you should be aware that the
_a-z-listing-extract-item-indicesfilter is meant for internal use so it is not guaranteed to function the same way in future versions.You might be able to achieve the same effect (to revert the title when you’ve overridden it for indexing) with better forward compatibility guarantees by copying the template into your theme and modifying line 57-59 to something like this:
<a href="<?php $a_z_query->the_permalink(); ?>"> <?php if ( 'term' === $a_z_query->get_the_item_type() ) { $term = get_term( $a_z_query->get_the_item_id() ); echo apply_filters( 'term_name', $term->term_name ); } else { $a_z_query->the_title(); } ?> </a>The default template is at
wp-content/plugins/a-z-listing/templates/a-z-listing.php.Forum: Plugins
In reply to: [A-Z Listing] How to add thumbnail on the list?Oh,
I completely failed to remember that bit when I posted the above code snippet. Thanks, @filomedio, for posting the correct call.
The purpose of that statement is that pulling the whole object will potentially slow down or break larger listings, so I wanted to make sure people really understood the implication when they use it.
Forum: Plugins
In reply to: [A-Z Listing] custom field optionSorry, @verylongelbow , I completely missed your original plea for help. I’m glad that you managed to get something working for your site, even though it’s via an alternative plugin. This is a feature that my plugin isn’t equipped to handle properly at the moment, so the likelihood is the AZIndex plugin suits your purposes better now. This is especially true as you have got your site into a working setup, which replacing the plugin again would be a “pain in the neck” (to use a British term) 🙂
Forum: Plugins
In reply to: [A-Z Listing] Change the field from which is usedHi,
This is not a feature that the plugin anticipates, and so it might be complex to set up how you want it, or possibly not doable at all.
I think you can possibly use either:
a_z_listing_item_index_letterto override the index letter, but leave the title unchanged, ora_z_listing_pre_index_item_titleto change the title
For the first option something like this in your theme’s
functions.phpmight work:<?php add_filter( 'a_z_listing_item_index_letter', 'override_a_z_index_letter' ); function override_a_z_index_letter( $original_index, $item, $type ) { $surname = get_post_meta( $item->ID, 'surname', true ); if ( $surname ) { return array( \A_Z_Listing\Strings::maybe_mb_substr( $surname, 0, 1 ) ); } return $original_index; }For the second option, something like this in your theme’s
functions.phpmight work:<?php add_filter( 'a_z_listing_pre_index_item_title', 'override_a_z_title' ); function override_a_z_title( $original_title, $item, $type ) { $surname = get_post_meta( $item->ID, 'surname', true ); if ( $surname ) { return $surname; } return $original_title; }