<center>https://www.perun.net/wp-content/uploads/2015/02/wordpress-code.png</center> <br/><a href="http://codex.wordpress.org/Custom_Fields">Benutzerdefinierte Felder</a> gehören zum Funktionsumfang von WordPress, wenn ich es richtig in Erinnerung habe, seit mehr als zehn Jahren. Auf jeden Fall waren Sie für mich immer dabei. :-) Sie stellen eine sehr interessante Funktion dar, die in meinen Augen viel zu wenig beachtet wird. Ich hoffe, dass ich sie mit diesem Artikel noch ein bisschen mehr ins Rampenlicht bringen kann. Mit benutzerdefinierten Feldern kann man nämlich zusätzliche Informationen zum eigentlichen Inhalt darstellen. <img src="https://www.perun.net/wp-content/uploads/2015/02/wordpress-benutzerdefiniertes-feld.png" alt="WordPress: benutzerdefiniertes Feld" width="686" height="349" class="alignnone size-full wp-image-7982" /><br/> Im Admin-Bereich findet man die Eingabemaske für benutzerdefinierte Felder unterhalb der Textbox wo man den Inhalt für Beiträge und Seiten eingibt. Ist diese Eingabemaske nicht sichtbar, dann muss man sie gegebenenfalls rechts oben unter "Optionen" sichtbar machen. <img src="https://ssl-vg03.met.vgwort.de/na/6db5c199ec3d45a7b6a2e676ae44ec29" width="1" height="1" alt="" /><br/> Im Theme, ich lasse mal jetzt die diversen Plugins außen vor, macht man die benutzerdefinierte Felder sichtbar mit dem folgendem Code: <pre class="quelltext"><code><?php the_meta(); ?></code></pre> So weit, so gut. Leider funktioniert das ganze nur innerhalb <a href="http://codex.wordpress.org/The_Loop">des Loops</a> oder besser gesagt im Inhaltsbereich, also nicht zum Beispiel im Footer, in der Kopfzeile oder in der Sidebar. Möchte man den Inhalt der benutzerdefinierten Felder auch außerhalb des Loops, dann muss man sich mit dem folgenden Code behelfen: <pre class="quelltext"><code><?php global $wp_query; $postid = $wp_query->post->ID; echo get_post_meta($postid, 'Zusatztitel', true); wp_reset_query(); ?></code></pre> Wen es nicht stört, dass bei Beiträgen und Seiten ohne Inhalte aus den benutzerdefinierten Feldern nichts erscheint, der kann diesen Code-Schnipsel nutzen. Wer aber nicht bei jedem Beitrag oder Seite benutzerdefinierte Felder einsetzt, aber an der entsprechenden Stelle doch einen Text haben möchte, der baut eine zusätzliche "Abfrage" in Form von einem <code>if</code>-<code>else</code>-Statement auf: <pre class="quelltext"><code><?php global $wp_query; $postid = $wp_query->post->ID; if (get_post_meta($postid, 'Zusatztitel', true)) { echo get_post_meta($postid, 'Zusatztitel', true); } else { echo "Ersatztext"; } wp_reset_query(); ?></code></pre> Was macht das Code-Fragment? Ist ein bestimmtes benutzerdefiniertes Feld samt Inhalt vorhanden, dann wird dieses ausgegeben. Falls nicht, dann wird der Ersatztext eingeblendet. <hr /> <p>Aus <a href="https://www.perun.net/2015/02/25/wordpress-benutzerdefinierte-felder-ausserhalb-loops/">meinem Weblog</a> via <a href="https://wordpress.org/plugins/steempress/">SteemPress</a> publiziert.</p>
post_id | 68,596,727 | ||||||
---|---|---|---|---|---|---|---|
author | vladimir-simovic | ||||||
permlink | wordpressbenutzerdefiniertefelderauerhalbloops-u283ij2h2f | ||||||
category | steempress | ||||||
json_metadata | {"original_link":"https:\/\/www.perun.net\/2015\/02\/25\/wordpress-benutzerdefinierte-felder-ausserhalb-loops\/","tags":["steempress","deutsch","wordpress","wordpress-tipps"],"community":"steempress","app":"steempress\/1.4"} | ||||||
created | 2019-01-09 15:25:48 | ||||||
last_update | 2019-01-09 15:25:48 | ||||||
depth | 0 | ||||||
children | 3 | ||||||
net_rshares | 3,631,367,140,301 | ||||||
last_payout | 2019-01-16 15:25:48 | ||||||
cashout_time | 1969-12-31 23:59:59 | ||||||
total_payout_value | 1.216 SBD | ||||||
curator_payout_value | 0.440 SBD | ||||||
pending_payout_value | 0.000 SBD | ||||||
promoted | 0.000 SBD | ||||||
body_length | 3,100 | ||||||
author_reputation | 56,522,611,888,290 | ||||||
root_title | "WordPress: benutzerdefinierte Felder außerhalb Loops" | ||||||
beneficiaries |
| ||||||
max_accepted_payout | 1,000,000.000 SBD | ||||||
percent_steem_dollars | 0 | ||||||
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
team | 0 | 80,653,961,897 | 10% | ||
steempress | 0 | 15,002,903,018 | 3.5% | ||
shaka | 0 | 973,757,020,180 | 20% | ||
germansailor | 0 | 104,210,278,934 | 100% | ||
phusionphil | 0 | 130,457,909 | 1.9% | ||
saamychristen | 0 | 6,886,770,470 | 80% | ||
deutschbot | 0 | 164,534,509,643 | 90.79% | ||
eforucom | 0 | 20,974,453,040 | 1% | ||
vannour | 0 | 3,688,629,018 | 5% | ||
steemcultures | 0 | 100,738,062 | 5% | ||
steemworld | 0 | 349,815,186 | 5% | ||
schamangerbert | 0 | 115,211,513,412 | 25% | ||
sodom | 0 | 511,932,396 | 100% | ||
eisenbart | 0 | 32,980,443,952 | 100% | ||
ralph-rennoldson | 0 | 576,640,123 | 0.25% | ||
urukai | 0 | 6,689,888,754 | 100% | ||
gammastern | 0 | 21,024,625,949 | 100% | ||
vladimir-simovic | 0 | 138,034,174,293 | 100% | ||
alexs1320 | 0 | 87,021,219,518 | 100% | ||
jegede | 0 | 403,835,486 | 100% | ||
scienceangel | 0 | 71,833,472,619 | 100% | ||
rilc0n | 0 | 123,425,208 | 20% | ||
snackaholic | 0 | 5,585,653,285 | 80% | ||
endurance1968 | 0 | 941,784,175 | 100% | ||
thedende | 0 | 1,905,788,388 | 100% | ||
satren | 0 | 42,676,923,684 | 25% | ||
sep91seb | 0 | 137,300,526 | 31% | ||
mwfiae | 0 | 42,368,547,431 | 100% | ||
rivalzzz | 0 | 40,682,274,972 | 50% | ||
fr4mer | 0 | 552,685,476 | 100% | ||
fsherberg | 0 | 555,682,158 | 100% | ||
yu-stem | 0 | 33,090,333,037 | 100% | ||
big-m | 0 | 402,525,903 | 10% | ||
misan | 0 | 3,560,558,845 | 13% | ||
chuuuckie | 0 | 4,510,352,642 | 5% | ||
steempress-io | 0 | 1,394,671,836,408 | 3.5% | ||
jensvoigt | 0 | 13,153,009,206 | 50% | ||
finanzamt | 0 | 78,303,348 | 5.9% | ||
yaraha | 0 | 3,484,979,722 | 25% | ||
lilbastard | 0 | 30,686,772,221 | 100% | ||
xers | 0 | 89,903,762 | 20% | ||
followmikecee | 0 | 3,637,748,024 | 35% | ||
extropia | 0 | 161,663,155 | 50% | ||
altobot | 0 | 2,508,636,217 | 50% | ||
tiblog | 0 | 27,749,560,482 | 100% | ||
johnfogel | 0 | 511,528,852 | 100% | ||
ivanslonov | 0 | 512,063,280 | 100% | ||
albinasamirova | 0 | 511,414,165 | 100% | ||
nilus | 0 | 130,151,370 | 42.5% | ||
cvltrvm | 0 | 162,078,310 | 50% | ||
helmimemes | 0 | 506,459,860 | 100% | ||
spero2711 | 0 | 79,747,366 | 25% | ||
artyr.kalmetov | 0 | 511,763,165 | 100% | ||
steemchoose | 0 | 12,239,717,943 | 0.56% | ||
changjia | 0 | 667,031,534 | 10.81% | ||
steem-ua | 0 | 114,907,245,701 | 1.07% | ||
steemexpress | 0 | 840,314,187 | 1.64% | ||
altofit | 0 | 352,029,057 | 25% | ||
flodor | 0 | 706,589,939 | 25% | ||
sternekoechin | 0 | 250,116,834 | 25% | ||
paolatorrealba77 | 0 | 72,738,667 | 100% | ||
dinhanhuy | 0 | 512,617,937 | 100% |
Hi I found that this is a really good post, So I give you one upvote! Please upvote for me if you can
post_id | 68,596,806 |
---|---|
author | dinhanhuy |
permlink | re-vladimir-simovic-wordpressbenutzerdefiniertefelderauerhalbloops-u283ij2h2f-20190109t152713331z |
category | steempress |
json_metadata | {"tags":["steempress"],"app":"steemit\/0.1"} |
created | 2019-01-09 15:27:18 |
last_update | 2019-01-09 15:27:18 |
depth | 1 |
children | 0 |
net_rshares | 0 |
last_payout | 2019-01-16 15:27:18 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 SBD |
curator_payout_value | 0.000 SBD |
pending_payout_value | 0.000 SBD |
promoted | 0.000 SBD |
body_length | 102 |
author_reputation | 4,786,300,923 |
root_title | "WordPress: benutzerdefinierte Felder außerhalb Loops" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 SBD |
percent_steem_dollars | 10,000 |
Hey, Du wurdest von @altobot gevotet!
post_id | 68,597,450 |
---|---|
author | altobot |
permlink | re-wordpressbenutzerdefiniertefelderauerhalbloops-u283ij2h2f-20190109t154049z |
category | steempress |
json_metadata | {"app":"beem\/0.20.14"} |
created | 2019-01-09 15:40:51 |
last_update | 2019-01-09 15:40:51 |
depth | 1 |
children | 0 |
net_rshares | 15,037,109,235 |
last_payout | 2019-01-16 15:40:51 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 SBD |
curator_payout_value | 0.000 SBD |
pending_payout_value | 0.000 SBD |
promoted | 0.000 SBD |
body_length | 38 |
author_reputation | 7,566,392,895,503 |
root_title | "WordPress: benutzerdefinierte Felder außerhalb Loops" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 SBD |
percent_steem_dollars | 10,000 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
vladimir-simovic | 0 | 15,037,109,235 | 11% |
#### Hi @vladimir-simovic! Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation! Your **UA** account score is currently 4.080 which ranks you at **#3357** across all Steem accounts. Your rank has improved 3 places in the last three days (old rank 3360). In our last Algorithmic Curation Round, consisting of 233 contributions, your post is ranked at **#205**. ##### Evaluation of your UA score: * Some people are already following you, keep going! * The readers like your work! * Try to work on user engagement: the more people that interact with you via the comments, the higher your UA score! **Feel free to join our [@steem-ua Discord server](https://discord.gg/KpBNYGz)**
post_id | 68,620,314 |
---|---|
author | steem-ua |
permlink | re-wordpressbenutzerdefiniertefelderauerhalbloops-u283ij2h2f-20190110t035916z |
category | steempress |
json_metadata | {"app":"beem\/0.20.14"} |
created | 2019-01-10 03:59:18 |
last_update | 2019-01-10 03:59:18 |
depth | 1 |
children | 0 |
net_rshares | 0 |
last_payout | 2019-01-17 03:59:18 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 SBD |
curator_payout_value | 0.000 SBD |
pending_payout_value | 0.000 SBD |
promoted | 0.000 SBD |
body_length | 729 |
author_reputation | 23,203,609,903,979 |
root_title | "WordPress: benutzerdefinierte Felder außerhalb Loops" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 SBD |
percent_steem_dollars | 10,000 |