• Resolved visualnoise

    (@visualnoise)


    I’m trying to add the_content to the list

    I have tried both adding the following to a-z-listing.php:
    <?php $a_z_query->the_title(); ?> and <?php the_content(); ?>

    I’m adding the code below <?php $a_z_query->the_title(); ?> in ‘a-z-listing.php’

    • This topic was modified 5 years, 8 months ago by visualnoise.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter visualnoise

    (@visualnoise)

    Any help would be greatly appreciated

    • This reply was modified 5 years, 8 months ago by visualnoise.
    • This reply was modified 5 years, 8 months ago by visualnoise.
    Plugin Author Dani Llewellyn

    (@diddledani)

    You’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_object must read exactly I 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_object you can use all the usual WordPress post-related functionality such as the_content().

    Thread Starter visualnoise

    (@visualnoise)

    That did it. Thank you so much for your excellent plugin and support

    I’m trying to get the content to display below the title. I’m unable to get this to work. Would you mind letting me know what’s wrong with the following.

    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(); ?></a><br />
          <?php $a_z_query->the_content(); ?>

    Error I’m getting is:
    Fatal error: Call to undefined method A_Z_Listing\Query::the_content()

    • This reply was modified 5 years, 4 months ago by jdinsmore.
    Plugin Author Dani Llewellyn

    (@diddledani)

    the_content() doesn’t exist on $a_z_listing. It is an in-built WordPress function. You need to call $a_z_query->get_the_item_object() as you have done to get enough information into WordPress for the normal template tags to operate as you would expect like when you are working in other templates in your theme. Once you’ve called ->get_the_item_object every template tag will work as the WordPress documentation says they will.

    The reason for the extra step of calling ->get_the_item_object is because I am anticipating that someone will use the plugin to show a LOT of items which will consume all available memory to build thereby causing their site to crash on the A-Z pages. For those situations I’ve attempted to alleviate the memory pressure by loading the absolute bare minimum from the database to show the items’ titles as hyperlinks to each of them.

    I hope this helps ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Including the_content in a-z list’ is closed to new replies.