- This topic has 3 replies, 2 voices, and was last updated 6 years, 2 months ago by Tom.
-
AuthorPosts
-
January 29, 2018 at 10:23 am #482727Bruno Dario
Hello there, i’m facing a strange result when trying to use the generate_after_entry_header hook.
The situation is as follows:
I’m using the metabox plugin to generate specific data to courses pages (such as dates, locations, etc) and i’m trying to make those infos to appear right after the entry header so i’m hooking into the action to add it. Right now the page that shows those infos is a custom template but nothing was changed in the code (may change after i solve this).Ok, now here is the strange part, on my child theme “functions.php” file i’ve got this:
/** function to show the meta boxes info using a generatepress hook */ function show_bpmetaboxes(){ /** Is this a course page? (Child of any of the 3 top courses pages) */ if(is_tree(81)) { /** get meta data of courses and display it if it exists**/ $carga = rwmb_meta( 'cargahoraria' ); $local = rwmb_meta( 'localcurso' ); $horario = rwmb_meta('horariocurso'); if (isset($carga) || isset($local) || isset($horario)) { echo "<ul id='dadoscurso'>"; } if(isset($carga)) { echo "<li> <b><i class='fa fa-calendar'></i> Carga Horária: </b>" . $carga . "</li>"; } if(isset($local)) { echo "<li> <i class='fa fa-map-marker'></i> <b>Local do Curso: </b>" . $local . "</li>"; } if(isset($horario)) { echo "<li> <b><i class='fa fa-clock-o'></i> Horário: </b>" . $horario . "</li>"; } if (isset($carga) || isset($local) || isset($horario)) { echo "</ul'>"; } } } add_action( 'generate_after_entry_header', 'show_bpmetaboxes', 10, 3 );
As you can see, this puts an unordered list after the entry header and it’s working ALMOST fine, the issue i’m having is that the following code, found at ‘content-page.php’ file, line 43 is being rendered inside the unordered list instead of apearing after it as desired:
<div class="entry-content" itemprop="text"> <?php the_content(); wp_link_pages( array( 'before' => '<div class="page-links">' . __( 'Pages:', 'generatepress' ), 'after' => '</div>', ) ); ?> </div><!-- .entry-content -->
So i end up with something like:
<ul> <li></li> <li></li> <li></li> <div class="entry-content" itemprop="text"></div> </ul>
Expecting to be:
<ul> <li></li> <li></li> <li></li> </ul> <div class="entry-content" itemprop="text"></div>
Can you please tell me where’s the trick in here? Thx in advance!
January 29, 2018 at 4:57 pm #483080TomLead DeveloperLead DeveloperHi there,
You have an error in your HTML.
This:
echo "</ul'>";
Should be:
echo "</ul>";
January 30, 2018 at 4:52 am #483432Bruno DarioThanks, and sorry for that
January 30, 2018 at 9:17 am #483721TomLead DeveloperLead DeveloperNo problem! 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.