Wordpress the_content('more') fails to display <--more--> - wordpress

I'm having an annoying problem with my wordpress 3.5 blog .
the_content() function fails to display the short version of the posts on the first page / index page, and it shows the content of the posts in full .
my current the_content() codeline from loop.php file is:
<?php the_content('Read more...'); ?>
I did try to search the wordpress forums stackoverflow and codex and i tried this :
<?php
global $more; // Declare global $more (before the loop).
$more = 0; // Set (inside the loop) to display content above the more tag.
the_content("More...");
?>
but it does not work.
Any ideea what this problem could be ?

Have you added a <!--more--> tag to your page content where you'd like to show the more link? Taken from the Codex on the_excerpt():
Sometimes it is more meaningful to use only the_content() function. the_content() will decide what to display according to whether <!--more--> tag was used. The <!--more--> tag splits post/page into two parts: only content before the tag should be displayed in listing. Remember that <!--more--> is (of course) ignored when showing single post/page.

Related

Archive Page Template returns posts instead of page content on Polylang second language

I have an issue with Polylang and custom archive page template. On my main language my archive page shows page content but on second language it starts looping trough posts.
<?php
/* Template Name: Archive Page Custom */
get_header();
while (have_posts()) : the_post();
the_content();
endwhile;
?>
<?php
get_footer(); ?>
What causes this?
Cheers
I have solved this. It turns out that under Polylang settings I had to uncheck my custom taxonomies because it completely breaks the site.
EDIT: Never mind this doesn't work because as I turn it off it shows posts from all languages on my archive first page. So it still has to be turned off to filter posts between languages.
So the issue remains. Archive page with default language loads content in from the page and secondary language shows posts for some reason instead of content.
EDIT: It was a conflict with archive-portfolio.php template and also I had custom post type slug named same as my secondary translation so the page broke. I had to rename my archive-portfolio.php template to portfoliotemplate.php and it works now.

Wordpress: Pages work, Posts don't

First of all, I'm totally new to WordPress so please be patient :)
Anyway, I have created a custom theme with a bunch of pages, a menu and a startpage (index.php), and everything is working fine. I have also created a few posts and those are not working at all. I have created a small loop that display the 5 latest posts on the startpage as links with date, and they show up as intended, but if I click on one of the links the startpage just reloads. As the page has reloaded it displays the correct permalink in the browser address bar, but I'm still stuck on the startpage. Same if I try to preview my posts from WP-admin, it just display my start page.
I have no idea what I'm doing wrong here and I'm no php coder. This is the code I have in my page.php file, maybe there is something wrong with it?
<?php get_header(); ?>
<div class="content">
<?php while ( have_posts() ) : the_post(); the_content(); endwhile; // THE LOOP ?>
</div>
<?php get_footer(); ?>
there is a difference between posts and pages. Try to put this code into a file called index.php so it will work for posts too.
If wordpress cant find a page.php (this is for pages) or single.php (this is for posts) it will look into the index.php as a fallback.
those are the files - enjoy :)
1. style.css: your page styling goes in here.
2. index.php: acts as fallback if the specific php files are not found.
3. single.php: single posts template
4. page.php: single page styling goes here
5. archive.php: acts as archives template (by month, author,...)
6. searchform.php: style and configure your searchform here
... there are many more. here is a cheat sheet with page types / theme structure .If you need further information google for types followed by tutorial
example: wordpress single.php tutorial
all the best
fab

Remove post and comment box in WordPress

I'm designing a website using WordPress. I want to know how to remove the post and comment boxes which is available by default in WordPress...and also I want to know how to add plugin's in that static page
First, create page with name "Home", insert shortcode of plugin or anything you want.
Second, go to Apperance, choose Customize. At Static Front Page, tick A static page radio button, choose "Home" from dropdown list Front page. Save.
In order to remove comments yoy must select the "Screen options" in the post editor (it's an option located at top-right on the screen) and check the Comments checkbox. Then at the editor's bottom you'll find a box with a checkbox to disable comments.
If you're working in Wordpress.com you cannot add plugin's for free. This is for security reasons. You must install Worpress in your own server to do that.
Ok, as per your comments on main question, I understand you want to remove posts and comment box on public facing page, not in WP-Admin panel.
I am giving you an overview of how you can proceed.
If you are using default TwentyThirteen thee then just remove this part from single.php
<?php /* The loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', get_post_format() ); ?>
<?php twentythirteen_post_nav(); ?>
<?php comments_template(); ?>
<?php endwhile; ?>
This will remove post and comments template.
However I will recommend you to use custom page templates rather :
http://codex.wordpress.org/Page_Templates
Here you'll find way to add custom page templates. There you can remove posts and comments :-)

wordpress <!--more--> not rendering a link

I am using the <!--more--> tag in my wordpress copy to create an excerpt from the main content and also echo a link, however it is totally disregarding this tag and just posting the full article, below is hope I am implementing it in my templates,
<?php the_content("Read more about this article..."); ?> am I doing something wrong? Currently it is showing the while post when I use the above code, however it is my belief that it should only only show everything above the <!--more--> tag?
As per the official WordPress support site:
From the use of your PHP code, it looks like you want to use the more tag on pages. More works with blog posts but not pages. Please add the following code to your document above your PHP line you provided to make it work:
<?php
global $more;
$more = 0;
?>
Also, be sure that you are not simply in preview mode and that you have actually published the article and previewed it:
[T]he more tag is not displayed in post previews, since previews display
posts in entirety, but the more tag will appear once the post has been
published.
Perhaps you are using custom page template to display archives. "More" tag doesn't work in pages. If you want to turn it on in Pages...
<?php the_content("Read more about this article..."); ?>
you should use the code like this if you wanna show the to work in a page
<?php
global $more;
$more = 0;
the_content("Read more about this article...");
?>

adding single.php page to wordpress or if condition for main page or post detail page

I use Barecity Theme for WordPress. i built everything, but now i need to add a single.php file to theme. now it displays all post content at homepage, I created a short_desc Custom Field. and I call it from code with;
<?php //get_post_meta($post->ID, 'short_desc', true); ?>
it is fine. but i need to display this short desc at home page listing, and the main content at details page. how can do that?
I appreciate helps!!
It sounds like what you are trying to do is show a custom field that you have set on a post on the index page (which lists all the posts).
To do that you'll need to modify index.php by adding your snippet where you would like to have the short description.
<?php echo get_post_meta($post->ID, 'short_desc', true); ?>
You need to use echo to display the results from the get_post_meta function.
Depending on how your posts are setup you can also use the More button when you write your posts. This will cut off your post at a certain point that you decide and only show that short part on the index and archive pages.
Another option would be to use
<?php the_excerpt(); ?>
Which shows the first 55 words (this can be adjusted though) of the post.
Hope that helps,
Paul

Resources