Hai,
I am designing a blog in wordpress. I am facing problem when I display the topic through the_excerpt().It only display 3 lines and then Continue Link comes.But I want each post will
come with 6-10 line and the continue-> link.how I can increase the line numbers.
You need to add an excerpt_length filter to your theme before you call the_except.
In the filter you sepcify how many words you want in your except (you can only specify words, not lines).
An example:
function my_excerpt_length($length) {
return 120;
}
add_filter('excerpt_length', 'my_excerpt_length');
If you REALLY want to filter on a certain number of lines, you could call get_the_content and extract the number of lines you wanted - but make sure you filter the content to ensure nothing unwanted makes it into your blog.
Related
I have two blue prints for the space content type in OA. On the toolbar dropdown i want to show only the spaces created using the default blue print. AO uses the oa_core_get_groups_by_user_access(found in OA core module in the oa_core.util.inc file) to pull all spaces a use subscribed to. I want to alter this function to show only spaces created using the default blue print by altering the query used in this function.
All my attempts to do so have failed probably because i don't understand the drupal database abstraction queries. Can someone help me with the piece of code i can add to this function to achieve this functionality.
Finally got it. To show only the default spaces in the dropdown, you have to make changes to the oa_core_get_titles function in the oa_core_util.inc file of oa_core.
Add the following line below line 641 of that particular file.
$query->leftJoin('field_data_field_oa_space_type','t','n.nid=t.entity_id');
$query->condition('t.field_oa_space_type_tid',1);
This filters out only spaces created using the default space.
I want to find exact phrase results looking anywhere in the body or the title. It has to be ordered from the most recent to oldest. The only way I get pretty close results is by forcing quotes around all my searches via this hook:
/**
* Implements hook_apachesolr_query().
*/
function hcp_node_apachesolr_query_prepare($query) {
// Adding quotes to all searches so it gives an accurate search result
$search_result = $query->getParam('q');
$has_quotes = preg_match('/^(["\']).*\1$/m', $search_result);
if(!$has_quotes) {
$query->replaceParam('q', '"' . $search_result . '"');
}
}
My Bias Settings:
Results Biasing: All are set to ignore but More recently created is set to 10
Type Biasing: All set to ignore
Field Biasing: All set to omit.
This seems to work well with two or three word phrase but if for example I search a whole title of an article it can't find anything.
I tried setting the Title and The full, rendered content field bias to the same thing (21). Again it would show good results but it wouldn't be in most recent order(I think this was pretty close but just wish it displayed most recent first).
I also tried updating my schema.xml: updated WhitespaceTokenizerFactory to KeywordTokenizerFactory but I didn't get good results.
This is how I fixed this:
Installed Apache Solr Term Proximity Module Updated field bias to .3
for both Title and the full rendered content (the rest are set to
omit) Set the term proximity to .1
Set the Most recent created to 10
FYI I tried different settings and this seems like the best.
I need to replicate the behavior of this site:
http://www.theincipit.com/2013/11/la-notte-di-halloween-tost/9/
As you can see, I linked a "story" divided in various chapters (1-10). Every single chapter, though, displays the same list of comments. So you can comment every chapter but it will go automatically under the same list, displayed in every chapter.
In my site I have different posts grouped in different categories, and I''d like that the same posts form one category display the same list of comments (and when you comment from every post of that category, you update the same list)
Thanks!
Here's a start, anyway. Haven't tested this, yet.
add_rewrite for to get an extra querystring
Add a rewrite to the specific page (id as XX, below).
add_rewrite_tag('%chapter%','([^&]+)');
add_rewrite_rule('^story-slug/([^/]*)/?','index.php?page_id=XX&speaker=$matches[1]','top');
make a template for that specific page.
And create a page-xx.php where xx is the page ID (or slug) that will make use of an extra piece on the end of the url: /story-slug/1/ the 1 in this case. Don't forget to include the comments in this template!
In the post editor, write the whole thing as one entry, wrapping the chapters in [chapter id="X"]
Then, hide chapters that don't correspond to the url's chapter query, via shortcode.
add_shortcode('chapter', 'chapter_display')
function chapter_display($atts, $content) {
$current_chpater = $wp_query->query_vars['chapter'];
$chapter = $atts['id'];
if ($chapter == $current_chapter)
return $content;
}
Only thing missing from this solution is pagination across the top / bottom.
By continually referencing the same post, but showing different parts,
PS - don't forget to hit up wp-admin/options-permalink.php to flush the rewrite rules after you add the the add_rewrite_xxx functions to make sure that they take.
I would like to restrict the fields while creating a new post in WordPress. For the title, it should not exceed 40 characters. For the content, it should not exceed 400 characters. If these maximum values are exceeded, I would like to show an error message and not let the user continue. How do I do that in WordPress?
You should be able to use wordpress filters to modify the code that gets outputted when the editor is called. Essentially you would want to use it to insert some javascript and an extra div tag to display your error, then just read the contents of the "editorcontainer" id and show the error once it reaches a certain character limit.
I don't have the time at the moment to write a case example, but depending on your skill level, the functions you are looking for are:
apply_filters("the_editor", "customfunction_limitarea");
Where customfunction_limit area is your created function to insert the javascript. You can see how the_editor is currently called and how the default filters are applied in "wp-includes\general-template.php" on line 1822. The default looks like this:
$the_editor = apply_filters('the_editor', "<div id='editorcontainer'><textarea rows='$rows'$class cols='40' name='$id' tabindex='$tab_index' id='$id'>%s</textarea></div>\n");
I would try modifying that statement by placing a new filter in a functions.php file located in your themes directory, that way you don't have to worry about it getting over-written during an update. Otherwise, if you absolutely have to edit the wordpress core (generally a no-no), general_template.php would be the place to do it I think.
Essentially just read up on wordpress filters a little bit (be warned there's not a ton of documentation or examples available for it other than the basic stuff), and that should provide everything you need. The input verification end is easy enough to find scripts, just google jquery post limiting. Something like this might be exactly what your looking for:
http://swiki.fromdev.com/2010/02/jquery-maximum-limit-texttextarea-with.html
So I added some code in my css and there are boxes that appear over every image that is attached to a post. I've wanted to number the images and show the image number in the box(1...n). I have this in my functions.php
edit: code was added here http://pastebin.com/gVszwf75
If I run only count_images it will show the correct number of attached images to a post(let's say 15). But for some reason the number that is shown in the boxes over the images is always 1. I've seen this done on several blogs with just php so there has to be a way(even if I have to change my whole code).
The problem with your code is that you're looping through the array each time you call your callback function caption_image_callback() ... it has no memory of how many times it's looped!
The easiest way to fix this is to add a global variable at the beginning of the plug-in, I call it $caption_image_count and set it equal to zero. Then call the variable in caption_image_callback() and increment by 1 each time you call the function. This will keep track of the number of captioned images you have on the page.
If you want, you can also re-set the variable to zero before you return $post_body_content in caption_image(). I've posted the full solution to your pastebin: http://pastebin.com/sFe6dhqL