Automattic / Automattic/jetpack

[markdown] html short code remove markdown formating 2

Open
#1,624 10 comments 0 reactions 0 assignees View on GitHub
[Feature] Markdown [Pri] Low [Status] Stale Bug
Dominant language
PHP
Stars
1.8k
Forks
898
Avg merge
1d 18h
Merged PRs (30d)
774

Description

Hello @jeherve

I get the same bug please see [#1151](https://github.com/Automattic/jetpack/issues/1151) . This time I really have `wpcom-markdown` with this post type and the shortcode (custom made this time) only display the content of an other post type (please see the code bellow).

**Content in the WordPress Editor of the custom post type at the beginning**

```
### Sommaire

[plan-module post_id="5719"]

[plan-module post_id="5724"]

[plan-module post_id="5726"]

### Ressources

Toutes les ressources liées au module.

#### Liste de plugins utilisés durant le WordPress 1

* [Admin Menu Reorder](https://wordpress.org/plugins/admin-menu-reorder/ "Ouverture"): Pour réorganiser ses menus dans l'admin.
* [BackWPUp](https://wordpress.org/plugins/backwpup/): pour les sauvegardes
* [Black Studio TinyMCE Widget](https://wordpress.org/plugins/black-studio-tinymce-widget/ "Ouverture"): Widget avec un éditeur visuel de type page ajouté
* [Easy FancyBox](https://wordpress.org/plugins/easy-fancybox/): Pour ajouter des effets lightbox sur les images.
* [Jetpack par WordPress.com](https://wordpress.org/plugins/jetpack/ "Ouverture"): Ensemble de plugins incontournables (partage, formulaire, effets de galerie...)
* [Meta Slider](https://wordpress.org/plugins/ml-slider/ "Ouverture"): Pour ajouter des widgets personnalisés

```

**Content in the WordPress Editor of the custom post type after a while**

```

Sommaire

[plan-module post_id="5719"]

[plan-module post_id="5724"]

[plan-module post_id="5726"]

Ressources

Toutes les ressources liées au module.

Liste de plugins utilisés durant le WordPress 1

```

**Code for the shortcode used at the beginning**

```
/**
* Short code plan module
*
* Pour affichier les plan de module en y insérant le shortcode suivant
* [plan-module post_id="$id"]
* @since 1.0
* @author Grégoire Noyelle
*/

add_shortcode( 'plan-module', 'gncom_plan_shortcode' );
function gncom_plan_shortcode( $atts ) {

// Pull in shortcode attributes and set defaults
$atts = shortcode_atts( array(
'post_id' => false
), $atts, 'plan-module' );

// attribut ID
$post_id = $atts['post_id']; // Sanitized later as an array of integer

// Set up initial query for post
$args = array(
'post_type' => 'gnpost_planmod',
'post__in' => array( $post_id ),
);

// Query
$plan = new WP_Query( $args );

while ( $plan->have_posts() ): $plan->the_post(); global $post;

$content = '';

/** This filter is documented in wp-includes/post-template.php */
$content .= '

' . get_the_content() . '
';

endwhile; wp_reset_postdata();

return $content;
}
```

Thanks

Contributor guide

Open the contributing guide

Research direction

Start with the referenced issue #1151 and the custom `gncom_plan_shortcode` entry point, especially its `get_the_content()` call and the documented filter in `wp-includes/post-template.php`. Reproduce the change from Markdown to HTML in the custom post type, then establish why shortcode-rendered content is reformatted and verify that the intended content formatting is preserved.

Written by the indexing model from the issue text.

Assessment

Tech stack
markdown, php
Domain
backend, content
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.