• The Problem: I’m trying to remove photo thumbnails from my main pages. I want only text there. Then I want the photo to show up on the actual single post url when they have clicked through there.

    Customize Page does not work on my script. Developer will not explain why. Nor does he want to help or answer e-mails. So I’m stuck trying remove this PHP code that I don’t even know what looks like or where it is.

    I read in forum that it should be under single dot php but it’s not in my theme. Any idea what code I am looking for and what it may look like?

    I assume it’s called thumbnail or photo or image.

    Any help would be much appreciated. I’ve had so many problems with this theme and there are so many things I’ve had to just forget about because it doesn’t function properly. This however I can’t overlook and I must fix it.

Viewing 15 replies - 1 through 15 (of 17 total)
  • What theme?

    Thread Starter JamesWord2016

    (@jamesword2016)

    major-themes DOT com/themes/barcelona/

    Thread Starter JamesWord2016

    (@jamesword2016)

    I’m suspecting it’s here but when I removed some of this the whole site stopped working. Not event ext showed up.

    // Post thumbnail generator
    
    	function mamontov_post_thumb($id, $size='preview') {
    
    		$post_custom_thumb = get_post_meta($id, 'video_thumb', true);
    
    		if(!$post_custom_thumb) {
    			if(is_singular()) {
    				$post_thumb = wp_get_attachment_image_src(get_post_thumbnail_id($id), 'main');
    				$imgsize = 'main';
    			} else {
    				$post_thumb = wp_get_attachment_image_src(get_post_thumbnail_id($id), $size);
    				$imgsize = $size;
    			}
    			if($post_thumb[0]) {
    				if(is_singular()) {
    					$post_thumb = '<div class="post-thumb" style="background-image: url('.$post_thumb[0].');"></div>';
    				} else {
    					if(MAMONTOV_LAZYLOAD == 1) {
    						$post_thumb = "<a href='".esc_url( get_permalink() )."' class='featured-image'><i data-srcurl='".$post_thumb[0]."' data-alt='".get_the_title()."' data-title='".get_the_title()."' class='lazyload'></i></a>";
    					} else {
    						echo "<a href='".esc_url( get_permalink() )."' class='featured-image'>";
    						the_post_thumbnail($imgsize);
    						echo "</a>";
    						$post_thumb = null;
    					}
    				}
    			} else {
    				$post_thumb = null;
    			}
    		} else {
    			$post_thumb = '<div class="custom-featured">'.do_shortcode($post_custom_thumb).'</div>';
    		}
    
    		return $post_thumb;
    	}
    
    	// Images in post for post type Gallery
    
    	function mamontov_images_in_post($size = 'main') {
    
    		if($images = get_posts(array(
    			'post_parent'	=> get_the_ID(),
    			'post_type'	  => 'attachment',
    			'numberposts'	=> -1, // show all
    			'post_status'	=> null,
    			'post_mime_type' => 'image',
    			'orderby'		=> 'menu_order',
    			'order'			=> 'DESC'
    		))) {
    			$i = 0;
    			foreach($images as $image) {
    				$i++;
    				$attimg = wp_get_attachment_image_src($image->ID, $size);
    				if(is_singular()) {
    					echo "<li class='singular-thumbnail-as-slider' style='background-image: url(".$attimg[0].");'>";
    				}
    				else {
    					echo "<li>";
    					if(MAMONTOV_LAZYLOAD == 1) {
    						echo "<i data-srcurl='".$attimg[0]."' data-alt='".$image->post_name."' data-title='".$image->post_title."' class='lazyload'></i>";
    					} else {
    						echo "<img src='".$attimg[0]."' alt='".$image->post_name."' title='".$image->post_title."' />";
    					}
    				}
    				echo "</li>\n";
    
    			}
    		}
    	}
    
    	// Previous / next navigation in Archive
    
    	function mamontov_content_nav() {
    		global $wp_query;
    
    		if ( $wp_query->max_num_pages > 1 && !is_singular() && !is_404()) : ?>
    			<nav class='navigation' role='navigation' data-infinitescroll='<?php echo MAMONTOV_INFINITE_SCROLL; ?>'>
    				<?php next_posts_link( ''.__( 'Older posts', 'mamontov'). ' <span class="meta-nav next"><i class="fa fa-angle-right"></i></span>' ); ?>
    				<?php previous_posts_link( '<span class="meta-nav"><i class="fa fa-angle-left"></i></span> '.__( 'Newer posts', 'mamontov').'' ); ?>
    			</nav>
    		<?php endif;
    	}
    
    	if (!function_exists('print_a')) {
    		function print_a( $a ) {
    			print( '<pre>' );
    			print_r( $a );
    			print( '</pre>' );
    		}
    	}

    Since it is a commercial theme, I will not be able to tell you the exact code that needs to be modified, but I can hopefully give you the right hints

    • Open content.php and search for the function get_the_post_thumbnail
    • Add an if around it to check if it is the home page. Something like this <?php if(!is_home() && !is_front_page()) get_the_post_thumbnail(); ?>

    Hope this helps.

    Thread Starter JamesWord2016

    (@jamesword2016)

    Hey the code is clear. Thank you for answering ??

    There is no content PHP file.

    Why is there a rule against helping someone modify something they’ve bought?

    If you had a Samsung TV and wanted to rebuild it into a fridge I think Samsung could not sue me for helping you with that ??

    Jokes aside. I’m searching through all php files now for thumbnail text but not sure what I’m looking for. This is confusing. Thank you for trying though.

    Your post was like Greek to me.

    Thread Starter JamesWord2016

    (@jamesword2016)

    Do you think this is it? Is there a small thing I can take off int hat code which would make script still work? I’m so afraid to modify things lest I destroy everything. Been working on this nonstop for a week now.

    // Post thumbnail generator
    
    	function mamontov_post_thumb($id, $size='preview') {
    
    		$post_custom_thumb = get_post_meta($id, 'video_thumb', true);
    
    		if(!$post_custom_thumb) {
    			if(is_singular()) {
    				$post_thumb = wp_get_attachment_image_src(get_post_thumbnail_id($id), 'main');
    				$imgsize = 'main';
    			} else {
    				$post_thumb = wp_get_attachment_image_src(get_post_thumbnail_id($id), $size);
    				$imgsize = $size;
    			}
    			if($post_thumb[0]) {
    				if(is_singular()) {
    					$post_thumb = '<div class="post-thumb" style="background-image: url('.$post_thumb[0].');"></div>';'
    Thread Starter JamesWord2016

    (@jamesword2016)

    Under page PHP there is something I thought might help so I removed the whole 4th line but it didn’t have any effect.

    <?php get_header(); ?>
    
    <div class='posts page'>
    
    	<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
    
    		<?php echo mamontov_post_thumb($post->ID); ?>
    
    		<div class='inside-post-wrap'>
    
    			<?php if(!is_front_page()) { ?>
    
    					<h2 class='post-title'>
    						<?php the_title(); ?>
    					</h2>

    Why is there a rule against helping someone modify something they’ve bought?

    Not a hard-fast rule IF someone here is able and willing to help, but here’s the details about that:

    https://codex.www.ads-software.com/Forum_Welcome#Commercial_Products

    I am not against helping fix issues/make changes in commercial products, but without access to the code, I might end up barking up the wrong tree (just like I did here).

    However, the function you identified mamontov_post_thumb is right on spot. Here is a quick fix: Add these line at the start of the function (right after the line function mamontov_post_thumb...)

    if (is_home() || is_front_page()) {
    	return null;
    }

    Basically, at the start of the function, you check if it is the home or front page and you return an empty value.

    Thread Starter JamesWord2016

    (@jamesword2016)

    thecodeisclear, thank you for replying. I feel a solution may be in reach. I tried many varieties of your code:

    <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
    
    		<?php echo mamontov_post_thumb($post->ID) if (is_home() || is_front_page()) {
    	return null;
    }; ?>
    
    		<div class='inside-post-wrap'>

    and

    <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
    
    		<?php echo mamontov_post_thumb($post->ID); ?>
    
    if (is_home() || is_front_page()) {
    	return null;
    }
    
    		<div class='inside-post-wrap'>
    
    			<?php if(!is_front_page()) { ?>

    and this

    <?php echo mamontov_post_thumb if (is_home() || is_front_page()) {
    	return null;
    } ($post->ID); ?>
    
    		<div class='inside-post-wrap'>
    
    			<?php if(!is_front_page()) { ?>

    But the pictures still remain and nothing changes. Of course this is some ridiculous mistake I’m making but I just don’t see it. Could it be this is the wrong PHP file? or am I using the code you gave me the wrong way?

    Again thanks for helping me.

    Thread Starter JamesWord2016

    (@jamesword2016)

    I even tried removing the whole mamontov_post_thumb code from the text below and updated. The images were still there.

    ( have_posts() ) while ( have_posts() ) : the_post(); ?>
    
    		<?php echo mamontov_post_thumb($post->ID); ?>
    
    		<div class='inside-post-wrap'>
    Thread Starter JamesWord2016

    (@jamesword2016)

    Hey, so I was experimenting with PHP editing and now my whole site is down. I cannot even access wordpress and my site won’t load. I just get this message on the screen:

    Parse Error Syntax Error, unexpected if:

    How do I solve this if I can’t even log in to wordpress and install theme again?

    Thread Starter JamesWord2016

    (@jamesword2016)

    my site is haraldbaldr DOT com

    Thread Starter JamesWord2016

    (@jamesword2016)

    ok, after re-uploading a backup of the file in FTP I was able to get site up and running again but back to square one now. At least wordpress is working again.

    Can you guys recommend someone I can hire to solve this issue?

    Hi,

    Sorry, I think I was not clear where to make the change. You need to make the change in the same file which you pasted in reply#4

    What I have suggested is to modify the theme function that creates the post thumbnail to return nothing when it is called from the home page. Please don’t make any changes to any other files where the function is being called from (For e.g. <?php echo mamontov_post_thumb($post->ID); ?>)

    Cheers,
    Ramesh

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘How to find PHP code in custom script’ is closed to new replies.