[Support request] Something happens to my social icons on publishing

Home Forums Support [Support request] Something happens to my social icons on publishing

Home Forums Support Something happens to my social icons on publishing

Viewing 15 posts - 16 through 30 (of 30 total)
  • Author
    Posts
  • #1391981
    Randy

    To clarify my question, at the moment, I think I need to find out where I can find the element IDs. I have both author boxes active, but both are showing up on every page. The PHP doesn’t seem to be working yet. I’ve tried a couple different things for the IDs, but apparently, I have gotten it right yet.

    Thanks!

    #1392061
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    When editing the Element in the Dashboard, you can see the ID in the URL. It should be the only number.

    Let us know πŸ™‚

    #1392132
    Randy

    Hmmm. That’s what I thought. As far as I know, then, the code is correct. But, they’re both being inserted after the content, as here.

    Thanks!

    #1392683
    David
    Staff
    Customer Support

    Aside of the ID numbers being correct we also have the is_author() condition which can use ID, Nice Name and Nickname. These examples explain then well:

    https://developer.wordpress.org/reference/functions/is_author/#user-contributed-notes

    #1393112
    Randy

    Thanks for the info. I’ve worked with this, but still have trouble.

    I did some digging in myPHPAdmin and found my Nicename and I verified IDs and Nicknames. I also tried to make sure I followed the code examples you shared. But nothing has worked yet.

    In case it helps, here’s my current code (though I’ve tried all the variations in the examples) …

    add_filter( 'generate_block_element_display', function( $display, $element_id ) {
        //First Author 
        if ( 10317 === $element_id && is_author('6')) {
            $display = true;
        }
        //Second Author
        if ( 10331 === $element_id && is_author('5')) {
            $display = true;
        }
    
        return $display;
    }, 10, 2 );

    Thanks!

    #1393364
    Tom
    Lead Developer
    Lead Developer

    A good way to test your conditions is to do this:

    add_action( 'generate_before_header', function() {
        if ( is_author('6') ) {
            var_dump('hello');
        }
    } );

    Does that output “hello” before the header on the author page you’re targeting?

    #1393387
    Randy

    No, it doesn’t, actually. Also tried Author ID 5. I added it as a new snippet in Code Snippets.

    Not really sure what this means, other than the test failed. πŸ™‚

    For what it’s worth, I did add some code to the Dashboard, with the code at #8 on this page to “Add the User ID column” partly to see if it would work and to verify user ID numbers (it worked).

    #1393821
    David
    Staff
    Customer Support

    Try this snippet instead:

    add_filter( 'generate_block_element_display', function( $display, $element_id ) {
        global $post;
        $post_author_id = $post->post_author;
    
        //First Author 
        if ( 10317 === $element_id && $post_author_id = '6' ) {
            $display = true;
        }
        //Second Author
        if ( 10331 === $element_id && $post_author_id = '5' ) {
            $display = true;
        }
    
        return $display;
    }, 10, 2 );
    #1394613
    Randy

    Thanks for the suggestion. I was hopeful, but it wasn’t successful, either.

    After trying it, I thought I would take a shot in the dark and check with the webhost just to see if they thought there might be any conflicts in the setup. They didn’t see anything or have anything to suggest. I was just glad they looked into it. πŸ™‚

    #1395769
    Tom
    Lead Developer
    Lead Developer

    Perhaps something like this?:

    add_filter( 'generate_block_element_display', function( $display, $element_id ) {
        global $post;
        $post_author_id = $post->post_author;
    
        //First Author 
        if ( 10317 === $element_id && 6 == $post_author_id ) {
            $display = true;
        }
        //Second Author
        if ( 10331 === $element_id && 5 == $post_author_id ) {
            $display = true;
        }
    
        return $display;
    }, 10, 2 );
    #1395926
    Randy

    Hmmm. This is interesting. The one thing I noticed with this latest code is that, while it didn’t change anything on the individual post (still showing both author blocks), it only showed MY author block on the homepage/index, but it did even on the ones I didn’t write. The previous code showed both author blocks on the index page.

    The first code(s) didn’t add the author blocks to the index page.

    Thanks for all of your help. I certainly didn’t know this was going to be such a chore. πŸ™‚

    #1396116
    Tom
    Lead Developer
    Lead Developer

    So you’re showing the author boxes within archives as well? Not just within single posts?

    #1396185
    Randy

    Yes. On checking again, my author block appears at the bottom of every page — including Contact, About, Archives, Subscribe. But on the single posts, both author blocks show up.

    #1397410
    Tom
    Lead Developer
    Lead Developer

    Can you try:

    1. Removing any and all Display Rules from the actual Element.

    2. Adding this code:

    add_filter( 'generate_block_element_display', function( $display, $element_id ) {
        if ( is_singular() ) {
            global $post;
            $post_author_id = $post->post_author;
    
            //First Author 
            if ( 10317 === $element_id && 6 == $post_author_id ) {
                $display = true;
            }
            //Second Author
            if ( 10331 === $element_id && 5 == $post_author_id ) {
                $display = true;
            }
        }
    
        return $display;
    }, 10, 2 );
    #1397611
    Randy

    Okay, I removed the one display rule I had (posts/all posts). This worked for the single posts for each author (yay!), but …

    Here’s what else is happening:

    • My author block appears at the bottom of each page (About, Contact, etc.).
    • My author block appears at the end of each post on the main index page, even for the posts written by my wife (but, it shows her block when clicking on the single post).
    • When I click on her author page, it shows her block with each post.
    • Thanks! πŸ™‚

Viewing 15 posts - 16 through 30 (of 30 total)
  • You must be logged in to reply to this topic.