-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Blog shortcode no-post message #18
Comments
The placeholder is added via function
Or, if you just want to use the placeholder text in your add-on, you can simply make a function call and pass your post type label here - I hope this will help. |
Hi yawalkar, is it possible to have more information about that? Thank you! |
Hi @pixfil It really depends on what you wish to accomplish. There usually no need to override that particular function unless editing/overriding an existing element. So if it doesn't fit your purposes you should be able to use your own function. If you do want to use the function fusion_builder_placeholder( 'post', 'blog posts' );
Unfortunately, the code @yawalkar won't be possible right now since the function within Fusion Builder is not pluggable. Can you provide some more information about the particular situation you are facing a problem with? |
Thank you mikka23 for your quick reply. Yes, I can tell a bit more about me and my issue: I'm using Avada and want to display something else than "Please add blog posts for them to display here" if I got no post to display. But! Ideally I'd like to display something for my guests like "no events right now" because I use a specific category post to display an upcoming event, which move to another category and another place in my website after the date is passed. So I got a "blank" on the initial "slot" -upcoming event-. Another important thing: I'm not a developer and I don't really understand functions construction.. "add action" and all the others things. I just know how to put it when I found what I want "ready to use".. Hope I was clear enough. If you can help I'll really appreciate, instead I'll keep it blank. Thank you |
Have you created your own element for this purpose? Or are you using an existing builder element but swapping the post type? |
i'm using the default element "Blog" (which display one post from a specific categorie "competition") that's all. No particular customisation. |
Hi @pixfil In that case i am afraid that is not really possible when using the default fusion blog shortcode. Even if the placeholder could be overridden right now it does not check for a specific category. So in your case you would not be able to alter the output just for a single category. Instead, you would be better of filtering the entire shortcode output using a core WP filter. For example: function empty_specific_category_blog( $output, $tag, $attr, $m ) {
if ( empty( $output ) && 'fusion_blog' === $tag && isset( $attr['cat_slug'] ) && 'competition' === $attr['cat_slug'] ) {
return 'No competitions to show.';
}
return $output;
}
add_filter( 'do_shortcode_tag', 'empty_specific_category_blog', 10, 4 ); You can add that to a child theme functions.php. It will check if the output is empty (so this will only show if you are logged out, because placeholder is shown if logged in so output is not empty). If the shortcode tag is fusion_blog and that the category selected is competition (assuming only a single category is selected) |
Hi mikka23, Thank you a lot, filtering the entire shortcode output works almost like a charm! I've two little problems which I try to resolve yet: - utf8 character issue : i got a "-?-" instead of my accent
Can we resolve those directly in the function? Thanks again :) |
I wrote again too fast! for the CSS, it's working when I use CSS ID on the column element. column CSS ID: "competune" Thank you a lot mikka23! problem solved for me. |
When the Blog shortcode has no posts to show it prints out the message
Please add blog posts for them to display here.
It is not very relevant for my add-on since we are dealing with custom post types rather then with blog posts.
Is it customizable somehow?
Can you please advise on the best way to do it?
The text was updated successfully, but these errors were encountered: