Title: giannit's Replies | WordPress.org

---

# giannit

  [  ](https://wordpress.org/support/users/giannit/)

 *   [Profile](https://wordpress.org/support/users/giannit/)
 *   [Topics Started](https://wordpress.org/support/users/giannit/topics/)
 *   [Replies Created](https://wordpress.org/support/users/giannit/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/giannit/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/giannit/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/giannit/engagements/)
 *   [Favorites](https://wordpress.org/support/users/giannit/favorites/)

 Search replies:

## Forum Replies Created

Viewing 15 replies - 1 through 15 (of 55 total)

1 [2](https://wordpress.org/support/users/giannit/replies/page/2/?output_format=md)
[3](https://wordpress.org/support/users/giannit/replies/page/3/?output_format=md)
[4](https://wordpress.org/support/users/giannit/replies/page/4/?output_format=md)
[→](https://wordpress.org/support/users/giannit/replies/page/2/?output_format=md)

 *   Forum: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
   
   In reply to: [Insert HTML in content property and render it using shortcodes or other](https://wordpress.org/support/topic/insert-html-in-content-property-and-render-it-using-shortcodes-or-other/)
 *  Thread Starter [giannit](https://wordpress.org/support/users/giannit/)
 * (@giannit)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/insert-html-in-content-property-and-render-it-using-shortcodes-or-other/#post-12186022)
 * Thank you very much [@joyously](https://wordpress.org/support/users/joyously/)!
   
   I improved a bit the code and now the result looks like this
 * ![](https://i0.wp.com/i.stack.imgur.com/oDAEC.png?ssl=1)
 * code is
 *     ```
       .above {
           position: relative;
           display: inline-block;
           margin-bottom: 1.5em;
         }
         .above::before {
           position: absolute;
           top: 90%;
           height: 6px;
           width: 100%;
           border: 1.5px currentcolor solid;
           border-top: 0;
           content: "";
         }
         .above .below {
           position: absolute;
           width: 100%;
           left: 0;
           top: 140%;
           font-size: 0.75em;
           text-align: center;
         }
       ```
   
 * `The product <span class="above">2 · 2 · 2 <span class="below">2<sup>3</sup></
   span></span> can be written as power.`
 * Do you think the code can be improved more?
    Here is a [DEMO](https://jsfiddle.net/8kq5oa6f/1/),
   I noticed that if I increase the font-size then the distance between the border
   and the below text increases, why is that? Thank you very much!
    -  This reply was modified 6 years, 5 months ago by [giannit](https://wordpress.org/support/users/giannit/).
    -  This reply was modified 6 years, 5 months ago by [giannit](https://wordpress.org/support/users/giannit/).
 *   Forum: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
   
   In reply to: [Insert HTML in content property and render it using shortcodes or other](https://wordpress.org/support/topic/insert-html-in-content-property-and-render-it-using-shortcodes-or-other/)
 *  Thread Starter [giannit](https://wordpress.org/support/users/giannit/)
 * (@giannit)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/insert-html-in-content-property-and-render-it-using-shortcodes-or-other/#post-12181938)
 * [@joyously](https://wordpress.org/support/users/joyously/) How can we achieve
   the same effect using a sibling span?
    -  This reply was modified 6 years, 5 months ago by [giannit](https://wordpress.org/support/users/giannit/).
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[MathJax-LaTeX] when using it adds linebreak](https://wordpress.org/support/topic/when-using-it-adds-linebreak/)
 *  [giannit](https://wordpress.org/support/users/giannit/)
 * (@giannit)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/when-using-it-adds-linebreak/#post-12179426)
 * Try adding the following to the file `style.css` in your site folder
 * `p:empty { display: none; }`
 * which hides the empty paragraphs `<p></p>`.
    If you want to hide just the `<p
   ></p>` generated by mathjax you may use the css combinators.
    -  This reply was modified 6 years, 5 months ago by [giannit](https://wordpress.org/support/users/giannit/).
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [Write text below a specific part of a sentence](https://wordpress.org/support/topic/write-text-below-a-specific-part-of-a-sentence/)
 *  Thread Starter [giannit](https://wordpress.org/support/users/giannit/)
 * (@giannit)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/write-text-below-a-specific-part-of-a-sentence/#post-12171825)
 * This seems to work very good, testing it
 *     ```
       [data-annotation] {
         position    : relative;
         white-space : nowrap;
         display: inline-block;
         margin-bottom: 2em;
       }
   
       [data-annotation]::before,
       [data-annotation]::after {
         position : absolute;
         z-index  : 1;  
         width  : 100%;
         opacity: .5;
       }
   
       [data-annotation]::before {
         top    : calc(100% + 2px);
         height : 5px;
         border : 1px currentcolor solid;
         border-top : 0;
         content: "";
       }
   
       [data-annotation]::after {
         content    : attr(data-annotation);
         left       : 0;
         font-size  : .75em;
         text-align : center;
         top        : calc(100% + 10px);
       }
       ```
   
 * for example
 * `The quick brown <span data-annotation="What if we remove this?">fox jumps over
   the lazy</span> dog.`
 * ![](https://i0.wp.com/i.imgur.com/FzKX96m.png?ssl=1)
 *   Forum: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
   
   In reply to: [Simulate shortcodes with javascript](https://wordpress.org/support/topic/simulate-shortcodes-with-javascript/)
 *  Thread Starter [giannit](https://wordpress.org/support/users/giannit/)
 * (@giannit)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/simulate-shortcodes-with-javascript/#post-12100328)
 * [@sterndata](https://wordpress.org/support/users/sterndata/) Thank you, I am 
   using the plugin Advanced Excerpt, I don’t have templates, instead I write the`
   <p class=textbox><b>TOPIC</b> description</p>` at the very beginning of each 
   post, and the plugin shows just that `<p>` and nothing else. That is, I don’t
   have to manually create the excerpts.
 * [@joyously](https://wordpress.org/support/users/joyously/) Thank you, I do want
   to see the shortcode in the excerpts. Since I have a hundreds of posts it is 
   handy to have a plugin (advanced excerpt) which automatically creates the excerpts.
 * I tried this javascript to replace the string `[VF]`, but it doesn’t work, why?
 *     ```
       function myFunction() {
         var str = document.getElementsByClassName("textbox")[0].innerHTML;
         var res = str.replace("[VF]", "test");
         document.getElementsByClassName("textbox")[0].innerHTML = res;
       }
       ```
   
 *   Forum: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
   
   In reply to: [Autogenerate shortcodes from an array of strings](https://wordpress.org/support/topic/autogenerate-shortcodes-from-an-array-of-strings/)
 *  Thread Starter [giannit](https://wordpress.org/support/users/giannit/)
 * (@giannit)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/autogenerate-shortcodes-from-an-array-of-strings/#post-12077133)
 * Solution
 *     ```
       $shortcodes = array("foo", "bar");
       foreach ($shortcodes as $name) {
           add_shortcode( $name, function ( $atts ) use ( $name ) {
               remove_filter( 'the_content', 'wpautop' );
               $content = apply_filters( 'the_content', '<div class=con>[block slug=' . $name . ']</div>' );
               add_filter( 'the_content', 'wpautop' );
               return $content;
           });
       }
       ```
   
 *   Forum: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
   
   In reply to: [Autogenerate shortcodes from an array of strings](https://wordpress.org/support/topic/autogenerate-shortcodes-from-an-array-of-strings/)
 *  Thread Starter [giannit](https://wordpress.org/support/users/giannit/)
 * (@giannit)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/autogenerate-shortcodes-from-an-array-of-strings/#post-12076616)
 * I know it is not a common usage, but since in my posts there will be only this
   kind of shortcodes, it is useless to have to write each time `[my_name_shortcode
   name="shortcode_name"]` when I can more rapidly write `[shortcode_name]`.
 * The previous example (print the name of the shortcode) is just an example to 
   let you understand that what I need is to be able to handle a string variable(
   taken from an array of strings) and use it inside the definition of a shortcode.
 * What have I to write in place of `???` in order to generate the shortcodes `[
   foo]` and `[bar]` having as content `<div class=con>[block slug=foo]</div>` and`
   <div class=con>[block slug=bar]</div>` respectively?
 *     ```
       $shortcodes = array("foo", "bar");
       function my_shortcode_function() {
       	remove_filter( 'the_content', 'wpautop' );
       	$content = apply_filters( 'the_content', '<div class=con>[block slug=???]</div>' );
       	add_filter( 'the_content', 'wpautop' );
       	return $content;
       }
       foreach( $shortcodes as $name ){
           add_shortcode ($name, 'my_shortcode_function');
       }
       ```
   
 *   Forum: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
   
   In reply to: [Autogenerate shortcodes from an array of strings](https://wordpress.org/support/topic/autogenerate-shortcodes-from-an-array-of-strings/)
 *  Thread Starter [giannit](https://wordpress.org/support/users/giannit/)
 * (@giannit)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/autogenerate-shortcodes-from-an-array-of-strings/#post-12075332)
 * Ok thanks, I’m having some problem with variable `name`, so let simplify the 
   problem so that each auto generated shortcode just has to print `my name is: "
   shortcode name"`
 *     ```
       $shortcodes = array("foo", "bar");
       function my_shortcode_function() {
           return ???;
       }
       foreach( $shortcodes as $name ){
           add_shortcode ($name, 'my_shortcode_function');
       }
       ```
   
 * I tried with `return 'my name is: $name';` and `return 'my name is: ' . $name;`
   but it doesn’t work since the output is `my name is: $name` in the first case
   and `my name is:` in the second case.
 * Which is the correct syntax?
    -  This reply was modified 6 years, 6 months ago by [giannit](https://wordpress.org/support/users/giannit/).
    -  This reply was modified 6 years, 6 months ago by [giannit](https://wordpress.org/support/users/giannit/).
 *   Forum: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
   
   In reply to: [Autogenerate shortcodes from an array of strings](https://wordpress.org/support/topic/autogenerate-shortcodes-from-an-array-of-strings/)
 *  Thread Starter [giannit](https://wordpress.org/support/users/giannit/)
 * (@giannit)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/autogenerate-shortcodes-from-an-array-of-strings/#post-12075216)
 * Oh thanks, is this correct?
 *     ```
       $shortcodes = array("foo", "bar");
       function my_shortcode_function( $name ) {
       	remove_filter( 'the_content', 'wpautop' );
       	$content = apply_filters( 'the_content', '<div class=con>[block slug=$name]</div>' );
       	add_filter( 'the_content', 'wpautop' );
       	return $content;
       }
       foreach( $shortcodes as $name ){
           add_shortcode ($name, 'my_shortcode_function( $name )');
       }
       ```
   
 *   Forum: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
   
   In reply to: [Autogenerate shortcodes from an array of strings](https://wordpress.org/support/topic/autogenerate-shortcodes-from-an-array-of-strings/)
 *  Thread Starter [giannit](https://wordpress.org/support/users/giannit/)
 * (@giannit)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/autogenerate-shortcodes-from-an-array-of-strings/#post-12075139)
 * > If every shortcode is the same, just define a single function and set that 
   > for each shortcode.
 * [@catacaustic](https://wordpress.org/support/users/catacaustic/) yes I have to
   define dozens of shortcodes with same funcionality (the only difference is the
   name in `[block slug=$name]`). I would like to avoid to manually write the definition
   of each shortcode, is it possibile to do it automatically?
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [How to reduce the vertical space above and below a ul list with one command?](https://wordpress.org/support/topic/how-to-reduce-the-vertical-space-above-and-below-a-ul-list-with-one-command/)
 *  Thread Starter [giannit](https://wordpress.org/support/users/giannit/)
 * (@giannit)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/how-to-reduce-the-vertical-space-above-and-below-a-ul-list-with-one-command/#post-12069611)
 * [@jdembowski](https://wordpress.org/support/users/jdembowski/) oh thank you!
   
   Could you please re-open my thread which has been closed since it was incorrectly
   associated with this one? Here is the thread [https://wordpress.org/support/topic/how-to-properly-hide-the-div-of-an-inline-collapsible-button/](https://wordpress.org/support/topic/how-to-properly-hide-the-div-of-an-inline-collapsible-button/)
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [How to reduce the vertical space above and below a ul list with one command?](https://wordpress.org/support/topic/how-to-reduce-the-vertical-space-above-and-below-a-ul-list-with-one-command/)
 *  Thread Starter [giannit](https://wordpress.org/support/users/giannit/)
 * (@giannit)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/how-to-reduce-the-vertical-space-above-and-below-a-ul-list-with-one-command/#post-12068552)
 * [@bcworkz](https://wordpress.org/support/users/bcworkz/) excuse me, this thread
   is very different from the other one titled “How to properly hide the div of 
   an inline collapsible button?”.
    Could you please re-open it?
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [How to reduce the vertical space above and below a ul list with one command?](https://wordpress.org/support/topic/how-to-reduce-the-vertical-space-above-and-below-a-ul-list-with-one-command/)
 *  Thread Starter [giannit](https://wordpress.org/support/users/giannit/)
 * (@giannit)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/how-to-reduce-the-vertical-space-above-and-below-a-ul-list-with-one-command/#post-12068546)
 * Ah so it’s enough to write `.redtext + ul`
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [How to reduce the vertical space above and below a ul list with one command?](https://wordpress.org/support/topic/how-to-reduce-the-vertical-space-above-and-below-a-ul-list-with-one-command/)
 *  Thread Starter [giannit](https://wordpress.org/support/users/giannit/)
 * (@giannit)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/how-to-reduce-the-vertical-space-above-and-below-a-ul-list-with-one-command/#post-12068329)
 * Oh thank you very much, I never heard about “sum” of objects.
    I played a bit
   and this seems to do the job
 *     ```
       .div+ul { margin-top: 0.5em; }
       .ul+div { margin-top: -0.5em; }
       .p+ul { margin-top: -0.5em; }
       .ul+p {	margin-top: -0.5em; }
       ```
   
 * This code works for the cases `p+ul+p`, `p+ul+div`, `div+ul+p` and `div+ul+div`.
 * I’m gonna test this in other situations.
 * Do you know if using the `+` notation is possibile to aim for a specific class?
   
   For example, say we want to apply `.p+ul {...}` but only for the `p` class `redtext`,
   is it possibile to write something like `.redtext p+ul {...}`?
 * Thank you again!
    -  This reply was modified 6 years, 6 months ago by [giannit](https://wordpress.org/support/users/giannit/).
    -  This reply was modified 6 years, 6 months ago by [giannit](https://wordpress.org/support/users/giannit/).
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [How to reduce the vertical space above and below a ul list with one command?](https://wordpress.org/support/topic/how-to-reduce-the-vertical-space-above-and-below-a-ul-list-with-one-command/)
 *  Thread Starter [giannit](https://wordpress.org/support/users/giannit/)
 * (@giannit)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/how-to-reduce-the-vertical-space-above-and-below-a-ul-list-with-one-command/#post-12068259)
 * I can’t since I’m working on localhost, I can show you screens from the inpector
   tool though:
 * ![](https://i0.wp.com/i.imgur.com/srIXbXL.png?ssl=1)
 * ![](https://i0.wp.com/i.imgur.com/jTcklJ9.png?ssl=1)

Viewing 15 replies - 1 through 15 (of 55 total)

1 [2](https://wordpress.org/support/users/giannit/replies/page/2/?output_format=md)
[3](https://wordpress.org/support/users/giannit/replies/page/3/?output_format=md)
[4](https://wordpress.org/support/users/giannit/replies/page/4/?output_format=md)
[→](https://wordpress.org/support/users/giannit/replies/page/2/?output_format=md)