Wordpress Advanced Custom Field Not showing up on front-end - php

I'm working on my WordPress child theme and utilizing Advanced Custom Fields, but I'm having a pain displaying one of them on the front-end.
<?php if( get_field('pp-full-image') ): ?>
<? // closes main .row and .container from header & inserts full width image ?>
</div><!-- .row from header -->
</div><!-- .container from header -->
<div class="pp-sub" style="background-image: url(<?php the_field('pp-full-image'); ?>)"></div>
<!-- .pp-sub -->
<? // displays section 3 content ?>
<?php $ppsec3 = get_field('pp-section3');
if( $ppsec3 ): ?>
<div class="container">
<div class="row">
<div class="pp-sec sec3">
<h3 class="pp-title sec3"><?php echo ( $ppsec3['pp-section3-title'] ); ?></h3>
<div class="pp-txt sec3">
<?php echo ( $ppsec3['pp-section3-text'] ); ?>
</div>
</div>
</div><!-- /.pp-wrapper -->
</div>
<?php endif; ?>
<? // closes section 3 content ?>
<?php endif; ?>
<? // closes full width image and section 3 content ?>
<?php
get_footer();

Related

Blog Main Header Showing Recent Post Title Instead

My Wordpress blog works fine on the main page that shows all posts, however, when I click a category the most recent post's title becomes the main header and that post doesn't even show up in the blog post list of that category.
https://ibb.co/ebReRV
I spied on other people with the same theme as me and they have the same problem so I believe this is a problem with the original code. My theme's creator seems to have disappeared and hasn't responded to any of my messages.
archive.php
<section id="wp-main-content" class="clearfix main-page title-layout-standard">
<?php do_action( 'naturalfood_before_page_content' ); ?>
<div class="container">
<div class="main-page-content row">
<!-- Main content -->
<div class="content-page <?php echo esc_attr($main_content_config['class']); ?>">
<div id="wp-content" class="wp-content">
<?php get_template_part('templates/layout/archive') ?>
</div>
</div>
You Need to Create Archive Page
Give Archive Page name is "archive.php".
Archive Page Structure Like this:
<?php
/*
Template Name: Archives
*/
get_header(); ?>
<div id="primary" class="site-content">
<div id="content" role="main">
<?php while ( have_posts() ) : the_post(); ?>
<h1 class="entry-title"><?php the_title(); ?></h1>
<div class="entry-content">
<?php the_content(); ?>
/* Custom Archives Functions Go Below this line */
/* Custom Archives Functions Go Above this line */
</div><!-- .entry-content -->
<?php endwhile; // end of the loop. ?>
</div><!-- #content -->
</div><!-- #primary -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>

How to add post format to theme?

For classipress theme. I can register post_formats the normal way in functions (works - I can select "link" type in the editor), but I can't figure out how to get it to actually use a template file for link posts.
I have used the get_template_part('content', get_post_format()); in the past successfully,
but I can't figure how to inject that into the single.php's code for this theme:
Single.php
<?php
/**
* The Template for displaying all single posts.
*
* #package ClassiPress\Templates
* #author AppThemes
* #since ClassiPress 1.0
*/
?>
<div class="content">
<div class="content_botbg">
<div class="content_res">
<div id="breadcrumb"><?php cp_breadcrumb(); ?></div>
<div class="content_left">
<?php appthemes_before_blog_loop(); ?>
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php appthemes_before_blog_post(); ?>
<?php appthemes_stats_update( $post->ID ); //records the page hit ?>
<div class="shadowblock_out">
<div class="shadowblock">
<div class="post">
<?php appthemes_before_blog_post_title(); ?>
<h1 class="single blog"><?php the_title(); ?></h1>
<?php appthemes_after_blog_post_title(); ?>
<div style="margin-top:10px; text-align:center;">
<?php if ( function_exists( 'ADDTOANY_SHARE_SAVE_KIT' ) ) { ADDTOANY_SHARE_SAVE_KIT(); } ?>
</div>
<?php appthemes_before_blog_post_content(); ?>
<?php if ( has_post_thumbnail() ): ?>
<div id="main-pic">
<?php cp_get_blog_image_url(); ?>
</div>
<?php endif; ?>
<?php the_content(); ?>
<div class="dotted"></div>
<div class="pad5"></div>
<?php appthemes_after_blog_post_content(); ?>
</div><!-- .post -->
</div><!-- .shadowblock -->
</div><!-- .shadowblock_out -->
<?php appthemes_after_blog_post(); ?>
<?php endwhile; ?>
<?php appthemes_after_blog_endwhile(); ?>
<?php else: ?>
<?php appthemes_blog_loop_else(); ?>
<?php endif; ?>
<div class="clr"></div>
<?php appthemes_after_blog_loop(); ?>
<div class="clr"></div>
<?php comments_template(); ?>
</div><!-- .content_left -->
<?php get_sidebar( 'blog' ); ?>
<div class="clr"></div>
</div><!-- .content_res -->
</div><!-- .content_botbg -->
</div><!-- .content -->
Content.php
<?php
/**
* Post loop content template.
*
* #package ClassiPress\Templates
* #author AppThemes
* #since ClassiPress 3.4
*/
?>
<div <?php post_class( 'shadowblock_out' ); ?> id="post-<?php the_ID(); ?>">
<div class="shadowblock">
<?php appthemes_before_blog_post_title(); ?>
<h3 class="loop"><?php the_title(); ?></h3>
<?php appthemes_after_blog_post_title(); ?>
<?php appthemes_before_blog_post_content(); ?>
<div class="entry-content">
<?php if ( has_post_thumbnail() ) the_post_thumbnail( 'blog-thumbnail' ); ?>
<?php the_content( __( 'Continue reading ...', APP_TD ) ); ?>
</div>
<?php appthemes_after_blog_post_content(); ?>
</div><!-- #shadowblock -->
</div><!-- #shadowblock_out -->
Tried a lot of things, unsuccessful in doing anything but breaking the page.
Thanks
Post formats are used to customize the presentation of post items. If you check out some theme that supports post formats (For example Twenty Fifteen), you will see that the single.php file is not used to output the contents of the post - which is delegated to content-*.php files. (For example, the the_content() function, which outputs a post's content is not in single.php, but in content.php (and content-link.php and others).
Your single.php does not seem to be built this way, so it does not support post formats, but it can be refactored easily, just split it into two files (in single.php you should keep the "frame" code that is common for every post format, then move the rest into a new content.php file, which will be used as the default format):
single.php
<?php
/**
* The Template for displaying all single posts.
*
* #package ClassiPress\Templates
* #author AppThemes
* #since ClassiPress 1.0
*/
?>
<div class="content">
<div class="content_botbg">
<div class="content_res">
<div id="breadcrumb"><?php cp_breadcrumb(); ?></div>
<div class="content_left">
<?php appthemes_before_blog_loop(); ?>
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php appthemes_before_blog_post(); ?>
<?php appthemes_stats_update( $post->ID ); //records the page hit ?>
<?php
// Note the below line which loads the desired content*.php
get_template_part('content', get_post_format());
?>
<?php appthemes_after_blog_post(); ?>
<?php endwhile; ?>
<?php appthemes_after_blog_endwhile(); ?>
<?php else: ?>
<?php appthemes_blog_loop_else(); ?>
<?php endif; ?>
<div class="clr"></div>
<?php appthemes_after_blog_loop(); ?>
<div class="clr"></div>
<?php comments_template(); ?>
</div><!-- .content_left -->
<?php get_sidebar( 'blog' ); ?>
<div class="clr"></div>
</div><!-- .content_res -->
</div><!-- .content_botbg -->
</div><!-- .content -->
content.php
<div class="shadowblock_out">
<div class="shadowblock">
<div class="post">
<?php appthemes_before_blog_post_title(); ?>
<h1 class="single blog"><?php the_title(); ?></h1>
<?php appthemes_after_blog_post_title(); ?>
<div style="margin-top:10px; text-align:center;">
<?php if ( function_exists( 'ADDTOANY_SHARE_SAVE_KIT' ) ) { ADDTOANY_SHARE_SAVE_KIT(); } ?>
</div>
<?php appthemes_before_blog_post_content(); ?>
<?php if ( has_post_thumbnail() ): ?>
<div id="main-pic">
<?php cp_get_blog_image_url(); ?>
</div>
<?php endif; ?>
<?php the_content(); ?>
<div class="dotted"></div>
<div class="pad5"></div>
<?php appthemes_after_blog_post_content(); ?>
</div><!-- .post -->
</div><!-- .shadowblock -->
</div><!-- .shadowblock_out -->
Now, for additional post formats, for example gallery, you will have to create a file named content-gallery.php and implement it. You can derive it from the default content.php, but you decide how it should look like.

How to display images from Advanced Custom Fields relationship fields in WordPress

I have a Main Case Studies Page, where I would like to show the images from each of the case studies post type pages in a list. I have the following code:
<div class="CaseStudyOverview" id="CaseStudyOverview">
<div class="CaseStudyOverview-Contents">
<?php while ( have_posts() ) : the_post(); ?>
<div class="CaseStudyPic-left">
<div class="CaseStudyRightButton">
<?php
$photo = get_field('casestudy_image');
$pic = get_field('casestudy_platform_image');
?>
<img src="<?php echo $photo['url']; ?>" />
<?php the_field('case_studies_go_to_button'); ?>
</div><!-- end of CaseStudyRightButton -->
<div class="CaseStudyLeftPic">
<img src="<?php echo $pic['url']; ?>" />
</div><!-- end of left-pic -->
</div><!-- end of content-left -->
<?php endwhile; ?>
</div><!-- end of CaseStudyOverview-Contents -->
Is there anything missing?

Wordpress posts not displaying through dedicated url

A bit of an odd one. My news posts are not displaying through their unique URL.
Example:
- through the site you can see the news section and click through:
http://disciplesldn.com/
As a stand alone post, content disappears:
http://disciplesldn.com/2014/12/win-tickets-to-see-us-play-in-liverpool-on-boxing-day/
The theme is a custom build, using wordpress plugin 'types' for posting as single.php template file.
single.php code example:
<?php get_header(); the_post(); ?>
<section id="singlepost">
<div class="loadwrapper">
<div class="titleheaderpost">
<h1 class="singletitle"><? the_title(); ?></h1>
<p class="back">< back to News</p>
</div><!-- end of .titleheader -->
<div class="thenewscontent" id="thecontent">
<? the_content(); ?>
</div>
</div>
</section><!-- end of #singlepost -->
<?php get_footer(); ?>
In your css on line 757 you have positioning styled on the 'singlepost' id. you need to remove the left & top rules and the post displays correctly.
eg:
#singlepost {
position: relative;
/* left: 1200px; */
/* top: -482px; */
max-width: 960px;
overflow: hidden;
height: 100%;
margin: 0 auto;
}
Try with this code.
<?php get_header();?>
<?php while ( have_posts() ) : the_post(); ?>
<section id="singlepost">
<div class="loadwrapper">
<div class="titleheaderpost">
<h1 class="singletitle"><? the_title(); ?></h1>
<p class="back">< back to News </p>
</div><!-- end of .titleheader -->
<div class="thenewscontent" id="thecontent">
<? the_content(); ?>
</div>
</div>
</section><!-- end of #singlepost -->
<?php endwhile; // end of the loop. ?>
<?php get_footer(); ?>

Display static content in Wordpress if page/post empty

I want to display a message if the Wordpress page is empty (eg. "Still under progress").
My loop looks like this:
<?php get_header(); ?>
<!-- Main-menu open -->
<div id ="menu-maincontent">
<?php if ( have_posts() ) while ( have_posts() ) : the_post() ; ?>
<h2><?php echo the_title(); ?></h2>
</div>
<!-- Main-menu close -->
<!-- Main-content open -->
<div id="main-content">
<!-- Main-content-in open -->
<div id="main-content-in">
<?php the_content(); ?>
</div>
<div class="cleared"></div>
<?php if ( comments_open() ) : ?>
<?php comments_template( '', true ); ?>
<?php endif; // End if comments_open() ?>
</div><!-- Main-content close -->
<?php endwhile; ?>
<?php get_sidebar(); ?>
How could I code in this message? It would be even better if I could have a separate PHP file that I call in with it (as I have a lot of page-templates in the theme).
I only changed the part which was necessary, which is div#main-content-in.
<!-- Main-content-in open -->
<div id="main-content-in">
<?php
// Get the content
$content = get_the_content();
if(trim($content) == "") // Check if the string is empty or only whitespace
{
echo "Static content";
get_template_part('slug','name');
}
else
{
// Apply filters the same as the_content() does:
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
echo $content;
}
?>
</div>
<!-- Main-content-in close -->
Sources:
http://codex.wordpress.org/Function_Reference/the_content
http://codex.wordpress.org/Function_Reference/get_the_content
http://codex.wordpress.org/Function_Reference/get_template_part
Check what I did in end while
<?php get_header(); ?>
<!-- Main-menu open -->
<div id ="menu-maincontent">
<?php if ( have_posts() ) while ( have_posts() ) : the_post() ; ?>
<h2><?php echo the_title(); ?></h2>
</div>
<!-- Main-menu close -->
<!-- Main-content open -->
<div id="main-content">
<!-- Main-content-in open -->
<div id="main-content-in">
<?php the_content(); ?>
</div>
<div class="cleared"></div>
<?php if ( comments_open() ) : ?>
<?php comments_template( '', true ); ?>
<?php endif; // End if comments_open() ?>
</div><!-- Main-content close -->
<?php endwhile; else: ?>
<? require('page_not_found.php'); ?>
<?php endif; ?>
<?php get_sidebar(); ?>

Categories