Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #657742

    I want to insert a “back” icon in the single post view. I have to insert the following code in single.php before the loop. But it does’nt work. In the article itself works the Code, if I write it in the code area.
    But I want to display the icon automatically in any post What can I do?
    Here a part of the code:

    	
    ...	
    <div class='container_wrap container_wrap_first main_color <?php avia_layout_class( 'main' ); ?>'>
    
    			<div class='container template-blog template-single-blog '>
    
    				<main class='content units <?php avia_layout_class( 'content' ); ?> <?php echo avia_blog_class_string(); ?>' <?php avia_markup_helper(array('context' => 'content','post_type'=>'post'));?>>
    
    <div>
    <a href="javascript:history.go(-1)" onMouseOver="self.status=document.referrer;return true" class="icon-reply"  title="zurück">
    <span class="avia_button_icon" data-av_iconfont="entypo-fontello" data-av_icon="?" aria-hidden="true"></span>
    </a>
    </div>
    
                        <?php
                        /* Run the loop to output the posts.
                        * If you want to overload this in a child theme then include a file
                        * called loop-index.php and that will be used instead.
                        *
                        */
    
                            get_template_part( 'includes/loop', 'index' );
    ...
    
    #657975

    Hey MargitW,

    Could you link to an example post so that we can have a closer look please?

    Best regards,
    Rikard

    #658056

    At the moment this situation:
    Included in the single.php is the code. In addition, I have included a Code Block with this code below the sample post.
    The code from the single.php should insert above the article a Reply icon, what does not work. The block of code in the sample post works. But now the title of the post has disappeared. Even if I remove the code block again, the title will no longer appear. What is this effect???

    #659045

    Hi,

    If you use the advance layout builder to build the content of the post, it’s not going to use the single.php file. You have to add the script in the template-builder.php file.

    Best regards,
    Ismael

    #659459

    This is a good hint. But where must’ll insert this code for the back button?

    ?><div>
    <a href='javascript:history.go(-1)' onMouseOver='self.status=document.referrer;return true' class='icon-reply'  title='zurück'>
    <span class='avia_button_ico' data-av_iconfont='entypo-fontello' data-av_icon='ue830' aria-hidden='true'></span>
    </a>
    </div>
    <?php

    I have tried several places, nothing works.
    This is the Code of template-builder.php:

    <?php
    	if ( !defined('ABSPATH') ){ die(); }
    	
    	global $avia_config, $post;
    
    	if ( post_password_required() )
        {
    		get_template_part( 'page' ); exit();
        }
    
    	/*
    	 * get_header is a basic wordpress function, used to retrieve the header.php file in your theme directory.
    	 */
    	 get_header();
    	 
    
     	 // set up post data
    	 setup_postdata( $post );
    
    	 //check if we want to display breadcumb and title
    	 if( get_post_meta(get_the_ID(), 'header', true) != 'no') echo avia_title();
    	 
    	 do_action( 'ava_after_main_title' );
    
    	 //filter the content for content builder elements
    	 $content = apply_filters('avia_builder_precompile', get_post_meta(get_the_ID(), '_aviaLayoutBuilderCleanData', true));
    
    	 //if user views a preview me must use the content because WordPress doesn't update the post meta field
    	if(is_preview())
    	{
    		$content = apply_filters('avia_builder_precompile', get_the_content());
    	}
    
    	 //check first builder element. if its a section or a fullwidth slider we dont need to create the default openeing divs here
    
    	 $first_el = isset(ShortcodeHelper::$tree[0]) ? ShortcodeHelper::$tree[0] : false;
    	 $last_el  = !empty(ShortcodeHelper::$tree)   ? end(ShortcodeHelper::$tree) : false;
    	 if(!$first_el || !in_array($first_el['tag'], AviaBuilder::$full_el ) )
    	 {
            echo avia_new_section(array('close'=>false,'main_container'=>true, 'class'=>'main_color container_wrap_first'));
    	 }
    	
    	$content = apply_filters('the_content', $content);
    	$content = apply_filters('avf_template_builder_content', $content);
    	echo $content;
    
    	$avia_wp_link_pages_args = apply_filters('avf_wp_link_pages_args', array(
    																			'before' =>'<nav class="pagination_split_post">'.__('Pages:','avia_framework'),
    														                    'after'  =>'</nav>',
    														                    'pagelink' => '<span>%</span>',
    														                    'separator'        => ' ',
    														                    ));
    
    	wp_link_pages($avia_wp_link_pages_args);
    
    	
    	
    	//only close divs if the user didnt add fullwidth slider elements at the end. also skip sidebar if the last element is a slider
    	if(!$last_el || !in_array($last_el['tag'], AviaBuilder::$full_el_no_section ) )
    	{
    		$cm = avia_section_close_markup();
    
    		echo "</div>";
    		echo "</div>$cm <!-- section close by builder template -->";
    
    		//get the sidebar
    		if (is_singular('post')) {
    		    $avia_config['currently_viewing'] = 'blog';
    		}else{
    		    $avia_config['currently_viewing'] = 'page';
    		}
    		get_sidebar();
    	}
    	else
    	{
    		echo "<div><div>";
    		
    	}
    
    echo avia_sc_section::$close_overlay;
    echo '		</div><!--end builder template-->';
    echo '</div><!-- close default .container_wrap element -->';
    
    get_footer();
    
    #659475

    Hi!

    No need for any php. Just add a content block and paste the following inside

    <a href='javascript:history.go(-1)' onMouseOver='self.status=document.referrer;return true' class='icon-reply'  title='zurück'>
    <span class='avia_button_ico' data-av_iconfont='entypo-fontello' data-av_icon='ue830' aria-hidden='true'></span>

    it will show the informatious properly for you.

    Let us know if that works out

    Best regards,
    Basilis

    #659544

    Where should I insert the code block? Below the article I tested this code. He destroyed the post. The title disappears. Please visit the link. In the future, there are several editors. These editors are not to insert a block of code. I want to display the icon automatically over any post over the post title.

    #660652

    Hi,

    Sorry for the confusion. Please use the previous code then place it below or above this line:

    echo $content;
    

    Or use the “avf_template_builder_content” filter. Example: https://kriesi.at/support/topic/show-share-icons-on-portfolio-items-placement-issue/#post-586829

    Best regards,
    Ismael

    #661683

    I have now inserted the code in the single.php. It works, but it does’nt appear the icon but the numbers “ue830”. What code should I add to make the icon appear? Now, in the code: data-av_icon = ‘ue830’. See the link please – you can see this over the title.

    #663166

    Hi,

    Use this html code instead:

    <a href="javascript:history.go(-1)" onmouseover="self.status=document.referrer;return true" class="icon-reply" title="zur�ck">
    <span class="avia_button_icon" data-av_iconfont="entypo-fontello" data-av_icon="" aria-hidden="true"></span>
                        </a>

    Best regards,
    Ismael

    #663287

    Thank you, Ismael. That was the solution. I’ve already tried this before, but Notepad ++ always made the symbol to a question mark. Now I have tried in the editor explicitly set the encoding of the file to utf8. And now the icon is maintained. I am very happy!

    #663586

    Hi,

    Great, glad you got it working :-)

    Please open a new thread if you should have any further questions or problems.

    Thanks,
    Rikard

Viewing 12 posts - 1 through 12 (of 12 total)
  • The topic ‘Back-Icon in single.php’ is closed to new replies.