• Resolved sallywp

    (@sallywp)


    Hello,

    I’m currently using the below code snippet so I can add recent posts as well as custom content to my home page. I would like to include custom content before my recent posts. When I set it the hook to “after_header,” the custom content appears as a full-width page and excludes my sidebar. If I set it “before_content,” the content displays before every single one of my recent posts.

    Is there any way to set it so I can have custom content before my recent posts but still integrate the content according to the default layout (right sidebar)?

    My site is https://passportandplates.com

    Thanks in advance for your help!

    CODE:

    add_filter( ‘tc_default_widgets’ , ‘add_featured_page_widget’ );
    function add_featured_page_widget( $defaults ) {
    $defaults[‘fp_widgets’] = array(
    ‘name’ => __( ‘Featured Pages Widget’ , ‘customizr’ ),
    ‘description’ => __( ‘Above the featured pages area on home’ , ‘customizr’ )
    );
    return $defaults;
    }

    add_action(‘__after_header’ , ‘display_my_fp_widget’);
    function display_my_fp_widget() {
    dynamic_sidebar(‘fp_widgets’);
    }

Viewing 15 replies - 1 through 15 (of 25 total)
  • Hi,
    Try
    add_action(‘__after_fp’ , ‘XXX’);

    Thread Starter sallywp

    (@sallywp)

    Hi Menaka,

    That only works if I activate the featured pages. I would like to avoid activating FP unless absolutely necessary. Is there a workaround?

    Thanks!

    Hi Sally,
    This is a workaround. Do see if it works for you. Add this to your child theme’s functions.php

    add_action('__loop','add_custom_content_before_posts');
    function add_custom_content_before_posts(){
    global $wp_query;
    if ($wp_query->current_post == 0) {
      echo "YOUR CUSTOM CONTENT\n";
    }
    Thread Starter sallywp

    (@sallywp)

    Hi Menaka,

    What exactly goes in the “your custom content” section? I just copied and pasted the code as is and it caused my site to go down.

    Hi Sally,
    “Your Custom content” refers to the content you want to show above the recent posts.
    Take a look here.
    If it caused your site to go down, can you show the contents of your functions.php so that I can check it?

    Thread Starter sallywp

    (@sallywp)

    Hi Menaka,

    I had my hosting provider remove the error and it’s restored. so if I want a specific page in the custom content, how would I do that?

    replace “custom content” with page id=32 for each of time it says custom content in the below code?

    add_action(‘__loop’,’add_custom_content_before_posts’);
    function add_custom_content_before_posts(){
    global $wp_query;
    if ($wp_query->current_post == 0) {
    echo “YOUR CUSTOM CONTENT\n”;
    }

    Thread Starter sallywp

    (@sallywp)

    Is there a way to use this code but prevent it from repeating before every piece of content? Just have it display before content once?

    add_action(‘__before_content’ , ‘display_my_fp_widget’);
    function display_my_fp_widget() {
    if ( ! tc__f(‘__is_home’) )
    return;
    dynamic_sidebar(‘fp_widgets’);
    }

    Try this.

    add_action('__before_content' , 'display_my_fp_widget');
    function display_my_fp_widget() {
    if ( ! tc__f('__is_home') )
      return;
    global $wp_query;
    if ($wp_query->current_post == 0) {
      dynamic_sidebar('fp_widgets');
    }
    }
    Thread Starter sallywp

    (@sallywp)

    Hi Menaka,

    That is REALLY close.

    I’m trying to add in a map using the Interactive Map Builder. When I add in the shortcode, the map gets placed next to the post thumbnail and the post title and excerpt get pushed to the bottom.

    Is there a way to make the area stretch so it takes up the entire length it’s occupying? I don’t need it to be the full width of the page as I’m using a the right sidebar template but I don’t want it to interfere with the content showing the posts. https://passportandplates.com

    Thanks so much!

    Hi Sally,
    If this issue is fixed, can you mark this as resolved and open a different thread for the map issue? Also give link to the page where there is an issue so that it is easy to diagnose – particularly layout issues.

    Thread Starter sallywp

    (@sallywp)

    Hi Menaka,

    This is still part of the same issue but I can open another thread if you would like. Essentially any content I try to put in the area doesn’t take up the full width of the page according to the layout. It interferes with the content below it.

    I don’t have it live at the moment as it makes the site look really bad. Is there a way I can send you a screenshot?

    Thanks!

    Do send a screenshot on https://imgur.com/ or similar sites.

    Thread Starter sallywp

    (@sallywp)

    Hi Menaka,

    As you can see, the photo on the top left corner is actually the thumbnail from the most recent post.

    It’s interfering with the content I’m trying to add to the FP widget area. In this case, the map. This happens any time I try to add content to the FP area, no matter the size. Essentially, I would like the content to take up the full width of the area / be responsive so that the posts are pushed below whatever gets added to the widget area. is this possible?

    Thanks!

    https://picasaweb.google.com/109402086603161483632/January82016#6237597911613668898

    Hi,
    Sorry, I don’t get to see that image. “Sorry Page not found”

Viewing 15 replies - 1 through 15 (of 25 total)
  • The topic ‘Featured Pages Widget: "After Content" Error’ is closed to new replies.