In most Wordpress themes, they make use of Wordpress templates that can be chosen for a page. Now, in this particular theme, when you choose a template for a page, it discards the content you add in the editor section.
Surely you should be able to enable this somewhere? How can this be done or does it differ from theme to theme?
Add the loop and the_content() template tag in the page template. Look at the page.php template in your theme folder for the exact markup needed for your theme:
// Start the Loop.
while ( have_posts() ) : the_post();
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php the_title( '<header class="entry-header"><h1 class="entry-title">', '</h1></header>' ); ?>
<div class="entry-content">
<?php
the_content();
wp_link_pages();
?>
</div><!-- .entry-content -->
</article><!-- #post-## -->
<?php
endwhile;
Related
I need your help! Do you have any idea what's going on?
I have following code:
<div id="post-list">
3
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
1
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<div class="article-inner <?php flatsome_blog_article_classes(); ?>">
<?php get_template_part('template-parts/posts/partials/entry-header', flatsome_option('blog_posts_header_style') ); ?>
<?php get_template_part('template-parts/posts/content', 'default' ); ?>
<?php get_template_part('template-parts/posts/partials/entry-footer', 'default' ); ?>
</div><!-- .article-inner -->
</article><!-- #-<?php the_ID(); ?> -->
2
<?php endwhile; ?>
4
<?php flatsome_posts_pagination(); ?>
</div>
Do you see that numbers 4321? So, problem that when I go to single author posts archive page I see only 3 and 4 (that's mean code inside while not work for it but I can see all posts, just in different template), BUT when I open some category page with posts listing — it's show me all numbers in following order: 3124 that's mean that everything working how it's should be. This code in archive.php file. I need setup the same template for authors posts and category listings. Thank you!
The problem was in that it have this plugin https://toolset.com/ that overwrite some templates and store all code in database.
I wish to use the Pinbin theme for my Wordpress blog only. I have created a custom theme for everything else, but for the blog, I would like to use this theme.
I took the main index php file from this template, along with the header and footer files. I renamed the header and footer files, and changed the header/footer calls to these files rather than the ones used by the rest of the site.
I assigned the theme to a page, but it's not showing any posts. The code is as follows:
<?php if (have_posts()) : ?>
<div id="post-area">
<?php while (have_posts()) : the_post(); ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php if ( has_post_thumbnail() ) { ?>
<div class="pinbin-image"><?php the_post_thumbnail( 'summary-image' ); ?></div>
<div class="pinbin-category"><p><?php the_category(', ') ?></p></div>
<?php } ?>
<div class="pinbin-copy"><h2><a class="front-link" href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
<p class="pinbin-date"><?php the_time(get_option('date_format')); ?> </p>
<?php the_excerpt(); ?>
<p class="pinbin-link">→</p>
</div>
</div>
<?php endwhile; ?>
Any ideas on why I'm not seeing anything?
Thanks, S
The index.php file is used as a backup if there's no other template defined, you'll have to edit a different file if you want to edit a certain page type. See template hierarchy in the WordPress codex.
+
You forgot an endif; at the bottom of your file.
i have a WordPress template page, which shows header, footer and sidebar, but the content not showing up anyone can help?
<?php
/**
* Template Name: Template 2
*/
?>
<?php get_header(); ?>
<div class="main_right" style="float:right;">
<?php get_sidebar(1); ?>
</div>
<div style="float:left">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php echo the_content();?>
<?php endwhile; endif; ?>
</div>
<?php get_footer(); ?>
Is this within your wordpress loop? It has to be in order for the_content to work.
Also, you don't need to echo the function, just place it in your file like so…
<?php the_content(); ?>
Also, why would you want to wrap the content in <p> tags? Wordpress does this for you automatically. If you want to wrap it something a <div> would be much better, probably with a class or id for css use.
Have you had a look at the wordpress codex? - http://codex.wordpress.org/Function_Reference/the_content
I'm trying to style a search page in wordpress. In search.php I can style most of the page but then the following statement (which I got from the original uneditted page) generates the content.
<?php
/* Include the Post-Format-specific template for the content.
* If you want to overload this in a child theme then include a file
* called content-___.php (where ___ is the Post Format name) and that will be used instead.
*/
get_template_part( 'content', get_post_format() );
?>
<?php endwhile; ?>
This ALMOST displays the page as I want it, but there are a few elements off the page, making it expand etc. I can't figure out what file is generating this content!
Using the instructions I created a content-search.php and change the line of code to this...
get_template_part( 'content', get_post_format() );
Which works...but it doesn't display much of anything because I don't know what to put in my page within seeing the original.
Anyone have any clue?
You can use a template part named post-search.php and can use it inside your search.php file like
get_template_part( 'post' , 'search')
but you have to create a php file inside your theme folder and name it post-search.php and inside this file just put the WordPress' loop i.e.
<?php while (have_posts()) : the_post(); ?>
<div class="post-entry clearfix"> <!-- Main wrapper -->
<div class="post-entry-content"> <!-- Post-entry-content -->
<h2><?php the_title(); ?></h2>
<div class="post-entry-date">Posted on <?php the_time('F Y') ?> with <?php comments_popup_link('0 Comments', '1 Comment', '% Comments'); ?></div>
<?php the_excerpt(); ?>
Read More ?
</div><!-- END of post-entry-content -->
</div><!--End of main wrapper -->
<?php endwhile; ?>
and your search.php could be something like this
<?php get_header(' '); ?>
<div id="post-wrap">
<div id="post-content">
<?php if (have_posts()) : ?>
<?php get_template_part( 'post' , 'search') ?> // This will load/include the file post-search.php and result will be displayed as formatted in this file
<?php else : ?>
<p>Sorry, it does not exist !</p>
<?php endif; ?>
</div><!-- END post-conten -->
<?php get_sidebar(' '); ?>
</div><!-- END post-wrap -->
<?php get_footer(' '); ?>
This is just an example, change div/h2 id/class names according to your theme css.
Note: I'm currently using this approach in one of my site and I've one file named 'post-entry.php' in my theme folder and in my every template file (index.php, search.php e.t.c) I just use this file by calling
<?php get_template_part( 'post' , 'entry') ?>
When I installed WordPress I had a home menu. While editing, I added a menu item to the menu but my home menu item disappeared.
I don't know what's going on. How do I add the home menu item which links to homepage back?
I'm not sure why your home item would have disappeared after adding another item, but make sure your theme is using wp_page_menu():
http://codex.wordpress.org/Template_Tags/wp_page_menu
This carries the benefit of listing your "Home" along with your other pages.
Edit the line in the header.php
wp_page_menu( 'show_home=1');
reference in the codex : http://codex.wordpress.org/Function_Reference/wp_page_menu
If you have already added Home as menu, then copy the content of index.php into your Home.php (create this empty file in your theme) file.
Then run and check the home page.
Step 1. For linking your home page, create index.php as template file for home like the code below:
Use these codes if you're using custom theme(theme created by yourself in themes folder of wp-content other than twentyelevan, twentyten and so on.
<?php
/**
* Template Name: home
*
* Selectable from a dropdown menu on the edit page screen.
*/
?>
<?php get_header(); ?>
// whatever body code u need,u can include it here.
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<div class="post-header">
<!-- <div class="date"><?php the_time( 'M j y' ); ?></div>-->
<!-- <h2><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent
Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>-->
<!-- <div class="author"><?php the_author(); ?></div>-->
</div><!--end post header-->
<div class="entry clear">
<?php if ( function_exists( 'add_theme_support' ) ) the_post_thumbnail(); ?>
<?php the_content(); ?>
<!-- <?php edit_post_link(); ?>-->
<?php wp_link_pages(); ?>
</div><!--end entry-->
<div class="post-footer">
<!-- <div class="comments"><?php comments_popup_link( 'Leave a Comment', '1
Comment', '% Comments' ); ?></div>-->
</div><!--end post footer-->
</div><!--end post-->
<?php endwhile; /* rewind or continue if all posts have been fetched */ ?>
<div class="navigation index">
<div class="alignleft"><?php next_posts_link( 'Older Entries' ); ?></div>
<div class="alignright"><?php previous_posts_link( 'Newer Entries' ); ?></div>
</div><!--end navigation-->
<?php else : ?>
<?php endif; ?>
<div id="slider">
<?php
$tmp = $wp_query;
$wp_query = new WP_Query('posts_per_page=5&category_name=featured');
if(have_posts()) :
while(have_posts()) :
the_post();
?>
<a href="<?php the_permalink(); ?>"><?php
the_post_thumbnail('nivothumb'); ?></a>
<?php
endwhile;
endif;
$wp_query = $tmp;
?>
</div><!-- close #slider -->
<?php get_footer(); ?>
Or, if you're using wordpress builtin themes, then use these codes:
<?php
/**
* Template Name: onebyone
*
* Selectable from a dropdown menu on the edit page screen.
*/
?>
<html>
// whatever body code u need,u can include it here.
</html>
Step 2. Then open the home page in wordpress, Pages -> All pages, click edit.
Step 3. In edit page of home, in the right side you will see Dropdown named Template. Click the
dropdown, there you will see your template name as home select it and then click update
button.
Step 4. Then,On top left side corner,click your website or blog name and visit the website or
blog to check your home page by clicking on it.
Do you have a link to your site?
It may be as simple as checking a box. OR, you can create a custom menu.