I'm trying to use a slider in different blog pages in a Wordpress website, but it doesn't work. When I use it, it only shows plain text: [metaslider id=4281]
It seems that "blog entries" don't understand the Metaslider code, because I have tried in a simple page, and it works. Here's the code of a blog entry (single.php)
<?php get_header()?>
<div id="maincontent">
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); //The Loop?>
<div <?php post_class()?>>
<?php if(has_tag()){the_tags( _e('Keywords','polaroids') . ': ', ', ');}?><br/>
<hr style="border: 0;border-bottom: 1px dashed #DDDDDD;"></br>
<h1><?php the_title()?></h1>
<div class="date"><?php /* the_date() */ ?></div>
<div class="post-content"><? echo $post->post_content; /*php the_content()*/ ?></div>
<div class="postfooter">
<?php wp_link_pages('before=Pages&after='); ?><br/>
</div>
<hr style="border: 0;border-bottom: 1px dashed #DDDDDD;">
<div class="breadcrumbs"><?php the_category(', '); ?></div>
<hr style="border: 0;border-bottom: 1px dashed #DDDDDD;">
</div>
I haven't tested this but I suspect that echoing the post_content might be returning the plain text. Not sure why the_content is commented out but try using that.
So instead of this:
<? echo $post->post_content; /*php the_content()*/ ?></div>
Try using this:
<?php the_content(); ?>
Related
I'm trying to implement a dedicated template for any post with a category slug of 'rentals'. There are posts in the database with a category of rentals set up and applied. I've created the template with a standard loop and called it category-rentals.php, saving it in my root folder.
It's just not working. It keeps reverting to single post template (index.php specifically).
My rendered body classes are as such:
post-template-default single single-post postid-278 single-format-standard
Am I missing a step here?
category-rentals.php:
/*
* Rental property template
*/
?>
<?php get_header(); ?>
<div class="jumbotron jumbotron-fluid" style="background-image: url('<?php bloginfo( 'template_url' ); ?>/img/bg-semi-trans.png'), url('<?php bloginfo( 'template_url' ); ?>/img/bg-jumbotron.jpg');">
<div class="container">
<div class="headline text-center animated fadeInUp">
<p><?php wp_title(''); ?></p>
</div>
</div>
</div>
<section>
<div class="container">
<div class="row">
<div class="col-12">
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; else : ?>
<p><?php esc_html_e( 'Sorry, no content matched your criteria.' ); ?></p>
<?php endif; ?>
<hr>
← Go Back | Contact Us
</div>
</div>
</div>
</section>
<?php get_footer(); ?>
I'm trying to figure out how to create a custom single post template on wordpress. I'm not very familiar with it but was required to use it.
I've followed the steps required to create it but it seems that my new post template called educators is still referencing the original post template instead of the one i've created for it.
Here is my single-post_educator.php file code.
<?php get_header(); ?>
<div class="container-fluid">
<img src="<?php the_field('post_banner','option');?>" style="width :100%;">
<div class="container">
<?php if (have_posts()) :
while (have_posts()) : the_post(); ?>
<?php if( get_field('post_content_right') ) { ?>
<div class="post-right col-sm-6 col-xs-12">
<h2><?php echo get_the_title();?></h2>
<p><?php echo the_field('post_content');?></p>
</div>
<div class="col-sm-6 col-xs-12 post-right">
<a href="<?php echo home_url();?>/#educator" style="font-size:
15px;color:#000000;float:right;font-family: 'calibri';text-
decoration: underline;text-align:right;">Back</a>
<p><?php echo the_field('post_content_right');?></p>
</div>
<?php } else { ; ?>
<div class="post-right col-sm-6 col-xs-12">
<a href="<?php echo home_url();?>/#educator" style="font-size:
15px;color:#000000;float:right;font-family: 'calibri';text-
decoration:underline;text-align:right;">Back</a>
<h2><?php echo get_the_title();?></h2>
<p><?php echo the_field('post_content');?></p>
</div>
<?php } ;?>
<?php
endwhile;
endif; ?>
</div>
</div>
<?php get_footer(); ?>
I included a photo of how it currently is and how i actually want it to be like:
Thanks in advance.. help is much appreciated
The file should be named:
single-{post_type}.php
So in your case it should be
single-post_educators.php
You're missing the s
Asking here because of better response rate than Wordpess community.
I set up a custom post type called Training Services. I created a custom field called content_snippet and assigned it to only apply to the relevant post type. I see the field on the post type edit screen and enter in some lorem ipsum.
My code for implementation is below (content-page.php): Why does the title, content and thumbnail of the post type show on the front-end but not the custom field? It simply shows an empty tag where the lorem should be if I look at it in chrome dev tools.
Thanks in advance for the help!
<!-- Custom Fields
================================================== -->
<?php
$content_snippet = get_field('content_snippet');
?>
<section class="container-fluid section-spacing" style="border:1px solid black;">
<div class=" text-align-center row" style="border:1px solid green;">
<h1><?php the_title(); ?></h1>
<hr class="headingUnderline">
<div class="responsiveShrink" style="border:1px solid yellow;"><?php the_content() ; ?></div>
<?php $loop = new WP_Query( array( 'post_type' => 'training_services', 'orderby' => 'post_id', 'order' => 'ASC' ) ); ?>
<?php while( $loop->have_posts() ) : $loop->the_post(); ?>
<div class="text-align-center col-xs-12 col-sm-6" style="border:1px solid red;">
<div class="postWrapper">
<div class="imageWrapper">
<?php
if ( has_post_thumbnail() ) {
the_post_thumbnail();
}
?>
</div>
<div class="postContentWrapper">
<h3><?php the_title(); ?></h3>
<div><?php echo $content_snippet; ?></div>
<div><?php the_content(); ?></div>
</div>
</div>
</div>
<?php endwhile; wp_reset_query(); ?>
</div>
</section>
Stupid mistake. Custom field must be declared inside the loop. Leaving this up for future readers.
I've seen this article but it's not exactly relevant to what I'm trying to do. I have a simple blog loop in which each blog has an <div class="exerpt">for the preview of the blog text. All of my posts have a border-bottom and I'm simply trying to get rid of the border-bottom, as well as make other adjustments for the last-child. However every element is being styled, not just the last one. Please note I'm using the mighty html5blank
index.php
<div class="page-section" style="padding-top:150px;">
<div class="wrapper">
<?php get_template_part('loop'); ?>
<?php get_template_part('pagination'); ?>
</div>
</div>
loop.php
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<h2 class="journal-title">
<?php the_title(); ?>
</h2>
<span class="date"><?php the_time('F j, Y'); ?> </span>
<!-- post thumbnail -->
<?php if ( has_post_thumbnail()) : // Check if thumbnail exists ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
<?php the_post_thumbnail(); // Declare pixel size you need inside the array ?>
</a>
<?php endif; ?>
<!-- /post thumbnail -->
<!-- post title -->
<!-- /post title -->
<div class="exerpt">
<?php html5wp_excerpt('html5wp_index'); // Build your custom callback length in functions.php ?>
</div>
</article>
.exerpt {
margin-bottom:80px;
border-bottom:1px solid #999;
padding:40px 0px 80px 0px;
}
.exerpt:last-child {
border:none;
margin-bottom: 60px;
}
Thanks!
You can add a separate class for the last item in the loop by doing something like this:
First add this before the loop starts:
<?php $post_counter = 0; ?>
Add this within the loop:
<?php $post_counter++; ?>
Then modify your excerpt code:
<div class="exerpt <?php if( $post_counter == count( $posts ) ) echo 'last-post'?>">
<?php html5wp_excerpt('html5wp_index'); // Build your custom callback length in functions.php ?>
</div>
CSS:
.last-post {
border:none;
margin-bottom: 60px;
}
Im trying to make a popup window which will display the post title and post thumbnail.
I have added this popup code into the category page template.
Basically if you click on the post title, the popup window will display showing the post thumbnail and post title, however each popup window is showing the same post details.
What changes would I need to make, so each popup window displays the corresponding post details
example. I have 3 post, titled, Post A, Post B, Post C, but in the lightbox all post titles say "Post A"
Any suggestions would be appreciated
Here is the code im using.....................
<div id="maincontainer" style="width:700px; height:auto; display:block;"><!-- Begin Main Container -->
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<span id="magblock"> <!-- Begin Post Block -->
<div class="magazinethumbs">
<?php
// check if the post has a Post Thumbnail assigned to it.
if ( has_post_thumbnail() ) {
the_post_thumbnail( 'magazine-thumb' );
}
?>
</div>
<!-- This opens the Lightbox -->
<a class="lbp-inline-link-1 cboxElement" href="#">
<h2 class="indextitle" style="font-size:12px;">
<?php the_title(); ?>
</h2>
</a>
</span> <!-- End Post Block-->
<div style="display: none;"> <!-- Lightbox Popup -->
<div id="lbp-inline-href-1" style="padding:10px; background: #fff;">
<!-- Here is the bug, the lightbox is loading the same post details -->
<div class="magazinethumbs">
<?php
// check if the post has a Post Thumbnail assigned to it.
if ( has_post_thumbnail() ) {
the_post_thumbnail( 'magazine-thumb' );
}
?>
</div>
<h2 class="indextitle" style="font-size:12px;">
<?php the_title(); ?>
</h2>
</div>
</div> <!-- End Lightbox Popup -->
<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
<?php wp_reset_query();?>
</div><!-- End Main container -->
Im using "Lightbox Plus For Wordpress" plugin
http://www.endocreative.com/how-to-insert-content-in-a-popup-using-lightbox-plus-for-wordpress/
I tried your modified code but did not work... Simply loads the entire category page inside the lightbox...
Here is the modified code
<a class="lbp-inline-link-<?php the_ID(); ?> cboxElement" href="#">
<h2 class="indextitle" style="font-size:12px;">
<?php the_title(); ?>
</h2>
</a>
<div style="display: none;"> <!-- begin popup -->
<div id="lbp-inline-href-<?php the_ID(); ?>" style="padding:10px; background: #fff;">
<h2 class="indextitle" style="font-size:12px;">
<?php the_title(); ?>
</h2>
</div>
</div> <!-- End popup -->
Thanks
I may be sleeping when you answer my comment, so.
You have to do the step 2 of that tutorial, it will give you Inline Lightbox Individual Settings.
it'll give you a sequential classes
lbp-inline-link-1 for lbp-inline-href-1,
lbp-inline-link-2 for lbp-inline-href-2 and so on..
before
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
insert:
<?php
$i = 1;
if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
in the place of:
<a class="lbp-inline-link-1 cboxElement" href="#">
put
<a class="lbp-inline-link-<?php echo $i;?>" href="#">
do the same for the:
<div id="lbp-inline-href-1" style="padding:10px; background: #fff;">
put
<div id="lbp-inline-href-<?php echo $i; ?>" style="padding:10px; background: #fff;">
and before the endwhile put
<?php
$i++;
endwhile; else: ?>
OBS: you have to set the number os posts being show the same number of the "Number of Inline Lightboxes::"
Eg.: If the post list will show, 10 posts per page, on step 2 "Number of Inline Lightboxes::" you have to set to 10.