Aumentar quantidade de post

  • Avatar de Desconhecido

    <?php

    /******************************
    * CUSTOM POST TYPES
    ******************************/
    $dir_custom_post_types = ‘custom-post-types’;
    require($dir_custom_post_types . ‘/anuncios.php’);

    /******************************
    * CUSTOM POST TYPES TAXONOMIES
    ******************************/

    $dir_custom_post_types_taxonomies = ‘custom-post-types/taxonomies’;
    require($dir_custom_post_types_taxonomies . ‘/posts-arquivo-taxonomy.php’);

    /******************************
    * ACF Página de opções
    ******************************/

    require(‘custom-fields/option-fields.php’);

    if (function_exists(‘acf_add_options_page’)) {
    acf_add_options_page(array(
    ‘page_title’ => ‘Informações do Cabeçalho e Rodapé’,
    ‘menu_title’ => ‘Cabeçalho/Rodapé’,
    ‘menu_slug’ => ‘header-footer’,
    ‘capability’ => ‘edit_posts’,
    ‘icon_url’ => ‘dashicons-admin-home’,
    ‘redirect’ => false,
    ));

    acf_add_options_page(array(
    ‘page_title’ => ‘Informações das Redes Sociais’,
    ‘menu_title’ => ‘Redes Sociais’,
    ‘menu_slug’ => ‘redes-sociais’,
    ‘capability’ => ‘edit_posts’,
    ‘icon_url’ => ‘dashicons-admin-home’,
    ‘redirect’ => false,
    ));

    acf_add_options_page(array(
    ‘page_title’ => ‘Informações das Páginas’,
    ‘menu_title’ => ‘Páginas’,
    ‘menu_slug’ => ‘pages’,
    ‘capability’ => ‘edit_posts’,
    ‘icon_url’ => ‘dashicons-admin-home’,
    ‘redirect’ => false,
    ));
    }

    /******************************
    * ACF Página de produtos
    ******************************/

    require(‘custom-fields/post-fields.php’);

    // Suporte para thumbs
    add_theme_support(‘post-thumbnails’);

    // Remove as paginas da pesquisa
    function query_post_conditional($query)
    {
    if (!is_admin() && $query->is_main_query()) {
    if (is_search()) {
    $query->set(‘posts_per_page’, 6);
    $query->set(‘post_type’, array(‘post’, ‘produtos’));
    $query->set(‘category__not_in’, 1);
    return;
    }
    }
    }

    add_action(‘pre_get_posts’, ‘query_post_conditional’);

    //========== Registrar os Scripts ==========//
    function registerScripts()
    {
    // Register Main
    wp_register_script(‘main’, get_template_directory_uri() . ‘/dist/js/main.js’, array(), false, true);
    // Register App
    wp_register_script(‘app’, get_template_directory_uri() . ‘/dist/js/app.js’, array(), false, true);

    // Ajax Load posts
    wp_register_script(‘ajaxLoadPosts’, get_template_directory_uri() . ‘/dist/js/ajaxLoadPosts.js’, array(), false, true);

    // Ajax Load anuncios
    wp_register_script(‘ajaxLoadAnuncios’, get_template_directory_uri() . ‘/dist/js/ajaxLoadAnuncios.js’, array(), false, true);

    // Ajax Load anuncios
    wp_register_script(‘forms’, get_template_directory_uri() . ‘/dist/js/forms.js’, array(), false, true);

    // Carrega todos os scripts
    wp_enqueue_script(‘main’);
    wp_enqueue_script(‘ajaxLoadPosts’);
    wp_enqueue_script(‘ajaxLoadAnuncios’);
    wp_enqueue_script(‘forms’);
    wp_enqueue_script(‘app’);
    }
    add_action(‘wp_enqueue_scripts’, ‘registerScripts’);

    //========== Registrar Styles ==========//
    function registerStyles()
    {
    // Register style
    wp_register_style(‘style’, get_template_directory_uri() . ‘/dist/css/style.css’, array(), false, false);
    // Register slick css
    wp_register_style(‘slick’, get_template_directory_uri() . ‘/libs/slick/slick.css’, array(), false, false);
    wp_register_style(‘slick-theme’, get_template_directory_uri() . ‘/libs/slick/slick-theme.css’, array(), false, false);

    // Carrega todos as folhas de estilo
    wp_enqueue_style(‘style’);
    wp_enqueue_style(‘slick’);
    wp_enqueue_style(‘slick-theme’);
    }
    add_action(‘wp_enqueue_scripts’, ‘registerStyles’);

    function getTermsTaxonomy($taxonomy) {
    $sem_categoria = get_term_by(‘slug’, ‘sem-categoria’, ‘category’);

    $terms = get_terms(array(
    ‘taxonomy’ => $taxonomy,
    ‘hide_empty’ => false,
    ‘parent’ => 0,
    ‘orderby’ => ‘ID’,
    ‘order’ => ‘ASC’,
    ‘exclude’ => $sem_categoria->term_id,
    ));
    return $terms;
    }

    // funcção que carrega os posts
    function load_posts()
    {
    // variaveis da query
    $numPosts = (isset($_GET[‘numPosts’]) ? $_GET[‘numPosts’] : 0);
    $page = (isset($_GET[‘page’]) ? $_GET[‘page’] : 0);
    $categoryId = (isset($_GET[‘categoryId’]) ? $_GET[‘categoryId’] : false);
    $taxonomy = (isset($_GET[‘taxonomy’]) ? $_GET[‘taxonomy’] : ”);
    $search = (isset($_GET[‘search’]) ? $_GET[‘search’] : ”);

    // modificados do loop
    $posts_query = new WP_Query(array(
    ‘showposts’ => $numPosts,
    ‘paged’ => $page,
    ‘post_status’ => ‘publish’,
    ‘post_type’ => ‘post’,
    ‘orderby’ => ‘date’,
    ‘order’ => ‘DESC’,
    ‘tax_query’ => $categoryId ? array(
    array(
    ‘taxonomy’ => $taxonomy,
    ‘field’ => ‘term_id’,
    ‘terms’ => $categoryId,
    ),
    ) : ”,
    ‘s’ => $search,
    ));

    // loop
    if ($posts_query->have_posts()) : while ($posts_query->have_posts()) : $posts_query->the_post(); ?>
    <li class=”post-list-item”>
    <?php get_template_part(‘templates/card’, ‘blog’); ?>

    <?php if (($posts_query->current_post + 1) % 2 == 0) {
    $anuncios_query = new WP_Query(array(
    ‘showposts’ => ‘2’,
    ‘post_status’ => ‘publish’,
    ‘post_type’ => ‘anuncio’,
    ‘orderby’ => ‘rand’,
    ‘order’ => ‘DESC’
    )); ?>
    <li class=”post-list-item posts-area-anuncios”>
    <?php if ($anuncios_query->have_posts()) : while ($anuncios_query->have_posts()) : $anuncios_query->the_post(); ?>
    <div class=”anuncio-img”>
    <?php
    $link = get_post_meta( get_the_ID(), ‘anuncio_link’, true );
    $post_thumbnail = get_the_post_thumbnail();
    if($link) :
    $post_thumbnail = ‘‘.get_the_post_thumbnail().’‘;
    endif;
    echo $post_thumbnail;
    ?>
    </div>
    <?php endwhile; endif; ?>

    <?php } ?>
    <?php endwhile; endif;
    // limpa da memória a query
    wp_reset_query();

    // finaliza o script
    wp_die();
    }
    add_action(‘wp_ajax_load_posts’, ‘load_posts’);
    add_action(‘wp_ajax_nopriv_load_posts’, ‘load_posts’);

    // funcção que carrega os anuncios
    function load_anuncios()
    {

    // modificados do loop
    $ids = get_field(‘home_sidebar_anuncios_order’, ‘option’, false);
    $anuncios_query = new WP_Query(array(
    ‘post_status’ => ‘publish’,
    ‘post_type’ => ‘anuncio’,
    ‘posts_per_page’ => -1,
    ‘post__in’ => $ids,
    ‘orderby’ => ‘post__in’,
    ));

    // loop
    if ($anuncios_query->have_posts()) : while ($anuncios_query->have_posts()) : $anuncios_query->the_post(); ?>
    <div class=”anuncio-area”>
    <?php
    $link = get_post_meta( get_the_ID(), ‘anuncio_link’, true );
    $post_thumbnail = get_the_post_thumbnail();
    if($link) :
    $post_thumbnail = ‘‘.get_the_post_thumbnail().’‘;
    endif;
    echo $post_thumbnail;
    ?>
    </div>
    <?php endwhile; endif;
    // limpa da memória a query
    wp_reset_query();

    // finaliza o script
    wp_die();
    }
    add_action(‘wp_ajax_load_anuncios’, ‘load_anuncios’);
    add_action(‘wp_ajax_nopriv_load_anuncios’, ‘load_anuncios’);

    function isMobile() {
    return preg_match(“/(android|avantgo|blackberry|bolt|boost|cricket|docomo|fone|hiptop|mini|mobi|palm|phone|pie|tablet|up.browser|up.link|webos|wos)/i”, $_SERVER[“HTTP_USER_AGENT”]);
    }

  • Olá!

    Como não encontrei nenhum site em sua conta do WordPress.com, acredito que você esteja usando o WordPress.org em outra hospedagem.

    Nesse caso, o ideal é publicar sua questão no fórum focado no WordPress.org:

    https://br.forums.wordpress.org/

  • O tópico ‘Aumentar quantidade de post’ está fechado para novas respostas.