I have a wordpress blogg where i want to change the value of the "more" tag. I tried to change "the content" code that is in the post but that wont work.
I have tried to look trough every file i can find without managing to change the value that is "read more..".
When i look in the sourcecode i can se this
"class="more-link">(mer…)</a></p>"
Anyone got any ide where i could change it ? right now i do not know what i should do.
try this one
function new_excerpt_more($more) {
global $post;
return '<a class="moretag" href="'. get_permalink($post->ID) . '"> Read the full article...</a>';
}
add_filter('excerpt_more', 'new_excerpt_more');
Related
I am working on a website on WordPress and I’m getting an undefined variable in image url. WordPress automatically links to a random previous post with a picture from that previous link if there is a previous post but this notice keeps popping up on the bottom of my latest post. This does not show up on any other post. It says there is something wrong with the previous post image url. Since it is undefined should I try to define it in the code and include a url and image url from one of my previous posts to see if that works? This is where it says the error is on. And if I do define it myself, what is the code that I should input to create a variable for image url?
previous_post_link( '%link', '<div class="post-navigation-image"><img src="' . $previous_post_image_url . '" /></div><div class="post-navigation-content"><div class="post-navigation-title"><span class="next-post">Next Post ></span><h3>%title</h3></div></div>' );
echo '</div>';
You should add validation to check if the variable exists before trying to use it. If the variable does not exist, then you can assign a default value to that variable which will be used to avoid error.
$previous_post_image_url = !empty($previous_post_image_url) ? $previous_post_image_url : '';
previous_post_link( '%link', '<div class="post-navigation-image"><img src="' . $previous_post_image_url . '" /></div><div class="post-navigation-content"><div class="post-navigation-title"><span class="next-post">Next Post ></span><h3>%title</h3></div></div>' );
echo '</div>';
I have set a blog page that is separate from my static home page.
I have modified the “[...]” link that comes after each post’s excerpt on the blog page by using a filter function.
To do this, I used WordPress’s “excerpt_more” hook.
add_filter('excerpt_more', 'new_excerpt_more');
function new_excerpt_more($more) {
global $post;
return '... <br clear="all"/><a class="moretag" href="'. get_permalink($post->ID) . '">Continue Reading</a>';
}
The problem I am having is that, for some reason, this works for every post, except the very first post of the blog page.
Is there something different or special about the very first post of the blog page that would make it not go through this filter hook?
Thank you very much for any help.
Try with this one:
add_filter('excerpt_more', 'new_excerpt_more');
function new_excerpt_more($more) {
return '... <br clear="all"/><a class="moretag" href="'. get_permalink( get_the_ID() ) . '">Continue Reading</a>';
}
Also, if in Wordpress a post has a manual excerpt, the excerpt_more filter wont get executed. So it's always recommended to check that, just in case.
Almost sure that I'm not the first one that has this question but when I test my (WordPress) page on Google Snippet Test Tool I got hatom-enty errors like:
hatom-feed
hatom-entry:
Fout: At least one field must be set for HatomEntry.
Fout: Missing required field "entry-title".
Fout: Missing required field "updated".
Fout: Missing required hCard "author".
I found some tutorials about this but that is for standard WordPress themes. I'm using Inovado from ThemeForest and I can't figure out in which file I have to edit this data.
Someone familiar with this?
I also got problems with snippet review... Good in testresults but doesn't show up in de Google Search Results. Don't know why...
You can Add this code to the function.php file in your theme's directory and it will solve the problems.
//mod content
function hatom_mod_post_content ($content) {
if ( in_the_loop() && !is_page() ) {
$content = '<span class="entry-content">'.$content.'</span>';
}
return $content;
}
add_filter( 'the_content', 'hatom_mod_post_content');
//add hatom data
function add_mod_hatom_data($content) {
$t = get_the_modified_time('F jS, Y');
$author = get_the_author();
$title = get_the_title();
if(is_single()) {
$content .= '<div class="hatom-extra"><span class="entry-title">'.$title.'</span> was last modified: <span class="updated"> '.$t.'</span> by <span class="author vcard"><span class="fn">'.$author.'</span></span></div>';
}
return $content;
}
add_filter('the_content', 'add_mod_hatom_data');
The code contains 2 functions. The first function will use the WordPress filter hook for “the_content” to add the class of “entry-content” to the article. To add in the other essential hAtom fields, the second function will add a short sentence to the end of your post article, which contains updated time, post title and author, with required microdata.
On my Drupal site I've got a set of Primary Links. The ones that expand I'd like to make the parent not click able e.g
-home
-about
-history
-website
Only home, history, website should link to a page. If the user clicks on aboutnothing should happen. I've tried searching around the admin panels as well as leaving the field blank but it doesn't seem to be working. I'd assume I'd have to hardcode this? If so, how?
Try this module http://drupal.org/project/special_menu_items
Its probably the simplest way to achieve what you want.
If you can live with it, the easiest solution is to use js to disable clicks.
Adding a yourtheme_menu_item function in template.php seems to be the way to go for this. The documentation for the original function is at http://api.drupal.org/api/function/theme_menu_item
The function passes a $has_children variable and a $menu variable, so it should be pretty easy to adjust Primary Menu items with children as needed.
Some untested example code:
function yourtheme_menu_item($link, $has_children, $menu = '', $in_active_trail = FALSE, $extra_class = NULL) {
// ... original theme code copy-pasted ...
if ($has_children) {
$modified_link_name = youtheme_write_menu_item_without_links($link);
return '<li class="'. $class .'">'. $modified_link_name ."</li>\n";
} else {
// From original function
return '<li class="'. $class .'">'. $link . $menu ."</li>\n";
}
}
You just need to add in the path the phrase <nolink>.
"You just need to add in the path the phrase <nolink>"
i used this before and it worked, but for some reason it didn´t work for a different site that i am using now.
So i tried to write # in the path and worked fine for me.
Hug everybody.
I am having trouble with the previous_post_link() and next_post_link() functionality. When there is no previous post, the function previous_post_link() does not display a link, likewise for the next_post_link() and the last post. I would like to have a placeholder image so that the design stays consistent.
Currently I have images of green arrows pointing left and right, I would like to place an image of a grey arrow if there are no more posts to go back to.
Is there a way to use the next_post_link()/previous_post_link() functions but not have the link removed.
I also wonder if there is a way for the links to cycle, so that if you come to the most recent post, the next post link would bring you back to the first post.
************ UPDATED ************
Here is the code, based on "silent's" advice (accepted answer) to use get_adjacent_post():
<?php
if(get_adjacent_post(false, '', true)) {
previous_post_link('%link','<img src="larr.gif"/>');
}
else {
echo '<img src="larr2.gif"/>';
};
if(get_adjacent_post(false, '', false)) {
next_post_link('%link','<img src="rarr.gif"/>');
}
else {
echo '<img src="rarr2.gif">';
};
?>
So you can "capture" what next_post_link() and previous_post_link() return using ob_start() and ob_get_clean(), then apply a conditional to it.
Code in practice:
$previous_string = "<-Back";
ob_start(); // start output buffering
previous_post_link("%link", $previous_string);
$previous_link = ob_get_clean(); // stop output buffering and store
if ($previous_link == '') {
echo '<span style="color: #ccc">' . $previous_string . '</span>';
} else {
echo $previous_link;
}
I never try this myself. However, you may refer to this post. It uses get_adjacent_post().
Why cant you try the below?
<div style="float:right"><?php if(get_previous_posts_link()) { previous_posts_link('Newer Entries »'); } else { echo 'No Newer Entries'; } ; ?></div>
Alternatively to display Next and Previous Post Links to Blog post you can easily do that. This is very well explained at globinch.com (WordPress Tips : How to Add Next and Previous Post Links to Blog? )
http://www.globinch.com/2010/10/12/wordpress-tips-how-to-add-next-and-previous-post-links-to-blog/