• The Cobalt Apps Community Forum is for community interaction and assistance, but is not our official Cobalt Apps Product Support solution. If you need Cobalt Apps Product Support please contact our support team through the contact form found at the bottom of your "My Account" page.

The is_home and is_first_page conditionals not working

dev77

New Member
#1
re: https://k6anc.com/wpnhrc

I've been using DWB for many years now.

I want to write some code for homepage only, which is an EZ wigitized page construct.

For the life of me I can't get either of the WP conditionals to work:

if (is_home() {
echo "This should print at top!";
}

Same with is_first_page().

I tried with a wp_reset_query() and still it does not work.

I tried is_home(home) and using the page id is_home(4) but I didn't expect that to work since the home page is made up of a bunch of widget areas each with a featured page widget. So, what is the conditional to use when using an EZ "page" so as to execute some PHP code only on the homepage?

Help!
 

eric

Administrator
Cobalt Apps Developer
#2
Well the first thing I notice is that this:
PHP:
if (is_home() {
echo "This should print at top!";
}
Is missing a closing parenthesis right after the is_home() code. Is that how you have it in your code or did you just forget to add that in your forum post?
 

dev77

New Member
#3
That was a typ0.

What was not a typo was my lack of understanding of how WP works. In order to do what I wanted to do... which was remove the menu, it has to be done from within a hook. The functions.php is run before the DWB's front-page is run. So I was trying to remove the menu (or simply write some text to the header) BEFORE the menu or header was rendered.

Operator error!!

Here is how to do it:

add_action('get_header', 'anc_child_remove_genesis_do_nav');
function anc_child_remove_genesis_do_nav() {
if (is_front_page()) {
remove_action('genesis_after_header', 'genesis_do_nav');
echo 'Just a test line of text to see if we can see this';
}
}

(PS: how do you render code on this new editor. I don't see an icon for it?)
 

eric

Administrator
Cobalt Apps Developer
#4
Glad you were able to figure it out. :)

Here's a screenshot of the code button in the editor menu of this forum:
cobalt-forum-code-button.png
 
#5
I didn't notice that the the button was a drop-down menu! Thanks.

Code:
add_action('get_header', 'anc_child_remove_genesis_do_nav');
function anc_child_remove_genesis_do_nav() {
if (is_front_page()) {
remove_action('genesis_after_header', 'genesis_do_nav');
echo 'Just a test line of text to see if we can see this';
}
}