- This topic has 12 replies, 3 voices, and was last updated 1 year, 11 months ago by
David.
-
AuthorPosts
-
May 6, 2019 at 11:56 am #890993
Melissa
Hoping you can help with this page:
https://theslowroad.org/category/destinations/south-america/ecuador/I need to set the map and top text into 2 columns using an element. I know how to make column divs, but in this case I need to run php inside them, and my attempt doesn’t seem to work (I’m a total beginner at this.) The basic code did work before I tried the columns.
My element code:
// get the current taxonomy term// $term = get_queried_object(); // columns with map and description// <div class="grid-50 tablet-grid-50 mobile-grid-100 first-column"> <?php $description = get_field('country_description', $term); echo "<p>" . $description . "</p>"; ?> </div> <div class="grid-50 tablet-grid-50 mobile-grid-100 second-column"> <?php $description = get_field('country_description', $term); $map = get_field('country_map', $term); echo do_shortcode( ' '. $map .' ' ); ?> </div>
May 6, 2019 at 4:20 pm #891157Tom
Lead DeveloperLead DeveloperHi there,
That code looks like it should work. However, the Element on the page you linked me to seems to be using a different Element. Are you sure the one that applies to that category has the code?
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentMay 6, 2019 at 6:10 pm #891224Melissa
No, it was the right element. I had just left in an extra ?> that was breaking the php.
Now you should be able to see the columns issue. What I want is something like this:
text map
gallery head and grid (no posts right now, though)
post head and gridMay 7, 2019 at 2:12 am #891471David
StaffCustomer SupportHi there,
so the description is jumping into the second column. You would be able to share the entire code you are using for you Category Intro? When adding code to the forum, after you have pasted it in can you highlight it and hit the Code button 🙂
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/May 7, 2019 at 5:07 pm #892332Melissa
Here’s the whole Element:
<div id="category_intro"> <?php get_header(); //* get the current taxonomy term and load description and map*// $term = get_queried_object(); ?> <div class="grid-50 tablet-grid-50 mobile-grid-100 first-column"> <?php $description = get_field('country_description', $term); ?> </div> <div class="grid-50 tablet-grid-50 mobile-grid-100 second-column"> <?php $description = get_field('country_description', $term); $map = get_field('country_map', $term); echo "<p>" . $description . "</p>"; echo do_shortcode( ' '. $map .' ' ); ?> </div> <div id=cathead> <h2 class="border-heading"> <?php foreach((get_the_category()) as $category) { echo $category->cat_name . ' '; } ?> Photo Galleries </h2> <?php $terms = get_the_terms( get_the_ID(), 'category' ); if ( !empty( $terms ) ){ // get the first term $term = array_shift( $terms ); $term_slug = $term->slug; } wpsp_display( 26824, 'tax_term="' . $term_slug . '"' ); ?> </div> <div id=cathead> <h2 class="border-heading"> <?php foreach((get_the_category()) as $category) { echo $category->cat_name . ' '; } ?> Posts by Topic </h2> </div>
May 8, 2019 at 3:35 am #892643David
StaffCustomer SupportThis
<div id="category_intro">
looks like it is missing the closing</div>
which should come after the second column.Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/May 8, 2019 at 5:46 am #892725Melissa
It was–stupid mistake — thanks!
But that didn’t fix the layout.
May 8, 2019 at 7:04 am #892913David
StaffCustomer SupportSo i assume the first row is the Description (in first column) and map (in second column). If thats the case then move this:
echo "<p>" . $description . "</p>";
from the second column and place it in the first column so the first columns markup looks like this:
<div class="grid-50 tablet-grid-50 mobile-grid-100 first-column"> <?php $description = get_field('country_description', $term); ?> echo "<p>" . $description . "</p>"; </div>
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/May 8, 2019 at 8:34 am #893049Melissa
That worked well, except that the next div is still pulling up to the right.
https://theslowroad.org/category/destinations/south-america/ecuador/
May 8, 2019 at 8:42 am #893063Melissa
The most recent code:
<div id="category_intro"> //* get the current taxonomy term and load description and map*// <?php get_header(); $term = get_queried_object(); ?> <div class="grid-50 tablet-grid-50 mobile-grid-100 first-column"> <?php $description = get_field('country_description', $term); echo "<p>" . $description . "</p>"; ?> </div> <div class="grid-50 tablet-grid-50 mobile-grid-100 second-column"> <?php $description = get_field('country_description', $term); $map = get_field('country_map', $term); echo do_shortcode( ' '. $map .' ' ); ?> </div> </div> <div id=cathead> <h2 class="border-heading"> <?php foreach((get_the_category()) as $category) { echo $category->cat_name . ' '; } ?> Photo Galleries </h2> <?php $terms = get_the_terms( get_the_ID(), 'category' ); if ( !empty( $terms ) ){ // get the first term $term = array_shift( $terms ); $term_slug = $term->slug; } wpsp_display( 26824, 'tax_term="' . $term_slug . '"' ); ?> </div> <div id=cathead2> <h2 class="border-heading"> <?php foreach((get_the_category()) as $category) { echo $category->cat_name . ' '; } ?> Posts by Topic </h2> </div>
May 8, 2019 at 8:59 am #893080David
StaffCustomer SupportTry adding this CSS:
#category_intro { overflow: auto; }
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/May 8, 2019 at 9:01 am #893083Melissa
That’s it!
Thank you so much!
May 8, 2019 at 9:24 am #893112David
StaffCustomer SupportAwesome – glad to be of help!
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/ -
AuthorPosts
- You must be logged in to reply to this topic.