Addaswch Eich Porthiant WordPress Gyda Delwedd Sylw a Datganiad Hawlfraint (Cynnwys Cyn a Post)
Un peth diddorol am WordPress est que le delwedd dan sylw erioed wedi ei ymgorffori yn y RSS ymborth. Mae hyn braidd yn anffodus, oherwydd gall dewis neu ddylunio'r ddelwedd dan sylw dynnu llawer o sylw at erthygl.
Prepend Cynnwys At Y Postiadau Yn Eich RSS Feed
Nid yw paratoi'r ddelwedd dan sylw i'ch cynnwys yn rhy anodd. Dyma'r cod a ychwanegais at fy WordPress functions.php
yn fy Thema plentyn file:
function prerssfeedcontent($content) {
global $post;
$current_year = date('Y');
$post_title = get_the_title( $post->ID );
$post_link = get_permalink( $post->ID );
$post_image = get_the_post_thumbnail( $post->ID, 'medium' );
// Add the featured image
if ( has_post_thumbnail( $post->ID ) ) {
$precontent = '<p class="thumb">';
$precontent .= '<a href="' .$post_link. '" title="' .$post_title. '">';
$precontent .= $post_image;
$precontent .= '</a></p>';
}
$content = $precontent . $content;
return $content;
}
add_filter('the_excerpt_rss', 'prerssfeedcontent');
add_filter('the_content_feed', 'prerssfeedcontent');
Yn ogystal, rwyf hefyd am ychwanegu cynnwys ar ddiwedd fy mhyst bwydo.
Atodi Cynnwys I'r Postiadau Yn Eich Porthiant RSS
Gan fy mod yn adolygu backlinks i Martech Zone, Rwy'n aml yn gweld bod yna wefannau sy'n dwyn fy nghynnwys ac yn ei gyhoeddi fel eu rhai eu hunain ar eu gwefan. Mae'n helfa ddiddiwedd ac yn gwaethygu. Mae digon o weithiau y gallaf eu holrhain; adegau eraill, gallaf eu riportio i'w rhwydweithiau hysbysebu a'u darparwyr cynnal. Ond yn aml, maent yn ddienw i raddau helaeth ac yn anodd eu holrhain … os o gwbl.
O ganlyniad, fy unig ddewis yw addasu fy mhorthiant a chynnwys datganiad hawlfraint fel y gall ymwelwyr safle heb awdurdod weld y ffynhonnell. I wneud hyn, fe ddiweddarais y swyddogaeth uchod i ragbaratoi ac atodi'r wybodaeth roeddwn i ei heisiau.
function prepostrssfeedcontent($content) {
global $post;
$current_year = date('Y');
$post_title = get_the_title( $post->ID );
$post_link = get_permalink( $post->ID );
$post_image = get_the_post_thumbnail( $post->ID, 'medium' );
$company_title = "DK New Media, LLC";
$company_link = "https://martech.zone/partner/dknewmedia/";
// Add the featured image
if ( has_post_thumbnail( $post->ID ) ) {
$precontent = '<p class="thumb">';
$precontent .= '<a href="' .$post_link. '" title="' .$post_title. '">';
$precontent .= $post_image;
$precontent .= '</a></p>';
}
// Add the copyright
$postcontent = '<p>©';
$postcontent .= $current_year;
$postcontent .= ' <a href="'.$company_link.'">'.$company_title.'</a>, All rights reserved.</p>';
$postcontent .= '<p>Originally Published on Martech Zone: <a href="'.$post_link.'">'.$post_title.'</a></p>';
$content = $precontent . $content . $postcontent;
return $content;
}
add_filter('the_excerpt_rss', 'prepostrssfeedcontent');
add_filter('the_content_feed', 'prepostrssfeedcontent');
Gallwch weld y canlyniad ar fy mhorthiant ... mae'r ddelwedd dan sylw yn cael ei harddangos yn ogystal â'r hawlfraint a'r dolenni ffynhonnell wreiddiol ar ddiwedd pob post.