Hello,
I would like to show a message like, “This category has no posts” when a user lands on a category page that has no posts.
I am using the Posts Loop element. When the Posts Loop has no posts, how can I display a message to the user to let them know there are no posts rather than have a blank page?
Thank you.
Hello Anamaria,
That’s alright if there is no built in setting. I have experience programming — I just need to be pointed in the right direction.
Which file contains the logic for the Posts Loop element so that I can modify it to display a message if there are no posts?
Thank you.
-
This reply was modified 4 years by
patrickrodo.
Thank you!
Final question — I am trying to use a child theme to avoid losing the custom work every time I update WordPress/the Newspaper theme.
I have tried the following file structures and none of them seem to work:
- wp-content/themes/Newspaper-child/modules
- wp-content/themes/Newspaper-child/includes/modules
- wp-content/themes/Newspaper-child/td-cloud-library/modules
How do I modify wp-content/plugins/td-cloud-library/modules/tdb_module_loop.php, tdb_module_loop_2.php, and
wp-content/plugins/td-composer/legacy/common/wp_booster/td_block.php in the child theme?
Hello,
I just discovered code already in the theme that accomplishes exactly what I am looking for, but it has been commented out by your team.
wp-content/plugins/td-cloud-library/shortcodes/common
/**
* on composer iframe and on templates that do not have posts we show the no posts message
* @see td_page_generator::no_posts() - this function generates the __td('No posts to display').
* the text can be overwritten by the template using the global @see td_global::$custom_no_posts_message
*/
//if ( tdc_state::is_live_editor_ajax() || tdc_state::is_live_editor_iframe() ) {
//$buffy .= td_page_generator::no_posts();
//} else {
//$offset = intval($this->get_att('offset'));
//if ( $offset === 0 ) {
//$buffy .= td_page_generator::no_posts();
//}
//}
Lines 1717 – 1724.
When uncommented, this block shows the “No posts” message as expected.
Is this intentionally commented out or was it a mistake?
I would like a way to preserve my update of uncommenting it so that I don’t have to re-do it during the next theme update.
Please let me know if this is possible.
Thank you,
Patrick
-
This reply was modified 4 years by
patrickrodo.
-
This reply was modified 4 years by
patrickrodo.
-
This reply was modified 4 years by
patrickrodo.
Hello Patrick,
I don’t know exactly if it was intended, but I will ask the developers.
Also, the files that come from the tagDiv cloud library can’t be set in the child theme.
Thank you for your understanding!
Sounds good, Anamaria. Thank you! It seems it may have been inadvertently commented out as the behavior it produces is expected/correct and there is code all throughout the code base to support it.
Thanks again,
Patrick