-
Cristiana.4
Good morning,
I’ve already asked, but I can’t find the topic I opened anymore.I need to create filters php to view posts in this way on my new site by post id as present on the old site.
Here is an example…Old site:
normal viewing of the article: https://magazine.dooid.it/interessi/montagna/merano-e-dintorni-cosa-non-perdere/
view with filter: https://magazine.dooid.it/segnalazione/32651/Below is the php code of the old site:
<?php
/**
* Template Name: Viaggi segnalazione
*/get_header(‘vicinanze’);
$dooidid = get_query_var(‘dooidid’);
query_posts( ‘p=’ . $dooidid );?>
<div class=”main”>
<!– Content –>
<div class=”main-content single-post-main-content dooid-segnalazione-main-content”><!– Main section –>
<section class=”section dooid-segnalazione-section” id=”main-content-section” style=”margin-top: 25px;”>
<div class=”row dooid-segnalazione-row”>
<div class=”content dooid-segnalazione-content”>
<div class=”pst-block dooid-segnalazione-pst-block”>
<div class=”pst-block-main dooid-segnalazione-pst-block-main”>
<div class=”post-content dooid-segnalazione-post-content”><article class=”dooid-segnalazione-article”>
<?php
//$single_post_format = get_post_format();while (have_posts()) :
the_post();
//$pulsante_label = get_post_meta(get_the_ID(),’wpcf-label-pulsante’)[0];
// $link_pulsante = get_post_meta(get_the_ID(),’wpcf-link-diretto’)[0];
// $lang = ICL_LANGUAGE_CODE;
// $link_pulsante = $link_pulsante.’&lang=’.$lang;$the_id = get_the_ID();
?><H2 class=”dooid-segnalazione-h2″><?php the_title(); ?></H2><?php the_content();
?>
<?php endwhile; // End of the loop. ?>
</article>
</div>
</div>
</div>
</div></div>
</section></div>
<!– Content END –>
</div>
<!– Main END –><?php get_footer(‘vicinanze’); ?>
the new site where I have to recreate this visualization is dooid.it, created with the GeneratePress theme and GP Premium.
Thank you
-
David
Hi there,
is this the topic you’re looking for ?
-
Cristiana.4
yes this is the old topic. but I still can’t get the result I want.
I need to create a link like it was on the old site.
-
I need to create a link like it was on the old site.
Sorry but I’m not clear on what “link” you are referring to here.
Can you explain a bit more?
This might be require a custom solution that would be out of the scope of this forum.
-
Cristiana.4
I need to create a link that shows the article without header and footer.
I don’t want to set a site-wide display rule. I need to do it only via a link.On the old site this was done via the above code. now i need to replicated the same thing on the new site built with generatepress.
Thank you
-
David
You need to:
1. In Appearance > Elements -> Add New Layout.
Disable the Elements that you want to remove.
DO NOT set the Element Display Rules.
Make a note of the Element ID ( in the Browser URL field )2. Add this PHP Snippet to your site:
add_filter( 'generate_element_display', function( $display, $element_id ) { $url = $_SERVER['REQUEST_URI']; if ( 99 === $element_id && strpos($url, 'specific-string') !== false ) { $display = true; } return $display; }, 10, 2 );
Change the
99
to match your Layout Element ID.
Change thespecific-string
to the words you are looking to match in the URL.
For example i could change that tofun-holidays
and it would apply to any URL that has that string eg
https://mysite.com/spain/fun-holidays-for-kids
- You must be logged in to reply to this topic.