Skip to content

Commit

Permalink
Show resource pages if description is present, otherwise redirect to …
Browse files Browse the repository at this point in the history
…them.
  • Loading branch information
stefanbohacek committed Mar 12, 2023
1 parent 2dead41 commit 5ea2404
Showing 1 changed file with 17 additions and 24 deletions.
41 changes: 17 additions & 24 deletions includes/shortcodes/post-links.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@ public function post_link_shortcode( $atts ) {
if ( get_post_status( $post_id ) === 'publish' ){
$link_classes = $atts['class'];

$link_url = get_post_meta( $post_id, 'resource_url', true );

if ( empty( $link_url ) ){
$link_url = post_permalink( $post_id );
}
else{
if (empty(get_the_content($post_id))){
$is_external = true;
$link_url = get_post_meta( $post_id, 'resource_url', true );
} else {
$link_url = post_permalink( $post_id );
}

$link_title = get_the_title( $post_id );
Expand Down Expand Up @@ -50,13 +48,12 @@ public function btn_list_shortcode( $atts ) {
$link_list_html = '<ul class="btn-list mb-4">';

foreach ( $post_ids as $post_id ){
$link_url = get_post_meta( $post_id, 'resource_url', true );

if ( empty( $link_url ) ){
$link_url = post_permalink( $post_id );
}
else{
if (empty(get_the_content($post_id))){
$is_external = true;
$link_url = get_post_meta( $post_id, 'resource_url', true );
} else {
$link_url = post_permalink( $post_id );
}

$link_title = get_the_title( $post_id );
Expand All @@ -83,14 +80,11 @@ public function link_list_shortcode( $atts ) {

foreach ($post_ids as $post_id) {
if ( get_post_status( $post_id ) === 'publish' ){
$is_external = false;
$link_url = get_post_meta( $post_id, 'resource_url', true );

if ( empty( $link_url ) ){
$link_url = post_permalink( $post_id );
}
else{
if (empty(get_the_content($post_id))){
$is_external = true;
$link_url = get_post_meta( $post_id, 'resource_url', true );
} else {
$link_url = post_permalink( $post_id );
}

$link_title = get_the_title( $post_id );
Expand Down Expand Up @@ -187,13 +181,12 @@ public function link_cards_shortcode( $atts ) {

foreach ($post_ids as $post_id) {
if ( get_post_status( $post_id ) === 'publish' ){
$link_url = post_permalink( $post_id );

// $link_url = get_post_meta( $post_id, 'resource_url', true );

// if ( empty( $link_url ) ){
// $link_url = post_permalink( $post_id );
// }
if (empty(get_the_content($post_id))){
$link_url = get_post_meta( $post_id, 'resource_url', true );
} else {
$link_url = post_permalink( $post_id );
}

$link_title = get_post_meta( $post_id, 'card_title', true );
if ( empty( $link_title ) ){
Expand Down

0 comments on commit 5ea2404

Please sign in to comment.