前几天帮朋友做WordPress,朋友用的是Polished主题,分别遇上了如下两个问题:
1、即使增加图片,首页的摘要也没有图片
2、摘要部分为“…”
首先来说说第一个的解决办法
进入外观——Polished theme options——general setting
找到Grab the first post image,改为this is enable即可【或者在文章时注意右下角的“特色图片”,手动添加特色图片也行,稍微麻烦点】
第二个我百思不得其解,在主题设置里翻了半天愣是没见,只能从代码上下手了
首先看到featured.php的代码,发现输出摘要部分是这样的:
<div class="slide"> <h1><?php echo $arr[$i]["title"]; ?></h1> <br class="clear" /> <?php print_thumbnail($arr[$i]["thumb"], $arr[$i]["use_timthumb"], $arr[$i]["fulltitle"] , $width, $height,'featured_img'); ?> <?php echo $arr[$i]["excerpt"];?> <span class="readmore_g"><a href="<?php echo $arr[$i]["permalink"]; ?>"> <?php _e('Read More','Polished') ?></a></span> </div> <?php }; ?> </div>
<?php echo $arr[$i]["excerpt"];?>
看到这句,然后往前翻
<?php $ids = array(); $arr = array(); $i=1; $width = 177; $height = 177; $width2 = 35; $height2 = 35; $featured_cat = get_option('polished_feat_cat'); $featured_num = get_option('polished_featured_num'); if (get_option('polished_use_pages') == 'false') query_posts("showposts=$featured_num&cat=".get_catId($featured_cat)); else { global $pages_number; if (get_option('polished_feat_pages') <> '') $featured_num = $pages_number - count(get_option('polished_feat_pages')); else $featured_num = $pages_number; query_posts(array ('post_type' => 'page', 'orderby' => 'menu_order', 'order' => 'ASC', 'post__not_in' => get_option('polished_feat_pages'), 'showposts' => $featured_num )); }; while (have_posts()) : the_post(); $arr[$i]["title"] = truncate_title(22,false); $arr[$i]["title2"] = truncate_title(25,false); $arr[$i]["fulltitle"] = truncate_title(250,false); $arr[$i]["excerpt"] = truncate_post(350,false);//注意这里,调用truncate_post函数 //$arr[$i]["excerpt"] = the_content(''); $arr[$i]["permalink"] = get_permalink(); $arr[$i]["postinfo"] = __("Posted by", "Polished")." ". get_the_author_meta('display_name') . __(' on ','Polished') . get_the_time(get_option('polished_date_format')); $arr[$i]["thumbnail"] = get_thumbnail($width,$height,'featured_img',$arr[$i]["fulltitle"]); $arr[$i]["thumb"] = $arr[$i]["thumbnail"]["thumb"]; $arr[$i]["use_timthumb"] = $arr[$i]["thumbnail"]["use_timthumb"]; $arr[$i]["thumbnail2"] = get_thumbnail($width2,$height2,'',$arr[$i]["fulltitle"]); $arr[$i]["thumb2"] = $arr[$i]["thumbnail2"]["thumb"]; $i++; $ids[]= $post->ID; endwhile; wp_reset_query(); ?>
然后又继续找,找到custom_functions.php,开头就是这个函数【放在这里难道是故意让人首先看到?】
function truncate_post($amount,$echo=true) { global $post; $truncate = $post->post_content; if ( strlen($truncate) <= $amount ) $echo_out = ''; else $echo_out = '...';//如果文章长度大于之前传进来的$amount(350字),则在文章后放上“...” $truncate = apply_filters('the_content', $truncate);//启用本函数进行过滤 $truncate = preg_replace('@<script[^>]*?>.*?</script>@si', '', $truncate);//将script无视(去掉) $truncate = preg_replace('@<style[^>]*?>.*?</style>@si', '', $truncate);//将style无视(去掉)【想的挺周全】 $truncate = strip_tags($truncate);//去除一些特殊标签 if ($echo_out == '...') $truncate = substr($truncate, 0, strrpos(substr($truncate, 0, $amount), ' '));//这句是重点,如果有输出“...”【意思是文章字数大于$amount】。则截取从开头到$amount[第350字]之间的最后一个空格【空格啊,注意是空格!】
else $truncate = substr($truncate, 0, $amount);//如果没有“...”则直接输出 if ($echo) echo $truncate,$echo_out;//如果要求回显【默认】,否则以字符串输出 else return ($truncate . $echo_out); }
问题就出在
if ($echo_out == '...') $truncate = substr($truncate, 0, strrpos(substr($truncate, 0, $amount), ' '));
里了,因为截取的是空格【西欧语言里不可能没有空格】,而中文字里不一定会有空格,所以就杯具了
中文字里不可能没有什么?逗号!,直接将这句改成:
if ($echo_out == '...') $truncate = substr($truncate, 0, strrpos(substr($truncate, 0, $amount), ','));
即可
done~
评论
沙发是我的 :gudu
毕扬 谢谢撒花
不过貌似没有显示出最新文章?
过来看看 看看楼主~!
很漂亮啊….大家也来我的小站看看吧!免费在线电影 保证你大饱眼福www.bvod.info
你好,很久没来这了!
看看这种类型的游戏。。。。
博主的文章写的不错!!~~
访问速度很快啊
打酱油的 闪啦
文章不错,占个位置先
请问博主,我所用的主题和你的情况是一样的,但是用了你的方法不奏效。只有减少博文字数,才不显示”…”。现在不知改哪里了,请赐教。
honeyfish 可能你用的是半角逗号呢
if ($echo_out == ‘…’) $truncate = substr($truncate, 0, strrpos(substr($truncate, 0, $amount), ‘,’));
这么改就好啦
aarwwefdds的最新文章:Polished主题,文章摘要只有“…”和预览图片无法显示的解决方案
aarwwefdds 嘿。。。好了,我开始的时候是在本地测试的,没反应,刚才在服务器上直接试,就OK了。谢谢!
再问博主,如何更改摘要的字数限制呢?
FOMATTING.PHP改了没用。
honeyfish 函数用法:truncate_post([限制字数],[回显true or false])
因为是按照逗号截取,所以实际截取摘要不一定符合传入函数的限制字数,而是等于0~限制字数之前的最后一个逗号
如果修改不成功,把代码贴一下
aarwwefdds的最新文章:Polished主题,文章摘要只有“…”和预览图片无法显示的解决方案
aarwwefdds 能MAIL我你的联系方式么?
honeyfish webmaster@本站域名
aarwwefdds的最新文章:Polished主题,文章摘要只有“…”和预览图片无法显示的解决方案
不错的文章哈,踩踩啦!祝博主永远快乐!
膜拜一下 非常感谢 正在找
非常实用!博客不错!
已给楼主的邮箱 webmaster@本站域名 发了求助邮件,等您回复!急!
对了,那个代码插件名字叫啥来着?
Zmsky 额?哪个?
解决了我大问题啊,我一直在折腾类似主题的这段代码,但一直看不怎么懂,竟然是按照空格截断..
Jackie 嗯~很荣幸~
很好很强大!
又是神马的代码。。。
刚好解决了我的问题,谢谢!!
有用到,非常感谢!
改成中文“,”的话,貌似英文文章的摘要又会变成…。能不能同时处理呢
ThWa 那就只能多加个判断了,先优先使用中文提取法,如果中文提取出来的是“…”。那么则采用英文提取法
This ends in a extra defined and sculpted physique, making it a preferred selection among bodybuilders and athletes seeking to bulk up while sustaining a
lean appearance. The androgenic activity of Trenbolone can result in hair loss on the top however increased hair growth on the face and physique.
With any Trenbolone steroid, it’s not out of the question to
gain as a lot as 20 kilos in a cycle, and this will be high quality lean mass.
Your chance of reaching that degree goes to be elevated if you
stack it with other powerful bulking steroids like Dianabol.
Equipoise and Dianabol, working alongside Parabolan and testosterone at replacement
stage dosage, will present one of the most
highly effective bulking combos attainable. Dianabol at 25mg
daily provides a potent cycle kickstart and is simply used for the primary
six weeks as it’s a fast-acting oral steroid.
Trenbolone may be very popularly (and perhaps infamously) generally
identified as being the anabolic steroid with ‘harsh’ unwanted effects and ‘harsher’ side effects than some other anabolic
steroid. There is a good amount of reality to this, but it additionally carries with it an excellent amount of myth,
exaggeration, and rumor as well, which might be coated
in-depth in this part of the profile. For a long time
ever since its inception, Trenbolone has all the time been viewed
upon as a mythic, mystic, scary, and frightening compound.
Certainly many people upon first studying Facts about Steroids Trenbolone become very frightened of
it and for good reason. However this is because the nature of Trenbolone and its properties and effects
have all the time been poorly understood, and in many cases among the anabolic steroid group it still
is. The truth of the matter is that there are other compounds that are quite literally
much more mystic and mysterious than Trenbolone, corresponding to Anadrol.
Once Trenbolone is nicely understood, it’s not the scary compound
once thought.
Females who choose to use Testosterone, Dianabol, or different potent androgenic steroids will
almost all the time be conscious of and even keen to tolerate this
side effect. Can there be a more apparent sign of female steroid use than the expansion of hair on the face and body?
Individuals will notice this quickly regardless of it starting slowly (depending on which steroid, your dose,
and how lengthy you use it). While you can use
topical androgen blockers to attempt to stop hair development, it goes to be a case of dropping
the PED dosage or stopping use completely for most women. Any
situation the place you’re growing body/facial hair
is one the place your dosage is simply too high, and the best repair
is the apparent one mentioned above.
Trenbolone’s results on efficiency and physique are why all of us wish to use this incredible AAS and why it has legendary standing as the most effective steroid in the minds of so many
people. Sure, with such highly effective positive results can come some equally potent unwanted aspect effects,
but I’ll get to those later. In contrast, the most acquainted ester of Trenbolone Acetate is a veterinary product to be used in livestock
in the US to help within the growth of more muscle mass within the months earlier
than they are slaughtered. Because of the widespread use of
Trenbolone Acetate within the beef cattle industry,
it’s a steroid that is not troublesome to come by.
The PCT program should be continued until your ranges have normalized
and sperm manufacturing has resumed. These options may give you
extraordinarily similar outcomes (the good ones),
to Trenbolone itself, whereas avoiding the horrible effects Tren is notorious for.
THE #1 different to Trenbolone availible at present, is
undoubtedly TBULK.
Whether you’re a professional bodybuilder or a novice fitness fanatic, injecting the steroid slowly into the body is necessary.
From low to excessive concentrations, Trenbolone is out there in quite a lot of choices, however you must begin with a low concentrated vial to see your body’s reaction to the drug.
Also, ensure you select Trenbolone acetate that isn’t filled with benzyl alcohol
as a outcome of it’s more likely to set off the Tren cough.
That is to say, if Trenbolone doesn’t hit a
blood vessel, your body will absorb it by way of the
muscles and spread across evenly. Later within the Nineties, a French pharmaceutical company released
Trenbolone for people to treat muscle wasting, osteoporosis, and AIDS.
Quickly after, this version was discontinued in 1997 because of
the unwanted effects folks skilled after injecting it into their our bodies.
Some customers discover it increases their urge for food,
whereas others discover Anadrol does kill the urge for food.
These can embrace chest pain, shortness of breath,
fatigue, and dizziness. To handle androgenic results attributable to
Trenbolone use, people should search medical advice.
Healthcare providers can present suggestions for managing these unwanted facet effects and may suggest changes to the dosage or frequency of Trenbolone use.
In some instances, healthcare suppliers may also recommend various therapies for managing androgenic effects.
The Drug Enforcement Company (DEA) explains that anabolic steroids are Schedule III substances underneath the Controlled
Substances Act. A 2010 medical evaluation examined the adverse well
being results of anabolic steroid use. We conclude
from the available analysis that tren is likely to be effective for rising muscle mass, growing
muscle measurement, and enhancing energy and strength.
Sure, Anadrole is formulated to be a one hundred pc secure and pure formulation that doesn’t pose any
danger to the liver, kidneys, ldl cholesterol, or another aspects of your health.
It can do this as a outcome of Anadrole contains
no hormones or chemical compounds – solely naturally occurring amino acids, proteins, and extracts.
Anadrol will suppress your testosterone strongly,
so PCT is required after utilizing it to restore testosterone manufacturing quicker and avoid low testosterone
signs. Signs that you may need low testosterone on account of
this suppression include lack of muscle,
fat gain, lethargy, depression, and low libido.
Water retention is the most infamous physical facet effect of Anadrol.
You can cut back this by eating a low-sodium food plan and consuming much water.
This exhibits us how cautious we should be when injecting, ensuring no veins or arteries
are impacted. The lack of PCT requirement for females is one benefit ladies have over
men in relation to steroid use. Are you feminine and have NEVER used a single anabolic steroid in your life?
And when you won’t “turn into a man,” 99.9%
of females WILL want to avoid any masculinity… and especially
irreversible effects.
Facts about Steroids的最新文章:Facts about Steroids
Deca-Durabolin has a half-life of days because of the
slower-acting decanoate ester connected to the Nandrolone hormone.
However, it has a protracted detection time, as much as
18 months after your last dose. Deca-Durabolin is an intramuscular injection, and the best place to
manage it is among the massive muscular tissues. The thigh and buttocks are probably
the most recommended injection websites, and you must rotate your injection muscular tissues to
allow recovery. Keep Away From injecting
Deca-Durabolin into small muscular tissues and areas with arteries.
The injection site ought to be swapped with an alcohol wipe to wash before injecting to maintain hygiene and prevent
infection. For recovery (PCT), use zero.5mg/day Arimidex for 4
weeks post-last injection.
Known as the compound you should run for at least 10 weeks earlier
than the results actually become noticeable. EQ was initially used predominantly for
horses, and that’s why you;ll typically hear people check with
it as the Veterinary Steroid. EQ is also typically described as a “dryer” Deca Durabolin, and
that isn’t exactly 100% true. The massive determining factors are
still going to be genetics, coaching, and naturally food plan.
Regardless, apply good well being by taking excellent care of your well
being markers and organs while dabbling in EQ. Count On great strength and muscle
features, libido boost, large restoration boost, and only a common feeling of greatness.
In terms of pure muscle tissue being constructed, trenbolone can rival any bulking
steroid.
We find that high estrogen increases your sensitivity to sodium; thus, if
a person’s sodium consumption is average and they take Anadrol, they’ll retain extra water.
Anadrol may even raise blood pressure because of it considerably increasing
red blood cell count. We have seen Anadrol customers experience up to 5x the number of pink blood cells compared to a standard person (13).
The purpose why Anadrol might seem to trigger fats achieve is due to water retention.
He has been a board-certified MD since 2005 and provides steerage on harm reduction methodologies.
Superdrol is potentially the most effective steroid for energy; however, its unwanted effects are also harsh.
Our patients often use a liver support complement, SERM, and a powerful
PCT for hurt reduction on Superdrol. Primobolan is usually stacked with other
compounds for enhanced outcomes, such as trenbolone or halotestin (when cutting).
The Bulking Stack from CrazyBulk is an efficient way to placed on dimension and strength.
Anvarol which utterly replaces Anavar – permits you to get
the same advantages as Anavar without any of the unwanted effects.
It also helps with sexual performance as a end result of it increases libido and intercourse drive.
While I’m not saying you want to devour an entire bag of Doritos
or a bath of ice cream, a small portion of junk meals each day won’t hurt.
The best bulking stack for bulking for will combine Testosterone Enanthate and Dianabol as follows .
Males should take mg per day, while women should lower that proper back to 10mg per
day.
Over the years, they’ve provide you with a counterpart for every type of anabolic steroid
utilized by bodybuilders. In truth, they’ve authorized alternatives for the most effective steroids for cutting,
bulking, and strength. It works by bettering your urge for food and rising the manufacturing
of your purple blood cells. Coupled with correct vitamin, it
helps you achieve huge muscles and wonderful energy. Therefore, users will retain the
overwhelming majority of muscle they gain from steroids (if they continue to carry weights and train).
If users stop lifting weights and experience muscle atrophy,
ought to they resume coaching sooner or later, the physique will restore the earlier muscle dimension in a matter of weeks.
Anadrol (oxymetholone) is potentially equal to Dianabol
in terms of muscle mass and weight gain, in our expertise.
Whether you’re leaning out for summer or prepping for a photoshoot or event, WinMax gives
you the instruments to chop fats with out compromising efficiency.
It’s particularly in style with athletes, fighters, and bodybuilders who want to remain fast, lean, and explosive with out
including dimension. For best outcomes, Trenorol is usually stacked with Clenbutrol (for fats burning) or Winsol (for definition)
in cutting phases.
Throughout the cycle (or at least on hand), it’s good to take an aromatase inhibitor (AI) like Arimidex at 0.5mg/eod or 12.5mg/day Aromasin. Finest of all, though, you aren’t
going to have to watch as your hard-won features disappear alongside that fats
the method in which you might have with different cut approaches.
Best of all, you’ll be ready to get all of those efficiency enhancements without ever throwing your
short or long-term health a curveball. Some stacks (like those I go over in just a second) are
going to get you as near reliable steroid performance because it will get without truly running gear.
Optionally, you would contemplate adding an oral AAS like Dianabol for the
primary few weeks to kick things off quicker.
Have you discovered yourself questioning whether
or not you could be higher off utilizing a special anabolic steroid to
Testosterone Cypionate? We know testosterone is the safest and most well-tolerated AAS for males.
Nonetheless, I’d be mendacity if I stated there aren’t
other AAS that can be better suited to extra specific goals –
like extra excessive bulking or cutting, for example. A Testosterone Cypionate solely cycle is the most effective
place to start out for a newbie.
Bulking Stack from CrazyBulk is a secure alternative to steroids that incorporates natural components.
All-natural ingredients with no adverse unwanted facet effects make the bulking
stack a great choice for any bodybuilder. Just just like the unlawful steroids, DecaDuro
helps your physique to add more protein to your muscle tissue.
For maximum bulking gains, you can take a couple of of those steroids on the identical time in a stack.
Trenbolone is hailed by some as the best steroid ever created.
This is as a result of it produces big muscle positive aspects;
with none water retention.
References:
steroids for fat loss and muscle Gain (jbhnews.Com)
jbhnews.Com的最新文章:jbhnews.Com