I've got 2 versions of a site, a live testing version and a local version.
I'm currently working on the local version, using MAMP. The backend of both sites is identical, I've ensured that the admin of each site is exactly the same.
I'm trying to add images to the site via the Edit Page section, but the images aren't displaying.
I inspected the site to see any errors, none were found, however I came acrosss something interesting.
After comparing the html markup of the 2 site versions side by side, I noticed that my local version is missing the the div that displays images.
Here is the div on the live version -
Here is the my local version, in which the div is not being shown -
As you can see in the local version there is a ul instead of div class="image-16-8.
Here is the php file that is displaying these images
<?php
function tbhHeroShortcode($atts)
{
$values = shortcode_atts(array(
'images' => '',
'first-line' => '',
'second-line' => '',
'video' => '',
'link' => '',
), $atts);
ob_start();
?>
<div class="hero">
<?
$images = decode_shortcode_data($values['images']);
if ($images): ?>
<ul data-simple-slider>
<?php foreach ($images as $image): ?>
<li>
<div class="image-16-8" style="background-image: url(<?= $image->url; ?>); "></div>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<div class="hero-content">
<div class="hero-content-first-line">
<h1 class="header"><?= decode_shortcode_data($values['first-line']) ?></h1>
</div>
<h1 class="italic-header"><?= decode_shortcode_data($values['second-line']) ?></h1>
<div class="hero-content-cta">
<a class="hollow-button" href="<?= decode_shortcode_data($values['link']) ?>">Learn More</a>
</div>
</div>
<?php if (count($images) > 1): ?>
<div class="hero-controls">
<i class="fa fa-chevron-left hero-controls__left" aria-hidden="true"></i>
<i class="fa fa-chevron-right hero-controls__right" aria-hidden="true"></i>
</div>
<?php endif; ?>
</div>
<?php
$component = ob_get_contents();
ob_end_clean();
return $component;
}
add_shortcode('tbhHero', 'tbhHeroShortcode');
Does anyone have any idea of why this is happening?
Well the ul is showing because it's right there in your php
<div class="hero">
<?
$images = decode_shortcode_data($values['images']);
if ($images): ?>
<ul data-simple-slider>
However, on your screenshot from the live version your hero div is different, it looks like this
<div class="hero" id>
The output you are seeing is not being generated by the same file, so either there is some browser/server caching going on and what you are seeing from the live site doesnt reflect the current state of your php, or somehow your php file updates are out of sync between your two environments.
I would guess that the difference between the two sites is in the "edit page" area of whatever page is serving as the home page. I would expect that local version has a shortcode called [tbh-hero] on it with image listed, while the other one doesn't have any images listed or perhaps doesn't have a shortcode on it at all. But, honestly, there are a lot of ways that that code could be implemented within the structure of a given theme.
Related
Please am new in computer programming and am using php to develop a music website but i ran into a problem to keep occuring in different project that i have being building.
The problem is when ever am using a grid system either a css grid or a bootstrap grid system the grid keeps breaking due to padding to keeps adding automatically to any side of the grid as i uses the foreach loop to loop over many element on any side of the grid layout, this problem will always occur as far as one side of the grid has my content than the other side like maybe my side bar has many content that the main grid content vice versa ... please i don't know what to do, am using a css grid right now.. here are some screeen shot of how it will look..
enter image description here
Here is a sample of how i use my foreach loop to display many content from my database.
<?php $post = new media_data();
$posts = $post->get_posts(5);
$num_rows = $posts->num_rows;
echo '
<div class="show-slide-container">
<?php foreach ($posts as $no => $post) {
<div class="my-slides fade">
<div class="txt-number-sl">
<?php $no + 1 ?> / <?php $num_rows ?>
</div>
<a href="<?php 'single_posts.php?post-slug=' . $post['slug'] ?>">
<img class="img-sl" src="<?php 'static/images/' . $post['image']; ?>"
alt="<?php html_entity_decode(substrwords($post['title'], 230)); ?>">
</a>
<div class="txt-body-sl">
<?php html_entity_decode(substrwords($post['title'], 100)); ?>
</div>
</div>
'
} ?>
I am getting child pages of a specific page. below is my code.
<div class="col-sm-3 services">
<h3>SERVICES</h3>
<?php $get_subcategories = wp_list_pages(array('child_of'=>39)); ?>
<ul>
<?php foreach($get_subcategories as $subcategory){?>
<li><?php echo $subcategory->name;?></li>
<?php }?>
</ul>
</div>
Here is the output of above code.
Problem: I am getting an additional word PAGES also. which is encircled in the above image.
From where this words is coming, and how to hide this ?
It is a default from the wp_list_pages() function.
Source: https://developer.wordpress.org/reference/functions/wp_list_pages/
You need to enter your title_li
<?php $get_subcategories = wp_list_pages(array('child_of'=>39, 'title_li' => '')); ?>
Here i solved the issues of showing default title and bullet points on each list item, by following the guidelines of #Gavin & #misorude i changed the above code and now it is working fine.
<div class="col-sm-3 services">
<h3>SERVICES</h3>
<ul>
<?php $get_subpages = wp_list_pages(array('child_of'=>39,'title_li'=>'')); ?>
</ul>
</div>
I created a custom page template for a wordpress theme , as long as I had the theme installed locally page was displayed and showed within it the custom post type associated with it , but when I loaded online theme and I created the page by selecting the template to be used the page content doesn't show up.
It seems that by selecting the page template is not created the page with this template , but creates a page with the content of the index.
this is my page code with the loop that shows a custom_post_type
<?php
/*
*Template Name: Partecipanti
*Description : Pagina che raggiude tutte le associazioni partecipanti
*/
?>
<?php get_header(); ?>
<div id="partecipanti" class="content-container row">
<h2 class="titolo-pagina"><?php the_title(); ?></h2>
<?php
$wpquery = new WP_Query(array(
'post_type' => 'partecipanti',
'posts_per_page' => -1,
));
while ($wpquery->have_posts()): $wpquery->the_post();
?>
<div class="container-partecipante col-lg-3 col-md-3 col-sm-4 col-xs-12 visible-xs">
<?php the_post_thumbnail() ?>
<h2 class="nome"><?php the_title() ?></h2>
</div>
<div class="flip-container container-partecipante col-lg-3 col-md-3 col-sm-4 col-xs-12 hidden-xs" ontouchstart="this.classList.toggle('hover');">
<div class="flipper">
<div class="front">
<?php the_post_thumbnail() ?>
</div>
<div class="back">
<h2 class="nome"><?php the_title() ?></h2>
<a class="glyphicon glyphicon-plus" href="<?php the_permalink(); ?>"></a>
</div>
</div>
</div>
<?php endwhile; wp_reset_query(); ?>
Maybe you just forgot set Page Template in page's edit? Or it was bugged - try delete template, save page (to auto-remove page template), upload template, set it again and save.
Also check if page template is at all used - for example place plain HTML test before <div id="partecipanti" class="content-container row"> and check if is displayed.
Have you the same WordPress version and plugins installed? Maybe you missed changed setting?
Try with simple page template, for example default full-width - are editor content is displayed?
Or maybe you have the same bug like me with latest WP version - when page is child (have parent page), it's bugged and page template doesn't work + page is outputed as post instead page.
Check file permisions in your theme folder
What's the best way to make multiply-page menu?
For example Category1 -> Article -> Full article text?
Not dropdown menu.
There's site example: http://fl.jetcode.lv/service.html
There are on page "Услуги" (Services), list with point's (Обслуживание windows, Подключение интернета, Сборка компьютеров, Чистка вирусов, ...)
When i click one of them (for example 'Обслуживание windows'('Maintenance windows')), i need to get page with points of that category like Установка Windows XP /Vista /7 /8 / W.S 2003,2008 (Installing Windows), Установка Linux (Installing Linux). And each Category have their own list of that text. So what's the best way to make that?
By steps:
1. I'm here: http://fl.jetcode.lv/index.html
2. I click on 'Обслуживание windows', and go to that page http://fl.jetcode.lv/service.html
3. Now i see a list with services on that category
4. Click on 'Полное описание', under 'Установка Windows XP /Vista /7 /8 / W.S 2003,2008'
5. And get to that page http://fl.jetcode.lv/service_inside.html
So how i can structure that's menu with WordPress ?
I've created a Posts with first categories (Category1), then i added it to Appearance->Menus, and get that list on page. Now i can manage their content in post, but it will be hard for end-user. So i trying to make list with second-category in post, and stucked. So can somebody please advice how it correctly/better to do ?
Thanks!
To put this simply,
You won't be needed to change anything to header but in category.php.
Instead of including the <section id="menu"> in the header put it on categories.php then to the usual get post contents and you are done.
The logic isn't in the menu but the flow of how you call each file/element.
This is the sample structure in category.php
<h1 class="post-title"><?php single_cat_title(); ?></h1>
<!-- Display all posts under specific Category -->
<?php while(have_posts()): the_post(); ?>
<hr />
<div id="category-post">
<!-- Display the Post Title -->
<h1><?php the_title(); ?></h1>
<!-- Display the Date & Time of Post -->
<p class="post-date">Posted on <span><?php the_time('F j, Y'); ?></span></p>
<!-- Checks if the post has Featured Image, else will load
the default thumbnail called post-thumb.jpg.
Delete ELSE CLAUSE to remove default thumbnail feature.
-->
<?php
if ( has_post_thumbnail() ) {
the_post_thumbnail( add_image_size( 'post-thumbnail'), array( 'class' => "post-thumb" ) );
}
else {
echo '<img class="post-thumb wp-post-image" src="';
echo bloginfo( 'stylesheet_directory' );
echo '/_/img/post-thumb.jpg" />';
}
?>
<!-- Display the excerpt if specified IF NOT, will display the
first 20 words in the actual content.
See functions.php for the excerpt lenght setting.
-->
<div class="category-content">
<?php the_excerpt();?>
</div>
<!-- Displays a link to the actual post -->
<a class= "category-read" href="<?php echo get_permalink() ?>">Read</a>
</div>
<?php endwhile; ?>
<!-- Displays the link for NEXT and PREVIOUS entries.
By default, only 10 posts per page can be loaded.
See [Settings > Reading] in Wordpress Panel to configure
-->
<div id='paging'>
<?php next_posts_link('« Older Entries ') ?>
|
<?php previous_posts_link(' Newer Entries »') ?>
</div>
I'm building a wordpress site (here: http://dev.tps.entropii.com/contact-us/) that requires a full page width google map on the contact page. The Business has two addresses so they effectively need two maps with a means to switch between them. I'm using Advanced Custom Fields plugin to give the user the functionality to update/edit their addresses.
Here's the problem. In order to give the functionality to switch back and forth between the two maps I decided to put them inside a twitter bootstrap carousel. One slide for each map. This works as expected with one problem. The map that is contained within the inactive slide (e.g. the slide that doesn't have the class 'active' on page load), doesn't seem to fully load. If I put the maps side by side on the page without the carousel they load no problem.
Because I'm using advanced custom fields, the maps are being loaded using php. Here's the HTML/php from my template file:
`
<!-- Wrapper for slides -->
<div class="carousel-inner">
<div class="item active">
<!-- map 1 -->
<?php $map1 = get_field('map_1'); if( !empty($map1) ): ?>
<div class="acf-map" id="map1">
<div class="marker" data-lat="<?php echo $map1['lat']; ?>" data-lng="<?php echo $map1['lng']; ?>"></div>
</div>
<?php endif; ?>
</div>
<div class="item">
<!-- map 2 -->
<?php $map2 = get_field('map_2'); if( !empty($map2) ): ?>
<div class="acf-map" id="map2">
<div class="marker" data-lat="<?php echo $map2['lat']; ?>" data-lng="<?php echo $map2['lng']; ?>"></div>
</div>
<?php endif; ?>
</div>
</div>
<!-- Controls -->
<a class="left carousel-control" href="#map-carousel" data-slide="prev"></a>
<a class="right carousel-control" href="#map-carousel" data-slide="next"></a>
</div>`
My suspicion is that because the inactive slides of the bootstrap carousel are set to display none, that the content isn't being loaded int he first place properly. However I'm completely stabbing in the dark. Can anyone shed any light on this?
Let me know if you ned any more info. Thanks,