[Resolved] Problem hooking into generate_after_entry_header

Home Forums Support [Resolved] Problem hooking into generate_after_entry_header

Home Forums Support Problem hooking into generate_after_entry_header

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #482727
    Bruno 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!

    #483080
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    You have an error in your HTML.

    This: echo "</ul'>";

    Should be: echo "</ul>";

    #483432
    Bruno Dario

    Thanks, and sorry for that

    #483721
    Tom
    Lead Developer
    Lead Developer

    No problem! 🙂

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.