Forum Replies Created

Viewing 15 replies - 241 through 255 (of 927 total)
  • Plugin Author Dani Llewellyn

    (@diddledani)

    Oh, I think I see the issue.

    You’ve set grouping=26 which will group all the posts into a single bucket. This means that the only ordering will be via a PHP comparator using strcmp. The above code will only affect which group a particular title is listed within, not its order inside that group.

    Plugin Author Dani Llewellyn

    (@diddledani)

    Hi,

    Can you post an example of a title that is failing to ignore a special character with the above code?

    Make sure you copy it from the title field in your wp-admin editor and paste it inside a “code” block here, so that any special characters are not mangled by any intermediate processes. To paste into a code block click the “code” item in the toolbar above the reply text box and then paste the title between the ` characters.

    Plugin Author Dani Llewellyn

    (@diddledani)

    Aaaah, I think I’ve spotted the issue. I’m so sorry it has eluded me till now.

    I’ve been going over my code and comparing with the code you have a few posts above, and found a slight difference.

    The code below is a slightly modified version of yours, where I added an extra item to the returned $indices array. This extra item is used for the permalink:

    add_filter( 'a_z_listing_item_indices', 'my_a_z_index_filter', 10, 3 );
    
    function my_a_z_index_filter( $indices, $item, $item_type ) {
        // make sure we're filtering the right post type
        if ( 'post' === get_post_type( $item ) ) {
            // pull the title and get the first letter of the second word
            $full_name = explode( ' ', $item->post_title );
    
            // the last word is in the last element of $title_parts so check it is there
            $last_name = array_pop( $full_name );
    
            // ensure we actually found a last name
            if ( $last_name )  {
                // cut the first letter out for our index
                $index = substr( $last_name, 0, 1 );
    
                // set up a new empty array
                $indices = array();
    
                // only the first names are left in $full_name. Join them together again
                $first_names = join( ' ', $full_name );
    
                // Now put the last name first and separate with a comma+space from the first names
                $formatted_name = "{$last_name}, {$first_names}";
    
                // add the new name associated with the item into the new array we created
                $indices[ $index ][] = array(
                    'title' => $formatted_name,
                    'item' => $item,
                    'link' => get_the_permalink( $item ),
                );
    
                // return a new array with our new index letter instead of the
                // indices already discovered by the plugin
                return $indices;
            }
        }
    
        // if we get here we didn't override the indices so return
        // those already discovered.
        return $indices;
    }
    Plugin Author Dani Llewellyn

    (@diddledani)

    No, sorry, I meant a template in your theme called a-z-listing.php. You might not have one, but if you do then customisations there might be causing this issue.

    Plugin Author Dani Llewellyn

    (@diddledani)

    Have you got a custom a-z-listing.php in your theme?

    If you have can you post the full content onto a paste service like wpbin.io and share the link so that I can check to see if there’s a problem there?

    Plugin Author Dani Llewellyn

    (@diddledani)

    OK,

    That looks sane, and correct.

    As an experiment can you try disabling all other plugins and set your site to use a default twenty* theme (e.g. twentytwenty) to see if the issue is an interaction with another plugin or your theme?

    The easiest way to do this without lasting affects, or interrupting anyone else working on the site, is to use the Health Check plugin to disable the plugins and theme for your current session only.

    Plugin Author Dani Llewellyn

    (@diddledani)

    Would it be possible for you to post the function that you have on the staging site that does the Surname order adjustment? It might be that I wrote that wrong when I did it for you originally, or it got mangled somehow, so it’s a good idea to double-check for sanity..

    Plugin Author Dani Llewellyn

    (@diddledani)

    Hi, sorry, I made a mistake on the line you highlighted.

    $a_z_listing should be $a_z_query

    Plugin Author Dani Llewellyn

    (@diddledani)

    Hi,

    I see from the original post that you were having trouble with links when overriding the title to put the surname first. Does the staging site have the correct links, now, or is that still broken? Also, does the staging site still have the correct titles with the surnames moved to the beginning of the title, or has that stopped working or been removed?

    I think you have two problems that you’ve highlighted, though correct me if I’m wrong: surnames are last in the live site but links work correctly, and links possibly don’t work in the staging site but titles are correctly ordered with surname first.

    Which of these two sites would be best to work towards fixing? Do you want to ignore the staging site and only work on live, or do you want to work on staging and then migrate those changes to live?

    Plugin Author Dani Llewellyn

    (@diddledani)

    Hi,

    The solution to this problem is largely similar to the post you linked.

    Copy the template file from wp-content/plugins/a-z-listing/templates/a-z-listing.php into your theme or child theme (using a child theme is preferable if you’re using a theme that you did not create). From there you will need to edit the template to add the function you discovered into an appropriate place. Something like this might work (this isn’t the whole template for brevity; it is amended from the original code from line 52 through to line 61 in the template as shipped in the plugin):

    <?php while ( $a_z_query->have_items() ) : $a_z_query->the_item(); ?>
    	<li>
    		<?php woocommerce_subcategory_thumbnail( $a_z_listing->get_the_item_id() ); ?>
    		<a href="<?php $a_z_query->the_permalink(); ?>">
    			<?php $a_z_query->the_title(); ?>
    		</a>
    	</li>
    <?php endwhile; ?>

    You might want to amend the HTML inside the <li> and </li> tags to allow you to apply a suitable style with CSS. Here is an example with some inline-styles to use flexbox:

    <?php while ( $a_z_query->have_items() ) : $a_z_query->the_item(); ?>
    	<li>
    		<div style="display: flex; flex-direction: row;">
    			<?php woocommerce_subcategory_thumbnail( $a_z_listing->get_the_item_id() ); ?>
    			<a href="<?php $a_z_query->the_permalink(); ?>">
    				<?php $a_z_query->the_title(); ?>
    			</a>
    		</div>
    	</li>
    <?php endwhile; ?>
    Plugin Author Dani Llewellyn

    (@diddledani)

    Hi,

    I suspect you could alter the template with code that references get_term_children(). Something like this might work:

    <?php
    while ( $a_z_query->have_items() ) : $a_z_query->the_item();
        ?>
        <a href="<?php $a_z_query->the_permalink(); ?>">
            <?php $a_z_query->the_title(); ?>
            <?php
            $all_parents = get_ancestors( $a_z_query->get_the_item_id(), 'category', 'taxonomy' );
            $immediate_parent = array_shift( $all_parents );
            if ( $immediate_parent ) :
                $immediate_parent_term = get_term( $immediate_parent, 'category' );
                $children = get_term_children( $immediate_parent, 'category' );
                $count = 0;
                foreach ( $children as $child ) {
                    // add the child's count to the value used in the title
                    $count += $child->count;
                }
                echo "({$count}) - {$immediate_parent_term->name}";
            endif;
            ?>
        </a>
        <?php
    endwhile;
    ?>
    Forum: Plugins
    In reply to: [A-Z Listing] Paging
    Plugin Author Dani Llewellyn

    (@diddledani)

    Hi,

    This is not a feature that the plugin supports currently. I appreciate that it is a desired feature, but I don’t know how best to implement it yet.

    Plugin Author Dani Llewellyn

    (@diddledani)

    Hi,

    Unfortunately I’m unable to access your site to investigate, because it is behind a splash screen – I presume that is because you’re not ready to “go live” yet, and are still developing the new site.

    You refer to tabs; are you using the javascript supplied in the plugin to hide all-but-one letter at a time? I suspect, if you are using it, that this javascript is failing to target the second list because I wrote it under the anticipation that there’ll only be one list per page.

    Alternatively are you referring to the default CSS styles, where the first list is correctly styled, but the second list is not?

    With the brand product attribute taxonomy failing to link to the correct page, I will need to try to replicate this behaviour to understand why that might be. The plugin should use the URL that WordPress provides for each term in a taxonomy. If you try to display the term(s) elsewhere on your site, not in my plugin, do they have a permalink that leads to the correct page?

    Hi,

    Did this fix your problem?

    If your question has been answered, we would love if you would mark this topic as resolved in the sidebar. This helps our volunteers find the topics that still need attention and more people will get helped, possibly like you did.

    Hi, it looks like you’ve found the problem?

    If your question has been answered, we would love if you would mark this topic as resolved in the sidebar. This helps our volunteers find the topics that still need attention and more people will get helped, possibly like you did.

Viewing 15 replies - 241 through 255 (of 927 total)