ACF flexible content layout group for table of contents - php

I have an ACF flexible content field with a layout name of 'post_section' which has a group field called 'paragraph' with fields for 'id', 'title' and 'text'. In my component-post_section.php file i have the following php:
<?php if( have_rows('paragraph') ): ?>
<?php while( have_rows('paragraph' ) ): the_row(); ?>
<div class="container">
<div class="row" id="<?php the_sub_field('id'); ?>">
<h2><?php the_sub_field('title'); ?></h2>
<?php the_sub_field('text'); ?>
</div>
</div>
<?php endwhile; ?>
<?php endif; ?>
This produces the following which is fine:
But im trying to produce the following - a bootstrap accordion table of contents above with the titles of the two post_section titles:
This is my php:
<?php if( have_rows('paragraph') ): ?>
<?php while( have_rows('paragraph' ) ): the_row(); ?>
<div id="accordion">
<div class="card">
<div class="card-header" id="headingOne">
<h5 class="mb-0">
<button class="btn btn-link" data-toggle="collapse" data-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
Table of Contents
</button>
</h5>
</div>
<div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion">
<div class="card-body">
<p><?php the_sub_field('title'); ?></p>
</div>
</div>
</div>
</div>
<div class="container">
<div class="row" id="<?php the_sub_field('id'); ?>">
<h2><?php the_sub_field('title'); ?></h2>
<?php the_sub_field('text'); ?>
</div>
</div>
<?php endwhile; ?>
<?php endif; ?>
However, this is what i get:
Any ideas on how i can achieve what i want i.e an output of my title and text field fields for each paragraph BUT only a single output of the titles in the table of contents div like this?
Maybe i need to create a separate component php file for the accordion?
Thanks for any help.

If I am understanding your question right, you simply want a single accordion dropdown to reveal a list of your flexible content paragraph sections?
The single accordion dropdown content is essentially a list of anchor links to navigate directly directly to your flexible content paragraph sections.
If this is the case, then see working example below of how to achieve this.
All of this code below must be run inside your post loop.
<div class="container">
<?php if(have_rows('paragraph')): ?>
<div class="accordion" id="tableContentsAccordion">
<div class="card">
<div class="card-header" id="tableContents">
<h2 class="mb-0">
<button class="btn btn-link btn-block text-left" type="button" data-toggle="collapse" data-target="#tableContentsList" aria-expanded="true" aria-controls="tableContentsList">
Table of Contents
</button>
</h2>
</div>
<div id="tableContentsList" class="collapse show" aria-labelledby="tableContents" data-parent="#tableContentsAccordion">
<div class="card-body">
<?php while(have_rows('paragraph')): the_row();
$title = get_sub_field('title');
?>
<?php echo $title; ?><br/>
<?php endwhile; ?>
</div>
</div>
</div>
</div>
<?php endif; ?>
<?php if(have_rows('paragraph')): ?>
<div class="row">
<?php while(have_rows('paragraph')): the_row();
$title = get_sub_field('title');
?>
<div class="col-12" <?php echo $title ? 'id="' . sanitize_title($title) . '"' : ''; ?>>
<?php echo $title ? '<h2>' . $title . '</h2>' : ''; ?>
<?php the_sub_field('text'); ?>
</div>
<?php endwhile; ?>
</div>
<?php endif; ?>
</div>
As mentioned in previous comments on your question, you need to run the have_rows('paragraph') statement twice in order to output flexible content paragraph sections content in two separate html locations.
You can actually combine all my code into a single have_rows('paragraph') statement, but only if your section content immediately follows your table of contents html.
If you want to put your table of contents in the sidebar or anywhere separate from your paragraph section output, then you will need to use have_rows('paragraph') twice.
Update 1
So in response to your first comment, I created this example ACF flexible content field on a test environment.
Flexible content field named paragraphs and field location set to Post post type.
With a single block layout named paragraph with two sub fields title and name...
I then created a new post with this flexible content data...
I then ran this php code in my single.php...
<?php
// get our header
get_header();
?>
<main>
<div class="container">
<?php if(have_posts()): ?>
<?php while(have_posts()) : the_post(); ?>
<h1 class="pb-2 my-4 border-bottom"><?php the_title(); ?></h1>
<?php if(have_rows('paragraphs')): ?>
<div class="accordion" id="tableContentsAccordion">
<div class="card">
<div class="card-header" id="tableContents">
<h2 class="mb-0">
<button class="btn btn-link btn-block text-left" type="button" data-toggle="collapse" data-target="#tableContentsList" aria-expanded="true" aria-controls="tableContentsList">
Table of Contents
</button>
</h2>
</div>
<div id="tableContentsList" class="collapse show" aria-labelledby="tableContents" data-parent="#tableContentsAccordion">
<div class="card-body">
<?php while(have_rows('paragraphs')): the_row(); ?>
<?php $title = get_sub_field('title'); ?>
<?php echo $title; ?><br/>
<?php endwhile; ?>
</div>
</div>
</div>
</div>
<?php endif; ?>
<?php if(have_rows('paragraphs')): ?>
<div class="row my-4">
<?php while(have_rows('paragraphs')): the_row(); ?>
<?php $title = get_sub_field('title'); ?>
<div class="col-12" <?php echo $title ? 'id="' . sanitize_title($title) . '"' : ''; ?>>
<?php echo $title ? '<h2>' . $title . '</h2>' : ''; ?>
<?php the_sub_field('text'); ?>
</div>
<?php endwhile; ?>
</div>
<?php endif; ?>
<?php endwhile; ?>
<?php endif; ?>
</div>
</main>
<?php
// get our footer
get_footer();
And this is the tested output within the <main> html element...
This update code is the same as my first code example, but I've changed the flexible content field name from paragraph to paragraphs in this second update example, and I've also included the full singe.php post loop.
Not sure how my code outputted your However screenshot?
Let me know if you need more help.

Related

advanced custom fields can't do nested loops repeater inside repeater have_rows() not doing anything

I have a repeater inside a repeater and I need to loop what is in it.
I'm following this: https://www.advancedcustomfields.com/resources/have_rows/
This is my field structure:
agenda_section_events (parent/repeater)
agenda_event_time_pacific (text)
agenda_event_time_eastern (text)
agenda_event_title (text)
agenda_event_speakers (repeater)
agenda_event_speaker_headashot (image array)
agenda_event_speaker_name (text)
agenda_event_speaker_title (text)
agenda_event_speaker_content (wysiwyg editor)
So with that in mind, as I understand it, I need to loop over agenda_section_events and inside that I need to get rows https://www.advancedcustomfields.com/resources/have_rows/
So that code looks like this:
<div class="tc__agenda-items">
<?php foreach($agendaSectionEvents as $agendaSectionEvent): ?>
<div class="tc__agenda-item">
<div class="tc__agenda-time">
<div class="tc__agenda-time--pacific">
<?php echo $agendaSectionEvent['agenda_event_time_pacific'] ?>
</div>
<div class="tc__agenda-time--eastern">
<?php echo $agendaSectionEvent['agenda_event_time_eastern'] ?>
</div>
</div>
<h3><?php echo $agendaSectionEvent['agenda_event_title'] ?></h3>
<div class="tc__agenda-speaker-list">
<!-- DEBUG LINE - BUT ITS EMPTY -->
<div style="color: red;"><?php echo have_rows('agenda_event_speakers') ?></div>
<?php if(have_rows('agenda_event_speakers')): ?>
<div class="tc__agenda-speaker">
<?php while(have_rows('agenda_event_speakers')): ?>
<div class="tc__agenda-speaker-headshot">
<img src="<?php the_sub_field('agenda_event_speaker_headashot')['url'] ?>" alt="<?php the_sub_field('agenda_event_speaker_headashot')['alt'] ?>">
</div>
<div class="tc__agenda-speaker-info">
<h4><?php the_sub_field('agenda_event_speaker_name') ?></h4>
<p><?php the_sub_field('agenda_event_speaker_title') ?></p>
</div>
<?php endwhile ?>
</div>
<?php endif ?>
</div>
Learn More
</div>
<?php endforeach ?>
</div>
I'm really confused because all my field names are right, and the fields inside the second loop are sub fields but nothing is showing.
Why would that be?
I then thought its because I did a have rows inside a for each so then I tried doing a while inside a while like the acf docs
<div class="tc__agenda-items">
<?php while(have_rows('agenda_section_events')): ?>
<div class="tc__agenda-item">
<div class="tc__agenda-time">
<div class="tc__agenda-time--pacific">
<?php echo $agendaSectionEvent['agenda_event_time_pacific'] ?>
</div>
<div class="tc__agenda-time--eastern">
<?php echo $agendaSectionEvent['agenda_event_time_eastern'] ?>
</div>
</div>
<h3><?php echo $agendaSectionEvent['agenda_event_title'] ?></h3>
<div class="tc__agenda-speaker-list">
<!-- DEBUG LINE - BUT ITS EMPTY -->
<div style="color: red;"><?php echo have_rows('agenda_event_speakers') ?></div>
<?php if(have_rows('agenda_event_speakers')): ?>
<div class="tc__agenda-speaker">
<?php while(have_rows('agenda_event_speakers')): ?>
<div class="tc__agenda-speaker-headshot">
<img src="<?php the_sub_field('agenda_event_speaker_headashot')['url'] ?>" alt="<?php the_sub_field('agenda_event_speaker_headashot')['alt'] ?>">
</div>
<div class="tc__agenda-speaker-info">
<h4><?php the_sub_field('agenda_event_speaker_name') ?></h4>
<p><?php the_sub_field('agenda_event_speaker_title') ?></p>
</div>
<?php endwhile ?>
</div>
<?php endif ?>
</div>
Learn More
</div>
<?php endwhile ?>
</div>
<?php endif ?>
Since implementing this change, now the page just...doesn't load!? What!?
How do you do a nested for loop in advanced custom fields?
You need to add the_row(); inside your while loops. All ACF loops are formatted the same, nested or not. Something I do to keep it easy is make the if/while/the_row stuff all one line, see below:
Start loops like this:
<?php if (have_rows('agenda_section_events')): while (have_rows('agenda_section_events')) : the_row(); ?>
End loops like this:
<?php endwhile; endif; ?>
You can go wild with the number of loops you want to nest, just simply copy the parent loop lines and create a nested one, then change your row to the nested one of course.
I adjusted your code below, give this a shot.
You should also define your subfield array values inside the loop you're using it with, just keeps things cleaner – or just use the_sub_field to echo your subfield values since its a short function anyway.
<div class="tc__agenda-items">
<?php if (have_rows('agenda_section_events')): ?>
<?php while (have_rows('agenda_section_events')) : the_row(); ?>
<div class="tc__agenda-item">
<div class="tc__agenda-time">
<div class="tc__agenda-time--pacific">
<?php echo $agendaSectionEvent['agenda_event_time_pacific'] ?>
</div>
<div class="tc__agenda-time--eastern">
<?php echo $agendaSectionEvent['agenda_event_time_eastern'] ?>
</div>
</div>
<h3><?php echo $agendaSectionEvent['agenda_event_title'] ?></h3>
<div class="tc__agenda-speaker-list">
<!-- DEBUG LINE - BUT ITS EMPTY -->
<div style="color: red;"><?php // echo have_rows('agenda_event_speakers') ?></div>
<?php if (have_rows('agenda_event_speakers')) ?>
<div class="tc__agenda-speaker">
<?php while (have_rows('agenda_event_speakers')) : the_row(); ?>
<div class="tc__agenda-speaker-headshot">
<img src="<?php the_sub_field('agenda_event_speaker_headashot')['url'] ?>" alt="<?php the_sub_field('agenda_event_speaker_headashot')['alt'] ?>">
</div>
<div class="tc__agenda-speaker-info">
<h4><?php the_sub_field('agenda_event_speaker_name') ?></h4>
<p><?php the_sub_field('agenda_event_speaker_title') ?></p>
</div>
<?php endwhile ?>
</div>
<?php endif ?>
</div>
Learn More
</div>
<?php endwhile ?>
<?php endif ?>

Displaying wordpress page full contents

Here is LINK I am working on it. The About Us section is not displaying full contents and showing more button to go to next page whereas I want to show full contents of About Us page instead of short summary.
I checked a lot but not found any option in the theme to fix it
UPDATE:
I found this in (page-template/custom-home-page.php)
<?php while ( $query->have_posts() ) : $query->the_post(); ?>
<div class="row">
<div class="col-lg-8 col-md-7">
<h3><?php the_title(); ?></h3>
<hr>
<p><?php the_excerpt(); ?></p>
<div class="more-btn">
<?php esc_html_e('MORE','vw-one-page'); ?>
</div>
</div>
<div class="col-lg-4 col-md-5">
<img src="<?php the_post_thumbnail_url('full'); ?>"/>
</div>
</div>
<?php $i++; endwhile;
wp_reset_postdata();?>
<?php else : ?>
<div class="no-postfound"></div>
<?php endif;
endif;?>
</div>
</section>
Best regards
That code inside your theme with high probability.
Try to search inside theme files "/wp-content/themes/your_theme_name", something like that:
<div class="col-lg-8 col-md-7">
<h3>About Us</h3> <!-- Or <?php the_title(); ?> -->
<hr>
<?php the_exerpt(); ?>
<div class="more-btn">
MORE <!-- Or something like <?php the_permalink( ... ) ?> -->
</div>
</div>
This is an example. After all, I can't know how it is done in your theme.
Then <?php the_exerpt(); ?> change to <?php the_content(); ?>. and remove or hide:
<div class="more-btn">
...
</div>
But if this is not your personal WordPress theme, then it is better to do through Child Theme

Wordpress search results in columns

I'm trying to style my Wordpress search results so that they appear in columns (3 columns per row) but somehow it's not working. Maybe you can help me? I've googled this problem and tried placing the while loop inside the row div but that wouldn't work. The site is: www.medical-promotion.de
Thanks for your help! :)
Below is the code provided by the theme.
<?php
/**
* Search
*/
?>
<?php get_header(); ?>
<section class="site-content">
<div class="container">
<?php if( have_posts()) : ?>
<div class="row">
<?php while ( have_posts()) : the_post(); ?>
<div class="col-lg-4 col-sm-4 col-xs-12">
<div class="blog_large">
<?php
$aneeq_post_slide = get_post_meta( $post->ID, 'aneeq_all_post_slides_settings_'.$post->ID, true);
//blog option settings
$aneeq_option_settings = get_option('aneeq_blog_settings');
//feature img url
$aneeq_url = wp_get_attachment_url( get_post_thumbnail_id($post->ID), 'thumbnail' );
?>
<article class="post">
<figure class="post_img">
<a href="<?php the_permalink(); ?>">
<?php if($aneeq_url != NULL) { the_post_thumbnail(); } ?>
</a>
</figure>
<div class="post_date">
<span class="day"><?php echo get_the_date('j'); ?></span>
<span class="month"><?php echo get_the_date('M'); ?></span>
</div>
<div class="post_content">
<div class="post_meta">
<h2>
<?php the_title(); ?>
</h2>
<div class="metaInfo">
<span><i class="fa fa-user"></i> <?php esc_html_e('By', 'aneeq') ?> <?php the_author(); ?> </span>
<?php if (has_category()) : ?>
<span><i class="fa fa-th-list"></i>
<?php the_category(' ,&nbsp');?>
</span>
<?php endif; ?>
</div>
</div>
<?php the_content(); ?>
</div>
</article>
</div>
</div>
</div><!--/.row-->
</div> <!--/.container-->
</section>
<?php get_footer(); ?>
Have a look at the below image. That's the output of the file you shared.
As you can see within the post_content div and underneath the post_meta div that's where the search list is located, not way up higher where the row class is.
In your code, the output of that block relates to the following statement.
<?php the_content(); ?>
So, it looks like the content of the page is pulled in dynamically. Have a look in the WordPress admin section (when you edit the search page) and see if anything there gives you a clue.
Else, search for the fsn-row full-width-row classes within the files of your theme directory. This will give you a clue which file to edit.

wordpress pagination return blank page on page 2(building a theme from scratch)

to learn wordpress development, I'm building a wordpress theme from scratch .
Now i want to add pagination on my category page but the problem is:
when i click on older-post-link the url change from "http://localhost/wordpress4/category/bloc1/" to "http://localhost/wordpress4/category/bloc1/page/2/" but it take me to a blank page instead of showing the other posts.
this is the code on the category.php
<?php get_header(); ?>
<div class="container">
<?php
$counter = 1; //start counter
$grids = 3; //Grids per row
global $query_string; //Need this to make pagination work
/*Setting up our custom query (In here we are setting it to show 12 posts per page and eliminate all sticky posts) */
query_posts($query_string . '&caller_get_posts=1&posts_per_page=4');
if(have_posts()) : while(have_posts()) : the_post();
?>
<?php
//Show the left hand side column
if($counter == 1) :
?>
<div class="row">
<div class="col-md-4">
<div class="center">
<div class="postimage">
<?php the_custom_logo(); ?>
</div>
<h2><?php the_title(); ?></h2>
<h4><?php the_category(); ?></h4>
</div>
</div>
<?php
elseif($counter == 2) :
?>
<div class="col-md-4 border2">
<div class="center">
<div class="postimage">
<?php the_custom_logo(); ?>
</div>
<h2><?php the_title(); ?></h2>
<h4><?php the_category(); ?></h4>
</div>
</div>
<?php
elseif($counter == $grids) :
?>
<div class="col-md-4">
<div class="center">
<div class="postimage">
<?php the_custom_logo(); ?>
</div>
<h2><?php the_title(); ?></h2>
<h4><?php the_category(); ?></h4>
</div>
</div>
</div>
<div class="clear"></div>
<?php
$counter = 0;
endif;
$counter++;
endwhile;
?>
<div class="row">
<div class="col-xs-6 text-left">
<?php next_posts_link('<< Older post'); ?>
</div>
<div class="col-xs-6 text-right">
<?php previous_posts_link('Newer post >>'); ?>
</div>
<?php
endif;
?>
</div>
</div>
<?php get_footer(); ?>
I noticed that if i add the code below to my index.php the pagination work also on the category page.
but the second category page("http://localhost/wordpress4/category/bloc1/page/2/") will take the markup of index.php so the posts will not be in a grid format like the first category page.
global $query_string; //Need this to make pagination work
/*Setting up our custom query (In here we are setting it to show 12 posts per page and eliminate all sticky posts) */
query_posts($query_string . '&caller_get_posts=1&posts_per_page=4');
also on the category page the older post-link show up between rows instead of showing at the bottom of the pages.
finally this is the code on my index.php
<?php get_header(); ?>
<div class="container">
<div class="row">
<div class="col-xs-12 col-sm-8">
<?php
if(have_posts()):
while(have_posts()): the_post(); ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
<h3><?php the_title(); ?></h3>
<small><?php the_category(); ?></small>
</a>
<p><?php the_content(); ?></p>
<hr/>
<?php endwhile;
endif;
?>
</div>
<div class="col-xs-12 col-sm-4">
<?php get_sidebar(); ?>
</div>
</div>
</div>
<?php get_footer(); ?>
Thank You.
Use this code, may be it will solve your problem
<?php
// the query to set the posts per page to 3
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array('posts_per_page' => 3, 'paged' => $paged );
query_posts($args); ?>
<!-- the loop -->
<?php if ( have_posts() ) : while (have_posts()) : the_post(); ?>
<!-- rest of the loop -->
<!-- the title, the content etc.. -->
<?php endwhile; ?>
<!-- pagination -->
<div class="row">
<div class="col-xs-12>"
<div class="col-xs-6 text-left"><?php next_posts_link(); ?></div>
<div class="col-xs-6 text-right"><?php previous_posts_link(); ?></div>
</div>
</div>
<?php else : ?>
<!-- No posts found -->
<?php endif; wp_reset_postdata(); ?>
for more details, check this link https://codex.wordpress.org/Pagination
After a lot of searching i was able to find a solution .
The problem was that the The "Blog pages show at most" in the wordpress reading settings was interfering with the "posts_per_page=4" that i declared through the query_posts().
The solution :
I deleted the "query_posts()" because it is best to use the WP_Query() or the pre_get_posts filter.
for me even with using wp_query i couldnt get the pagination to work so i tried using the pre_get_posts filter and it worked .
so in the category.php i deleted the query_posts and used just the normal loop.
this is my new code in the category.php
<?php get_header(); ?>
<div class="container">
<?php
$counter = 1; //start counter
$grids = 3; //Grids per row
if(have_posts()) :
while(have_posts()) : the_post();
?>
<?php
//Show the left hand side column
if($counter == 1) :
?>
<div class="row">
<div class="col-md-4">
<div class="center">
<div class="postimage">
<?php the_custom_logo(); ?>
</div>
<h2><?php the_title(); ?></h2>
<h4><?php the_category(' '); ?></h4>
</div>
</div>
<?php
elseif($counter == 2) :
?>
<div class="col-md-4 border2">
<div class="center">
<div class="postimage">
<?php the_custom_logo(); ?>
</div>
<h2><?php the_title(); ?></h2>
<h4><?php the_category(' '); ?></h4>
</div>
</div>
<?php
elseif($counter == $grids) :
?>
<div class="col-md-4">
<div class="center">
<div class="postimage">
<?php the_custom_logo(); ?>
</div>
<h2><?php the_title(); ?></h2>
<h4><?php the_category(' '); ?></h4>
</div>
</div>
</div>
<div class="clear"></div>
<?php
$counter = 0;
endif;
?>
<?php
$counter++;
endwhile;
?>
<div class="row">
<div class="col-xs-12 text-left ">
<?php next_posts_link('<< Older post'); ?>
</div>
<div class="col-xs-12 text-right ">
<?php previous_posts_link('Newer post >>'); ?>
</div>
</div>
<?php
endif;
?>
</div>
<?php get_footer(); ?>
Then I added the pre_get_posts action on my function.php
this is the code:
add_action( 'pre_get_posts', function ( $q )
{
if ( !is_admin() // Very important, otherwise back end queries will be affected as well
&& $q->is_main_query() // Very important, we just need to modify the main query
&& $q->is_category() // Only target category pages
) {
$q->set( 'posts_per_page', 2 );
}
});
I hope my answer will help someone who have the same problem i had even if my answer is not so well explained.
for more info search for something like this:
using pagination with the wp_query
using pre_get_posts to set pagination for a custom page.
It will be so nice if a developer could explain my solution in more details and give us more information about using pre_get_posts to set pagination for a custom page.

How to break the content in two parts to use php the_content1 and php the_content2

I have a chunk of content in a textarea that I can call dynamically to the front by using <php the_content ?> See full code below.
The problem is, I dont have an assigned area for the image. (I'm open to options to create one but I think it will be too much effort), anyway, is there anything I can do (JQuery / JS is fine) that I can call the image to fill the: <?php echo $the_content['image'] ?> that you see in my code, which obviously does not work? Meanwhile leaving the actual text part or rest of the content separate.
I am attaching an illustration for a more visual idea of what I am looking for
Here is the entire code for that section
<section class="box classes-box" id="classes_box"><!-- Section Events -->
<div class="container light-grey-background">
<div class="row">
<div class="col-md-6 no-padding">
<div class="boxing-classes" style="background-image: url('<?php echo $the_content['image'] ?>')">
<div class="classes">
<nav class="classes-nav">
<ul class="clean-list toggle-list clearfix">
<?php foreach($slides as $i => $slide): ?>
<li class="classes-menu-item ">
<input type="radio" id="toggle-<?php echo $slide['post']->ID; ?>" name="toggle-helper" autocomplete="off">
<label for="toggle-<?php echo $slide['post']->ID; ?>"><?php echo get_the_title( $slide['post']->ID ) ?></label>
</li>
<?php endforeach; ?>
</ul>
</nav>
</div>
</div>
</div>
<div class="col-md-6 no-padding ">
<?php foreach($slides as $i => $slide): ?>
<div class="classes-content-block" id="classes_content_<?php echo $slide['post']->ID ?>" style="display:none;">
<header class="padding white-background">
<h2 class="entry-header black-background"><?php echo get_the_title( $slide['post']->ID ) ?></h2>
</header>
<div class="entry-content padding">
<?php echo apply_filters('the_content', $slide['post']->post_content); ?>
<?php if ( !empty( $slide['options']['button'] )): ?>
<div class="white-background">
<a class="read-more text-center red-black-hover" href="<?php echo $slide['options']['button']['link'] ? $slide['options']['button']['link'] : '#'; ?>"><?php echo $slide['options']['button']['link_text'] ? $slide['options']['button']['link_text'] : 'View Timeline' ; ?></a>
</div>
<?php endif; ?>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
</div>
Normally, what people do is to create a Shortcode that will produce the desired HTML, something like:
[image-block src="apple-touch-icon.png" class="all-imgs" id="my-img"]The content[/image-block]
This would be the shortcode:
add_shortcode( 'image-block', function( $atts, $content) {
return sprintf(
'<div class="left"><img src="%1$s" class="%2$s" id="%3$s"></div><div class="right">%4$s</div>',
$atts['src'],
$atts['class'],
$atts['id'],
$content
);
});
And this the output:
See CSS property FLOAT : left|right
<div id=container class="clearfix">
<div class="image-wrapper" style="float:left;max-width:50%;padding:0;margin:0">
<img src="images/mypicture.jpg" alt="" class="rwd-image" id="mymage">
</div>
<div class="content-wrapper" style="float:left;max-width:50%;padding:0;margin:0">
<p>Lorem Ipsum</p>
</div>
</div>

Categories