Determine page content based on page parent
$thispageid = get_the_ID(); $thispageparent = get_ancestors($thispageid); if( in_array( 9, $thispageparent ) ) echo do_shortcode(”); else the_content(); reference get_ancestors()
$thispageid = get_the_ID(); $thispageparent = get_ancestors($thispageid); if( in_array( 9, $thispageparent ) ) echo do_shortcode(”); else the_content(); reference get_ancestors()
It looks like you have the function both in bp-custom.php and in your plugin. You don’t need a plugin. Put your code in plugins/bp-custom.php only. Or in your-theme/functions.php
I not 100% clear what your question is so hopefully this can point you in the right direction for conditional widgets. I will give you 3 options. 1. is_active_widget checks if widgets are active based in the widget ID. http://codex.wordpress.org/Function_Reference/is_active_widget 2. Using is_active_sidebar and creating more sidebars usually gives you better control over widget output. … Read more
You can hook a filter to the post_thumbnail_html and check if its a post in that category and if the user is not logged in ex: add_filter( ‘post_thumbnail_html’, ‘my_post_image_html_wpa92119’, 10, 3 ); function my_post_image_html_wpa92119( $html, $post_id, $post_image_id ) { $category_to_exclude = “CHANGE_WITH_CATEGORY ID”; $logIn_Img_path = “CHANGE THIS WITH PATH/TO/NON-LOGGED/USERS/IMAGE”; //check if the post have that … Read more
You need to add your function in the template_redirect hook. You need to first wait for wordpress to finish loading pages before you can add your hook to remove wpautop, otherwise your hook will simply get run over. So your funtion will look like this function pietergoosen_remove_wpautop() { if ( is_page ( ‘services’ ) ) … Read more
The appropriately named get_children() should be what you want. if ( have_posts() ) { while ( $loop->have_posts() ) { $loop->the_post(); $args = array( ‘post_parent’ => get_the_ID(), // the ID from your loop ‘post_type’ => ‘page’, ‘posts_per_page’ => 1, // you only need to know if you have children so one is enough ‘post_status’ => ‘publish’ … Read more
You should probably add in more checks, but this should get you started. function change_pw_text($content) { // Just to save processing other pages. if ( !is_page(‘page-slug-one’) && !is_page(‘page-slug-two’) ) return $content; $find = ‘This post is password protected. To view it please enter your password below:’; if ( is_page(‘page-slug-one’) ) $replace=”Hint: Tell our system to … Read more
You need to learn how the WordPress template hierarchy works. It is very important for any individual who wants to learn WordPress or take their current WordPress experience to the next level to know of and understand all of the different aspects of the WordPress Template Hierarchy. If you plan on consolidating, or organizing the … Read more
I would suggest checking out a geolocation service to lookup the location of the users IP address, such as freegeoip.net. In order to do this you would need to make a rest api get request either through php or javascript. To get the ip address of the visiting user you can read in <?php echo … Read more
Changing the function to the following works, as it checks to see if the form was submitted from the correct page: function my_foo_registration_redirect( $redirect_to) { if ($_SERVER[‘HTTP_REFERER’] !== get_the_permalink(1693)) { return $redirect_to; } $redirect_to = ‘/videoguide-startpakke’; return $redirect_to; } Thanks a lot for the super helpful comments! EDIT: Here’s a slightly more polished solution function … Read more