Title: J's Replies | WordPress.org

---

# J

  [  ](https://wordpress.org/support/users/jamalorg/)

 *   [Profile](https://wordpress.org/support/users/jamalorg/)
 *   [Topics Started](https://wordpress.org/support/users/jamalorg/topics/)
 *   [Replies Created](https://wordpress.org/support/users/jamalorg/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/jamalorg/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/jamalorg/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/jamalorg/engagements/)
 *   [Favorites](https://wordpress.org/support/users/jamalorg/favorites/)

 Search replies:

## Forum Replies Created

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

 *   Forum: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
   
   In reply to: [Display post on page with this same name as page name](https://wordpress.org/support/topic/display-post-on-page-with-this-same-name-as-page-name/)
 *  [J](https://wordpress.org/support/users/jamalorg/)
 * (@jamalorg)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/display-post-on-page-with-this-same-name-as-page-name/#post-3178855)
 * Well, that was my bad. `pre_get_posts` is used to modify the main query, but 
   since you wanted to modify a secondary loop on the page, we’ll use to good old`
   WP_Query`.
 * Forget whatever I said in my previous post, and put the following loop where 
   you wanted your posts to appear.
 *     ```
       <?php 
   
       if ( is_page() ) {
       	global $post;  
   
       	$page_slug = $post->post_name;
   
       	$args = array(
       		'post_type' => 'post',
       		'name' => $page_slug,
       		'posts_per_page' => 1
       	);
       	$My_Query = new WP_Query( $args ); 
   
       	?>
   
       	<?php if ( $My_Query->have_posts() ) : ?>
       		<?php while ( $My_Query->have_posts() ) : $My_Query->the_post(); ?>
       			<h1 class="entry-title">
       				<a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( 'Permalink to %s', the_title_attribute( 'echo=0' ) ) ); ?>" rel="bookmark"><?php the_title(); ?></a>
       			</h1>
       			<?php the_excerpt(); ?>
       		<?php endwhile; ?>
       	<?php else:
       	// Your fallback content here
       	?>
       	<?php endif; ?>
       	<?php wp_reset_postdata(); ?>
   
       <?php } ?>
       ```
   
 * It should work this time.
 *   Forum: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
   
   In reply to: [Display post on page with this same name as page name](https://wordpress.org/support/topic/display-post-on-page-with-this-same-name-as-page-name/)
 *  [J](https://wordpress.org/support/users/jamalorg/)
 * (@jamalorg)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/display-post-on-page-with-this-same-name-as-page-name/#post-3178834)
 * If I understood you correctly, you wanted something like this:
 * **Example:**
    - You have two pages called _Android_ and _iPhone_ with the slugs `android` 
      and `iphone` respectively. You also have two posts with the same titles and
      the same slugs.
    - You want to display post “iPhone” on somewhere on page “iPhone”. The same 
      applies to post “Android”.
 * If that’s the case, try this code:
 *     ```
       <?php
       /**
        * Plugin Name: Derrtass&rsquo; Posts for Pages Plugin
        */
   
       /* Hook our querying function into WordPress. */
       add_action( 'pre_get_posts', 'derrtass_pre_get_posts' );
   
       /**
        * Filter through the posts allowed to appear on pages by
        * comparing the current page slug to our blog posts and
        * display the matching post on the current page.
        *
        * As described on WordPress developer blog.
        *
        * @link http://developer.wordpress.com/2012/05/14/querying-posts-without-query_posts/
        * @link http://codex.wordpress.org/Class_Reference/WP_Query#Post_.26_Page_Parameters
        * @link http://codex.wordpress.org/Conditional_Tags#A_PAGE_Page
        */
       function derrtass_pre_get_posts( $query ) {
           global $post;
           $page_slug = $post->post_name;
   
           // Get a post with the same slug as this page
           if ( $query->is_page( $page_name ) ) {
               $query->set( 'name', $page_name );
               $query->set( 'posts_per_page', 1 );
           }
       }
       ```
   
 * Use the above code as a plugin or in your theme’s `functions.php`, once you do
   this, use the normal WordPress loop to display the post you wanted on the target
   page.
 * Example:
 *     ```
       <?php if ( have_posts() ) : ?>
       	<?php while ( have_posts() ) : the_post(); ?>
       		<h1 class="entry-title">
       			<a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( 'Permalink to %s', the_title_attribute( 'echo=0' ) ) ); ?>" rel="bookmark"><?php the_title(); ?></a>
       		</h1>
       		<?php the_excerpt(); ?>
       	<?php endwhile; ?>
       <?php endif; ?>
       ```
   
 * I didn’t test this code, but it should work.
 *   Forum: [Themes and Templates](https://wordpress.org/support/forum/themes-and-templates/)
   
   In reply to: [Setting different font for Visual editor in RTL mode](https://wordpress.org/support/topic/setting-different-font-for-tinymce-rtl/)
 *  [J](https://wordpress.org/support/users/jamalorg/)
 * (@jamalorg)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/setting-different-font-for-tinymce-rtl/#post-3165326)
 * What happens if you edit the file `editor-style-rtl.css` and set the font there?
   It seems that another stylesheet is overriding the font family in your theme’s`
   editor-style.css`.
 *   Forum: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
   
   In reply to: [Get […] after custom excerpt](https://wordpress.org/support/topic/get-after-custom-excerpt/)
 *  [J](https://wordpress.org/support/users/jamalorg/)
 * (@jamalorg)
 * [14 years ago](https://wordpress.org/support/topic/get-after-custom-excerpt/#post-2716290)
 * Well, you can append the ellipsis at the end of your original code.
 * Example:
 *     ```
       <?php echo substr( get_the_excerpt(), 0, strrpos( substr( get_the_excerpt(), 0, 75), ' ' ) . '[...]' ); ?>
       ```
   
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [Virus attack by SonicWALL](https://wordpress.org/support/topic/virus-attack-by-sonicwall/)
 *  [J](https://wordpress.org/support/users/jamalorg/)
 * (@jamalorg)
 * [14 years ago](https://wordpress.org/support/topic/virus-attack-by-sonicwall/#post-2717399)
 * If you visit [http://dannybahl.dk/page/1](http://dannybahl.dk/page/1) you will
   see your homepage, and since this works, the virus notice seems to stem from 
   a source outside the WordPress original files.
 * SonicWall is not a virus, but a company that provides a network security appliances
   to web hosts, etc… The reason you get this warning could be that SonicWall have
   detected a virus on your host server, and the virus could be hidden somewhere
   outside your capability.
 * In this case, the best option would be to contact your host.
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [Virus attack by SonicWALL](https://wordpress.org/support/topic/virus-attack-by-sonicwall/)
 *  [J](https://wordpress.org/support/users/jamalorg/)
 * (@jamalorg)
 * [14 years ago](https://wordpress.org/support/topic/virus-attack-by-sonicwall/#post-2717361)
 * The reason is somebody (probably a hacker) has placed an `index.html` file in
   your WordPress root.
 * 1. Go to your file manager and remove the index.**html** file there.
 * 2. Change your passwords for cpanel, ftp, WordPress, etc…
 * 3. Go to your WordPress updates screen and update/re-update.
 * 4. Read the recommendations in this Codex page: [http://codex.wordpress.org/FAQ_My_site_was_hacked](http://codex.wordpress.org/FAQ_My_site_was_hacked)
 *   Forum: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
   
   In reply to: [Get […] after custom excerpt](https://wordpress.org/support/topic/get-after-custom-excerpt/)
 *  [J](https://wordpress.org/support/users/jamalorg/)
 * (@jamalorg)
 * [14 years ago](https://wordpress.org/support/topic/get-after-custom-excerpt/#post-2716277)
 * Rebah,
 * > I added this code to functions.php. Is that the right file?
 * Yes. The code goes into your active theme’s `functions.php` file.
 * > Do I also have to change the code I used mentioned in my first post[…]
 * Yes. Remove that code, and use the standard `<?php the_excerpt(); ?>` template
   tag.
 * The function I posted in my previous post checks if the post have a custom excerpt,
   and the post in question is not an attachment; it then appends `[...]` at the
   end of the custom excerpt text if the condition is true.
 *   Forum: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
   
   In reply to: [Get […] after custom excerpt](https://wordpress.org/support/topic/get-after-custom-excerpt/)
 *  [J](https://wordpress.org/support/users/jamalorg/)
 * (@jamalorg)
 * [14 years ago](https://wordpress.org/support/topic/get-after-custom-excerpt/#post-2716266)
 * Try the function below, which hooks to `get_the_excerpt` filter.
 *     ```
       /* Hook the rebah_custom_excerpt_more() function to 'get_the_excerpt' filter hook */
       add_filter( 'get_the_excerpt', 'rebah_custom_excerpt_more' );
   
       /**
        * Add [...] after custom excerpts.
        *
        * @param string $output [...]
        * @return string $output [...]
        */
       function rebah_custom_excerpt_more( $output ) {
       	if ( has_excerpt() && ! is_attachment() ) {
       		$output .= ' […]';
       	}
       	return $output;
       }
       ```
   

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