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...");
?>
Related
I am having a weird issue.
Normally when you paste a youtube video the video will embed properly automatically. However when I paste a link into the visual view I can play and see the embedded video in the EDIT view, but on preview or publish it echoes out the link without embedding it as plain text.
So far I have tried disabling all plugins (except Advanced Custom fields)
Using the [embed] shortcode
Changing the youtube links from http to https
What does work is pasting the embed code from Youtube, or writing <iframe> in the text view.
It also works fine to paste and embed when I change theme
For me the issue was I was using
<?php echo get_the_content(); ?>
Instead of
<?php the_content(); ?>
As per the Wordpress Codex:
An important difference from the_content() is that get_the_content()
does not pass the content through the the_content filter. This means
that get_the_content() will not auto-embed videos or expand
shortcodes, among other things.
https://developer.wordpress.org/reference/functions/get_the_content/#:~:text=An%20important%20difference%20from%20the_content()%20is%20that%20get_the_content()%20does%20not%20pass%20the%20content%20through%20the%20the_content%20filter.%20This%20means%20that%20get_the_content()%20will%20not%20auto%2Dembed%20videos%20or%20expand%20shortcodes%2C%20among%20other%20things.
Use the [video] short code instead. It is incorporated in the Wordpress core nowadays. Go to this link for more info: https://codex.wordpress.org/Video_Shortcode
For example:
[video width="640" height="360" src="/wp-content/uploads/files/movie.mp4"]
May this not work in a custom theme, then you want to look at how the content of the post is being processes. You may need to apply the the_content filter to the post content variable like this:
apply_filters('the_content', $post->post_content);
Im using the theme HTML 5 Blank (http://html5blank.com/) with WordPress 3.7.1.
On my page I want to display everthing from the posts, text and images.
In the settings in wordpress admin i have it set on show hole post but it does not work.
I have olso deleted the php code in the loop that inserts the excerpt from the theme. Sitt not workning. Any ideas? I can send code if you want, for now i do not know what code can be usefull.
Jim
Replace <?php the_excerpt() ?>and add the following code to your theme's loop.
<?php the_content(); ?>
That should display the content, rather that the excerpt.
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.
In This Page http://atthy.com/blog/
I'm using Custom template to show the list of blog posts, Since, I use home.php file to display custom home page. I use query_posts() since its a custom template. I created a page in wp admin with the custom blog Home template. Everything is fine. But I can't get read more.. links to work, when using the_content('read more..')
When I use the_content('read more..') whole post content is displayed without cutting it off after <!--more--> and also, read more link is not showing up.
I read through wp codex http://codex.wordpress.org/Function_Reference/query_posts and even resetted global $more to 0
Here is the page template I'm using. http://pastebin.com/VTvN5dtT
What am I doing wrong?? Please Help.
I've not tested this myself, but according to http://codex.wordpress.org/Customizing_the_Read_More#How_to_use_Read_More_in_Pages, the
global $more;
$more = 0;
needs to be inside the loop and before the_content('read more..');. As such, in your pastebin code, move lines 15-16 to line 30. Like I said, I've not tested this, but give it a whirl and see what happens.
You need to make sure that the statements:
global $more;
$more = 0;
are placed after the call to the_post()
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