You will need to customise the template that drives the output of the list to the page. To do this, copy the file from wp-content/plugins/a-z-listing/templates/a-z-listing.php into your theme (i.e. to the folder wp-content/themes/your-theme-name – it needs to be in the theme’s top-most folder, not a subfolder).
Once you have the template in your theme, you need to edit it to change the title output line. On line 53 is the following:
while ( $a_z_query->have_items() ) :
On a new line directly after that line you want to add:
$a_z_query->get_the_item_object( 'I understand the issues!' );
Note the text “I understand the issues!”: this must read exactly as is to indicate to the plugin that you accept that your listing may be slower or run out of memory and break due to using the get_the_item_object function. This is because it will load the whole post from your database for every post in your listing, which is not done by default because of the speed and memory overhead in doing that.
Once you’ve called get_the_item_object() you can then use the Advanced Custom Fields functions, which I believe for this case you want get_field or get_the_field or similar (I don’t know much about ACF so can’t advise on the correct function). You’ll want to add a print/echo of the custom field’s value on line 59 either inside the <a> tags to make it part of the post’s link or after </a> to make it unlinked text.
-
This reply was modified 5 years, 7 months ago by
Dani Llewellyn. Reason: Fix broken code formatting block
I am trying this but having no success. It’s also not displaying the featured image either which isn’t ACF-related. Am I missing something?
https://www.paipharma.com/new-products-page/
Actually, everything is showing up except for wahtever item is at the top of the list. If I haven’t changed it since posting this, I basiccally just repeated the first product and made two of them. They’re exactly identical. But the top one on the page doesn’t display anything like the rest of them do.
@garyupham I think I made a mistake in my above code. The line:
$a_z_query->get_the_item_object( 'I understand the issues!' );
Needs to be directly after BOTH of these TWO lines (not the ONE I wrote originally):
while ( $a_z_query->have_items() ) :
$a_z_query->the_item();
Without the $a_z_query->the_item(); the “loop” isn’t forwarded onto the correct item so you’re always “one item behind”.
Hello, I cant figured out how to display taxonomy description. This is my code. Its show description from specific ID. BUT how to show desctiption for each taxonomy? Many thanks for help.
a-z-listing/templates/a-z-listing.php
<ul class="columns <?php echo $a_z_listing_column_class; ?>">
<?php
while ( $a_z_query->have_items() ) :
$a_z_query->the_item();
$a_z_query->get_the_item_object( 'I understand the issues!' );
?>
<li>
<a href="<?php $a_z_query->the_permalink(); ?>">
<?php $a_z_query->the_title(); ?> (<?php $a_z_query->the_item_post_count(); ?>)
</a>
<?php echo 'Term desctiption: ' . term_description( '11','post_tag' ); ?>
</li>
<?php endwhile; ?>
This also dont work:
<?php $description = term_description(); ?>
@tomsk2121 the forum guidelines for ww.wp.xz.cn require that you start your own thread instead of jumping into somebody else’s. This prevents thread hijacking. For your problem try replacing:
term_description( '11','post_tag' );
with
term_description( $a_z_query->get_the_item_id(), 'post_tag' );
alternatively, save the response from $a_z_query->get_the_item_object() to a variable and use that instead of the ID.