I am hitting a bit of a brick wall with a simple WordPress problem. I am using the ACF plugin and can't seem to get it to show the field on the pages. My page.php file looks like this:
<?php get_header(); ?>
<?php get_sidebar(); ?>
<div id="main">
<div id="content">
<?php if (have_posts()) : ?>
<!-- Starting the loop -->
<?php while (have_posts()) : the_post(); ?>
<div <?php post_class() ?>>
<h1><?php the_title(); ?></h1>
</div>
<?php the_content(''); ?>
<?php endwhile; ?>
<h2><?php the_field('bottom'); ?></h2>
<?php else : ?>
<h1>Nothing Found</h1>
<p>Sorry but we cant find anything</p>
<?php endif; ?>
</div>
</div>
<?php get_footer(); ?>
It's really simple as far as I can tell. Was just doing this as an exercise to get a handle on ACF before using it for something more technical and I'm stumped!
The field is 'bottom' and I just want to stick the text in there after the loop.
Screen shot of the custom field in the plugin
I'm guessing this is going to be something really simple but can't seem to find an answer anywhere!
(Posting a solution on behalf of the OP).
The answer is simple, as expected. I hadn't clicked update on the specific pages after adding the custom field template! Simple but no less frustrating. Thanks for the help.
Related
I am creating my own custom theme from scratch and have run into a bit of trouble. On the blog page, each time a new post is displayed, it is smaller than the last. This is due to me setting the width of the blog post to 33.3%. Also each blogpost gets displayed slightly right of the one previous to it. How can I have each blog post be 33.3% of the content area and be displayed side by side, 3 per row? I am using wordpress functions to call each blog post. I am only displaying the blog posts thumbnail and when you click the thumbnail it takes you to the post. So basically 3 images side by side.
[BONUS]: How could I get text to display horizontally and vertically on hover over each blog post image?
I know this is a lot to ask, but I have been trying to work this out for days. A JS Fiddle or Codepen would be greatly appreciated.
Index.php:
<?php get_header(); ?>
<div class="blog-posts">
<?php while (have_posts()) : the_post(); ?>
<div id="page-content">
<a href="<?php the_permalink(); ?>">
<?php the_post_thumbnail(); ?>
<h3><?php the_title(); ?></h3>
</a>
<?php endwhile; ?>
</div>
</div>
<?php get_footer(); ?>
You should use bootstrap and do something like this :
<?php get_header(); ?>
<div class="blog-posts">
<?php while (have_posts()) : the_post(); ?>
<div class="col-md-4">
<div id="page-content">
<a href="<?php the_permalink(); ?>">
<?php the_post_thumbnail(); ?>
<h3><?php the_title(); ?></h3>
</a>
</div>
</div>
<?php endwhile; ?>
</div>
<?php get_footer(); ?>
Take care to remove the width: 33.33%; CSS rule and close your <div> tags in the loop, not after.
Hope it helps
[EDIT]
See this link for more information about how to use column classes with bootstrap : grid example basic
[EDIT #2]
You could do it without bootstrap but it will be a bit more difficult. You'll have to set the "display" to "inline-block" and set the width of the divs with taking care of the inherit margin of these tags. In this example, I had to set it to 32%. Here is the fiddle
I have created a sidebar.php-file with the code;
<section class="sidomeny"><p class="Senastenytt2"><?php get_search_form();?></p></section><!--Slut på sidomeny-->
<div id="nyhet3">
<?php
query_posts('category = all');
if (have_posts()) :
while (have_posts()) : ?>
<?php the_post(); ?>
<p class="datum2"><?php the_time('Y-m-d'); ?></p>
<p class="Nyhetsrubrik3"><a style="orange"; href="<?php the_permalink() ?>" ><?php the_title(); ?></a></p>
<?php the_excerpt(); ?>
<p class="textnyhet2"></p>
<?php
endwhile;
endif;
?>
</div><!--Slut på Nyhet3-->
And now I would like to add the function that if you press the sidebar news section, the "textnyhet2" section will get updated with the news you clicked on. That is how it's working now.
But the problem is that the sidebar vanished whenever you click on one of those "latest news" links. So what I need help with is to edit the sidebar.php-file so the "latest news" function with links is still there so you don't have to go back one page whenever you would like to read about another post.
Im not sure how to do this. If it's php involved or if you can do it by simple visiting the posts/pages section in wordpress.
Would be grateful if anyone could help me. If I have forgotten any necassary information please tell me and I will the post.
Thanks!
<?php
get_header();
?>
<section class="textinnehall">
<?php
if (have_posts()) :
while (have_posts()) :
the_post();
the_content();
endwhile;
endif;?>
</section>
<section class="sidomeny">
<?php
get_sidebar(); ?>
</section>
<?php
get_footer();
?>
This is my page.php file. Don't know if it will be to any help. But the sidebar is already active.
May be the sidebar is not called in your single page.
you need to have the same design in your themes single.php page(As per twenty ten theme standard).
<p class="Nyhetsrubrik3"><a style="orange"; href="<?php the_permalink() ?>" ><?php the_title(); ?></a></p>
The href <?php the_permalink() ?> takes the post to single page for full view
Just call the sidebar in your theme's single page.
I'm struggling with getting wordpress to search custom post meta from a page template. I've looked all over the internet and can't seem to find anything that will work. No plugins seem to work either.
On my posts, I have the custom meta: "rate" and the value: "10" - Wordpress delivers no result when searching any of these.
I'd be very appreciated if someone could write me a searchpage.php page template or point me in the right direction (I'm not good with php).
Here's my current PHP code:
<?php
/*
Template Name: Search Custom Meta
*/
?>
<?php get_header(); ?>
<div id="content">
<div class="container clearfix fullwidth">
<div id="left-area">
<?php query_posts('meta_value='.$s); ?>
<?php if (!empty($wp_query->posts)) : ?>
<?php while (have_posts()) : the_post(); ?>
<?php endwhile; ?>
<?php else : ?>
<?php endif; ?>
</div> <!-- end #left-area -->
</div> <!-- .container -->
</div> <!-- #content -->
<?php get_footer(); ?>
You checking incorrect variable in if so try removing that one,
query_posts('meta_value='.$s);
while ( have_posts() ) : the_post();
echo '<li>';
the_title();
echo '</li>';
endwhile;
I'm trying to make a custom search page, by creating all new search.php file, for my wordpress template...so far, so good.
The problem is that when I search for something it doesn't show any results.
I'm guesing that it has something to do with some php script or something I don't know.
How can I fix that ?
P.S The function for the number of the results works fine, but there isn't any results.
Here is the content of search.php
<?php
get_header();
?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<h1>Search Results</h1>
<?php endwhile; ?>
<?php else : ?>
<?php _e( 'Nothing Found' ); ?>
<?php endif; ?>
<?php
get_footer();
?>
The problem is that you don't have anything in your loop to print the results, i.e.
<?php while (have_posts()) : the_post(); ?>
<h1>Search Results</h1>
<!-- Needs something here -->
<?php endwhile; ?>
To fix the problem, simple replace <!-- Needs something here --> with the following
<a href="<?php the_permalink() ?>">
<h2><?php the_title(); ?></h2>
</a>
<p><?php the_excerpt(); ?></p>
You also need to move <h1>Search Results</h1> to above the loop to stop it from displaying multiple times. It may be best to move it above the if statement if you don't intend on adding it to your else statement as well.
What I want to know is, how can I implement my already made index.php file to apply custom posts to it. (See below)
What I want to accomplish:
Display all posts(already accomplished in index.php)
--> show normal post a.k.a 'Article' (already accomplished in index.php)
If category/or post type 'Aside' is used, don't apply a <a> tag, make title lighter(can figure it out in CSS)
-->show text for the 'Aside' marked post
If category/or post type 'Link' is used, wrap title in <a> tag linking to a site(<-- how would I do that in WordPress?)
-->show text for info about the link
If category/or post type 'Photo' is used, don't wrap title in a <a> tag
-->show attached image in post, and post text as a caption
I know this may look like a lot but I'm sure it's easily do-able.
Some source code may not help me all the way, so I have my index.php below to see if you can help me implement it into it:
<?php get_header(); ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<article>
<!-- <p><span class="metaCat"><?php the_category(', '); ?></span></p> -->
<h1><?php the_title(); ?></h1>
<p><span class="meta"><?php the_time('F jS, Y') ?></span></p>
<hr />
<div class="entry">
<?php the_content('Read the rest of this entry »'); ?>
</div>
</div>
</article>
<hr class="big" />
<?php endwhile; ?>
<?php else : ?>
<h2 class="center">Not Found</h2>
<p class="center">Sorry, but you are looking for something that isn't here.</p>
<?php include (TEMPLATEPATH . "/searchform.php"); ?>
<?php endif; ?>
If you can input the needed code into a workable index.php file you will get some well thought of brownie points!
Thanks and all help is welcomed!
I finally see what you meant to do here. This is easily done using the get_post_format() function. Just replace the title here with:
<?php
$format = get_post_format(get_the_ID());
if ($format == 'link') { ?>
<h1><?php the_title(); ?></h1>
<?php }else{ ?>
<h1><?php the_title(); ?></h1>
<?php } ?>
The other bit about linking to a site though, I'm not sure how you want to accomplish that. Are you referring to the blogroll?
The best option for the "link" post format, is to use a custom metabox/custom fields. Add your key as "URL" then type the address in the value field.
Use get_post_meta() to get the URL and use that instead of the_permalink() in the href.