Forum Replies Created

Viewing 12 replies - 16 through 27 (of 27 total)
  • Thread Starter hazratnoor

    (@hazratnoor)

    I am actually querying posts with post_type = "advanced_ads", like:

    $args = array(
        'post_type' => 'advanced_ads',
        'posts_per_page' => -1
    );
    
    $obituary_query = new WP_Query($args);

    Then why I am unable to get the related image URL (the image which I have added with the ad using Rich Content or Image Ad types using the following code:

    `<a href=”<?php the_permalink(); ?>” alt=”Test Thumbnail”>
    <img src=”<?php the_post_thumbnail(); ?>” />
    </a>`

    Here I get <imag src(unknown)> on inspecting the web page.

    • This reply was modified 5 years, 11 months ago by hazratnoor.
    Thread Starter hazratnoor

    (@hazratnoor)

    The following code is working fine. I just want to add some code (which I cannot figure out in this case) where I have added those comments, saying “Code Goes Here”.

    // Query the posts:
    $obituary_query = new WP_Query($args);
    
    // Loop through the obituaries:
    while ($obituary_query->have_posts()) : $obituary_query->the_post();
    	?>
    	<?php 
    		$moreLink = '<a href="' . get_the_permalink() . '"> Read More...</a>';
    		echo '<div class="advert-div" style="padding-bottom: 50px;">'; ?>
    		<h2 class="ad-title"><?php the_title(); ?></h2>
    
                    //Code Goes Here
                    //Code Goes Here
                    //Code Goes Here
    	
    		<?php
    		echo wp_trim_words(do_shortcode("[the_ad id=".$post->ID."]"), 55, $moreLink);
    		echo '</div>';
    		echo '<hr>';
    	endwhile;
    wp_reset_postdata();
    ?>
    Thread Starter hazratnoor

    (@hazratnoor)

    Hi Thomas!

    Thanks for your detailed response. Actually, I can display the ad using the code I have provided in my question. The provided link also shows that the ads are appearing on the page. What I want to do is to show the image of an ad on the right side of each ad as well, just like this

    Thread Starter hazratnoor

    (@hazratnoor)

    Hi Thomas!

    How is Advanced_Ads storing the ad image? Is it stores the image as a featured image or something else? Where exactly the images are located? In wp_posts or wp_postsmeta?

    Why isn’t this code working for me?

    <?php 
    	$args = array(
    		'posts_per_page'   => -1,
    		'post_type'        => 'advanced_ads',
    	);
    	$the_query = new WP_Query( $args );
    	?>
    	<?php if ($the_query->have_posts()) :         
            $i = 1;        
            while ($the_query->have_posts()) : the_post();
    		$image = get_field(''); //the field in DB where the ad image lies
    			if ($image == '') {
    					$image = get_post_thumbnail_id();
    				}
                $size = ''; //size of the image
    			if ($i == 1 || $i % 3 == 1) {
                    echo '<div class="row adv-ads">';
                }  ?>
    	<div class="col-lg-4">
                    <a class="block-link" href="<?php the_permalink(); ?>">
                        <div class="ads-block">
                            <?php echo wp_get_attachment_image( $image, $size ); ?>
                            <div class="inner-text">
                                <?php the_title(); ?>
                            </div>
                        </div>
                    </a>
                </div>        
             <?php        
                if ($i % 3 == 0) {
                    echo '</div>';
                }
                $i++;
            endwhile;        
            $i--;        
            if (! ($i % 3 == 0)) {
                echo '</div>';
            }  ?>
    Thread Starter hazratnoor

    (@hazratnoor)

    Hi Thomas!

    I need to query all the Ads (All ads placed by all advertisers) on an archive page. This page will have all ads regardless of the advertiser.

    Is it possible to query all the shortcodes of every single ad and place them on my archive page? As I have recently tested a few shortcodes within a text block and it was working. If I can’t query all the shortcodes, will it be possible to query all the ads instead?

    Any help will highly be appreciated!

    Thanks,
    Best Regards,
    Hazrat Noor

    Thread Starter hazratnoor

    (@hazratnoor)

    Hi Thomas!

    This is my website’s requirements that each ad must be a blog-post. So I can further collect them all in an archive page as well as allow all advertisers to view and manage their own ads.

    Let me know if I can try this so far. If it was creating problems, I will revert to my existing code and will look for another way.
    Thanks for your help!

    Best Regards,
    Hazrat Noor

    Thread Starter hazratnoor

    (@hazratnoor)

    Hi Thomas!

    I have used the following code in my functions.php and this allows me to show specific ads placed by a user. It allows logged in advertisers to view and their own ads.

    function remove_unvetted_authors( $query ) {
    	$current_user = wp_get_current_user();
        if ( is_admin() && in_array ($query->get( 'post_type'), array( 'advanced_ads' ) ) && !user_can( $current_user, 'administrator' ) ) {
            
            $query->set( 'author__in', $current_user->ID );
        }
    }
    add_action( 'pre_get_posts', 'remove_unvetted_authors' );

    Now, I need these ads to be saved in DB as blog-posts. I have verified it from DB and their post-type is advanced_ad. I need it to be blog-post instead of advanced_ad.

    Any help will highly be appreciated!

    Best Regards,
    Hazrat Noor

    Thread Starter hazratnoor

    (@hazratnoor)

    Hi Thomas!

    Although, I have used the same procedures (suggested by you) for allowing my Advertisers (Advertiser User) to access (view, edit and delete) ads. However, I want some special solution for limiting down the capability of each Advertiser only to access (view, edit and delete) their own ads not of others.

    For my existing solution, the Admin User create placements (more than one) and assign them to widgets. On the Advertiser User side (upon logging in as an Advertiser), I access all the placements and use them for placing ads on them. Here, I want some sort of limitations so that an Advertiser can either only read (neither delete nor edit) other advertiser’s ads or cannot access other advertiser’s ads.

    If your development time is more than a few days (because I need an instant solution to my problem), then kinldy suggest me a few of your filters which can help me select only those ads (On Advertiser User side) which I have created only.

    I should be thankful for your support and will appreciate your answer in this regard!

    Thanks,
    Best Regards,
    Hazrat Noor

    Thread Starter hazratnoor

    (@hazratnoor)

    Hi Thomas!

    I used your solution and it works for me. But I was wondering if a user (Advertiser in our case and generally an Editor user with limitations to access Widgets) is willing to place more than a single ads, then everytime he/she will inform the admin to create a placement in a particular widget?

    Isn’t there any automated way of allowing users to create more than a single ad with less or no involvement of Admin? Actually, I am looking for some way to exclude Admin involvement while users are managing their ads.

    For now, I am accepting your answer and marking this question as resolved.

    Thanks for your help.
    Regards,
    Hazrat Noor

    Thread Starter hazratnoor

    (@hazratnoor)

    Hi Thomas!

    I have just created a new user on my WordPress website as an Editor, after installing Advanced Ads plugin. Now, as I am logged in using this account, When I have to choose the Advanced Ads widget for positioning it on the sidebar, it tells me that you are not allowed to access this page. Although I have allowed the option Advanced Ads > Settings > General > Allow editors to manage ads

    Thread Starter hazratnoor

    (@hazratnoor)

    Hi Thomas!

    Although I want to allow users to access their profile and view his/her ads and manage them, however, I am sure that your solution will help me. Thanks for providing this update and let me try it. I will let you know once I create a new user.

    Best Regards,
    Hazrat Noor

    Thread Starter hazratnoor

    (@hazratnoor)

    Hi Thomas!

    I do not want to be involved in adding or managing any of the ads. I want to allow users as a whole, to place, manage or edit their ads using their own login credentials. In reference to your answer, kindly let me know if I can get any link to a demo so I can confirm if it can work for me.

    Thanks for your time and explanation!

    Hazrat Noor

Viewing 12 replies - 16 through 27 (of 27 total)