Respuestas de foro creadas

Viendo 8 respuestas - de la 1 a la 8 (de un total de 8)
  • Iniciador del debate melenas1414

    (@melenas1414)

    URL:
    http://new.iglesiaevangelicadesegovia.com/predicaciones/

    El custom post lo he creado con otro plugin, cuando consiga que funcione esto lo implemento en el plugin.

    Iniciador del debate melenas1414

    (@melenas1414)

    Archivo general del plugin:

    <?php
    /**
    * Plugin Name: Predicaciones
    * Plugin URI: 
    * Description: Crear custom post para configurar predicaciones
    * Version: 1.0.1
    * Author: Santiago Galán
    * Author EMAIL: santiagogalan13@gmail.com
    * License: GPL2
    */
    define( 'WPP_PLUGIN', __FILE__ );
    define( 'WPP_PLUGIN_DIR', untrailingslashit( dirname( WPP_PLUGIN ) ) );
    defined( 'ABSPATH' ) or die( '¡Sin trampas!' );
    
    require_once WP_PLUGIN_DIR . '/predicacion-plugin/archive-predicaciones.php';
    require_once WP_PLUGIN_DIR . '/predicacion-plugin/single-predicaciones.php';
    add_filter('single_template', function($original){
    
      global $post;
    
      $post_type = $post->post_type;
    
    if($post_type=="predicaciones"){
    
      $base_name = 'single-predicaciones.php';
    
      $template = locate_template($base_name);
    
      if ($template && ! empty($template)) return $template;
    
    }
    
      return $original;
    
    });
    add_filter( "archive_template", function($original){
    
      global $post;
    
      $post_type = $post->post_type;
    
    if($post_type=="predicaciones"){
    
      $base_name = 'archive-predicaciones.php';
    
      $template = locate_template($base_name);
    
      if ($template && ! empty($template)) return $template;
    
    }
    
      return $original;
    
    });
    ?>

    Archive:

    <?php
    /**
     * The template for displaying archive Predicaciones pages.
     *
     * Learn more: http://codex.wordpress.org/Template_Hierarchy
     *
     */
    
    get_header(); ?>
    
    <div class="row">
    
        <section id="primary" class="content-area">
    
            <div class="large-8 columns">
                
            <main id="main" class="site-main" role="main">
    
            <?php if ( have_posts() ) : ?>
    
                <header class="page-header">
                    <?php
                        the_archive_title( '<h1 class="page-title">', '</h1>' );
                    ?>
                </header><!-- .page-header -->
    
                <?php /* Start the Loop */ ?>
                <?php while ( have_posts() ) : the_post(); ?>
    
                    <?php
                        /* Include the Post-Format-specific template for the content.
                         * If you want to override this in a child theme, then include a file
                         * called content-___.php (where ___ is the Post Format name) and that will be used instead.
                         */
                        echo get_field('descripcion');
                    ?>
    
                <?php endwhile; ?>
    
                <?php gateway_paging_nav(); ?>
    
            <?php else : ?>
    
                <?php get_template_part( 'template-parts/content', 'none' ); ?>
    
            <?php endif; ?>
    
            </main><!-- #main -->
    
            </div><!-- .large-8 -->
    
        </section><!-- #primary -->
    
        <div class="large-3 large-offset-1 columns">
            <?php get_sidebar(); ?>
        </div><!-- .large-3 -->
    
    </div><!-- .row -->
    
    <?php get_footer(); ?>

    Post:

    <?php
    /**
     * The template for displaying archive Predicaciones pages.
     *
     * Learn more: http://codex.wordpress.org/Template_Hierarchy
     *
     */
    
    get_header(); ?>
    
    <div class="row">
        <section id="primary" class="content-area">
    
            <div class="large-8 columns">
                
            <main id="main" class="site-main" role="main">
    
            <?php if ( have_posts() ) : ?>
    
                <header class="page-header">
                    <?php
                        the_archive_title( '<h1 class="page-title">', '</h1>' );
                    ?>
                </header><!-- .page-header -->
    
                <?php /* Start the Loop */ ?>
                <?php while ( have_posts() ) : the_post(); ?>
    
                    <?php
                        /* Include the Post-Format-specific template for the content.
                         * If you want to override this in a child theme, then include a file
                         * called content-___.php (where ___ is the Post Format name) and that will be used instead.
                         */
                        get_template_part( 'template-parts/content', get_post_format() );
                    ?>
    
                <?php endwhile; ?>
    
                <?php gateway_paging_nav(); ?>
    
            <?php else : ?>
    
                <?php get_template_part( 'template-parts/content', 'none' ); ?>
    
            <?php endif; ?>
    
            </main><!-- #main -->
    
            </div><!-- .large-8 -->
    
        </section><!-- #primary -->
    
        <div class="large-3 large-offset-1 columns">
            <?php get_sidebar(); ?>
        </div><!-- .large-3 -->
    
    </div><!-- .row -->
    
    <?php get_footer(); ?>
    
    Iniciador del debate melenas1414

    (@melenas1414)

    Nadie me puede ayudar?=

    Iniciador del debate melenas1414

    (@melenas1414)

    no, disculpa no me ha cogido la plantilla, porque la he dejado en blanco y no me la detecta.

    Iniciador del debate melenas1414

    (@melenas1414)

    ya he conseguido que me agarré la plantilla, ahora creo que el problrema que es otro:
    Uncaught Error: Call to a member function have_posts() on null in /home/iglesiae/wp-includes/query.php:767 Stack trace: #

    Creo que estoy usando mal la sintaxis

    Iniciador del debate melenas1414

    (@melenas1414)

    No me había dado cuenta lo de la doble p, lo que menos me importa ahora es el CSS, pero si que quiero es que me use la plantilla, pero no sé si con el add_filte funciona.

    Iniciador del debate melenas1414

    (@melenas1414)

    Me falta lo que es la maquetación del archive y single de ese Custom post, porque con el código que he puesto, que es el que uso cuando monto los templates, no me implementa la maquetación que le pongo en los aechivos.

    Iniciador del debate melenas1414

    (@melenas1414)

    no, quiero el custom post independiente de la plantilla, sin importar que se cambien de plantilla, tenga la misma estructura, con su css etc.

Viendo 8 respuestas - de la 1 a la 8 (de un total de 8)