• I want to change the layout of the favourites list from the standard list output to a more styled one (with divs etc).

    Does anyone know how I can achieve this?

    I know the code section I want to use for the new look:

    <div class="grid-50 mobile-grid-100 propertybox">
                        <div class="featuredimage">
                            <a href="<?php echo get_permalink( $item->post_id );?>">
                                <?php echo get_the_post_thumbnail( $item->post_id, 'full' ); ?>
                            </a>
                        </div><!-- end featuredimage -->
                        <div class="grid-30">
                            <h4 class="pink price-page">
                                <?php the_ccyamt(get_field('property_price', $item->post_id)); ?>
                            </h4>
                            <br>
                            <?php the_field('details', $item->post_id); ?>
                            <br>
                            <br>
                            <p>REFERENCE: <?php the_field('reference_number', $item->post_id); ?></p>
                        </div><!-- end grid-30 -->
                        <div class="grid-70">
                            <h2 class="categorytitle">
                                <a href="<?php echo get_permalink( $item->post_id );?>">
                                    <?php echo get_the_title( $item->post_id ); ?>
                                </a>
                            </h2>
    
                            <?php
                            //the_content();
    
                            $my_postid = $item->post_id;
                            $content_post = get_post($my_postid);
                            $content = $content_post->post_content;
                            $content = apply_filters('the_content', $content);
                            $content = str_replace(']]>', ']]>', $content);
                            echo $content;
    
                            ?>
    
                            <a href="<?php echo get_permalink( $item->post_id ); ?>" class="button floatright">
                                More Details
                            </a>
                        </div>
                    </div>

    and I know it needs to go in somewhere around here:

    private function setList()
    	{
    		$favorites = get_user_favorites($this->data['user_id']);
    		$out = "";
    		foreach($favorites as $favorite){
    			$out .= '<li>';
    			if ( $this->data['links'] ) $out .= '<a href="' . get_permalink($favorite) . '">';
    			$out .= get_the_title($favorite);
    			if ( $this->data['links'] ) $out .= '</a>';
    			$out .= '</li>';
    			echo 'Text goes here'
    		}
    		$this->list = $out;
    	}

    on the FavoritesListHandler.php file.

    Can anyone help me?

    https://wordpress.org/plugins/favorites/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter Christopher Mitchell

    (@chrismitchell)

    Is there any way to set this to work with ALL users not just logged in ones?

    Thread Starter Christopher Mitchell

    (@chrismitchell)

    If thats not possible, is there a user level that this works with? As I can’t seem to see it working with a normal subscriber level user, but I can with admin level. Any help?

    Plugin Author Kyle Phillips

    (@kylephillips)

    Christopher,

    I may have misread your question earlier in our offline communication. If you’re looking for a way of displaying user favorites all in one place… yes, you’ll only have access to registered users.

    Non-registered users’ favorites are saved by either session or cookie, not in the DB.

    As for styling, I believe you can use the get_user_favorites() function to get what you’re looking for.This function returns an array of post IDs. You can either loop through that array, or pass the array of IDs to a new WP_Query object (using the post__in parameter):

    https://gist.github.com/kylephillips/9fe12f195c671c989af3

    Thread Starter Christopher Mitchell

    (@chrismitchell)

    Hi Kyle,

    The display is now working perfectly.. The only issue i’m now getting is the user level. For some reason or another, when I have the users set to lower than Administrator, they can’t make any favourite posts… It doesn’t make sense. Its as if that level of user isn’t permitted to use it. Any ideas as to why this might be?

    Chris

    Thread Starter Christopher Mitchell

    (@chrismitchell)

    Could the problem be that i’m running W3 total cache? As it doesn’t even work when the user is not logged in.

    The user can click the add to favourites button and it will go, but it doesn’t add to the favourites section. If you reload that page it just goes back to being unselected again.

    Also when the user isn’t logged in the Favourites page displays a load of posts instead of the ones that are favourited.

    http://the.villas/

    Is the URL.

    I’m hoping that you can help me figure this last bit out.

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

The topic ‘Style favourites list’ is closed to new replies.