Articles of conditional content

Force Log in to view a page

So I have a page (ex. site.com/start) where I want to show a login page (ex. site.com/start/login) if not logged in, in order to view the page. Without using any plugin, what would be the condition logic which if user visits /start page, while they are not not logged in, then the user is redirected […]

Check if sidebar is rendered?

I want to check if there are sidebars rendered on the front end and if so output some body classes so I can style the page differently. I tried using is_active_sidebar but that just returns true if the sidebar contains some widget (is active) – I want to check if it exists on the page. […]

How to make a conditional statement within $output in shortcodes.php?

I’ve got a shortcode that’s got HTML in an $output field that’s lovely. I just want to add one paragraph to it at the bottom that’s conditional on this statement: <?php if ( get_post_meta( get_the_ID(), ‘campus’, true ) ) : ?> I can’t quite figure out how to format a statement like that (if possible) […]

do_action in conditional

I’m using the “inbox-status” plugin. I can use this to display unread emails. <?php do_action( ‘inbox_status_count’, ‘inbox-unread’ ); ?> I want to use this code in a conditional. Only the number of emails shown if more than one. if ( 0 < did_action( ‘inbox_status_count’, ‘inbox-unread’ ) ) echo “<span class=’new badge’>”; echo do_action( ‘inbox_status_count’, ‘inbox-unread’ […]

Conditional featured image with youtube thumbnail

Basically what I am trying to do here is: Display the youtube thumbnail. If no youtube thumbnail -> Display the Featured image for the post. If no featured image -> Display the fallback image. However it seems I am doing something wrong because the webpage displays blank. <?php // Check if the post has a […]

Condition within single.php to send an email to the post author

I have this piece of code (below) that checks if the post was modified within the past 7 days. I’d like another piece of code that I can insert where “Needs Updating” is that will send a basic email to the post author that says “Someone was looking at your post and wants it updated” […]

Home Page Template – Specific Category

I cannot find a specific solution to my situation. I’m sure this is an easy one though. I have my homepage set to display posts. How can I narrow the posts to a single category? I’ve looked elsewhere without much luck figuring it out as the homepage is using post_formats. Thank you!

If user is logged in and has a role echo statement

I currently have a dive set up which I would like to display different bits of information when the user is logged in and has a specific role. I have three roles ‘administrator’ ‘adoption-agency’ and ‘shop-manager’ which I would like to display a link to the admin area. Then I have a role named ‘customer’ […]

How can I use 'edit_form_after_title' conditionally?

I’m using it to add a message to posts/pages/cpts, but it’s also appearing on one screen of a plugin – so I need to remove it. I have the screenID, but my knowledge-lacking efforts to add a conditional between the opening brace and echo in the code below produce a variety of errors. add_action( ‘edit_form_after_title’, […]

Multidimensional Array

I have an array in my wordpress template where i want to then target a specific status of the logged in user. Below is what i currently have with the $args containing a status with all the status values stored. $user_id = get_current_user_id(); $args = array( ‘status’ => array( ‘wcm-active’, ‘wcm-delayed’, ‘wcm-complimentary’, ‘wcm-pending’, ‘wcm-paused’, ‘wcm-expired’, […]