- This topic has 9 replies, 3 voices, and was last updated 4 years, 7 months ago by Tom.
-
AuthorPosts
-
July 27, 2019 at 10:31 am #968771Stan
Apologies if this is basic, but I have a weird mistake on the Previous and Next buttons on each post on my website. I have an image, but can’t attach it here. Basically, each post at the bottom has this code:
1, ‘include’ => $prevPost->ID ); $prevPost = get_posts($args); foreach ($prevPost as $post) { setup_postdata($post); ?>
And the a Previous button in red box inside a larger grey box and then this code:
1, ‘include’ => $nextPost->ID ); $nextPost = get_posts($args); foreach ($nextPost as $post) { setup_postdata($post); ?>
And then a Next button in a red box inside a larger grey box.
Any help in getting rid of this is much appreciated. I would prefer normal Previous and Next buttons.
Thanks.
July 27, 2019 at 7:38 pm #968935TomLead DeveloperLead DeveloperHi there,
Did you use a site in our Site Library?
If so, which one?
Let me know 🙂
July 27, 2019 at 10:44 pm #968992StanYes I used Dispatch
July 28, 2019 at 6:45 am #969153TomLead DeveloperLead DeveloperIf you go to “Appearance > Elements” and open the “Post Navigation” element, is the “Execute PHP” checkbox checked?
If it is, can you replace the hook content with this?:
<div id="post-nav"> <?php global $post; $prevPost = get_previous_post(false); $post_type = get_post_type(); if ( $prevPost ) { $args = array( 'posts_per_page' => 1, 'include' => $prevPost->ID, 'post_type' => $post_type, ); $prevPost = get_posts($args); foreach ($prevPost as $post) { setup_postdata($post); ?> <a class="post-previous" href="<?php the_permalink(); ?>"> <div class="post-nav-wrap" style="background: linear-gradient(0deg,rgba(52,62,71,0.1),rgba(52,62,71,0.3)),url('<?php the_post_thumbnail_url(); ?>');"> <div class="post-nav"><?php _e( 'Previous', 'generatepress' ); ?></div> <h3 class="post-nav-title"><?php the_title(); ?></h3> </div> </a> <?php wp_reset_postdata(); } //end foreach } // end if $nextPost = get_next_post(false); if ( $nextPost ) { $args = array( 'posts_per_page' => 1, 'include' => $nextPost->ID, 'post_type' => $post_type, ); $nextPost = get_posts($args); foreach ( $nextPost as $post ) { setup_postdata($post); ?> <a class="post-next" href="<?php the_permalink(); ?>"> <div class="post-nav-wrap" style="background: linear-gradient(0deg,rgba(52,62,71,0.6),rgba(52,62,71,0.3)),url('<?php the_post_thumbnail_url(); ?>');"> <h3 class="post-nav-title"><?php the_title(); ?></h3> <div class="post-nav"><?php _e( 'Next', 'generatepress' ); ?></div> </div> </a> <?php wp_reset_postdata(); } //end foreach } // end if ?> </div>
July 28, 2019 at 8:40 am #969381StanThanks for the response. The ‘Execute PHP’ line does not have a check option, and instead shows this: ‘Unable to execute PHP as DISALLOW_FILE_EDIT is defined’.
July 28, 2019 at 5:47 pm #969612LeoStaffCustomer SupportThis should help:
https://docs.generatepress.com/article/disallow-php-execution/Let me know 🙂
August 6, 2019 at 4:38 pm #977603StanHi, so based on the above instructions in the article, I placed the ‘define( ‘GENERATE_HOOKS_DISALLOW_PHP’, true );’ line after the ‘Disallow_File_Edit’ line in the wp-config.php file using File Manager in Bluehost and saved it.
There is still no ‘Execute PHP’ checkbox. It still shows‘Unable to execute PHP as DISALLOW_FILE_EDIT is defined’.
Is there something I’m missing?
August 6, 2019 at 5:29 pm #977624TomLead DeveloperLead DeveloperSorry, that’s an old article geared towards the old Hook system.
The reason you’re seeing that message is because File Editing is disabled on your site: https://wordpress.org/support/article/editing-wp-config-php/#disable-the-plugin-and-theme-editor
Usually, this is disabled because you don’t want people to be able to execute PHP in your Dashboard.
If you want to keep file editing turned off, but allow PHP execution in Elements, you can do this: https://docs.generatepress.com/article/generate_hooks_execute_php/
Hope this helps 🙂
August 8, 2019 at 8:42 am #979154StanThanks, Tom! That worked!
August 8, 2019 at 9:20 am #979194TomLead DeveloperLead DeveloperYou’re welcome 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.