Skip to content

Commit 62551f4

Browse files
authored
Add shortcode readmore_text and hide_subtitle
Now wordpress user could use shortcode to control `readmore_text` and `hide_subtitle`. e.g. [display_medium_posts handle="morpheus-network" readmore_text=">Read More" hide_subtitle=true]
1 parent 929079c commit 62551f4

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

display-medium-posts.php

+10-5
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ function run_display_medium_posts()
7878
function posts_display($atts)
7979
{
8080
ob_start();
81-
$a = shortcode_atts(array('handle' => '-1', 'default_image' => '//i.imgur.com/p4juyuT.png', 'display' => 3, 'offset' => 0, 'total' => 10, 'list' => false, 'title_tag' => 'p', 'date_format' => 'M d, Y'), $atts);
81+
$a = shortcode_atts(array('handle' => '-1', 'default_image' => '//i.imgur.com/p4juyuT.png', 'display' => 3, 'offset' => 0, 'total' => 10, 'list' => false, 'title_tag' => 'p', 'date_format' => 'M d, Y', 'readmore_text' => 'Read More', 'hide_subtitle' => false), $atts);
8282
// No ID value
8383
if (strcmp($a['handle'], '-1') == 0) {
8484
return "";
@@ -91,7 +91,8 @@ function posts_display($atts)
9191
$list = $a['list'] == 'false' ? false : $a['list'];
9292
$title_tag = $a['title_tag'];
9393
$date_format = $a['date_format'];
94-
94+
$readmore_text = $a['readmore_text'];
95+
$hide_subtitle = $a['hide_subtitle'] == 'false' ? false : $a['hide_subtitle'];
9596
$content = null;
9697

9798
$medium_url = "https://api.rss2json.com/v1/api.json?rss_url=https://medium.com/feed/" . $handle;
@@ -173,12 +174,16 @@ function posts_display($atts)
173174
?>
174175
<<?php echo $title_tag; ?> class="display-medium-title details-title"><?php echo $item['title']; ?></<?php echo $title_tag; ?>>
175176
</a>
176-
<p class="display-medium-subtitle">
177-
<?php echo $item['subtitle']; ?>
177+
<?php
178+
if ($hide_subtitle == false){
179+
echo "<p class='display-medium-subtitle'>" . $item['subtitle'] . "</p>";
180+
} else {
181+
}
182+
?>
178183
</p>
179184
<p class="display-medium-date-read">
180185
<?php echo "<span class='display-medium-date'>" . $item['date'] . "</span>"; ?> /
181-
<a href="<?php echo $item['url']; ?>" target="_blank" class="text-right display-medium-readmore">Read More</a>
186+
<a href="<?php echo $item['url']; ?>" target="_blank" class="text-right display-medium-readmore"><?php echo $readmore_text?></a>
182187
</p>
183188
</div>
184189

0 commit comments

Comments
 (0)