How to add custom div in wordpress static page - php

Here I have a Wordpress theme, which is working fine.
Now I want to append my custom div under existing content. here are 2 existing panels which are following:
I'm new comer in WordPress so kindly assist me, how to achieve this requirement. your kind efforts would be heartily appreciated.

STEP 1: Open your wp-content->themes->your Theme Name-> footer.php
at very top beginning add div there but make sure it will show on all page.
Example:
<div class="infooterfile"></div>
<footer>
<div class="footer-wrap">
<div class="icoach-section">
<div class="footer-logo fadeIn animated">
<?php
$icoach_dark_logo=get_theme_mod('icoach_dark_logo');
$icoach_dark_logo=wp_get_attachment_url($icoach_dark_logo);
?>
<?php if($icoach_dark_logo != '' && !empty($icoach_dark_logo)): ?>
<img class="img-responsive" src="<?php echo esc_url($icoach_dark_logo); ?>" alt="<?php esc_attr_e('Logo','icoach');?>">
<?php endif; ?>
</div>
NOTE: If you want to show it only home page then you need to add div above <?php get_footer(); ?> in home page separate template.
EXAMPLE: in homepage separate template
<?php
/**
* The main template file
**/
get_header(); ?>
<div class="heading-wrap blog-heading-wrap" >
<div class="heading-layer">
<div class="heading-title">
<h1><?php _e('Blog ','icoach'); ?></h1>
</div>
</div>
</div>
<div class="yourdiv"></div>
<?php get_template_part('content'); get_footer(); ?>

Related

Load Top Menu After page Load Magento 2

I'm new to using Magento, I have a question for you.
How can I load the contents of the Magento Top menu into hover, only when you do the hover and not at the first landing?
Let me explain, I have a phtml file and I would like it to be loaded only when I'm hovering on the Top Menu
<?php
/**
* #var $block Menu
*/
use MyStore\Widget\Block\Widget\Menu;
?>
<div class="header-widget-block">
<?php if($block->getData('link')): ?>
<a href="<?= $block->getData('link') ?>" class="header-widget-link">
<?php endif; ?>
<?php if($block->getData('image')): ?>
<div class="header-widget-image d-lg-block">
<img loading="lazy" src="<?= $block->getData('image') ?>" alt="<?= $block->getData('title') ? $block->getData('title') : '' ?>">
</div>
<?php endif; ?>
<?php if($block->getData('title')): ?>
<div class="header-widget-title">
<?= $block->getData('title') ?>
</div>
<?php endif; ?>
<?php if($block->getData('link')): ?>
</a>
<?php endif; ?>
</div>
This is my phtml file.
I would like if not possible for each hover as it is dynamic, that it is loaded at least after the complete loading of the page
I would very much like to know this too. Our menu has around 1500 categories and this means at least twice that number in DOM elements, which is a performance killer, sometimes not necessary if the user does not initiate the menu at all.

the_post_thumbnail() doesn't seem to work on front-page.php

I'm creating a WordPress theme and I need a section on front-page.php to display the posts.
I have a template section in a folder called "includes" that checks if there are any posts and displays their thumbnails with their respective links. If I call it in the archive.php page with get_template_part() it works just fine, but I want it in front-page.php and that doesn't work for some reason I've been unable to figure out for hours.
This are my files and folders:
This is what's in the section-portoflio.php file:
<?php if(have_posts()): while(have_posts()): the_post();?>
<div class="col-6">
<a id="client-project" href="<?php the_permalink();?>">
<?php the_post_thumbnail();?>
</a>
</div>
<?php endwhile; else: endif;?>
This is what's in the archive.php file:
<?php get_header('project');?>
<div class="container">
<div class="row">
<?php get_template_part('includes/section-portfolio');?>
</div>
</div>
<?php get_footer();?>
When I try to copy and paste the code above in a div in my front-page.php file, it doesn't work.

loop wordpress Posts NOT in index , in another template

did read alot on stackoverflow and wordpress documentation but nothing works
iam using newest WP version
i createt a template named contact.php
<?php
/*
* Template Name: Contact Template
* description: >-
Page template
*/
get_header();
?>
everything works , you can choose the template in wp admin dashboard when creating a new site
but the post loop dosent work. only on the index.php
this code i use in index. works fine. if i copy over to my template it will not load the posts
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div class="col-12 mt-4 mb-4 justify-content-center text-center">
<a href="">
<h1><a href="<?php the_permalink(); ?>">
<?php the_title(); ?> </a></h1>
</a>
<hr>
<p> <?php the_excerpt(); ?> <br> </p>
<style>
img {
height: 200px;
width: 200px;
border-radius: 20%;
}
</style>
<?php if (has_post_thumbnail()) : ?>
<?php the_post_thumbnail(); ?>
<?php endif; ?><br>
<p> <?php the_author(); ?> <?php the_date(); ?><br> </p>
<p></p>
</div>
<?php endwhile; ?>
<!--end the while loop-->
<?php else : ?>
<!-- if no posts are found then: -->
<p>No posts found</p> <!-- no posts found displayed -->
<?php endif; ?>
<!-- end if -->
</div>
Actually when you create a new template into Wordpress theme folder directory you should copy from the one that is used from your template to render the post list.
As you can see here from wordpress documentation index.php is just the deepest level wordpress reach if it doesn't find any other suitable template.
If you are unsure of what template to use i suggest you to install query monitor and see from the wpadmin top bar in your frontend which is the template for a standard post loop page.
If you copied from the correct template there should be no standard reason of why that should fail. If it doesn't work for you what i can suggest is to see if the problem still happens with default template (like twentytwenty) or disabling all your plugins.

How do I get my entire footer to show up on all page templates? It is currently only showing up on the home page. Using wordpress

I am using a Wordpress template made with Cherry Framework. The complete footer only appears on the home page. I would like it to appear on all page types, which are mostly 'fullwidth page templates'.
When I look at the PHP files for each template, the difference I can see is this:
<?php do_action( 'cherry_after_home_page_content' ); ?>
I can't seem to find where cherry_after_home_page_content is defined. Could this be what I'm looking for? I tried copying that into the fullwidth page template, but it doesn't work. If I'm totally off base, what would be the correct way to accomplish this?
Footer that appears on every page regardless of template type. Here is the screenshot:
Code from fullwidth page template:
<?php
/**
* Template Name: Fullwidth Page
*/
get_header(); ?>
<div class="motopress-wrapper content-holder clearfix">
<div class="container">
<div class="row">
<div class="<?php echo cherry_get_layout_class( 'full_width_content' ); ?>" data-motopress-wrapper-file="page-fullwidth.php" data-motopress-wrapper-type="content">
<div class="row">
<div class="<?php echo cherry_get_layout_class( 'full_width_content' ); ?>" data-motopress-type="static" data-motopress-static-file="static/static-title.php">
<?php get_template_part("static/static-title"); ?>
</div>
</div>
<div id="content" class="row">
<div class="<?php echo cherry_get_layout_class( 'full_width_content' ); ?>" data-motopress-type="loop" data-motopress-loop-file="loop/loop-page.php">
<?php get_template_part("loop/loop-page"); ?>
</div>
</div>
</div>
<?php do_action( 'cherry_after_home_page_content' ); ?>
</div>
</div>
</div>
<?php get_footer(); ?>
Complete footer that only appears on the home page. Below is a screenshot:
Code from homepage template:
<?php
/**
* Template Name: Home Page
*/
get_header(); ?>
<div class="motopress-wrapper content-holder clearfix">
<div class="container">
<div class="row">
<?php do_action( 'cherry_before_home_page_content' ); ?>
<div class="<?php echo apply_filters( 'cherry_home_layout', 'span12' ); ?>" data-motopress-wrapper-file="page-home.php" data-motopress-wrapper-type="content">
<div class="row">
<div class="<?php echo apply_filters( 'cherry_home_layout', 'span12' ); ?>" data-motopress-type="static" data-motopress-static-file="static/static-slider.php">
<?php get_template_part("static/static-slider"); ?>
</div>
</div>
<div class="row">
<div class="<?php echo apply_filters( 'cherry_home_layout', 'span12' ); ?>" data-motopress-type="loop" data-motopress-loop-file="loop/loop-page.php">
<?php get_template_part("loop/loop-page"); ?>
</div>
</div>
</div>
<?php do_action( 'cherry_after_home_page_content' ); ?>
</div>
</div>
</div>
<?php get_footer(); ?>
I figured this out, so just for anyone who comes across this with the same problem.
The "cherry_after_home_page_content" had nothing to do with it. (And actually I noticed afterward that in my pasted code above I accidentally put in the code where I had pasted it in to the fullwidth page template where it does not belong. Ooops!)
Anyway, it is just in the CSS. If you are seeing that the footer widgets only appear on your homepage, you probably have this in your CSS:
.home .footer .footer-widgets { display:block; }
In your child theme, paste in the above code but change .home to the pages where you want it to show up. For me it was .page for all regular pages, .blog and .single-post for the blog.
Hope that helps someone!

How Can i Remove all sidebars from specific wordpress pages?

hi everyone im trying to remove all of the sidebars from a specific video page im creating on a wordpress site ive found tutorials on google on how to do this if the sidebars are called to the page using the
<?php get_sidebar(); ?>
method however my theme uses following method to call sidebars to a page
<?php include(TEMPLATEPATH."/sidebar.php");?>
i cant find any good methods for removing the sidebars that calls them to a page the same way as my theme does. here is the code to my page.php file on my website any help understanding how to remove them would be greatly appreciated =)
<?php get_header(); ?>
<div id="breadcrumb"><?php breadcrumbs(); ?></div>
<?php include(TEMPLATEPATH."/sidebar.php");?>
<div id="kontenutama">
<div class="postingan">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<h2><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>" rel="bookmark">
<?php the_title(); ?></a></h2><?php the_content(); ?>
<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
<br style="clear:both;">
</div>
</div>
<?php include(TEMPLATEPATH."/r_sidebar.php");?>
<br style="clear:both"><div style="clear:both">
</div>
<?php get_footer()?>
Why not create a new WordPress page template and remove the sidebar include on that page?
The theme is pretty dodgy, it shouldn't ever include files like that in template pages.

Categories