Jorge Jaral
Forum Replies Created
-
Forum: Themes and Templates
In reply to: Twenty Eleven theme helpYes indeed gymgator; from time to time you will receive a notification on your WordPress admin dashboard to update or upgrade your system to the most recent and stable version, that will overwrite everything that comes with the installation package as a default, which includes the Twenty Eleven theme, so any change that you have performed directly on it will be lost.
That’s why it’s MANDATORY to work on a child theme, I hope you have got the message and acquired the best practice.
Greetings from Mexico.
JJ
Forum: Themes and Templates
In reply to: Shorten search box on Twenty ElevenThanks a lot Emil!
I changed it to 150px and it worked quite nice.
I’ll post the site url later to show everyone how it looks.
JJ
Forum: Plugins
In reply to: Get page content with formatI think this issue is now resolved, so the I will close de post, if somebody wants to modify the code I’d appreciate if you let me know.
JJ
Forum: Plugins
In reply to: Get page content with formatEureka! (I got it!)
The following function gets a random page AND trims the content to a specific number of words passed as a parameter AND not counting HTML tags, just pure ‘the_content’ words, there are some really minor bugs that somebody could help to fix (try it to find out)
This function is very useful when you don’t want to mess with categories or tags to get content from static pages to fill out columns in a dynamic front page; the output includes the page title plus the permalink and a customizable ‘Keep reading →’ link at the bottom
/** * Function: get_random_page_trim() * Author: Jedi Master S-Ha-Dum & the Padawan Jorge Jaral. * Task: Outputs a random page along with its title. * Description: $child_of is the page ID (number) from which you want to select the * random page. If $child_of is not set then it'll pick a random page from * all your pages. * Usage: To make it work you should insert in your template the instruction: * <?php get_random_page_trim(172, 200); ?> * where 172 is the parent page ID from which you want to get its child pages * randomly to show inside a specific space, i.e. as a column on a static page; * and 200 is the number of words that you want to obtain form the page post. */ function get_random_page_trim($child_of = 0, $all_words = 45) { $allowed_tags = array( 'a', 'abbr', 'b', 'blockquote', 'b', 'cite', 'code', 'div', 'em', 'fon', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hr', 'i', 'img', 'label', 'i', 'p', 'pre', 'span', 'strong', 'title', 'ul', 'ol', 'li', 'object', 'embed', 'param' ); $pages = &get_pages("child_of=".$child_of); $pageInd = rand(0, count($pages) - 1); $ga_title = apply_filters('the_title',$pages[$pageInd]->post_title); $ga_permalink = get_permalink($pages[$pageInd]); echo '<a href="'; echo $ga_permalink; echo '">'; echo $ga_title; echo '</a>'; $ga_content = apply_filters('the_content',$pages[$pageInd]->post_content); if($ga_content != '' && $all_words > 0) { // process allowed tags $allowed_tags = '<' . implode( '><', $allowed_tags ) . '>'; $ga_content = str_replace( ' ]]>', ' ]]>', $ga_content ); $ga_content = strip_tags( $ga_content, $allowed_tags ); // exclude HTML from counting words if( $all_words > count( preg_split( '/[\s]+/', strip_tags( $ga_content ), -1 ) ) ) return $ga_content; // count all $all_chunks = preg_split( '/([\s]+)/', $ga_content, -1, PREG_SPLIT_DELIM_CAPTURE ); $ga_content = ''; $count_words = 0; $enclosed_by_tag = false; foreach( $all_chunks as $chunk ) { // is tag opened? if( 0 < preg_match( '/<[^>]*$/s', $chunk ) ) $enclosed_by_tag = true; elseif( 0 < preg_match( '/>[^<]*$/s', $chunk ) ) $enclosed_by_tag = false; // get entire word if( !$enclosed_by_tag && '' != trim( $chunk ) && substr( $chunk, -1, 1 ) != '>' ) $count_words ++; $ga_content .= $chunk; if( $count_words >= $all_words && !$enclosed_by_tag ) break; } // native WordPress check for unclosed tags $ga_content = force_balance_tags( $ga_content ); } echo $ga_content; echo '<a href="'; echo $ga_permalink; echo '">Sigue leyendo →</a>'; //This means 'Keep reading' in spanish :) }
Thanks to Jedi Master S-Ha-Dum (see s_ha_dum above) and SofaRider for the code, as of me, I’m just an assembler.
JJ
Forum: Plugins
In reply to: Get page content with formatHello Jedi S-Ha-Dum; I’m having a hard time figuring out how to trim the output form this function to a specific number of words, let’s say 500, however I’ve made a modification to allow it to show the title with the corresponding permalink ??
function get_random_page($child_of=0) { $pages = &get_pages("child_of=".$child_of); $pageInd = rand(0, count($pages) - 1); $ga_title = apply_filters('the_title',$pages[$pageInd]->post_title); $ga_permalink = get_permalink($pages[$pageInd]); echo '<a href="'; echo $ga_permalink; echo '">'; echo $ga_title; echo '</a>'; echo apply_filters('the_content',$pages[$pageInd]->post_content); }
I’ve found a function from SofaRider, but it didn’t worked at all, or maybe I was just too dumb to make it work, anyway I’ll keep trying.
Have a great week and greetings from Mexico.
JJ
Forum: Plugins
In reply to: Get page content with formatThanks a lot s_ha_dum! You’re such a Jedi Master.
I used your contribution with an additional tweak to show also the title of the random page, the final code is as follows:
/** * Function: get_random_page() * Author: Jedi Master S-Ha-Dum & the Padawan Jorge Jaral. * Task: Outputs a random page along with its title. * Description: $child_of is the page ID (number) from which you want to select the * random page. If $child_of is not set then it'll pick a random page from * all your pages. * Usage: To make it work you should insert in your template the instruction: * <?php get_random_page(172); ?> * where 172 is the parent page ID from which you want to get its child pages * randomly to show inside a specific space, i.e. as a column on a static page. */ function get_random_page($child_of = 0) { $pages = &get_pages("child_of=".$child_of); $pageInd = rand(0, count($pages) - 1); echo apply_filters('the_title',$pages[$pageInd]->post_title); echo apply_filters('the_content',$pages[$pageInd]->post_content); }
I’m also trying to find out how to get only a specific number of words extending this function, if you can share a way to do it I will feel like a bully… but fine ??
Thanks for your immaculate help.
JJ
Forum: Fixing WordPress
In reply to: theme is showing full articles and not summary on front pageThis worked out incredibly fine, thanks!
Forum: Fixing WordPress
In reply to: How To Put Static Image in Twenty Eleven index.phpUse the ‘Featured Image’ option inside the page editor, you must ensure that its size fits the header (1000 x 288) and when setting it use the ‘Full Size’ option.
Hope this works.
JJ
Forum: Plugins
In reply to: [Header Image Slider] [Plugin: Header Image Slider] Does not show slides…Hi there shazdeh; I guess that you’ve been working hard on several things, I started to use your plugin and it works awesome, however there is still room for improvement.
In example, is there a way that you make the images clickable? I mean, to click them and redirect the user to a specific page, maybe a form to register or to make a requirement.
Also; I’d love to have the ability to select the slider to only work on the homepage.
I guess I’m exceeding my Santa Claus letter, but if you can make at least the first one you will gain a friend in Mexico ??
JJ