Delete all link
-
Hi
Using custom template seems that delete all button is always hidden. Is there any class we need to add to list wrapper to display it if count list > 1 ?
Regards
Greg
-
This will be the same as the answer to the previous topic, try the following code in Custom template.
<div data-ccc_favorite-delete_all=true><a href="#" class="ccc-favorite-post-delete-button">All Delete</a></div>Please see the related topic for usage. (Another reference)
Thanks
For some reason I get
style="display: none;"added to the above codeHi, @artefactdesign
Can you upload the code of the custom template of the problem to this topic?
If I can see both the PHP source code and the HTML elements of the output result, I may be able to figure out the cause.
Thanks
function ccc_my_favorite_list_custom_template( $my_favorite_post_id_array=false ) { $args= array( 'post_type' => 'any', 'post__in' => $my_favorite_post_id_array, ); $the_query = new WP_Query($args); if( $the_query->have_posts() ) : ?> <div data-ccc_favorite-delete_all=true><a href="#" class="ccc-favorite-post-delete-button">Delete all</a></div> <div> <?php while( $the_query->have_posts() ) : $the_query->the_post(); ?> <div class=""> // favorite list code hereresult into
<div id="ccc-my_favorite-list" data-ccc_my_favorites-list-style="none" data-ccc_my_favorite-posts_per_page="custom_template"> <div data-ccc_favorite-delete_all="true"> <a href="#" class="ccc-favorite-post-delete-button" style="display: none;">Delete all</a> </div> <div class=""> // favorite list code hereHi, @artefactdesign
Thanks for your reply.
Does that code stay hidden even when I have favorite posts?
In the JS settings, if none of the favorite posts are found, the all delete button is set to
style="display: none;.Yes the link is hidden despite some favorites posts
Hi, @artefactdesign
Unfortunately, I don’t know why this happens either.
I tried to reproduce that problem, but I couldn’t.
It was shown when I had favorite posts.Can you try the following code in a test environment?
function ccc_my_favorite_list_custom_template( $my_favorite_post_id=false ) { $args= array( 'post_type' => 'any', 'post__in' => $my_favorite_post_id, 'orderby' => 'post__in', 'posts_per_page' => -1, ); $the_query = new WP_Query($args); if( $the_query->have_posts() ) { ?> <p id="ccc-favorite-count"><span class="number"><?php echo $the_query->post_count; ?></span></p> <div data-ccc_favorite-delete_all=true><a href="#" class="ccc-favorite-post-delete-button">All Delete</a></div> <?php while( $the_query->have_posts() ) { $the_query->the_post(); ?> <div class="list-ccc_favorite"> <p><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></p> <div class="ccc-favorite-post-toggle"><a href="#" class="ccc-favorite-post-toggle-button" data-post_id-ccc_favorite="<?php echo $the_query->post->ID; ?>"></a></div> </div> <?php } //endwhile } //endif } // endfunctionshortcode:
[ccc_my_favorite_list_custom_template]-
This reply was modified 4 years, 4 months ago by
Takashi Matsuyama.
Thanks for your patience but I have the same issue with the above code
Hi, @artefactdesign
Thanks for your reply.Unfortunately, I can’t reproduce the same problem.
I may not be able to identify why it is hiding with the partial check on this topic.Is it a compatibility with other plugins?
Or it may be a compatibility issue with your theme.For example, you may want to try the following steps in a test environment.
- Stop other plugins.
- Try with a standard theme.
Thanks
-
This reply was modified 4 years, 4 months ago by
Takashi Matsuyama.
-
This reply was modified 4 years, 4 months ago by
Takashi Matsuyama.
Hi,
I wish you a happy new year.
I have the same issue here https://webserv2.ovh/playground/cc-favorite/ with basic WP theme and no plugin
Greg
Hi, @artefactdesign
Happy New Year!
And thanks for your reply.I found the cause probably by looking at your source.
Shortcode:
[ccc_my_favorite_list_menu slug="your_slug"]
Put this in place somewhere.You need to get the number of posts, and for that you need “.ccc-favorite-post-count”.
Its HTML class should be generated by this shortcode.
Thanks
Yeahh that is fixing the issue. What is the corresponding php version for this shortcode ? Is there a way to just get the number of favorite without a link which also will solve a above issue?
Hi, @artefactdesign
I believe this shortcode will work with php version 5.4.0 or higher.
I haven’t tried it without this shortcode, but maybe if you rewrite
<p id="ccc-favorite-count"><span class="number"><?php echo $the_query->post_count; ?></span></p>in “function ccc_my_favorite_list_custom_template” as<p id="ccc-favorite-count" class="ccc-favorite-post-count"><span class="number num"><?php echo $the_query->post_count; ?></span></p>
, it might work.I just thought about it without trying, so it may not work. Also, you may encounter other errors.
This is just one idea.Thanks
Unfortunately it does not work.
Hi, @artefactdesign
I tried it without the shortcode (
[ccc_my_favorite_list_menu]), and it worked when I added the following code.<div class="ccc-favorite-post-count"><span class="num"><?php echo $the_query->found_posts; ?></span></div><!-- /.ccc-favorite-post-count -->I wrote the HTML and query directly into my custom template, similar to the code generated by this shortcode.
function ccc_my_favorite_list_custom_template($my_favorite_post_id = false) { $args = array( 'post_type' => 'any', 'post__in' => $my_favorite_post_id, 'orderby' => 'post__in', 'posts_per_page' => -1, ); $the_query = new WP_Query($args); if ($the_query->have_posts()) { ?> <div class="ccc-favorite-post-count"><span class="num"><?php echo $the_query->found_posts; ?></span></div><!-- /.ccc-favorite-post-count --> <p id="ccc-favorite-count"><span class="number"><?php echo $the_query->post_count; ?></span></p> <div data-ccc_favorite-delete_all=true><a href="#" class="ccc-favorite-post-delete-button">All Delete</a></div> <?php while ($the_query->have_posts()) { $the_query->the_post(); ?> <div class="list-ccc_favorite"> <p><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></p> <div class="ccc-favorite-post-toggle"><a href="#" class="ccc-favorite-post-toggle-button" data-post_id-ccc_favorite="<?php echo $the_query->post->ID; ?>"></a></div> </div> <?php } //endwhile } //endif } // endfunctionIf you want, you can try it in a test environment.
Thanks
-
This reply was modified 4 years, 4 months ago by
The topic ‘Delete all link’ is closed to new replies.