Forum Replies Created

Viewing 15 replies - 16 through 30 (of 50 total)
  • Richard

    (@richardcoffee)

    You should also be using the wordpress function wp_die(), rather than the php function die().

    Richard

    (@richardcoffee)

    Trying to get property of non-object in plugins/user-last-login/user-last-login.php on line 147

    Still getting this error in 1.2. The rest api url of /wp-json/wp/v2/users generates this error. The $current_screen global will not be set in a rest api call.

    Richard

    (@richardcoffee)

    ahhh, then perhaps a shortcode may be the way to go.

    Insert a shortcode into the static page content where you want your post excerpt to appear:

    [mario_post_excerpt]

    Then, in the functions.php file, you can put the code to display what you need in a function like so:

    function mario_post() {
      $html = 'Content to be displayed';
      return $html;
    }
    add_shortcode('mario_post_excerpt','mario_post');

    The function code to retrieve the post excerpt will need to be a custom loop. The link I posted earlier has example code for that.

    Richard

    (@richardcoffee)

    Followup: Using the the_content filter will not work if the new loop is using the_content() to display it’s content, due to recursion issues. While solvable, I don’t really recommend trying it that way.

    Richard

    (@richardcoffee)

    If multiple posts are being displayed on the the page then you should be able to insert what you want between the posts, something like this:

    if (have_posts()) {
      while (have_posts()) {
        the_post();
        the_content();
        get_template_part('insert_stuff');
      }
    }

    You may want to use a counter to only insert it between the 2nd and 3rd post, for example.

    If only one post is being displayed then you may be able to use the filter the_content to insert something. Only problem there would be to figure where to insert it at.

    add_filter('the_content','insert_my_stuff');
    function insert_my_stuff($content) {
      if (is_home()) { // maybe is_front()
        // locate where you want to insert
        $pos = strpos($content,'insert here maybe');
        if (!$pos===false) {
          // split content at point of insertation
          $before = substr($content,0,$pos);
          $after  = substr($content,$pos+1);
          // get new content
          $new = new_content_loop();
          // add in the new content
          $content = $before . $new . $after;
        }
      }
      return $content;
    }

    This is just a general outline of how you might do something like this. You would need to work with it to arrive at a usable solution.

    Hope this helps. Good luck!

    Richard

    (@richardcoffee)

    You have complete control over where it shows up. What I usually do is put that second loop in a separate file, along with the HTML to display the content. Then in the static page I will use get_template_part() to load the file. This keeps it all modular, and allows me to use that same loop in other places if I need to.

    Richard

    (@richardcoffee)

    Followup:

    Break, definitely break.

    change needed to be:

    add_action( 'init', 'aioseop_init_class', 1 );

    plus, all_in_one_seo_pack.php:359: change priority 1 to a 2

    add_action( 'init', 'aioseop_load_modules', 2 );

    I thought it interesting just how many plugins want an init priority of 1. I feel sure the aioseop people will tell you to stay out of their code. And they will be right.

    Richard

    (@richardcoffee)

    Follow-up:

    all_in_one_seo_pack.php:206:

    add_action( 'plugins_loaded', 'aioseop_init_class' );

    can be changed to

    add_action( 'init', 'aioseop_init_class' );

    That might fix your problem. Or it might break your system.

    Tread with care.

    Richard

    (@richardcoffee)

    I am running the exact same wp and plugin versions

    This may be related to your issue. This error has been showing up in my logs: PHP Notice: bbp_setup_current_user was called <strong>incorrectly</strong>. The current user is being initialized without using $wp->init().

    debug_backtrace() produces this: (edited some for brevity)

    Array
    (
        [0] => Array
            (
                [file] => /home3/creatomb/public_html/wp-content/plugins/bbpress/includes/core/sub-actions.php
                [function] => _doing_it_wrong
                [args] => Array
                    (
                        [0] => bbp_setup_current_user
                        [1] => The current user is being initialized without using $wp->init().
                        [2] => 2.3
                    )
    
            )
    
        [1] => Array
            (
                [function] => bbp_setup_current_user
            )
    
        [2] => Array
            (
                [file] => /home3/creatomb/public_html/wp-includes/plugin.php
                [function] => call_user_func_array
                [args] => Array
                    (
                        [0] => bbp_setup_current_user
                    )
            )
    
        [3] => Array
            (
                [file] => /home3/creatomb/public_html/wp-includes/pluggable.php
                [function] => do_action
                [args] => Array
                    (
                        [0] => set_current_user
                    )
    
            )
    
        [4] => Array
            (
                [file] => /home3/creatomb/public_html/wp-includes/pluggable.php
                [function] => wp_set_current_user
    
        [5] => Array
            (
                [file] => /home3/creatomb/public_html/wp-includes/pluggable.php
                [function] => get_currentuserinfo
            )
    
        [6] => Array
            (
                [file] => /home3/creatomb/public_html/wp-includes/user.php
                [function] => wp_get_current_user
            )
    
        [7] => Array
            (
                [file] => /home3/creatomb/public_html/wp-content/plugins/all-in-one-seo-pack/admin/meta_import.php
                [function] => get_current_user_id
            )
    
        [8] => Array
            (
                [file] => /home3/creatomb/public_html/wp-content/plugins/all-in-one-seo-pack/all_in_one_seo_pack.php
                [args] => Array
                    (
                        [0] => /home3/creatomb/public_html/wp-content/plugins/all-in-one-seo-pack/admin/meta_import.php
                    )
            )
    
        [9] => Array
            (
                [function] => aioseop_init_class
            )
    
        [10] => Array
            (
                [file] => /home3/creatomb/public_html/wp-includes/plugin.php
                [function] => call_user_func_array
                [args] => Array
                    (
                        [0] => aioseop_init_class
                    )
            )
    
        [11] => Array
            (
                [file] => /home3/creatomb/public_html/wp-settings.php
                [function] => do_action
                [args] => Array
                    (
                        [0] => plugins_loaded
                    )
            )
    
        [12] => Array
            (
                [file] => /home3/creatomb/public_html/wp-config.php
            )
    
        [13] => Array
            (
                [file] => /home3/creatomb/public_html/wp-load.php
            )
    
        [14] => Array
            (
                [file] => /home3/creatomb/public_html/wp-blog-header.php
            )
    
        [15] => Array
            (
                [file] => /home3/creatomb/public_html/index.php
            )
    
    )

    As far as I can tell, this is what is happening:

    Item 11 is where the ‘plugins_loaded’ action is fired. This pulls in Item 9 – aioseop_init_class. Later code, Item 7, wants the user ID. This causes WP to go looking for that information, which causes the ‘set_current_user’ action to be fired off, Item 3. This pulls in Item 1, ‘bbp_setup_current_user’. That function checks to see if the action ‘after_setup_theme’ has been done – which it has not! It then calls _doing_it_wrong(), which calls trigger_error(). I have no idea what happens after that. Hopefully this can help someone more familiar with these plugins figure out how to fix the issue.

    Richard

    (@richardcoffee)

    I see a couple of things:

    The line <h4><?php echo $feature_posts->post_title; ?></h4> has an error in it. It should be <h4><?php echo $feature_post->post_title; ?></h4>.

    Also, as already pointed out, the image url is never defined.

    You shouldn’t need the array_reverse() call. Just add 'order' => 'ASC' to the array.

    Richard

    (@richardcoffee)

    Sorry for the late reply. I don’t log on here on a regular basis. I hope you have already solved the problem…

    If I am understanding your problem correctly, I would not create the 30 different pages, but rather 1 single template file that can display any category. The category can be passed back to the server as a POST variable, which the template can then read and include the appropriate php file to display the category requested.

    Frankly, this is not specifically a WordPress question, and you might be better served looking for information on websites dealing more generally with php .

    Richard

    (@richardcoffee)

    Sounds like you need to add a custom query to the page. Take a look at https://codex.www.ads-software.com/Class_Reference/WP_Query, and look at the multiple loops example.

    Richard

    (@richardcoffee)

    <?php include("../services/lulu.php"); ?>

    Depending on where you are inserting this in a file, you may not need the surrounding php tags. Also, this will not work from within the editor. WordPress does not execute php there, due to security concerns.

    Richard

    (@richardcoffee)

    One way could be to make the “weight history” an array using a date string as the index. Then just save it as user_meta using the ‘personal_options_update’ filter.

    add_action(‘personal_options_update’, ‘update_weight_history’);
    function update_weight_history($user_id) {
    if (current_user_can(‘edit_user’,$user_id)) {
    $weight_history = get_user_meta($user_id,’weight_history’);
    $weight_history[date(‘Y-m-d’,time())] = floatval($_POST[‘weight’]);
    update_user_meta($user_id, ‘weight_history’, $weight_history);
    }
    }

    Richard

    (@richardcoffee)

    https://codex.www.ads-software.com/Function_Reference/wp_redirect

    if (isset($_COOKIE[‘cookie_name’])) {
    wp_redirect(‘new_location_addr’); exit;
    }

Viewing 15 replies - 16 through 30 (of 50 total)