The function wp_link_pages() is not working at all in my wordpress template. I have tried all possibilities to make it work. I didn't get any satisfying help for the same online. Please do help me. Guide.
Thanks in advance.
You should use <!--nextpage--> for work wp_link_pages function.
This tutorial will be help to understand how to work <!--nextpage-->
https://www.youtube.com/watch?v=oGFjVx9jDd4
Example:
https://codex.wordpress.org/Function_Reference/wp_link_pages#Default_Usage
Use the plugin WP-PageNavi - sample code below:
<?php get_header(); ?>
<!-- Start Loop -->
<?php query_posts('category_name='SomeCategoryName'&orderby=title&order=ASC&paged='. get_query_var('paged')); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php //Loop Code Here ?>
<?php endwhile; else: ?>
<p class="error">No results found.</p>
<?php endif; ?>
<!-- Start Pagination - WP-PageNavi -->
<div id="pagination">
<?php wp_pagenavi(); ?>
</div>
<!-- End Pagination -->
<?php wp_reset_query(); ?>
<!-- End Loop -->
<?php get_footer(); ?>
I think header section
the_post(); missing
Related
This is a single.php and for example url is
http://url.com/sample-post/
I added some extra content with Advanced Custom Fields plugin and show it in the content. Everything is all right here but I want to show this extra content like http://url.com/sample-post/extra-content/
Is it possible? If yes how can I make it? I've been searching for hours but I have not found anything.
I hope you understand me and so sorry for my bad english. Thank you everyone who will help.
<?php get_header(); ?>
<main class="content" role="main">
<?php while ( have_posts() ) : the_post(); ?>
<?php the_content(); ?>
<?php the_field('some-extra-content'); ?> // Extra Content
<?php endwhile; ?>
</main>
<?php get_footer(); ?>
please try below code for ACF
<?php get_header(); ?>
<main class="content" role="main">
<?php while ( have_posts() ) : the_post(); ?>
<?php the_content(); ?>
<?php echo get_field('some-extra-content', $post->ID); ?>
<?php endwhile; ?>
</main>
<?php get_footer(); ?>
Not exactly the same url but you could use a query string.
http://url.com/sample-post?extra=true
<?php
if($_GET['extra'] === 'true'){
the_field('some-extra-content');
}
?>
http://www.florence.inspiremeland.gridhosted.co.uk/
I tried every single possible way to remove my feature images from my single posts while keeping the images when you visit my home page.
First of all I tried to use the following code:
.single-post .attachment-post-thumbnail {
display: none;
}
Along with many other in my style.css or single post file without any success.
This is in my single.php file:
<?php get_header(); ?>
<div class="container">
<div id="content">
<div id="main" <?php if(get_theme_mod('sp_post_layout') == 'full') : ?>class="fullwidth"<?php endif; ?>>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php get_template_part('content'); ?>
<?php endwhile; ?>
<?php endif; ?>
<?php if(get_theme_mod('sp_post_layout') == 'full') : else : ?><?php get_sidebar(); ?><?php endif; ?>
</div>
<?php get_footer(); ?>
Let me know what part you need from my CSS perhaps if you could help?
I am really desperate to solve this :(
2.
When I visit my blog posts the sidebar is below content and not at the side, my website is not live yet so I cannot show you that but if you could help I would really appreciate it.
Betty
Have a look at standard.php in includes/post-formats/ and you should find something like <?php the_post_thumbnail('thumbnail'); }?> which you can remove.
I have been trying to use several conditional statements using is_home/is_front_page or is_single and they are not working in my theme. Below is an example on such code:
<?php if(is_front_page() || is_home() ) : ?>
<?php if(function_exists('show_flexslider_rotator'))
echo show_flexslider_rotator('homepage_fexslider' ); ?>
This loads my Flexslider, but when I go to page 2, the slider remains on the page.
I have used these statements successfully in other themes.
Do I need to add support for this feature in my functions.php?
How can I troubleshoot this?
My home.php code is as follows:
<?php get_header(); ?>
<?php if(is_front_page() || is_home() ) : ?>
<?php if(function_exists('show_flexslider_rotator')) echo show_flexslider_rotator( 'homepage' ); ?>
<?php endif; ?>
<div class="row below-banner">
<div id="site-content" class="span8">
<div class="row">
<div class="span8">
<div class="widget-header">
<h2>What's new</h2>
</div>
</div>
</div>
<div class="row">
<div class="posts span8">
<?php $paged = (get_query_var('paged')) ? get_query_var('paged') :1; query_posts('cat=-35&paged=' . $paged);?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php get_template_part( 'entry' ); ?>
<?php endwhile; ?>
<?php wp_pagenavi(); ?>
<?php else : ?>
<h2>No Posts Found</h2>
<?php endif; wp_reset_query(); ?>
</div>
</div>
<?php get_footer(); ?>
We would need more info/code in order to give a definitive answer, but my best guess is that you need to add a wp_reset_query() somewhere.
A quick test: add wp_reset_query() immediately before the conditional statements and see if that resolves the issue. If so, then you need to find the offending query and make sure it is reset at the appropriate time.
The issue with wordpress conditionals like is_single is that they don't work outside a functions in functions.php
So the solution is to place the conditional within the function and call that function using add_action probably.
The code here is_single not working in functions.php explained how it won't work outside the function and how should it be instead
My code:
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div class="posts" id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<h2>
<?php the_title(); ?>
</h2>
<div class="entry">
<?php the_content();?>
</div>
</div><!--post end-->
<?php endwhile; ?>
<?php else : ?>
<h3>no content</h3>
<?php endif; ?>
I put the code into my customed wordpress theme file single.php. Why it can't output the post content, it can output the post title. thank you.
You can try the following to see if it works instead of the_content
<?php echo wpautop($post->post_content); ?> // content with p tags
<?php echo $post->post_content; ?> //without p tags
Also an option
<?php echo wpautop( get_the_content() ); ?> // content with p tags
see if that works for you.
When developing Wordpress themes it's advisable for you to switch the debug mode (found on your installation's root in wp-config.php) to true. This will alert you if you have any errors.
In your case, try out the <?php the_excerpt(); ?>.
Also, this may sound a bit dumb, but do you actually have posts? Not pages or rather content in that post?
Many a times i have come across queries from developers or first time theme developers about not able to show the_content() on their custom template page.
The issue is that the_content() function runs inside the WP loop so for example
if (have_posts()) {
while (have_posts()) {
the_post();
the_content();
}
} ?>
This will work, but in some cases you want to call the function outside the loop – the solution for that is:
echo $post->post_content;
So I have a page called "latest news" and using a custom template t_latest_news.php
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="latest-news" id="post-<?php the_ID(); ?>">
<?php the_content(); ?>
<?php edit_post_link('Edit this page','<p class="edit-link">','</p>'); ?>
</div><!-- /.latest-news -->
<?php endwhile; endif; ?>
I've created a page item and put some content into that page. Now, I want to show the content on the sidebar. How can I do that please?
I've tried something like:
<?php include(get_query_template('t_latest_news.php')); ?>
<?php include(TEMPLATEPATH . 't_latest_news.php'); ?>
<?php get_query_template('t_latest_news.php') ?>
<?php get_template_part( 't_latest_news.php' ); ?>
But none of them works. HELP!
<?php query_posts('page_id=76'); ?>
<?php while (have_posts()) { the_post(); ?>
<h2><?php the_title(); ?></h2>
<?php the_content(); ?>
<?php } ?>
<?php wp_reset_query(); ?>
It works with "page_id" but not pagename. any idea?
To query a specific page by name you do this:
<?php
query_posts('pagename=about'); //retrieves the about page only
?>
You should remove the .php at the end so that it reads t_latest_news
I was just showing this as an example, please be advised:
The query_posts function is intended to be used to modify the main page Loop only. It is not intended as a means to create secondary Loops on the page. If you want to create separate Loops outside of the main one, you should use get_posts() instead. Use of query_posts on Loops other than the main one can result in your main Loop becoming incorrect and possibly displaying things that you were not expecting.
see: http://codex.wordpress.org/Template_Tags/get_posts for more information