Forum Replies Created

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter Sam

    (@wamshatley)

    Hi Fernando, perfect – thanks for this.

    Good to know the block settings dynamic content will still render even with the empty loop and can then be modified – I was scratching my head trying to understand why the toolbar dynamic content stopped the element being rendered with just the prefix at least.

    Really appreciated!
    Sam

    • This reply was modified 2 years, 3 months ago by Sam.
    Thread Starter Sam

    (@wamshatley)

    Hi Fernando,

    Thanks for the reply. This is the block I’m creating:
    https://i.ibb.co/TmkRWnS/Screenshot-2022-11-16-at-08-16-45.png

    At the moment, I’ve ended up making a shortcode and embedding that in a container to do what I need it to do with the term metas I need, but it just felt like it shouldn’t be needed when a separate header element can access the term name on the same page and the GP dynamic content block can access the term description fine.

    But as you say, if there’s a filter to make this happen or if there’s a way of allowing it in the first place, that would be better than my shortcode approach.

    Thanks!

    • This reply was modified 2 years, 3 months ago by Sam.
    Thread Starter Sam

    (@wamshatley)

    Thanks, I figured it might be coming to that – a relatively harmless & simple feature, so hopefully it might get considered!

    Thread Starter Sam

    (@wamshatley)

    Hey, thanks for the reply.

    I just tried this, but the get_the_ID() or get_queried_object_id() at wpsp_inside_wrapper is at a point where it hasn’t started a WPSP query loop, so it’s checking the ID of the last post in the page’s main loop, which isn’t quite what I’m looking for, as I need to check for no results in the WPSP query.

    I guess this would work if

    $query = new WP_Query( apply_filters( 'wp_show_posts_shortcode_args', $args ) );

    was called above the hook, right? But again I think it comes down to reordering the position of the query in the plugin.

    Thanks for your help with this – maybe I’m overcomplicating this, just to get a title showing if there are results!

    Thread Starter Sam

    (@wamshatley)

    The hook’s working as you describe/as designed, but I’m trying to hide the title when there are no results (because it doesn’t fit in the design I’m working on to say “Latest Posts” but then show none, for example), so I’d like to wrap a hook in a conditional, i.e.:

    // Start the query.
    $query = new WP_Query( apply_filters( 'wpsp_query_args', $args, $settings ) );
    
    if ( $query->have_posts() ) {
    	do_action( 'wpsp_inside_wrapper_has_posts', $settings );
    }

    So that the hook only executes if the query returns posts. Alternatively, it’d be probably cleaner if the hook also made the query object available so it can be filtered if implemented, i.e.:

    do_action( 'wpsp_inside_wrapper', $settings, $query );

    Rather than adding in a separate conditional hook, but this would involve moving the query to before the hook executes.

    Failing that, it’d be great if there was actually a setting in the UI for adding a title to the block and conditionally showing it if results.

    Sorry for the explanation again – I just wondered how likely a pull request for adding/changing a hook would be.

    Thanks,
    Sam

    • This reply was modified 3 years, 7 months ago by Sam.
    Thread Starter Sam

    (@wamshatley)

    Thanks for the reply. I’m looking to add a title to the section of the page before the loop even starts, but show it only where the query returns results.

    That way, if there are no results, nothing at all is displayed, and if there are results then a title like “Latest Related Posts” is displayed before the loop.

    Thread Starter Sam

    (@wamshatley)

    Thanks for the response. I guess this is more complex than we’d hoped!

    Just out of interest, could there be any scope for paid customisation/addition of this functionality, or would this be something we’d have to reach out to Dokan about?

    Forum: Plugins
    In reply to: [Polylang] Error message
    Sam

    (@wamshatley)

    Sorry I’m a bit late to the game – the only way I got round this (not upgrade safe) is by hacking core.

    Have a look in translations.php file at that line, and you should see something like this:

    /**
    * @param Translation_Entry $entry
    */
    function translate_entry(&$entry) {
    	$key = $entry->key();
    	return isset($this->entries[$key])? $this->entries[$key] : false;
    }

    Add an if statement to the middle so that it looks like this, and it should be fine:

    /**
    * @param Translation_Entry $entry
    */
    function translate_entry(&$entry) {
    	$key = $entry->key();
    	if(!is_array($key))
    	return isset($this->entries[$key])? $this->entries[$key] : false;
    }

    It looks like at some point there’s an array being passed for translation, and it doesn’t like it.

    Every time WordPress updates, you’ll need to put this line back in though ??

Viewing 8 replies - 1 through 8 (of 8 total)