Merhaba wordpresste bir eklenti kullanıyorum. Bu eklenti ile herhangi bir etikete ait yazıları kısa kod ile yazı içerisinde listeleyebiliyorum. Listeleme en son eklenenler ilk sırada çıkacak şekilde yapılmış. Ben bunu en son eklenenler ilk sırada çıkacak listelemeye ek olarak alfabetik olarak listeleme ve ilk eklenenler ilk sırada çıkacak şekilde getirmek istiyorum. Yani 3 farklı listeleme şekli olacak. Bunu nasıl yapabilirim? Eklenti kodları aşağıdaki gibidir.
add_action('the_content', 'shortCodeEasyFilter');
function shortCodeEasyFilter($content) {
if (is_single()) {
$finds = getInbetweenStrings($content);
if (count($finds) > 0) {
$content = "<style>
.shortlink {
margin: 4px;
font-size: 18px;
background-image: linear-gradient(to top,#0c6fb1,#0c6fb1);
color: #FFFFFF !important;
padding: 8px;
border-radius: 8px;
position: relative;
display: block;
margin-bottom: 0px;
}
.shortlink:hover {
color: #FFFFFF !important;
opacity: 0.8;
text-decoration: none
}
.shortlink * {
display: inline;
}
.shortlink h3 {
color: #FFFFFF;
margin: 0;
}
.shortlink a {
color: #FFFFFF;
margin: 0
}
</style>".$content;
}
foreach($finds as $code) {
foreach(explode(",", $code) as $codepart) {
$output = '';
query_posts(array(
"post_status" => "publish",
"tag_id" => $codepart
));
while(have_posts()) {
the_post();
$title = get_the_title();
$link = get_the_permalink();
$output .= "<h3 style='margin-bottom: 5px'><a class='shortlink' href='$link' title='$title'><i class='fas fa-long-arrow-alt-right'></i> $title</a></h3>";
}
wp_reset_query();
$content = str_replace("[etikonu]".$code."[/etikonu]", $output, $content);
}
}
}
return $content;
}
function getInbetweenStrings($str){
preg_match_all('%\[etiketlist\](.*?)\[/etiketlist\]%i', $str, $matches, PREG_PATTERN_ORDER);
return $matches[1];
}
?>